Extracts shared section blocks for use beyond the homepage

HomeSection becomes PageSection, since every page needs the same section
frame, and gains a flushTop spacing for a block right below a page head.
The framed photo next to text from the homepage About block becomes
MediaText, and the accent label that four components wrote out by hand
becomes Eyebrow, which can also render as a heading. The homepage renders
exactly as before: a layout comparison of every element against master
at three widths shows no differences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 23:35:22 +02:00
co-authored by Claude Opus 5.5
parent 26106f280f
commit 01e849c6b0
18 changed files with 321 additions and 89 deletions
@@ -0,0 +1,42 @@
import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import Eyebrow from './Eyebrow';
describe('Eyebrow', () => {
it('is a paragraph by default', async () => {
const { container } = await renderWithProviders(
<Eyebrow>Over mij</Eyebrow>,
);
expect(screen.getByText('Over mij').tagName).toBe('P');
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
expect(await axeResults(container)).toHaveNoViolations();
});
it('can be a heading that a section refers to by id', async () => {
const { container } = await renderWithProviders(
<section aria-labelledby="story-title">
<Eyebrow as="h3" id="story-title">
Hoe het begon
</Eyebrow>
</section>,
);
expect(
screen.getByRole('heading', { level: 3, name: 'Hoe het begon' }),
).toHaveAttribute('id', 'story-title');
expect(
screen.getByRole('region', { name: 'Hoe het begon' }),
).toBeInTheDocument();
expect(await axeResults(container)).toHaveNoViolations();
});
it('passes other props through', async () => {
await renderWithProviders(
<Eyebrow data-testid="label" textAlign="center">
Binnenkort
</Eyebrow>,
);
expect(screen.getByTestId('label')).toHaveTextContent('Binnenkort');
});
});
+21
View File
@@ -0,0 +1,21 @@
import { Text, type TextProps } from '@chakra-ui/react';
type EyebrowProps = Omit<TextProps, 'as'> & {
// A heading level makes the label a real heading that keeps the small
// label look, e.g. the story headings on the about page
as?: 'p' | 'span' | 'h2' | 'h3' | 'h4';
};
// Small capitals label above a heading or text (design .eyebrow).
// accent.deep instead of the design's accent: meets 4.5:1 on paper and white.
export default function Eyebrow({ as = 'p', ...rest }: EyebrowProps) {
return (
<Text
as={as}
textStyle="eyebrow"
color="accent.deep"
mb={4}
{...rest}
/>
);
}