Skip to content

Commit 5516e4e

Browse files
refactor: improve code formatting and readability in multiple components
1 parent cbe3ce2 commit 5516e4e

9 files changed

Lines changed: 61 additions & 83 deletions

File tree

src/components/ShareButtons.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export default function ShareButtons({
9393
const labelClass = compact ? styles.labelCompact : styles.label;
9494
const buttonClass = compact ? `${styles.shareButton} ${styles.shareButtonCompact}` : styles.shareButton;
9595

96-
const badgeMarkdown = '[![software craftsmanship - value driven · ai-augmented](https://img.shields.io/badge/software%20craft-value--driven%20%C2%B7%20ai--augmented-4c1d95?style=flat-square&labelColor=111827)](https://ai-manifesto.software-craftsmanship.dev)';
96+
const badgeMarkdown =
97+
'[![software craftsmanship - value driven · ai-augmented](https://img.shields.io/badge/software%20craft-value--driven%20%C2%B7%20ai--augmented-4c1d95?style=flat-square&labelColor=111827)](https://ai-manifesto.software-craftsmanship.dev)';
9798
const [copied, setCopied] = React.useState(false);
9899

99100
const copyToClipboard = async () => {
@@ -126,11 +127,7 @@ export default function ShareButtons({
126127
<label className={styles.markdownLabel}>Embed on your page:</label>
127128
<div className={styles.markdownCodeWrapper}>
128129
<code className={styles.markdownCode}>{badgeMarkdown}</code>
129-
<button
130-
onClick={copyToClipboard}
131-
className={styles.copyButton}
132-
title="Copy to clipboard"
133-
>
130+
<button onClick={copyToClipboard} className={styles.copyButton} title="Copy to clipboard">
134131
{copied ? '✓' : '📋'}
135132
</button>
136133
</div>

src/components/SignManifest.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ export function SignManifest() {
270270
if (newCaptcha) setCaptchaChallenge(newCaptcha);
271271
setNameOnlyForm((prev) => ({ ...prev, captchaAnswer: '' }));
272272
} else if ((error as any).code === '42501') {
273-
setNameOnlyError('Permission denied (RLS). Please retry in a moment or contact support if this persists.');
273+
setNameOnlyError(
274+
'Permission denied (RLS). Please retry in a moment or contact support if this persists.'
275+
);
274276
} else {
275277
setNameOnlyError(error.message || 'Failed to submit signature. Please try again.');
276278
}
@@ -316,16 +318,15 @@ export function SignManifest() {
316318
// Optional: User informieren
317319
alert('Fehler beim Löschen des Accounts: ' + error.message);
318320
} else {
319-
320321
setSignature(null);
321-
try { sessionStorage.removeItem('signedUserId'); } catch {}
322+
try {
323+
sessionStorage.removeItem('signedUserId');
324+
} catch {}
322325
broadcastSignatureChange();
323326

324327
try {
325328
await supabase.auth.signOut();
326-
} catch (e) {
327-
328-
}
329+
} catch (e) {}
329330

330331
setSession(null);
331332
}

src/components/SignersList.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,12 @@ export default function SignersList({ variant = 'compact' }: SignersListProps) {
108108
tooltipParts.push(`Location: ${locationInfo}`);
109109
}
110110

111-
112111
tooltipParts.push(`Signed: ${new Date(s.created_at).toLocaleDateString()}`);
113112

114113
const tooltipText = tooltipParts.join('\n');
115114

116115
return (
117-
<li
118-
key={s.id}
119-
className={styles.signerCard}
120-
title={tooltipText}
121-
>
116+
<li key={s.id} className={styles.signerCard} title={tooltipText}>
122117
{avatarUrl ? (
123118
<img
124119
src={avatarUrl}

src/pages/index.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function splitManifest(manifestMarkdown?: string) {
2121
let start = -1;
2222
let end = -1;
2323
for (let i = 0; i < lines.length; i++) {
24-
if (isValue(lines[i])) { start = i; break; }
24+
if (isValue(lines[i])) {
25+
start = i;
26+
break;
27+
}
2528
}
2629
if (start === -1) {
2730
return { before: manifestMarkdown, values: [], after: '' };
@@ -56,18 +59,14 @@ export default function Home(): ReactNode {
5659
<header className={styles.manifestHeader}>
5760
<Heading as="h1" className={styles.manifestTitle}>
5861
<span className={styles.preamble}>Manifesto for</span>
59-
<span className={styles.coreSubject}>
60-
AI-Augmented Software Craftsmanship
61-
</span>
62+
<span className={styles.coreSubject}>AI-Augmented Software Craftsmanship</span>
6263
</Heading>
6364
</header>
6465

6566
{/* Intro text before values (from README) */}
6667
{parts.before && (
6768
<article className={styles.manifestContent}>
68-
<ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
69-
{parts.before}
70-
</ReactMarkdown>
69+
<ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>{parts.before}</ReactMarkdown>
7170
</article>
7271
)}
7372

@@ -87,9 +86,7 @@ export default function Home(): ReactNode {
8786
{/* Text after the values (e.g., "We pursue the values on the left…") */}
8887
{parts.after && (
8988
<article className={styles.manifestContent}>
90-
<ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>
91-
{parts.after}
92-
</ReactMarkdown>
89+
<ReactMarkdown remarkPlugins={[remarkGfm, remarkBreaks]}>{parts.after}</ReactMarkdown>
9390
</article>
9491
)}
9592

src/pages/preamble.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ import remarkGfm from 'remark-gfm';
55
import remarkBreaks from 'remark-breaks';
66
import sections from '@site/src/data/readmeSections.json';
77
import styles from './preamble.module.css';
8-
import Heading from "@theme/Heading";
8+
import Heading from '@theme/Heading';
99

1010
export default function PreamblePage() {
1111
return (
1212
<Layout title="Preamble" description="Preamble of the AI-Augmented Software Craftsmanship Manifesto">
1313
<main className={styles.preambleWrapper}>
14-
1514
<header className={styles.preambleHeader}>
1615
<Heading as="h1" className={styles.preambleTitle}>
17-
<span className={styles.coreSubject}>
18-
Preamble
19-
</span>
16+
<span className={styles.coreSubject}>Preamble</span>
2017
</Heading>
2118
</header>
2219

src/pages/principles.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ import remarkGfm from 'remark-gfm';
55
import remarkBreaks from 'remark-breaks';
66
import sections from '@site/src/data/readmeSections.json';
77
import styles from './preamble.module.css';
8-
import Heading from "@theme/Heading";
8+
import Heading from '@theme/Heading';
99

1010
export default function PrinciplesPage() {
1111
return (
1212
<Layout title="Principles" description="Principles of the AI-Augmented Software Craftsmanship Manifesto">
1313
<main className={styles.preambleWrapper}>
14-
1514
<header className={styles.preambleHeader}>
1615
<Heading as="h1" className={styles.preambleTitle}>
17-
<span className={styles.coreSubject}>
18-
Principles
19-
</span>
16+
<span className={styles.coreSubject}>Principles</span>
2017
</Heading>
2118
</header>
2219

@@ -29,4 +26,3 @@ export default function PrinciplesPage() {
2926
</Layout>
3027
);
3128
}
32-

src/pages/signatories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ export default function SignatoriesPage() {
2626
</Layout>
2727
);
2828
}
29-

src/theme/Footer/Layout/index.tsx

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
import React, {type ReactNode} from 'react';
1+
import React, { type ReactNode } from 'react';
22
import clsx from 'clsx';
3-
import {ThemeClassNames} from '@docusaurus/theme-common';
4-
import type {Props} from '@theme/Footer/Layout';
3+
import { ThemeClassNames } from '@docusaurus/theme-common';
4+
import type { Props } from '@theme/Footer/Layout';
55
import ShareButtons from '@site/src/components/ShareButtons';
66
import styles from './FooterLayout.module.css';
77

8-
export default function FooterLayout({
9-
style,
10-
links,
11-
logo,
12-
copyright,
13-
}: Props): ReactNode {
14-
return (
15-
<footer
16-
className={clsx(ThemeClassNames.layout.footer.container, 'footer', {
17-
'footer--dark': style === 'dark',
18-
})}>
19-
<div className="container container-fluid">
20-
{links}
21-
<div className={styles.shareButtonsContainer}>
22-
<ShareButtons compact={true} />
23-
</div>
24-
{(logo || copyright) && (
25-
<div className="footer__bottom text--center">
26-
{logo && <div className="margin-bottom--sm">{logo}</div>}
27-
{copyright}
28-
</div>
29-
)}
30-
</div>
31-
</footer>
32-
);
8+
export default function FooterLayout({ style, links, logo, copyright }: Props): ReactNode {
9+
return (
10+
<footer
11+
className={clsx(ThemeClassNames.layout.footer.container, 'footer', {
12+
'footer--dark': style === 'dark',
13+
})}
14+
>
15+
<div className="container container-fluid">
16+
{links}
17+
<div className={styles.shareButtonsContainer}>
18+
<ShareButtons compact={true} />
19+
</div>
20+
{(logo || copyright) && (
21+
<div className="footer__bottom text--center">
22+
{logo && <div className="margin-bottom--sm">{logo}</div>}
23+
{copyright}
24+
</div>
25+
)}
26+
</div>
27+
</footer>
28+
);
3329
}

src/theme/Footer/index.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import React, {type ReactNode} from 'react';
1+
import React, { type ReactNode } from 'react';
22

3-
import {useThemeConfig} from '@docusaurus/theme-common';
3+
import { useThemeConfig } from '@docusaurus/theme-common';
44
import FooterLinks from '@theme/Footer/Links';
55
import FooterLogo from '@theme/Footer/Logo';
66
import FooterCopyright from '@theme/Footer/Copyright';
77
import FooterLayout from '@theme/Footer/Layout';
88

99
function Footer(): ReactNode {
10-
const {footer} = useThemeConfig();
11-
if (!footer) {
12-
return null;
13-
}
14-
const {copyright, links, logo, style} = footer;
10+
const { footer } = useThemeConfig();
11+
if (!footer) {
12+
return null;
13+
}
14+
const { copyright, links, logo, style } = footer;
1515

16-
return (
17-
<FooterLayout
18-
style={style}
19-
links={links && links.length > 0 && <FooterLinks links={links} />}
20-
logo={logo && <FooterLogo logo={logo} />}
21-
copyright={copyright && <FooterCopyright copyright={copyright} />}
22-
/>
23-
);
16+
return (
17+
<FooterLayout
18+
style={style}
19+
links={links && links.length > 0 && <FooterLinks links={links} />}
20+
logo={logo && <FooterLogo logo={logo} />}
21+
copyright={copyright && <FooterCopyright copyright={copyright} />}
22+
/>
23+
);
2424
}
2525

2626
export default React.memo(Footer);

0 commit comments

Comments
 (0)