Adds the shoot page layout and the shoot-type submenu

Shoot pages follow design E: breadcrumb, story blocks, process
timeline with icons, photo mosaic, FAQ, package block and booking
call to action, with per-shoot OG images. The navigation gets a
"Soorten fotoshoots" submenu (desktop panel, mobile group) built from
shootTypes, with exact current-page matching in menu, footer and
breadcrumb. A 404 under /soorten-fotoshoots/ also offers a link back
to the overview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 14:43:43 +01:00
co-authored by Claude Opus 5.5
parent e5f4348178
commit 7af2069959
84 changed files with 6090 additions and 128 deletions
@@ -0,0 +1,41 @@
import { render } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { PROCESS_STEP_ORDER } from '@/lib/shootPageView';
import { axeResults } from '@/test/axe';
import { processIcons } from './ProcessIcons';
describe('processIcons', () => {
it('has exactly one icon for every step of the process', () => {
expect(Object.keys(processIcons).sort()).toEqual(
[...PROCESS_STEP_ORDER].sort(),
);
});
it.each(PROCESS_STEP_ORDER)(
'draws the %s icon as a hidden, unfocusable 24 px svg without a title',
(id) => {
const Icon = processIcons[id];
const { container } = render(<Icon />);
const svg = container.querySelector('svg')!;
expect(svg).toHaveAttribute('aria-hidden', 'true');
expect(svg).toHaveAttribute('focusable', 'false');
expect(svg).toHaveAttribute('viewBox', '0 0 24 24');
expect(svg).toHaveAttribute('width', '24');
expect(svg).toHaveAttribute('height', '24');
expect(svg.querySelector('title')).toBeNull();
expect(svg.children.length).toBeGreaterThan(0);
},
);
it('has no accessibility violations', async () => {
const { container } = render(
<div>
{PROCESS_STEP_ORDER.map((id) => {
const Icon = processIcons[id];
return <Icon key={id} />;
})}
</div>,
);
expect(await axeResults(container)).toHaveNoViolations();
});
});
@@ -0,0 +1,76 @@
import type { ReactElement, ReactNode } from 'react';
import type { ProcessStepId } from '@/content/types';
// One decorative 24 x 24 icon of the process timeline (design E, stroke
// icons in the text colour). Hidden from assistive technology: the step
// title says everything.
function Icon({ children }: { children: ReactNode }) {
return (
<svg
viewBox="0 0 24 24"
width="24"
height="24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
focusable="false"
>
{children}
</svg>
);
}
// The icon of every step; the Record makes a missing step a compile error
export const processIcons: Record<ProcessStepId, () => ReactElement> = {
// Envelope
aanvragen: () => (
<Icon>
<rect x="3" y="5.5" width="18" height="13" />
<path d="M3.5 6.5l8.5 6.5 8.5-6.5" />
</Icon>
),
// Calendar with a heart
datum: () => (
<Icon>
<rect x="3.5" y="5" width="17" height="15.5" />
<path d="M3.5 9.5h17M8 3v4M16 3v4" />
<path d="M12 18.6s-3-2.6-3-4.7a3 3 0 0 1 6 0c0 2.1-3 4.7-3 4.7z" />
<circle cx="12" cy="13.9" r="0.8" />
</Icon>
),
// Coin
aanbetaling: () => (
<Icon>
<circle cx="12" cy="12" r="9" />
<path d="M15.5 8.6a4.2 4.2 0 1 0 0 6.8" />
<path d="M7.5 10.9h5.5M7.5 13.1h5.5" />
</Icon>
),
// Camera
shoot: () => (
<Icon>
<path d="M3 8h4l1.6-2.5h6.8L17 8h4v11H3z" />
<circle cx="12" cy="13.5" r="3.5" />
</Icon>
),
// Sliders
bewerking: () => (
<Icon>
<path d="M4 7h9M17 7h3M4 12h4M12 12h8M4 17h3M11 17h9" />
<circle cx="15" cy="7" r="2" />
<circle cx="10" cy="12" r="2" />
<circle cx="9" cy="17" r="2" />
</Icon>
),
// Picture
oplevering: () => (
<Icon>
<rect x="3.5" y="4.5" width="17" height="15" />
<circle cx="9" cy="9.5" r="1.6" />
<path d="M3.5 17l5-4.5 3.5 3 3-2.5 5.5 4.5" />
</Icon>
),
};
@@ -79,4 +79,31 @@ describe('ShootBlock', () => {
expect(main).not.toHaveAttribute('loading', 'lazy');
expect(detail).toHaveAttribute('loading', 'lazy');
});
it.each([
['newborn', 'Lees meer over de newbornshoot'],
['zwangerschap', 'Lees meer over de zwangerschapsshoot'],
['gezin', 'Lees meer over de gezinsshoot'],
['loveshoot', 'Lees meer over de loveshoot'],
['portret', 'Lees meer over de portretshoot'],
])('links %s to its own page with the text "%s"', async (id, text) => {
await renderBlock(id);
const link = screen.getByRole('link', { name: text });
expect(link).toHaveAttribute('href', `/soorten-fotoshoots/${id}`);
expect(link).toBe(screen.getByTestId(`shoot-${id}-readmore`));
// The visible text is the name: no aria-label
expect(link).not.toHaveAttribute('aria-label');
});
it('puts the page link first in the row, before the contact link', async () => {
await renderBlock('newborn', { portfolioLink: true });
const links = within(
screen.getByRole('article', { name: 'Newborn' }),
).getAllByRole('link');
expect(links.map((link) => link.getAttribute('data-testid'))).toEqual([
'shoot-newborn-readmore',
'shoot-newborn-contact',
'shoot-newborn-portfolio',
]);
});
});
@@ -4,7 +4,9 @@ import { Box, Flex, Heading, Link, Stack, Text } from '@chakra-ui/react';
import { Link as RouterLink } from '@tanstack/react-router';
import MediaText from '@/components/MediaText/MediaText';
import type { PricingPackage, ShootType } from '@/content/types';
import { readMoreLabel } from '@/lib/readMoreLabel';
import { shootContactLink, shootPortfolioLink } from '@/lib/shootLinks';
import { shootPagePath } from '@/lib/shootPages';
type ShootBlockProps = {
shoot: ShootType;
@@ -21,7 +23,7 @@ type ShootBlockProps = {
const linkStyle = { py: 2.5, display: 'inline-block' } as const;
// One kind of shoot (design .shoot): its photo next to the name, the text
// and the links. The article is the anchor (#newborn) and is named by its
// and the links, the first of which leads to the shoot's own page. The article is the anchor (#newborn) and is named by its
// heading.
export default function ShootBlock({
shoot,
@@ -59,6 +61,16 @@ export default function ShootBlock({
))}
</Stack>
<Flex wrap="wrap" columnGap={6} mt={3}>
{/* The visible text already differs per shoot, so no
aria-label is needed to tell the links apart */}
<Link variant="underline" asChild {...linkStyle}>
<RouterLink
to={shootPagePath(shoot.id)}
data-testid={`shoot-${shoot.id}-readmore`}
>
{readMoreLabel(shoot)}
</RouterLink>
</Link>
<Link variant="underline" asChild {...linkStyle}>
{/* Five links say "Stuur een berichtje"; the full name
tells screen reader users which shoot each is about.
@@ -74,4 +74,23 @@ describe('ShootList', () => {
);
expect(tones).toEqual([false, true, false, true, false]);
});
it('gives every shoot its own page link, first in its row, with a unique name', async () => {
await renderList();
const ids = shootTypes.map((shoot) => shoot.id);
const names = ids.map((id) => {
const link = screen.getByTestId(`shoot-${id}-readmore`);
expect(link).toHaveAttribute('href', `/soorten-fotoshoots/${id}`);
const article = link.closest('article')!;
expect(within(article).getAllByRole('link')[0]).toBe(link);
return link.textContent;
});
expect(new Set(names).size).toBe(ids.length);
// The other links are still there
for (const id of ids) {
expect(
screen.getByTestId(`shoot-${id}-contact`),
).toBeInTheDocument();
}
});
});
@@ -1,26 +1,66 @@
import { screen } from '@testing-library/react';
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import loveshootPage from '@/content/shootPages/loveshoot';
import newbornPage from '@/content/shootPages/newborn';
import shootPageShared from '@/content/shootPageShared';
import packages from '@/content/packages';
import shootTypes from '@/content/shootTypes';
import siteContent from '@/content/siteContent';
import { shootPageView } from '@/lib/shootPageView';
import type { ShootTypeId } from '@/content/types';
import { shootPageView, type ShootPageView } from '@/lib/shootPageView';
import { axeResults } from '@/test/axe';
import { cssRulesFor } from '@/test/cssRules';
import { renderWithProviders } from '@/test/renderWithProviders';
import ShootPage from './ShootPage';
const view = shootPageView('newborn', newbornPage, {
const sources = {
shootTypes,
packages,
shared: shootPageShared,
site: siteContent,
portfolioShoots: [],
});
};
const viewOf = (id: ShootTypeId, page = newbornPage) => {
const view = shootPageView(id, page, {
...sources,
portfolioShoots: [id],
});
if (view === undefined) throw new Error(`no view for ${id}`);
return view;
};
const view = viewOf('newborn');
const loveshootView = viewOf('loveshoot', loveshootPage as typeof newbornPage);
const withoutFaq: ShootPageView = (() => {
const copy = shootPageView(
'newborn',
{ ...newbornPage, faq: { ...newbornPage.faq, items: [] } },
sources,
);
if (copy === undefined) throw new Error('no view');
return copy;
})();
// The heading levels and texts in page order
const outline = (container: HTMLElement) =>
[...container.querySelectorAll('h1, h2, h3, h4, h5, h6')].map(
(heading) => ({
level: Number(heading.tagName[1]),
text: heading.textContent,
}),
);
// No heading level is skipped when going down the page
const expectNoSkippedLevel = (levels: number[]) => {
expect(levels[0]).toBe(1);
levels.slice(1).forEach((level, index) => {
expect(level).toBeLessThanOrEqual(levels[index] + 1);
});
};
describe('ShootPage', () => {
it('toont label, de enige h1 en de intro', async () => {
if (view === undefined) throw new Error('no view for newborn');
const { container } = await renderWithProviders(
<ShootPage view={view} />,
);
@@ -32,4 +72,129 @@ describe('ShootPage', () => {
expect(screen.getByText(view.intro.text)).toBeInTheDocument();
expect(await axeResults(container)).toHaveNoViolations();
});
it('has a clean heading outline for newborn: h1, h2 per section, h3 per step', async () => {
const { container } = await renderWithProviders(
<ShootPage view={view} />,
);
const headings = outline(container);
expectNoSkippedLevel(headings.map((heading) => heading.level));
expect(headings.filter((h) => h.level === 1)).toHaveLength(1);
expect(headings.filter((h) => h.level === 3)).toHaveLength(6);
expect(
headings.filter((h) => h.level === 2).map((h) => h.text),
).toEqual([
...view.stories.map((story) => story.title),
view.process.title,
view.photos!.title,
view.faq!.title,
view.offer.title,
view.closing.title,
]);
expect(await axeResults(container)).toHaveNoViolations();
});
it('has a clean heading outline for the loveshoot, without a mosaic', async () => {
const { container } = await renderWithProviders(
<ShootPage view={loveshootView} />,
);
expectNoSkippedLevel(outline(container).map((h) => h.level));
expect(container.querySelector('#impressie')).toBeNull();
expect(screen.queryByTestId('photo-mosaic')).toBeNull();
expect(container.querySelector('#vragen')).not.toBeNull();
expect(await axeResults(container)).toHaveNoViolations();
});
it('leaves out the FAQ section and keeps the outline valid when there are no questions', async () => {
const { container } = await renderWithProviders(
<ShootPage view={withoutFaq} />,
);
expect(container.querySelector('#vragen')).toBeNull();
expect(screen.queryByTestId('faq-list')).toBeNull();
expectNoSkippedLevel(outline(container).map((h) => h.level));
expect(await axeResults(container)).toHaveNoViolations();
});
it('names every section by an existing heading and offers the anchors', async () => {
const { container } = await renderWithProviders(
<ShootPage view={view} />,
);
const sections = container.querySelectorAll('section');
expect(sections.length).toBe(view.stories.length + 6);
for (const section of sections) {
const target = section.getAttribute('aria-labelledby')!;
expect(target).toBeTruthy();
expect(container.querySelector(`#${target}`)).not.toBeNull();
}
for (const anchor of [
'zo-werkt-het',
'impressie',
'vragen',
'pakket',
]) {
expect(container.querySelector(`section#${anchor}`)).not.toBeNull();
}
});
it('never gives two adjacent bands the same colour', async () => {
const { container } = await renderWithProviders(
<ShootPage view={view} />,
);
const sections = [
...screen
.getByTestId('shoot-page')
.querySelectorAll(':scope > section'),
];
const alt = sections.map((section) =>
cssRulesFor(section).join().includes('var(--slp-colors-paper-alt)'),
);
// The intro is paper; every band after it alternates
// The intro and the first story are both paper on purpose: the
// story has no space above it and continues the intro (flushTop).
// From the first story on, the bands alternate.
expect(alt[0]).toBe(false);
const bands = alt.slice(1);
bands.forEach((isAlt, index) => {
expect(isAlt).toBe(index % 2 === 1);
});
expect(sections).toHaveLength(view.stories.length + 6);
expect(container).toBeTruthy();
});
it('shows the breadcrumb, the package with its actions and the closing button', async () => {
await renderWithProviders(<ShootPage view={view} />);
const crumb = screen.getByTestId('shoot-breadcrumb');
expect(within(crumb).getAllByRole('link')).toHaveLength(2);
const offer = screen.getByTestId('package-block');
expect(
within(offer).getByRole('link', { name: view.offer.bookLabel }),
).toHaveAttribute('href', '/contact?pakket=newborn');
expect(
within(offer).getByRole('link', { name: view.offer.askLabel }),
).toHaveAttribute('href', '/contact');
expect(
within(screen.getByTestId('shoot-closing')).getByRole('link', {
name: view.closing.buttonLabel,
}),
).toHaveAttribute('href', '/contact?pakket=newborn');
expect(
screen.getByRole('link', {
name: `Bekijk meer ${view.shoot.photosLabel}`,
}),
).toHaveAttribute('href', '/portfolio?shoot=newborn');
});
it('shows one primary button and no price for a shoot on request', async () => {
await renderWithProviders(<ShootPage view={loveshootView} />);
const offer = screen.getByTestId('package-block');
expect(
within(offer).getByText(loveshootView.offer.onRequest.price),
).toBeInTheDocument();
expect(within(offer).getAllByRole('link')).toHaveLength(1);
expect(
within(offer).getByRole('link', {
name: loveshootView.offer.onRequest.linkLabel,
}),
).toHaveAttribute('href', '/contact');
});
});
@@ -1,17 +1,217 @@
import type { ReactElement } from 'react';
import { Box, Flex, Grid, Heading, Link, useRecipe } from '@chakra-ui/react';
// The router's own Link keeps the route types, so `search` is checked
// against the target route (as in ShootBlock)
import { Link as RouterLink } from '@tanstack/react-router';
import Breadcrumb from '@/components/Breadcrumb/Breadcrumb';
import CallToAction from '@/components/CallToAction/CallToAction';
import Eyebrow from '@/components/Eyebrow/Eyebrow';
import FaqList from '@/components/FaqList/FaqList';
import PackageBlock from '@/components/PackageBlock/PackageBlock';
import PageIntro from '@/components/PageIntro/PageIntro';
import PageSection from '@/components/PageSection/PageSection';
import PhotoMosaic from '@/components/PhotoMosaic/PhotoMosaic';
import ProcessTimeline from '@/components/ProcessTimeline/ProcessTimeline';
import RichParagraph from '@/components/RichParagraph/RichParagraph';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
import { processIcons } from '@/components/shoots/ProcessIcons/ProcessIcons';
import StoryBlocks from '@/components/shoots/StoryBlocks/StoryBlocks';
import { shootPageBands, type SectionBand } from '@/lib/shootPageBands';
import type { ShootPageView } from '@/lib/shootPageView';
type ShootPageProps = {
view: ShootPageView;
};
// One shoot page. For now only the page head with the h1; unit 2 adds the
// sections in the order of the page structure.
// Links under or beside a text: room around them for a 44px touch target
const linkStyle = { py: 2.5, display: 'inline-block' } as const;
// One shoot page (FR-ST-02..08): the intro with the breadcrumb, the story
// blocks, the process timeline, the photos and the FAQ when there are any,
// the offer and the closing block, in the order and colours of
// shootPageBands. Everything comes from the view; nothing is stored here.
export default function ShootPage({ view }: ShootPageProps) {
const { intro } = view;
const { intro, shoot, offer } = view;
const linkButton = useRecipe({ key: 'linkButton' });
// The accent button style for the router's own Link, which keeps the
// route types, so `search` is checked against /contact (as PriceCard)
const accentButton = linkButton({ variant: 'accent' });
const bands = shootPageBands(view);
const tone = (id: SectionBand['id']) =>
bands.find((band) => band.id === id)?.tone ?? 'paper';
return (
<PageIntro eyebrow={intro.eyebrow} title={intro.title}>
{intro.text}
</PageIntro>
<Box data-testid="shoot-page">
<PageIntro
eyebrow={intro.eyebrow}
title={intro.title}
titleId="intro-title"
breadcrumb={
<Breadcrumb
label={view.breadcrumb.label}
items={view.breadcrumb.items}
data-testid="shoot-breadcrumb"
/>
}
>
{intro.text}
</PageIntro>
<StoryBlocks
stories={view.stories}
frameColor={shoot.frameColor}
idPrefix="story"
/>
<PageSection
id="zo-werkt-het"
labelledBy="process-title"
tone={tone('process')}
>
<SectionHeading
id="process-title"
eyebrow={view.process.eyebrow}
title={view.process.title}
lead={view.process.lead}
/>
<ProcessTimeline
steps={view.process.steps.map((step) => {
// An id without an icon gets none (BR-SP-74)
const Icon: (() => ReactElement) | undefined =
processIcons[step.id];
return {
id: step.id,
title: step.title,
text: step.text,
icon: Icon ? <Icon /> : undefined,
};
})}
tone={tone('process')}
data-testid="process-timeline"
/>
</PageSection>
{view.photos && (
<PageSection
id="impressie"
labelledBy="photos-title"
tone={tone('photos')}
>
<Flex
wrap="wrap"
justify="space-between"
align="end"
columnGap={6}
mb="sectionHeadGap"
>
<Box>
<Eyebrow>{view.photos.eyebrow}</Eyebrow>
<Heading
as="h2"
id="photos-title"
textStyle="sectionTitle"
>
{view.photos.title}
</Heading>
</Box>
{view.photos.portfolioLink && (
<Link variant="underline" asChild {...linkStyle}>
<RouterLink {...view.photos.portfolioLink}>
Bekijk meer {shoot.photosLabel}
</RouterLink>
</Link>
)}
</Flex>
<PhotoMosaic
images={view.photos.images}
data-testid="photo-mosaic"
/>
</PageSection>
)}
{view.faq && (
<PageSection
id="vragen"
labelledBy="faq-title"
tone={tone('faq')}
>
<Grid
templateColumns={{ base: '1fr', lg: '1fr 2fr' }}
gap="clamp(2rem, 6vw, 5.5rem)"
alignItems="start"
>
<Box color="ink.soft">
<Eyebrow>{view.faq.eyebrow}</Eyebrow>
<Heading
as="h2"
id="faq-title"
textStyle="sectionTitle"
mb={4}
>
{view.faq.title}
</Heading>
<RichParagraph paragraph={view.faq.lead} />
</Box>
<FaqList
items={view.faq.items}
data-testid="faq-list"
/>
</Grid>
</PageSection>
)}
<PageSection
id="pakket"
labelledBy="offer-title"
tone={tone('offer')}
>
<PackageBlock
titleId="offer-title"
eyebrow={offer.eyebrow}
title={offer.title}
image={offer.image}
frameColor={shoot.frameColor}
pkg={offer.pkg}
onRequest={offer.onRequest}
note={offer.depositNote}
data-testid="package-block"
>
{offer.pkg ? (
<>
<Box asChild css={accentButton}>
<RouterLink {...offer.bookLink}>
{offer.bookLabel}
</RouterLink>
</Box>
<Link variant="underline" asChild {...linkStyle}>
<RouterLink {...offer.askLink}>
{offer.askLabel}
</RouterLink>
</Link>
</>
) : (
<Box asChild css={accentButton}>
<RouterLink {...offer.bookLink}>
{offer.onRequest.linkLabel}
</RouterLink>
</Box>
)}
</PackageBlock>
</PageSection>
<CallToAction
title={view.closing.title}
titleId="closing-title"
lead={<RichParagraph paragraph={view.closing.lead} />}
tone={tone('closing')}
data-testid="shoot-closing"
>
<Box asChild css={accentButton}>
<RouterLink {...view.closing.link}>
{view.closing.buttonLabel}
</RouterLink>
</Box>
</CallToAction>
</Box>
);
}
@@ -0,0 +1,119 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import loveshootPage from '@/content/shootPages/loveshoot';
import newbornPage from '@/content/shootPages/newborn';
import type { StoryBlock } from '@/content/types';
import { axeResults } from '@/test/axe';
import { cssRulesFor } from '@/test/cssRules';
import { renderWithProviders } from '@/test/renderWithProviders';
import StoryBlocks from './StoryBlocks';
const tone = (element: HTMLElement) =>
cssRulesFor(element).join().includes('var(--slp-colors-paper-alt)')
? 'alt'
: 'paper';
describe('StoryBlocks', () => {
it('shows one section per newborn story, each named by its h2', async () => {
const stories = newbornPage.stories;
const { container } = await renderWithProviders(
<StoryBlocks
stories={stories}
frameColor="frame.stone"
idPrefix="story"
/>,
);
expect(container.querySelectorAll('section')).toHaveLength(4);
for (const story of stories) {
const section = screen.getByTestId(`story-${story.id}`);
expect(screen.getByRole('region', { name: story.title })).toBe(
section,
);
expect(
within(section).getByRole('heading', { level: 2 }),
).toHaveTextContent(story.title);
}
expect(await axeResults(container)).toHaveNoViolations();
});
it('loads only the first photo with priority and alternates the tones', async () => {
const stories = newbornPage.stories;
await renderWithProviders(
<StoryBlocks
stories={stories}
frameColor="frame.stone"
idPrefix="story"
/>,
);
const images = screen.getAllByRole('img');
expect(images).toHaveLength(stories.length);
expect(images[0]).toHaveAttribute('fetchpriority', 'high');
expect(images[0]).not.toHaveAttribute('loading', 'lazy');
for (const image of images.slice(1)) {
expect(image).toHaveAttribute('loading', 'lazy');
expect(image).not.toHaveAttribute('fetchpriority');
}
expect(
stories.map((story) =>
tone(screen.getByTestId(`story-${story.id}`)),
),
).toEqual(['paper', 'alt', 'paper', 'alt']);
});
it('gives the loveshoot one photo and three text-only bands', async () => {
const { container } = await renderWithProviders(
<StoryBlocks
stories={loveshootPage.stories}
frameColor="accent"
idPrefix="story"
/>,
);
expect(container.querySelectorAll('section')).toHaveLength(4);
expect(screen.getAllByRole('img')).toHaveLength(1);
for (const story of loveshootPage.stories.slice(1)) {
const section = screen.getByTestId(`story-${story.id}`);
expect(within(section).queryByRole('img')).toBeNull();
expect(
within(section).getByRole('heading', { level: 2 }),
).toHaveTextContent(story.title);
}
expect(await axeResults(container)).toHaveNoViolations();
});
it('gives hostile story ids valid aria-labelledby targets', async () => {
const stories: StoryBlock[] = [
{
id: 'Met Spatie',
eyebrow: 'a',
title: 'Een',
paragraphs: [['x']],
},
{
id: '</script>',
eyebrow: 'b',
title: 'Twee',
paragraphs: [['y']],
},
];
const { container } = await renderWithProviders(
<StoryBlocks
stories={stories}
frameColor="sand"
idPrefix="story"
/>,
);
for (const section of container.querySelectorAll('section')) {
const target = section.getAttribute('aria-labelledby')!;
expect(target).toMatch(/^[a-z0-9\-_]+$/);
expect(container.querySelector(`#${target}`)).not.toBeNull();
}
expect(await axeResults(container)).toHaveNoViolations();
});
it('renders nothing without stories', async () => {
const { container } = await renderWithProviders(
<StoryBlocks stories={[]} frameColor="sand" idPrefix="story" />,
);
expect(container.querySelector('section')).toBeNull();
});
});
@@ -0,0 +1,90 @@
import { Box, Heading, Stack } from '@chakra-ui/react';
import Eyebrow from '@/components/Eyebrow/Eyebrow';
import MediaText from '@/components/MediaText/MediaText';
import PageSection from '@/components/PageSection/PageSection';
import Reveal from '@/components/Reveal/Reveal';
import RichParagraph from '@/components/RichParagraph/RichParagraph';
import type { FrameColor, StoryBlock } from '@/content/types';
import { headingId } from '@/lib/headingId';
import { storyLayout } from '@/lib/storyLayout';
type StoryBlocksProps = {
stories: readonly StoryBlock[];
// Colour of the block behind every photo
frameColor: FrameColor;
// Start of the heading ids, so they cannot clash with other ids
idPrefix: string;
};
// The story blocks of a shoot page (FR-ST-03, BR-SP-10..14): one band per
// story, named by its h2. Tone, side, spacing and the photo's shape come
// from storyLayout. A story without a photo is a text-only band in a
// narrow column, with no frame and no empty column.
export default function StoryBlocks({
stories,
frameColor,
idPrefix,
}: StoryBlocksProps) {
const layouts = storyLayout(stories);
return (
<>
{stories.map((story, index) => {
const layout = layouts[index];
const titleId = `${headingId(idPrefix, story.id)}-title`;
const text = (
<>
<Eyebrow>{story.eyebrow}</Eyebrow>
<Heading
as="h2"
id={titleId}
textStyle="sectionTitle"
mb={5}
>
{story.title}
</Heading>
<Stack gap={4} color="ink.soft">
{story.paragraphs.map((paragraph, number) => (
// Static content: the order never changes
<RichParagraph
key={number}
paragraph={paragraph}
/>
))}
</Stack>
</>
);
return (
<PageSection
key={story.id}
labelledBy={titleId}
tone={layout.tone}
spacing={layout.spacing}
width={story.image === undefined ? 'narrow' : 'default'}
data-testid={`story-${story.id}`}
>
{story.image !== undefined && layout.media ? (
<MediaText
image={story.image}
aspectRatio={layout.media.aspectRatio}
mediaSize={layout.media.mediaSize}
reverse={layout.reverse}
priority={layout.priority}
frameColor={frameColor}
>
{text}
</MediaText>
) : (
<Reveal>
<Box maxW="36rem" mx="auto">
{text}
</Box>
</Reveal>
)}
</PageSection>
);
})}
</>
);
}