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
+72
View File
@@ -2,6 +2,7 @@ import fc from 'fast-check';
import type { ContactField, ContactValues } from '../contact/types';
import type { ContactFormEvent } from '../lib/contactFormReducer';
import type { LightboxEvent } from '../lib/lightboxReducer';
import { shootPageView, type ShootPageView } from '../lib/shootPageView';
import type { Point } from '../lib/swipeDirection';
import type {
ContentImage,
@@ -673,3 +674,74 @@ export const slugInput: fc.Arbitrary<unknown> = fc.oneof(
fc.object(),
),
);
// --- Shoot page UI (unit 2) ---
// A photo whose proportions sit around the landscape threshold of 1.2:
// exactly on it, just below and just above, and anywhere else
export const imageWithOrientation: fc.Arbitrary<ContentImage> = fc
.tuple(
contentImage,
fc.integer({ min: 20, max: 1500 }),
fc.constantFrom('exact', 'below', 'above', 'any'),
fc.integer({ min: 20, max: 4000 }),
)
.map(([base, step, kind, anyWidth]) => {
// A height divisible by 5, so that 1.2 x height is a whole number
const height = step * 5;
const edge = step * 6;
const width =
kind === 'exact'
? edge
: kind === 'below'
? edge - 1
: kind === 'above'
? edge + 1
: anyWidth;
return { ...base, width, height };
});
// Counts around the mosaic sizes, below zero included
export const mosaicCount = fc.integer({ min: -3, max: 12 });
// One step of a timeline with hostile strings
const hostileText = fc.oneof(
fc.string({ minLength: 1, maxLength: 30 }),
fc.constantFrom(
'</script>',
'<',
'>',
'&',
'x'.repeat(120),
' ',
' ',
'a<b>c&d',
),
);
// 1 to 8 timeline steps with unique ids
export const timelineSteps = fc.uniqueArray(
fc.record({ id: slug, title: hostileText, text: hostileText }),
{ selector: (step) => step.id, minLength: 1, maxLength: 8 },
);
// A shoot page view built the way the route builds it: stories 0 to 6, the
// photos present or not, the FAQ present or not, a package or none
export const shootPageViewArb: fc.Arbitrary<ShootPageView> = fc
.tuple(shootType, uniquePackages, shootPageShared, anySiteContent)
.chain(([shoot, packages, shared, site]) =>
shootPageContent(shoot.id, [
shoot.image,
...(shoot.detailImage ? [shoot.detailImage] : []),
]).map((page) => {
const view = shootPageView(shoot.id, page, {
shootTypes: [shoot],
packages,
shared,
site,
portfolioShoots: [shoot.id],
});
if (view === undefined) throw new Error('no view for a valid case');
return view;
}),
);
+115
View File
@@ -0,0 +1,115 @@
import fc from 'fast-check';
import {
initialNavMenuState,
navMenuReducer,
type NavMenuEvent,
type NavMenuState,
} from '../lib/navMenuState';
import { shootPagePath } from '../lib/shootPages';
import { knownRoutePath, shootTypeId } from './arbitraries';
// Generators of the navigation submenu unit (unit 3). Kept apart from
// arbitraries.ts, which other units edit as well.
// Any menu event with a random payload; viewport, toggles and escape are
// weighted up so sequences actually open and close things
export const navMenuEvent: fc.Arbitrary<NavMenuEvent> = fc.oneof(
{
weight: 4,
arbitrary: fc
.boolean()
.map((isDesktop) => ({ type: 'viewport' as const, isDesktop })),
},
{
weight: 4,
arbitrary: fc
.boolean()
.map((inSection) => ({ type: 'toggleMenu' as const, inSection })),
},
{ weight: 3, arbitrary: fc.constant({ type: 'toggleGroup' as const }) },
{ weight: 4, arbitrary: fc.constant({ type: 'toggleSubmenu' as const }) },
{
weight: 4,
arbitrary: fc
.boolean()
.map((focusInside) => ({ type: 'escape' as const, focusInside })),
},
{ weight: 2, arbitrary: fc.constant({ type: 'outside' as const }) },
{ weight: 2, arbitrary: fc.constant({ type: 'focusLeave' as const }) },
{ weight: 1, arbitrary: fc.constant({ type: 'linkChosen' as const }) },
{ weight: 1, arbitrary: fc.constant({ type: 'routeChanged' as const }) },
{ weight: 2, arbitrary: fc.constant({ type: 'focusHandled' as const }) },
);
// A sequence of up to 40 menu events
export const navMenuEvents: fc.Arbitrary<NavMenuEvent[]> = fc.array(
navMenuEvent,
{ maxLength: 40 },
);
// A state reached from the initial one by random events, so it satisfies the
// invariants by construction (I1-I4 are checked on it by the tests)
export const navMenuState: fc.Arbitrary<NavMenuState> = navMenuEvents.map(
(events) => events.reduce(navMenuReducer, initialNavMenuState),
);
// The same, restricted to a viewport: a state that has seen that width
export const navMenuStateOn = (
isDesktop: boolean,
): fc.Arbitrary<NavMenuState> =>
navMenuEvents.map((events) =>
[{ type: 'viewport', isDesktop } as const, ...events].reduce(
navMenuReducer,
initialNavMenuState,
),
);
// Strings that must never break a path comparison
const hostilePathname = fc.constantFrom(
'',
'/',
'//',
'///',
' ',
'/ soorten-fotoshoots',
'/soorten-fotoshoots%2F',
'/soorten-fotoshoots/%2e%2e/',
'/soorten-fotoshoots\newborn',
'/soorten-fotoshoots?x=1',
'/soorten-fotoshoots#top',
'\u0000',
'/İNDEX',
'a'.repeat(5000),
);
// Prefix look-alikes of the overview: not the overview, not a shoot page
const lookAlike = fc.constantFrom(
'/soorten-fotoshoots-extra',
'/soorten-fotoshootsX',
'/soorten-fotoshoot',
'/soorten-fotoshoots/newborns',
'/soorten-fotoshoots/newborn/extra',
'/x/soorten-fotoshoots',
);
// The ways a visitor or the router may spell a path
const spelling = (path: string) =>
fc.constantFrom(
path,
`${path}/`,
path.toUpperCase(),
`${path.toUpperCase()}/`,
);
// A pathname: known routes and shoot pages in several spellings (trailing
// slash, letter case), prefix look-alikes and hostile strings
export const pathname: fc.Arbitrary<string> = fc.oneof(
{ weight: 4, arbitrary: knownRoutePath.chain(spelling) },
{
weight: 4,
arbitrary: shootTypeId.chain((id) => spelling(shootPagePath(id))),
},
{ weight: 2, arbitrary: lookAlike },
{ weight: 2, arbitrary: hostilePathname },
{ weight: 1, arbitrary: fc.string() },
);
+74
View File
@@ -0,0 +1,74 @@
import { act } from '@testing-library/react';
import { afterEach, vi } from 'vitest';
// Makes window.matchMedia answer for a viewport of `width` px, so Chakra's
// breakpoint hooks (min-width queries) and prefers-reduced-motion behave as
// in a browser. jsdom has no layout and ignores @media rules, so the
// responsive display of the desktop list and the mobile menu is applied by a
// style element here (the browser check is Step 17). The stub is undone by
// vi.restoreAllMocks() in the global afterEach.
const styleId = 'nav-viewport-style';
afterEach(() => document.getElementById(styleId)?.remove());
export function mockViewport(width: number, { reducedMotion = false } = {}) {
type Listener = (event: { media: string; matches: boolean }) => void;
const listeners: { query: string; listener: Listener }[] = [];
let current = width;
const matches = (query: string) => {
if (query.includes('prefers-reduced-motion')) return reducedMotion;
const min = /min-width:\s*([\d.]+)(px|em|rem)/.exec(query);
if (!min) return false;
return current >= parseFloat(min[1]) * (min[2] === 'px' ? 1 : 16);
};
vi.spyOn(window, 'matchMedia').mockImplementation(
(query: string) =>
({
get matches() {
return matches(query);
},
media: query,
onchange: null,
addEventListener: (_type: string, listener: Listener) => {
listeners.push({ query, listener });
},
removeEventListener: (_type: string, listener: Listener) => {
const index = listeners.findIndex(
(entry) => entry.listener === listener,
);
if (index >= 0) listeners.splice(index, 1);
},
addListener: () => {},
removeListener: () => {},
dispatchEvent: () => false,
}) as unknown as MediaQueryList,
);
// At lg and up the desktop list shows and the mobile menu is gone
const applyLayout = () => {
document.getElementById(styleId)?.remove();
if (current < 992) return;
const style = document.createElement('style');
style.id = styleId;
style.textContent =
'nav[aria-label="Hoofdmenu"] > ul { display: flex !important; }' +
'#mobile-nav { display: none !important; }';
document.head.append(style);
};
applyLayout();
return {
// Resizes the "window" and tells every listener, like a browser does
resize(next: number) {
current = next;
applyLayout();
act(() => {
for (const { query, listener } of [...listeners]) {
listener({ media: query, matches: matches(query) });
}
});
},
};
}