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:
@@ -0,0 +1,84 @@
|
||||
import { cleanup, screen } from '@testing-library/react';
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
import { contentImage } from '@/test/arbitraries';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { cssRulesFor } from '@/test/cssRules';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import PhotoMosaic from './PhotoMosaic';
|
||||
|
||||
const photo = (n: number): ContentImage => ({
|
||||
src: `/foto-${n}.jpg`,
|
||||
alt: `Foto ${n}`,
|
||||
width: 800,
|
||||
height: 1200,
|
||||
});
|
||||
const photos = (count: number) =>
|
||||
Array.from({ length: count }, (_, index) => photo(index + 1));
|
||||
|
||||
describe('PhotoMosaic', () => {
|
||||
it.each([
|
||||
[2, 2],
|
||||
[3, 3],
|
||||
[4, 4],
|
||||
[5, 4],
|
||||
])('shows %i photos as %i tiles', async (count, tiles) => {
|
||||
const { container } = await renderWithProviders(
|
||||
<PhotoMosaic images={photos(count)} data-testid="mosaic" />,
|
||||
);
|
||||
const list = screen.getByTestId('mosaic');
|
||||
expect(list.tagName).toBe('UL');
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(tiles);
|
||||
expect(screen.getAllByRole('img')).toHaveLength(tiles);
|
||||
expect(
|
||||
screen.getAllByRole('img').map((img) => img.getAttribute('alt')),
|
||||
).toEqual(photos(tiles).map((image) => image.alt));
|
||||
expect(container.querySelector('a, button')).toBeNull();
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('renders nothing without photos', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<PhotoMosaic images={[]} />,
|
||||
);
|
||||
expect(container.querySelector('ul')).toBeNull();
|
||||
});
|
||||
|
||||
it('places the tiles in a 4 x 2 grid from md and in two columns below', async () => {
|
||||
await renderWithProviders(<PhotoMosaic images={photos(4)} />);
|
||||
const rules = cssRulesFor(screen.getByRole('list')).join('\n');
|
||||
expect(rules).toContain('repeat(2, minmax(0, 1fr))');
|
||||
expect(rules).toMatch(
|
||||
/min-width: 48rem[^}]*repeat\(4, minmax\(0, 1fr\)\)/,
|
||||
);
|
||||
const second = cssRulesFor(screen.getAllByRole('listitem')[1]).join(
|
||||
'\n',
|
||||
);
|
||||
expect(second).toContain('span 2');
|
||||
expect(second).toMatch(/min-width: 48rem[^}]*grid-column: 3 ?\/ ?5/);
|
||||
});
|
||||
|
||||
it('shows min(n, 4) photos with the given alt texts, in order (invariant)', async () => {
|
||||
const images = fc.array(contentImage, { minLength: 2, maxLength: 6 });
|
||||
for (const sample of fc.sample(images, { numRuns: 6 })) {
|
||||
const unique = sample.map((image, index) => ({
|
||||
...image,
|
||||
src: `${index}${image.src}`,
|
||||
}));
|
||||
await renderWithProviders(<PhotoMosaic images={unique} />);
|
||||
const shown = screen.queryAllByRole('img');
|
||||
const expected = unique.slice(0, 4);
|
||||
expect(document.querySelectorAll('li > img')).toHaveLength(
|
||||
expected.length,
|
||||
);
|
||||
expect(
|
||||
[...document.querySelectorAll('li > img')].map((img) =>
|
||||
img.getAttribute('alt'),
|
||||
),
|
||||
).toEqual(expected.map((image) => image.alt));
|
||||
expect(shown.length).toBeLessThanOrEqual(4);
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
||||
import Reveal from '@/components/Reveal/Reveal';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
import { MOSAIC_MAX_PHOTOS, mosaicLayout } from '@/lib/mosaicLayout';
|
||||
|
||||
type PhotoMosaicProps = {
|
||||
images: readonly ContentImage[];
|
||||
'data-testid'?: string;
|
||||
};
|
||||
|
||||
// A mosaic of up to four photos (FR-ST-05, BR-SP-30b..35): a 4 x 2 grid from
|
||||
// `md`, two columns on phones. Only a picture: no link, no button, no
|
||||
// hover effect. The photos fill their cells, so their own size never sets a
|
||||
// row height. Renders nothing without photos.
|
||||
export default function PhotoMosaic({
|
||||
images,
|
||||
'data-testid': testId,
|
||||
}: PhotoMosaicProps) {
|
||||
const shown = images.slice(0, MOSAIC_MAX_PHOTOS);
|
||||
const tiles = mosaicLayout(shown.length);
|
||||
if (tiles.length === 0) return null;
|
||||
|
||||
return (
|
||||
<Box
|
||||
as="ul"
|
||||
role="list"
|
||||
listStyle="none"
|
||||
m={0}
|
||||
p={0}
|
||||
display="grid"
|
||||
gridTemplateColumns={{
|
||||
base: 'repeat(2, minmax(0, 1fr))',
|
||||
md: 'repeat(4, minmax(0, 1fr))',
|
||||
}}
|
||||
gridTemplateRows={{
|
||||
md: 'repeat(2, clamp(12rem, 22vw, 18.75rem))',
|
||||
}}
|
||||
gap="gridGap"
|
||||
data-testid={testId}
|
||||
>
|
||||
{tiles.map((tile, index) => (
|
||||
<Reveal
|
||||
as="li"
|
||||
key={shown[index].src}
|
||||
delay={index * 0.08}
|
||||
position="relative"
|
||||
overflow="hidden"
|
||||
bg="paper.deep"
|
||||
gridColumn={{
|
||||
base: tile.wide ? 'span 2' : 'auto',
|
||||
md: tile.column,
|
||||
}}
|
||||
gridRow={{ md: tile.row }}
|
||||
aspectRatio={{ base: tile.phoneRatio, md: 'auto' }}
|
||||
>
|
||||
<DeferredImage
|
||||
image={shown[index]}
|
||||
position="absolute"
|
||||
inset={0}
|
||||
w="100%"
|
||||
h="100%"
|
||||
objectFit="cover"
|
||||
/>
|
||||
</Reveal>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user