diff --git a/.ai/layout-conventions.md b/.ai/layout-conventions.md index 514f995..a20512a 100644 --- a/.ai/layout-conventions.md +++ b/.ai/layout-conventions.md @@ -13,7 +13,7 @@ Used by every page except Shell (see exception below): - If a page needs more blocks than the template currently has letters for, add a new letter/color rather than cycling back to `A` — never reuse a color, since that would visually suggest two different blocks are "the same element." A new color's stroke is always its fill at 25% darker (multiply each RGB channel by 0.75, round, convert back to hex), kept in the same style: medium-high saturation, similar lightness to the existing set. - For two sections that sit side-by-side in one row (e.g. Contact's Photo + Contact form), switch that page's diagram to `columns 2`, give full-width blocks a `:2` span, and place the side-by-side pair as plain unspanned nodes next to each other in the code (no composite container needed) — small manual width tweaks to line them up are fine, it only needs to look "good enough." -Current letter → color template (extend with a new letter using the same formula if an 8th block is ever needed): +Current letter → color template (letters A to J; extend with a new letter using the same formula if an 11th block is ever needed): ``` style A fill:#e76f51,stroke:#ad533d,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px @@ -23,6 +23,9 @@ style D fill:#264653,stroke:#1d353e,color:#fff,font-size:16px,width:400px,height style E fill:#e9c46a,stroke:#af9350,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px style F fill:#b56576,stroke:#884c59,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px style G fill:#6d7fcc,stroke:#525f99,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px +style H fill:#9b6bb5,stroke:#745088,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px +style I fill:#4cc3e0,stroke:#3992a8,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px +style J fill:#8cb83f,stroke:#698a2f,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px ``` ## Exception — Shell diff --git a/LAYOUT.md b/LAYOUT.md index 822e197..0ee15b4 100644 --- a/LAYOUT.md +++ b/LAYOUT.md @@ -88,6 +88,34 @@ columns 1 style G fill:#6d7fcc,stroke:#525f99,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px ``` +## Shoot page +```mermaid +block-beta +columns 1 + A["Intro"] + B["Story 1"] + C["Story 2"] + D["Story 3"] + E["Story 4"] + F["Process timeline"] + G["Photos"] + H["FAQ"] + I["Package"] + J["Book"] + + style A fill:#e76f51,stroke:#ad533d,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style B fill:#f4a261,stroke:#b77a49,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style C fill:#2a9d8f,stroke:#20766b,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style D fill:#264653,stroke:#1d353e,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style E fill:#e9c46a,stroke:#af9350,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style F fill:#b56576,stroke:#884c59,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style G fill:#6d7fcc,stroke:#525f99,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style H fill:#9b6bb5,stroke:#745088,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style I fill:#4cc3e0,stroke:#3992a8,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style J fill:#8cb83f,stroke:#698a2f,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px +``` +Photos is left out below the minimum number of photos. + ## Contact ```mermaid block-beta diff --git a/aidlc-docs/_shared/reverse-engineering/api-documentation.md b/aidlc-docs/_shared/reverse-engineering/api-documentation.md index e163c31..b8c78c6 100644 --- a/aidlc-docs/_shared/reverse-engineering/api-documentation.md +++ b/aidlc-docs/_shared/reverse-engineering/api-documentation.md @@ -14,7 +14,8 @@ None. There is no back-end yet (`api/` is empty). The static design README antic | `/` | `routes/index.tsx` | `pageHead('/')` | `Hero` + six home sections; search `?pakket=` | yes | | `/over-mij` | `routes/over-mij.tsx` | `pageHead('/over-mij')` + `AboutPage` JSON-LD | `PageIntro`, `AboutIntro`, `StorySection` ×2, `PhotoDuo`, `LinkButton` | yes | | `/portfolio` | `routes/portfolio.tsx` | `pageHead('/portfolio')` + `ImageGallery` JSON-LD; search `?shoot=` (`ShootTypeId`) | `PageIntro`, `PortfolioGallery`, `InstagramGrid` | yes | -| `/soorten-fotoshoots` | `routes/soorten-fotoshoots.tsx` | `pageHead('/soorten-fotoshoots')` + `WebPage` JSON-LD (`webPage()` + `shootServices()`) | `PageIntro`, `shoots/ShootList` (5× `ShootBlock`), `CallToAction`, `RichParagraph`, `LinkButton` | yes | +| `/soorten-fotoshoots` | `routes/soorten-fotoshoots/index.tsx` | `pageHead('/soorten-fotoshoots')` + `WebPage` JSON-LD via `StructuredData` (`webPage()` + `shootServices()`; Service `@id` `…/soorten-fotoshoots/#service` per D2) | `PageIntro`, `shoots/ShootList` (5× `ShootBlock`), `CallToAction`, `RichParagraph`, `LinkButton` | yes | +| `/soorten-fotoshoots/` (newborn, zwangerschap, gezin, loveshoot, portret) | `routes/soorten-fotoshoots/.tsx` | `pageHead('/soorten-fotoshoots/')` with its own `ogImage` (`/og-.jpg`, 1200 × 630, unit 2); JSON-LD via `StructuredData` (`shootPageGraph`: `WebPage` with the shoot's Service, `FAQPage` when there are questions) | `shoots/ShootPage` (intro, story blocks, process timeline, photo mosaic when there are at least two photos, FAQ when there are questions, package block, closing call to action), `NotFound` when `shootPageView` returns `undefined` | yes | | `/contact` | `routes/contact.tsx` | `pageHead(...)` | `PageIntro` placeholder | no | | `/privacyverklaring` | `routes/privacyverklaring.tsx` | `pageHead(...)` | `PageIntro` placeholder | no | | (not found) | — | — | `NotFound` | — | @@ -25,10 +26,11 @@ None. There is no back-end yet (`api/` is empty). The static design README antic - `canonicalUrl(path, base?)`, `jsonLdScript(data)`, `structuredDataScript(data)`, `professionalService(content)` (with `@id` `businessId` and `founder` → `personId`), `person(content, site, image)`, `aboutPage(path, content, site)` - `sitePages: Record`, `pageList(pages)` - `sitemapXml(...)` — used by `config/sitemapPlugin.ts` +- Shoot pages (unit 1): `shootServiceId(id)` (`…/soorten-fotoshoots/#service`), `shootService(shoot, site, pkg?)` (Service, `offers` only with `pkg`), `breadcrumbList(items)`, `faqPage(path, items)` (`undefined` without items), `shootPageGraph(view, site)` (WebPage + optional FAQPage); `shootServices` builds the overview list with `shootService` ### Components (props) - `AppShell()`, `NavigationBar()`, `BackToTop()`, `NotFound()` — no props -- `MobileNav({ id, open, onClose })`, `NavLink(RouterLink props)` +- `MobileNav({ id, open, groupOpen, pathname, dispatch })`, `NavLink(RouterLink props & { sectionCurrent? })`, `NavSubmenu({ item, id, open, pathname, transparent, toggleRef, dispatch })` (desktop panel), `MobileNavGroup({ item, id, open, pathname, dispatch })`, `ChevronIcon()` - `Footer({ content: SiteContent })`, `FooterColumn({ title, children })`, `FooterLink(LinkProps)` - `Hero({ content: HeroContent, socials: SocialLink[] })`, `HeroArrows({ onPrev, onNext })`, `HeroPauseButton({ stopped, onToggle })`, `HeroSocials({ socials })` - `PageIntro({ title, eyebrow?, children? })` — renders the page's only h1 @@ -53,6 +55,7 @@ None. There is no back-end yet (`api/` is empty). The static design README antic - `useSwipe({ onPrev, onNext, enabled? })` → `{ onTouchStart, onTouchEnd }` (threshold and direction from `lib/swipeDirection`) - `useScrolledPast(getThreshold)` → boolean (stable `getThreshold` required) - `useRouteFocus()` — focuses `
` after navigation +- `useDismiss(ref, active, onDismiss(reason: 'escape' | 'outside'))` — document-level Escape and outside pointer down, listeners only while `active` (unit 3) - `useInView({ rootMargin, skip })` → `{ ref, inView }`; `usePageLoaded()` → boolean; `useReveal()` → `{ ref, visible }` ### Pure helpers (`lib/`) @@ -64,6 +67,9 @@ None. There is no back-end yet (`api/` is empty). The static design README antic - `slideLabel`, `formatPrice`, `bookLabel`, `visiblePackages`, `visibleTestimonials`, `packageFromSearch`, `shootOptions`, `mailSubject`/`mailtoLink`, `validateField`/`validateContact`, `isLikelySpam`, `toContactPayload`, `contactFormReducer` - Portfolio (`lib/portfolioFilters.ts`): `isShootTypeId`, `shootTypesWithPhotos(shootTypes, photos)`, `shootFromSearch(value, available)`, `filterPhotos(photos, shoot)`, `filterOptions(shootTypes, allLabel)`, `toGalleryItems(photos, shootTypes)`, `photoCountLabel(n)`; `seo.ts`: `galleryImages(photos)` - Gallery (portfolio-page): `wrapIndex(index, count)`, `swipeDirection(start, end, threshold = 50)`, `masonryRowSpan({ width, height }, K = 40, gapRows = 2)`, `neighbourIndexes(index, count, radius = 2)`, `lightboxReducer(state, event)` (+ `LightboxState`, `LightboxEvent`) +- Shoot pages (unit 1): `shootPagePath(id)`, `shootIdFromSlug(slug)`, `shootIdFromPath(pathname)` (`lib/shootPages.ts`); `shootPackage(shoot, packages)` (`lib/shootPackage.ts`); `fillPlaceholders(text, values)`, `fillRichText(rich, values)` (`lib/fillPlaceholders.ts`); `richTextToPlain(text)` (`lib/richTextToPlain.ts`); `shootPageView(id, page, sources)` (`lib/shootPageView.ts`) +- Shoot pages (unit 2): `headingId(prefix, id)` (`lib/headingId.ts`), `readMoreLabel(shoot)` (`lib/readMoreLabel.ts`), `mosaicLayout(count): MosaicTile[]` (`lib/mosaicLayout.ts`), `storyLayout(stories): StoryLayout[]` (`lib/storyLayout.ts`), `shootPageBands(view): SectionBand[]` (`lib/shootPageBands.ts`; the section order of `ShootPage`), `isShootSectionPath(pathname)` (`lib/isShootSectionPath.ts`, FR-ST-14, used by `NotFound`) +- Navigation (unit 3): `shootNavItems(shoots): NavItem[]` (`lib/shootNavItems.ts`); `isItemCurrent(item, pathname)`, `isSectionCurrent(item, pathname)` (`lib/navCurrent.ts`); `navMenuReducer(state, event)` with `NavMenuState`, `NavMenuEvent`, `initialNavMenuState`, `FocusRequest` (`lib/navMenuState.ts`) ### Monitoring - `monitoringFor(hostname): Monitoring | null`, `startSentry(hostname?)`, `reportError(error)` @@ -95,6 +101,6 @@ None. There is no back-end yet (`api/` is empty). The static design README antic ### HeroContent - **Fields**: `title`, `tagline`, `cta: { label, to }`, `slides: { id, src, alt }[]` ### NavItem (`navigation.ts`) -- **Fields**: `to: RoutePath`, `label: string` +- **Fields**: `to: RoutePath`, `label: string`, `children?: readonly NavItem[]` (one level; `hasChildren(item)` is true only for a non-empty list; the shoot pages are the children of `/soorten-fotoshoots`) ### PageMeta (`sitePages.ts`) - **Fields**: `title`, `description`, `indexed`, `ogImage?` diff --git a/aidlc-docs/_shared/reverse-engineering/architecture.md b/aidlc-docs/_shared/reverse-engineering/architecture.md index 3ae2d3e..8a2e7eb 100644 --- a/aidlc-docs/_shared/reverse-engineering/architecture.md +++ b/aidlc-docs/_shared/reverse-engineering/architecture.md @@ -19,6 +19,7 @@ graph TD Outlet --> About["routes/over-mij.tsx: about page"] Outlet --> Portfolio["routes/portfolio.tsx: PortfolioGallery + InstagramGrid"] Outlet --> Placeholders["contact, privacyverklaring: PageIntro"] + Outlet --> ShootPages["routes/soorten-fotoshoots/: overview and five shoot pages"]:::page Home --> Hero["Hero (HeroArrows, HeroPauseButton, HeroSocials, useHeroSlider)"] Home --> Sections["components/home/: IntroGallery, AboutBlock, Pricing, Testimonials, ContactSection; shared InstagramGrid"] Sections --> Blocks["Shared blocks: PageSection, MediaText, CallToAction, RichParagraph, Eyebrow, SectionHeading, FramedImage, DeferredImage, Reveal; gallery: PortfolioGrid, Lightbox, FilterBar"] @@ -40,7 +41,7 @@ graph TD class Content,NavData,Seo,Theme,Blocks support; ``` -Text alternative: main.tsx starts Sentry and mounts the router; the root route renders AppShell (skip link, NavigationBar, the page via Outlet, Footer, BackToTop, Umami); the home route renders the Hero and six sections built from shared blocks (one of them lazily loads the contact form); the about route renders the Over mij page; the other routes render placeholder PageIntros; content, navigation, SEO and theme modules support all of it. +Text alternative: main.tsx starts Sentry and mounts the router; the root route renders AppShell (skip link, NavigationBar, the page via Outlet, Footer, BackToTop, Umami); the home route renders the Hero and six sections built from shared blocks (one of them lazily loads the contact form); the about route renders the Over mij page; the other routes render placeholder PageIntros; the shoot pages render `shoots/ShootPage`, whose sections follow `shootPageBands(view)` (`lib/shootPageBands.ts`): intro, stories, process, photos, FAQ, package, closing; content, navigation, SEO and theme modules support all of it. ## Component Descriptions ### main.tsx @@ -61,6 +62,7 @@ Text alternative: main.tsx starts Sentry and mounts the router; the root route r ### components/NavigationBar/ - **Purpose**: Site header and navigation - **Responsibilities**: Fixed header, transparent over the hero on desktop until scrolled; shrinks after scroll; logo links home; desktop links and full-screen mobile menu from `mainNav` +- **Menu state**: one `useReducer(navMenuReducer)` (`lib/navMenuState.ts`) holds the mobile menu, its group, the desktop submenu and the focus request, so the hamburger, the panels and the route listener cannot disagree; `routeChanged` closes everything (also on browser back) - **Type**: Application ### components/Footer/ @@ -97,6 +99,7 @@ Text alternative: main.tsx starts Sentry and mounts the router; the root route r - **Purpose**: Static content until the CMS API exists - **Responsibilities**: `types.ts` (API-shaped interfaces incl. `ContentImage`, `HomeContent`, `PricingPackage`, `Testimonial`), `siteContent.ts` (footer intro, socials, e-mail parts, contact form switch), `heroContent.ts`, `homeContent.ts` (texts and photos of the homepage sections), `packages.ts`, `testimonials.ts`, `socialPlatforms.ts` - **Type**: Application (data) +- **D5 (unit 3)**: `navigation.ts` imports `shootTypes` (the submenu is built from it), so the shoot type data is in the main bundle instead of its own chunk. Measured in the Step 16 build: main chunk 150.69 → 152.58 kB gzip (+1.89 kB, limit 2.5 kB; raw 528.98 → 536.68 kB) ### lib/ - **Purpose**: Pure, fully tested helpers diff --git a/aidlc-docs/_shared/reverse-engineering/code-structure.md b/aidlc-docs/_shared/reverse-engineering/code-structure.md index ff968dc..ca449e3 100644 --- a/aidlc-docs/_shared/reverse-engineering/code-structure.md +++ b/aidlc-docs/_shared/reverse-engineering/code-structure.md @@ -24,6 +24,8 @@ graph TD NavigationBar --> MobileNav["NavigationBar/MobileNav.tsx"] NavigationBar --> navigation["navigation.ts"] Footer --> navigation + navigation --> shootNavItems["lib/shootNavItems.ts"] + navigation --> shootTypes["content/shootTypes.ts"] Index["routes/index.tsx"] --> Hero["Hero/Hero.tsx"] Hero --> HeroArrows["Hero/HeroArrows.tsx"] Hero --> HeroPause["Hero/HeroPauseButton.tsx"] @@ -44,7 +46,7 @@ graph TD classDef util fill:#e2e8f0,stroke:#4a5568,stroke-width:1px,color:#000; class Root,AppShell,NavigationBar,Footer,BackToTop,Umami,NavLink,MobileNav shell; class Index,Hero,HeroArrows,HeroPause,HeroSocials,Placeholder,PageIntro,HomeParts page; - class navigation,useHeroSlider,LinkButton,RouterLink,PageSection,SectionHeading,Reveal,FramedImage,DeferredImage util; + class navigation,shootNavItems,shootTypes,useHeroSlider,LinkButton,RouterLink,PageSection,SectionHeading,Reveal,FramedImage,DeferredImage util; ``` Text alternative: the root route renders AppShell (NavigationBar, Footer, BackToTop, Umami); NavigationBar and Footer read navigation.ts; the index route renders the Hero and the six home sections, which are built from the shared PageSection, SectionHeading, Reveal, FramedImage and DeferredImage blocks; placeholder routes render PageIntro. @@ -58,48 +60,61 @@ Candidates for modification are marked with ★ for the over-mij-page feature. - `web/src/routes/index.tsx` — home (`/`): Hero + six sections, `?pakket=` search param - `web/src/routes/over-mij.tsx` — the about page (indexed; `AboutPage` JSON-LD) - `web/src/components/about/*` — `AboutIntro`, `StorySection` -- `web/src/components/shoots/*` — `ShootList`, `ShootBlock` (soorten-fotoshoots page) -- `web/src/components/{CallToAction,RichParagraph}/` — shared closing block; paragraph with inline links +- `web/src/components/shoots/*` — `ShootList`, `ShootBlock` (soorten-fotoshoots page; unit 2: "Lees meer over de …" link first in the row, to the shoot page) +- `web/src/components/shoots/ShootPage/ShootPage.tsx` — shoot page, `ShootPageView` in: intro, then the sections in `shootPageBands` order (unit 2: stories, process, photos, FAQ, package, closing; wrapper `data-testid="shoot-page"`) +- `web/src/components/shoots/{StoryBlocks,ProcessIcons}/` — shoot page parts (unit 2): one `PageSection` per story (`StoryBlocks`); the six process icons as inline SVG (`ProcessIcons`) +- `web/src/components/{Breadcrumb,ProcessTimeline,PhotoMosaic,FaqList,PackageBlock}/` — shoot page parts (unit 2), each with a test +- `web/src/components/StructuredData/StructuredData.tsx` — JSON-LD script via `jsonLdScript`; the only `dangerouslySetInnerHTML` of the shoot pages +- `web/src/components/{CallToAction,RichParagraph}/` — shared closing block (unit 2 adds `tone`); paragraph with inline links - `web/src/content/{shootTypes,shootTypesPageContent}.ts` — shoot types (also used by the portfolio filters) and page texts; `web/src/assets/shoots/` — 4:5 shoot photos - `web/src/lib/shootLinks.ts` — contact and portfolio link targets per shoot type +- `web/src/lib/{shootPages,shootPackage,fillPlaceholders,richTextToPlain,shootPageView}.ts` — shoot page helpers (ids and paths, package, placeholders, plain text, view), each with a test +- `web/src/lib/{headingId,readMoreLabel,mosaicLayout,storyLayout,shootPageBands}.ts` — shoot page helpers (unit 2): safe heading ids, "Lees meer" label, photo-mosaic and story layout, section bands; each with a test at 100 % coverage +- `web/src/lib/isShootSectionPath.ts` — whether a pathname is under `/soorten-fotoshoots/` (FR-ST-14, used by `StatusPage/NotFound`), with a property-based test +- `web/src/lib/{shootNavItems,navCurrent,navMenuState}.ts` — navigation helpers (unit 3), each with a test: submenu items from the shoot types (`shootNavItems`), current-page and section-current matching (`isItemCurrent`, `isSectionCurrent`), menu state reducer (`navMenuReducer`, `NavMenuState`, `NavMenuEvent`; `navMenuState.ts` at 100 % coverage) - `web/src/components/PhotoDuo/PhotoDuo.tsx` — two photos side by side - `web/src/content/aboutContent.ts` — about page content; `web/src/assets/about/*` — portrait and duo photos; `web/public/og-over-mij.jpg` — preview image -- `web/src/routes/soorten-fotoshoots.tsx` — the shoot types page +- `web/src/routes/soorten-fotoshoots/index.tsx` — the shoot types page (moved from `routes/soorten-fotoshoots.tsx`); `newborn.tsx`, `zwangerschap.tsx`, `gezin.tsx`, `loveshoot.tsx`, `portret.tsx` — one route per shoot page (`/soorten-fotoshoots/`); `-shootPageSources.ts` — the sources the shoot routes share +- `web/src/content/shootPageShared.ts` — shared shoot page content (breadcrumb, process, deposit, shared FAQ items, offer texts); `web/src/content/shootPages/*.ts` — one content module per shoot page, plus `shootPages.test.ts` (content consistency) +- `web/src/test/renderApp.tsx` — `renderApp(path)` and `expectShell()` for the route tests +- `web/src/shootPages.test.tsx` — route tests for the five shoot pages (unit 2): outline, sections, breadcrumb, `aria-current` (main and menus), package variants, OG registry, axe; the overview's "Lees meer" links - `web/src/routes/portfolio.tsx` — the portfolio (indexed; `?shoot=` filter; `ImageGallery` JSON-LD); `web/src/components/portfolio/PortfolioGallery/`, `web/src/content/portfolioContent.ts`, `web/src/lib/portfolioFilters.ts`, `web/src/assets/portfolio/*` (10 photos × 2 sizes), `web/public/og-portfolio.jpg` - `web/src/routes/{contact,privacyverklaring}.tsx` — placeholders with `PageIntro` - `web/src/components/AppShell.tsx` — shell -- `web/src/components/NavigationBar/*` — header, NavLink, MobileNav +- `web/src/components/NavigationBar/*` — header, NavLink (`sectionCurrent` underline for the parent of an open section), MobileNav (scrolls; Escape returns focus to the hamburger), NavSubmenu (desktop disclosure panel), MobileNavGroup (expandable shoot list on mobile), ChevronIcon - `web/src/components/Footer/*` — footer, FooterColumn, FooterLink - `web/src/components/Hero/*` — hero slider, arrows, pause button, socials, slider hook - `web/src/components/home/*` — five homepage sections (AboutBlock is the closest relative of the Over mij page's first block) - `web/src/components/InstagramGrid/InstagramGrid.tsx` — Instagram block, shared by the homepage and the portfolio (moved from `home/` in portfolio-page) - ★ `web/src/components/PageSection/PageSection.tsx` — section frame for any page (was `HomeSection`) -- ★ `web/src/components/MediaText/MediaText.tsx`, `Eyebrow/Eyebrow.tsx` — framed photo next to text; accent label +- ★ `web/src/components/MediaText/MediaText.tsx`, `Eyebrow/Eyebrow.tsx` — framed photo next to text; accent label (unit 2 adds `mediaSize` `'medium'`) - ★ `web/src/components/SectionHeading/SectionHeading.tsx` — eyebrow + h2 + lead - ★ `web/src/components/FramedImage/FramedImage.tsx`, `DeferredImage/DeferredImage.tsx`, `Reveal/Reveal.tsx` — photo blocks and fade-in - `web/src/components/ContactForm/*` — contact form and gate - `web/src/components/BackToTop/BackToTop.tsx` — back-to-top button - `web/src/components/Analytics/UmamiAnalytics.tsx` — Umami script injection -- ★ `web/src/components/PageIntro/PageIntro.tsx` — page head block (eyebrow, h1, intro) -- `web/src/components/StatusPage/*` — StatusPage layout, NotFound, ErrorPage +- ★ `web/src/components/PageIntro/PageIntro.tsx` — page head block (eyebrow, h1, intro; unit 2 adds optional `titleId` and `breadcrumb`) +- `web/src/components/StatusPage/*` — StatusPage layout, NotFound (unit 2, FR-ST-14: under `/soorten-fotoshoots/` buttons back to the overview and to home, decided by `lib/isShootSectionPath.ts`), ErrorPage - ★ `web/src/components/LinkButton.tsx`, `RouterLink.tsx` — router links (button style / Chakra-wrapped) - ★ `web/src/content/types.ts` — content interfaces (API shape) - ★ `web/src/content/*.ts` — static content (`siteContent`, `heroContent`, `homeContent` (exports `introPhotos`), `instagramContent`, `packages`, `testimonials`, `socialPlatforms`) - `web/src/contact/*` — contact form types and placeholder submit - `web/src/hooks/*` — `useRouteFocus`, `useScrolledPast`, `useInView`, `usePageLoaded`, `useReveal`, `useSwipe` (shared by the hero and the lightbox) +- `web/src/hooks/useDismiss.ts` — Escape and outside pointer down while active (`useDismiss(ref, active, onDismiss)`), used by NavSubmenu and MobileNav (unit 3) - `web/src/components/{PortfolioGrid,Lightbox,FilterBar}/` — gallery building blocks (portfolio-page unit 2): masonry grid in reading order (CSS only), lightbox on Chakra `Dialog` (lazy-loadable default export), single-choice toggle buttons; generic over `GalleryItem` / `FilterOption` - `web/src/lib/*.ts` — pure helpers with tests - `web/src/monitoring/*` — Sentry/Umami config and loader -- `web/src/navigation.ts` — `RoutePath`, `mainNav`, `footerNav` +- `web/src/navigation.ts` — `RoutePath`, `NavItem` (with `children`, one level), `hasChildren`, `mainNav` (the shoot submenu comes from `shootTypes` via `shootNavItems`), `footerNav` - ★ `web/src/seo.ts`, `sitePages.ts`, `sitemap.ts` — SEO (`/over-mij` is `indexed: false` today) - ★ `web/lighthouserc.cjs` / `.desktop.cjs` — own list of indexed/noindex paths, guarded by a test - `web/src/theme.ts`, `web/src/recipes/*.ts` — design system - `web/src/test/*` — `renderWithProviders`, axe matcher, fast-check arbitraries, `fakeIntersectionObserver`, setup +- `web/src/test/navArbitraries.ts` — navigation generators (menu events, menu states, pathnames; unit 3, not in `lib/` so the 100 % threshold does not apply); `web/src/test/navViewport.ts` — viewport helper (`matchMedia` stub and the `lg` display rules, because jsdom ignores `@media`) - `web/src/assets/*` — hero photos (8), `home/` (intro 1–4, andrea, deco 1–2, two review photos), light/dark logos - `web/config/securityHeaders.ts` — CSP - `web/config/serverConfig.ts`, `writeServerConfig.ts`, `sitemapPlugin.ts`, `testSeed.ts` - `web/deploy/iis/web.config`, `web/deploy/nginx/*.conf` — generated server configs -- `web/public/*` — favicon, logo, og-image, robots.txt, icons.svg +- `web/public/*` — favicon, logo, og-image, robots.txt, icons.svg; `og-{newborn,zwangerschap,gezin,loveshoot,portret}.jpg` (unit 2: 1200 × 630, the shoot pages' `ogImage`) ## Design Patterns ### API-shaped static content diff --git a/aidlc-docs/active-features.md b/aidlc-docs/active-features.md index a6596aa..e4f8074 100644 --- a/aidlc-docs/active-features.md +++ b/aidlc-docs/active-features.md @@ -9,3 +9,4 @@ | Feature | soorten-fotoshoots-page | ✅ Complete | feature/soorten-fotoshoots-page | web/src/routes/soorten-fotoshoots.tsx, new web/src/content/shootTypes.ts, new web/src/assets/shoots/, new shared CallToAction, MediaText (reverse prop), Pricing (id="prijzen" only), siteContent (service area), own entries in sitePages.ts / lighthouserc.cjs, JSON-LD via the shared webPage() helper in seo.ts | 2026-10-24 | | Feature | contact-page | ✅ Complete | feature/contact-page | web/src/routes/contact.tsx, web/src/content, possibly ContactForm/ContactSection, PageIntro, MediaText/FramedImage, web/src/seo.ts, sitePages/sitemap | 2026-10-24 | | Feature | portfolio-page | ✅ Complete | feature/portfolio-page (based on master after over-mij merge; worktree ../AndreaSlopFotografie-portfolio) | web/src/routes/portfolio.tsx, web/src/content, new PortfolioGrid + Lightbox, InstagramGrid (moved to shared), own entries in sitePages.ts / lighthouserc.cjs, ImageGallery JSON-LD via the shared webPage() helper | 2026-10-24 | +| Feature | shoot-type-pages | ✅ Complete (content follow-up: [content-pending.md](features/shoot-type-pages/content-pending.md)) | feature/shoot-type-pages (worktree ../AndreaSlopFotografie-shoot-type-pages) | new route(s) per shoot type under web/src/routes, web/src/content (shootTypes.ts extension, timeline content), shared Timeline component, links from soorten-fotoshoots, seo.ts (webPage helper), sitePages.ts / sitemap, lighthouserc.cjs | 2026-10-29 | diff --git a/aidlc-docs/features/shoot-type-pages/aidlc-state.md b/aidlc-docs/features/shoot-type-pages/aidlc-state.md new file mode 100644 index 0000000..ecab440 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/aidlc-state.md @@ -0,0 +1,64 @@ +# AI-DLC State Tracking + +## Project Information +- **Feature Name**: Shoot type pages (one page per shoot type, e.g. `/soorten-fotoshoots/`) +- **Feature Slug**: shoot-type-pages +- **Project Type**: Brownfield +- **Start Date**: 2026-10-29T17:19:19Z +- **Current Stage**: Complete (merged to master via PR #13; content follow-up as a separate feature, see content-pending.md) +- **Branch**: feature/shoot-type-pages (from master 18e81d0) +- **Worktree**: K:\Development\SlpSoftware\Projects\AndreaSlopFotografie-shoot-type-pages + +## Workspace State +- **Existing Code**: Yes +- **Programming Languages**: TypeScript (React/TSX) +- **Build System**: pnpm + Vite (`tsc && vite build`), Gitea Actions CI +- **Project Structure**: Single front-end SPA in `web/`; static HTML design reference in `design/andreaslop-static/`; `api/` (.NET back-end) +- **Reverse Engineering Needed**: No (team agreement: no full RE refresh per feature; only this feature's own route/component lines are updated in `_shared/reverse-engineering/`) +- **Workspace Root**: K:\Development\SlpSoftware\Projects\AndreaSlopFotografie-shoot-type-pages + +## Code Location Rules +- **Application Code**: Workspace root (NEVER in aidlc-docs/) — front-end lives in `web/` +- **Feature Documentation**: aidlc-docs/features/shoot-type-pages/ only +- **Shared Artifacts**: aidlc-docs/_shared/ +- **Structure patterns**: See code-generation.md Critical Rules + +## Language Configuration +- **Documentation Language**: English +- **Conversation Language**: User Language (Dutch) +- **Source**: inherited from aidlc-docs/language-preference.md (answer A); user may override + +## Orchestration +- The main session orchestrates and is the only Opus (user, 2026-10-30). Sub-agents: Haiku where it can handle the task (registry/config entries, docs, running checks), otherwise Sonnet (code and tests from the plan, content drafts, functional design, diagnosis, reviews). Two Opus sub-agents already running for unit 1 steps 3–7/13 and 8–12/14–15 were kept to finish + +## Extension Configuration +| Extension | Enabled | Decided At | +|---|---|---| +| Security Baseline | Yes | Requirements Analysis | +| Property-Based Testing | Yes (full enforcement) | Requirements Analysis | + +## Operations Configuration +- **Include Operations Phase**: No +- **Decided At**: Requirements Analysis + +## Stage Progress + +### 🔵 INCEPTION PHASE +- [x] Workspace Detection +- [x] Reverse Engineering - SKIP (shared artifacts used; delta lines only) +- [x] Requirements Analysis (approved) — design E chosen (canvas https://claude.ai/artifact/BdXmEgsTPK2567g9AFQCXa) +- [x] User Stories - SKIP (single visitor persona; concrete FRs) +- [x] Workflow Planning (approved) +- [x] Application Design - EXECUTE (standard) — approved (D1–D6 all A) +- [x] Units Generation - SKIP (three units fixed in the plan) + +### 🟢 CONSTRUCTION PHASE +- [x] Functional Design - EXECUTE (units 2, 3) / SKIP (unit 1) — both approved 2026-10-30 +- [ ] NFR Requirements - SKIP +- [ ] NFR Design - SKIP +- [ ] Infrastructure Design - SKIP +- [x] Code Generation - EXECUTE (per unit): 1 Content and SEO foundation ✅ (e5f4348) → 2 Shoot page UI ✅ ∥ 3 Navigation submenu ✅ (7af2069; plus FR-ST-14); open: unit 2 Step 23 mobile Lighthouse gezin/loveshoot < 0.85 (owner keeps fade-in) +- [x] Build and Test - EXECUTE (build and 888 tests pass at d3bc1d7; content pending, see content-pending.md) + +### 🟡 OPERATIONS PHASE +- [ ] Deployment Setup, Monitoring Setup, Production Readiness Validation - SKIP (Operations = No) diff --git a/aidlc-docs/features/shoot-type-pages/audit.md b/aidlc-docs/features/shoot-type-pages/audit.md new file mode 100644 index 0000000..20e05b4 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/audit.md @@ -0,0 +1,439 @@ +# AI-DLC Audit Log — shoot-type-pages + +## Workspace Detection — Initial Request + +**Timestamp**: 2026-10-29T17:19:19Z + +**User Input**: "Ik wil voor de front-end per shoot type een pagina maken. Dat zou de SEO moeten verbeteren en je kan per shoor dieper ingaan op wat het inhoudt en eventueel een paar higlighted foto's laten zien als impressie. Je zou ook wat mee rgenerieke info kunnen laten zien die je op elke pagina laat zien zoals een tijdlijn om een indruk te krijgen welke stappen worden doorlopen zoals aanvragen, datum & locatie kiezen., aanbetaling. Shoot en de duur voor het opleveren van de foto's (dit zou per shoot kunnen verschillen) en de oplevering om even een idee te geven. Ik wil dit met aidlc doen. Zorg dat je gedurende dit proces sub-agents gebruikt zodat je kleinere taken aan kleinere agents kan geven en complexere taken aan grotere. Jijzelf kan dan de orchstratie doen. Ik zou ook graag eerst een paar suggesties voor een design willen zien" + +**AI Response**: "Classified as Feature (new user-facing pages). Brownfield; shared reverse-engineering artifacts reused (no full refresh, per team agreement). Created worktree ../AndreaSlopFotografie-shoot-type-pages on branch feature/shoot-type-pages from master 18e81d0. Language inherited from language-preference.md (English docs, Dutch chat). Next: Requirements Analysis, starting with design suggestions produced by sub-agents." + +**Context**: Workspace Detection complete. Parallel sessions: one idle interactive peer (andreaslopfotografie-d3, task unknown); no active features in active-features.md, so no component conflicts. + +--- + +## Requirements Analysis — Design Suggestions and Clarifying Questions + +**Timestamp**: 2026-10-29T17:52:00Z + +**User Input**: "(none; continuing from the initial request, which asked for design suggestions first)" + +**AI Response**: "Sub-agent (sonnet) gathered a context brief (brand tokens, shoot content, photos, routing/SEO, LAYOUT.md rules). Sub-agent (opus) produced three layout directions for the newborn page as an example (A Verhaal / B Beeld eerst / C Praktisch) plus a mobile timeline board, published on the Design canvas https://claude.ai/artifact/BdXmEgsTPK2567g9AFQCXa. Created inception/requirements/requirement-verification-questions.md (12 content questions + security, PBT and Operations opt-ins). Findings: only newborn/zwangerschap/gezin have packages; loveshoot and portret have 2 photos each; no deposit or delivery-time content exists anywhere." + +**Context**: Requirements Analysis, Step 6 — awaiting answers (gate). + +--- + +## Requirements Analysis — Design Feedback + +**Timestamp**: 2026-10-29T18:10:00Z + +**User Input**: "We hebben de foto's bekeken. Optie A is het beste, maar met een paar aanpassingen. Het stukje \"Pakket\" mag vervangen worden met de stijl van Pakket van optie B. Ook zou ik graag een wat visuelere tijdlijn zien. Als het past nog gewoon horizontaal met icoontjes in plaats van nummers en de tekst om en om aan de ene kant van de lijn en dan de andere kant. Kan je dat in Ontwerp D verwerken?" + +**AI Response**: "Delegated design D to a sub-agent (opus): direction A as base, B's package section, horizontal icon timeline with step texts alternating above/below the line (vertical on narrow screens), plus a phone board of the timeline. To be published on the same canvas." + +**Context**: Requirements Analysis — design iteration before the questions are answered. + +--- + +## Requirements Analysis — Answers Received + +**Timestamp**: 2026-10-29T18:35:00Z + +**User Input**: "ik heb de vragen beantwoord" — answers in requirement-verification-questions.md: Q1 "D + de FAQ van optie C. Zet dat eventueel als Design E in de design asset zodat ik hem nog kan bekijken voordat het gebouwd wordt."; Q2 A; Q3 A; Q4 A; Q5 "X, De termijn voor nu is voor alles 2-3 weken"; Q6 "A, €50,-"; Q7 A; Q8 A; Q9 "A, dit kan een mix zijn van specifieke vragen voor dat type shoot en algemene vragen."; Q10 "A, Andrea levert later meer foto's aan"; Q11 B; Q12 A; Security A; PBT A; Operations B. + +**AI Response**: "No contradictions. Open point: deposit settlement and refund policy → requirement-clarification-questions.md (2 questions) with my reading of Q1+Q3 and Q2+Q4 stated for correction. Design E (D + FAQ from C, confirmed € 50 and 2–3 weken filled in) delegated to a sub-agent (sonnet)." + +**Context**: Requirements Analysis — clarification round. + +--- + +## Requirements Analysis — Clarifications Received + +**Timestamp**: 2026-10-29T19:05:00Z + +**User Input**: "Ik heb de vragen beantwoord" — requirement-clarification-questions.md: Verduidelijkingsvraag 1 A (deposit settled against the total, remainder paid after the shoot); Verduidelijkingsvraag 2 B (cancellation/rescheduling not mentioned on the site). Stated readings (loveshoot/portret "Prijs op aanvraag" + 2 photos; URLs under /soorten-fotoshoots/, anchors kept) left uncorrected → accepted. + +**AI Response**: "Design E published on the canvas (version 5). requirements.md delegated to a sub-agent (opus) with all answers, design E, and the Security Baseline and PBT rules." + +**Context**: Requirements Analysis — Step 7 (generate requirements document). + +--- + +## Requirements Analysis — Design Confirmed + +**Timestamp**: 2026-10-29T19:08:00Z + +**User Input**: "Ja, design is E de basis" + +**AI Response**: "Recorded design E as the confirmed basis for the requirements." + +**Context**: Requirements Analysis — design decision. + +--- + +## Requirements Analysis — Approval Prompt + +**Timestamp**: 2026-10-29T19:25:00Z + +**User Input**: "(none)" + +**AI Response**: "requirements.md written by a sub-agent (opus) and reviewed by the orchestrator: 13 FR, 5 SEO, 7 NFR, 5 content requirements, Security/PBT compliance tables, traceability. Presented the completion message with options Request Changes / Add User Stories / Continue to Workflow Planning." + +**Context**: Requirements Analysis — awaiting approval. + +--- + +## Requirements Analysis — Change Request + +**Timestamp**: 2026-10-29T19:32:00Z + +**User Input**: "De newbornshoot is ietsje anders dan de rest. Je bent daar afhankelijk van wanneer de baby geboren wqordt. dus die tekst mag blijven staan." + +**AI Response**: "Moved the Newborn 'voorlopige datum … schuiven mee' line from CON-ST-04 (open) to CON-ST-01 (fixed facts) as a Newborn-specific exception to Clarification 2 = B; other shoots get no such line. Re-presented the approval prompt." + +**Context**: Requirements Analysis — requirements.md updated; awaiting approval. + +--- + +## Requirements Analysis — Approval + +**Timestamp**: 2026-10-29T19:40:00Z + +**User Input**: "ga verder" + +**AI Response**: "Requirements approved; User Stories skipped; proceeding to Workflow Planning." + +**Context**: Requirements Analysis complete. + +--- + +## Workflow Planning — Approval Prompt + +**Timestamp**: 2026-10-29T19:55:00Z + +**User Input**: "(none)" + +**AI Response**: "Created inception/plans/execution-plan.md: risk Medium; execute Application Design (standard), Functional Design (units 2, 3), Code Generation (3 units: 1 content+SEO foundation → 2 shoot page UI ∥ 3 navigation submenu), Build and Test; skip RE, User Stories, Units Generation, NFR Requirements/Design, Infrastructure Design, Operations. Content approval gate by Andrea before merge. Presented approval prompt." + +**Context**: Workflow Planning — awaiting approval. + +--- + +## Workflow Planning — Approval + +**Timestamp**: 2026-10-29T20:00:00Z + +**User Input**: "continue to next stage" + +**AI Response**: "Plan approved; proceeding to Application Design (delegated to an opus sub-agent)." + +**Status**: Approved + +**Context**: Workflow plan created with 5 stages to execute (Application Design, Functional Design ×2, Code Generation ×3, Build and Test). + +--- + +## Application Design — Design Written, Questions Created + +**Timestamp**: 2026-10-29T20:20:00Z + +**User Input**: "(none)" + +**AI Response**: "Sub-agent (opus) wrote application-design.md, components.md, component-methods.md, services.md, component-dependency.md and plans/application-design-plan.md. Recommendation: five static route files + overview moved to soorten-fotoshoots/index.tsx; pure shootPageView feeding both the page and the JSON-LD; units 2 and 3 have disjoint file sets. Six user decisions (D1–D6) put in inception/application-design/application-design-questions.md. Risks noted: TanStack prefix-active links → aria-current on parents, no node_modules in the worktree, Lighthouse sync test checks order, MobileNav cannot scroll, main bundle growth vs the / 0.8 budget." + +**Context**: Application Design — awaiting answers. + +--- + +## Application Design — Answers Received + +**Timestamp**: 2026-10-30T08:00:00Z + +**User Input**: "ik heb de vragen beantwoord" — application-design-questions.md: Q1 A, Q2 A, Q3 A, Q4 A, Q5 A, Q6 A. + +**AI Response**: "All answers match the recommendations; design unchanged, confirmation noted in application-design.md. Presented the Application Design completion message." + +**Context**: Application Design — awaiting approval. + +--- + +## Application Design — Approval + +**Timestamp**: 2026-10-30T08:10:00Z + +**User Input**: "continue to next stage" + +**AI Response**: "Application Design approved. Proceeding to CONSTRUCTION, unit 1 (Content and SEO foundation): Functional Design skipped for unit 1 per plan → Code Generation Part 1 (planning)." + +**Context**: Application Design complete. + +--- + +## Code Generation (unit 1) — Plan Approval Prompt + +**Timestamp**: 2026-10-30T08:40:00Z + +**User Input**: "(none)" + +**AI Response**: "Sub-agent (opus) wrote construction/plans/content-and-seo-foundation-code-generation-plan.md: 27 steps tagged [small]/[large]. Deviations from the design surfaced: no typecheck script (use pnpm exec tsc); route tree regenerated via vite build; lighthouserc.d.cts and sitemap.test.ts added to unit 1 scope; old Service @id tests rewritten (D2); Newborn copy drops the package-count sentence and the unconfirmed 'dekens' line; Loveshoot/Portret duration and the gallery step marked DRAFT + OPEN(CON-ST-04); nav/'Lees meer' consistency checks moved to units 3/2. Presented plan approval prompt." + +**Context**: Code Generation unit 1 — Part 1 Planning, awaiting approval. + +--- + +## Code Generation (unit 1) — Plan Approval + +**Timestamp**: 2026-10-30T08:50:00Z + +**User Input**: "approve plan" + +**AI Response**: "Plan approved. Starting Part 2 with sub-agents: sonnet steps 1–2 → parallel opus (content 3–7, 13) and opus (logic/SEO 8–12, 14–15) → opus routes/app tests (16–18, 22) ∥ sonnet registry/config (19–21) → sonnet verification/docs (23–26)." + +**Status**: Approved + +**Context**: Code Generation unit 1 — Part 2 Generation. + +--- + +## Orchestration — Model Choice + +**Timestamp**: 2026-10-30T09:20:00Z + +**User Input**: "Is het echt nodig om beide agents in opis te doen en niet in sonnet of misschien zelfs Haiku?" … "Houd ze aan en pas de verdeling vanaf hier aan. Als het kan wil ik dat jij de enige Opus bent. Verder wil ik het liefst Haiku gebruiken en anders Sonnet. De agent moet natuurlijk wel de taak aankunnen" + +**AI Response**: "Running Opus agents kept. From here: orchestrator is the only Opus; Haiku for mechanical steps (19–21, 25–26), Sonnet for routes/app tests (16–18, 22), verification (23–24), functional designs and reviews. Recorded in aidlc-state.md § Orchestration and in memory." + +**Context**: Code Generation unit 1 — Part 2; orchestration change. + +--- + +## Code Generation (unit 1) — Completion Prompt + +**Timestamp**: 2026-10-30T12:30:00Z + +**User Input**: "(none)" + +**AI Response**: "Unit 1 generated by sub-agents (Steps 1–26; Step 24 not green). Verification: lint/format/tsc clean; 90 files / 595 tests pass; coverage 95.4 % lines; build OK; lockfile unchanged; shoot content only in route chunks. pnpm check stops at audit:deps (seroval@1.6.7 advisories, identical lockfile on master → pre-existing). Lighthouse: desktop all green (shoot pages 100); mobile shoot pages 0.90, '/' 0.76 and '/contact' 0.85 fail — master measured the same way fails too (0.78 / 0.87). Router matches paths case-insensitively (left unchanged). Asked the user to choose the seroval fix (A separate branch from master / B commit on this branch) and presented the unit 1 completion message." + +**Context**: Code Generation unit 1 — awaiting approval. + +--- + +## Code Generation (unit 1) — Seroval Fix and Content Review + +**Timestamp**: 2026-10-30T13:10:00Z + +**User Input**: "kan je toelichten wat het probleem met seroval is?" … "ja, doe maar optie A voor de seroval fix. Kan jij 1 bestand maken met alle conceptteksten en waar ze te vinden zijn zodat ik die aan Andrea kan geven en zij alvast kan kijken wat ze ermee wil of dat ze het goedkeurt? Verder ook nog even aangeven waar je hoeveel foto's nodig hebt om de initiële pagina's neer te zetten zoals het design." + +**AI Response**: "Explained the three seroval advisories (fromJSON/fromCrossJSON DoS and callable invocation; not reachable in this client-only SPA, seroval absent from the bundle, but the audit gate blocks). Option A: worktree ../AndreaSlopFotografie-seroval-fix on branch fix/seroval-advisories from origin/master 18e81d0; fix delegated to a sonnet sub-agent (no commit until the user asks). Review document for Andrea (Word + Markdown copy in construction/content-review/) with all DRAFT texts, open questions and photo needs per shoot delegated to a sonnet sub-agent." + +**Context**: Unit 1 still awaiting approval; side tasks in progress. + +--- + +## Seroval Fix — Merged + +**Timestamp**: 2026-10-30T08:50:00Z + +**User Input**: "ja je mag de seroval fix committen pushen en pr maken en meteen afronden zodat we hier verder kunnen" + +**AI Response**: "Committed ddc3743 on fix/seroval-advisories (pnpm overrides seroval/seroval-plugins ^1.6.8 → 1.7.3), pushed, PR #12. CI run 583: check green; lighthouse job failed in pnpm/action-setup with exit code -1 (runner glitch, same step passed in check) → rerun via API (job 4820) green. Merged PR #12 (merge commit 1416497, branch deleted on the server). Peer session unreachable for the merge announcement. Fast-forwarded feature/shoot-type-pages to 1416497 (unit 1 still uncommitted, no conflicts); pnpm install, audit:deps clean, tsc clean, 90 files / 595 tests green. Fix worktree removed from git; its folder could not be deleted (long paths, removal blocked) — left for the user." + +**Context**: Unit 1 still awaiting approval. + +--- + +## Code Generation (unit 1) — Approval + +**Timestamp**: 2026-10-30T09:00:00Z + +**User Input**: "ga verder naar de volgende stage. Andrea controleert ondertussen de teksten en de foto's" + +**AI Response**: "Unit 1 approved (still uncommitted). active-features.md → 🟢 Construction. Starting Functional Design for unit 2 (Shoot page UI) and unit 3 (Navigation submenu) in parallel with sonnet sub-agents; Andrea reviews the texts and photos meanwhile." + +**Status**: Approved + +**Context**: Code Generation unit 1 complete; CONSTRUCTION - Functional Design units 2 and 3. + +--- + +## Functional Design (units 2 and 3) — Questions Created + +**Timestamp**: 2026-10-30T09:40:00Z + +**User Input**: "(none)" + +**AI Response**: "Sonnet sub-agents wrote provisional functional designs (based on their recommended options) for unit 2 shoot-page-ui (7 questions) and unit 3 navigation-submenu (5 questions). Orchestrator added two deviation questions: unit 3 Q6 (pure navMenuReducer in new lib/navMenuState.ts) and unit 2 Q8 (optional MediaText mediaSize='medium' and CallToAction tone). Noted: test/arbitraries.ts appends from units 2 and 3 must run sequentially; 1024 px nav fit and Lighthouse with real photos are estimates until Code Generation." + +**Context**: Functional Design units 2 and 3 — awaiting answers. + +--- + +## Functional Design (units 2 and 3) — Answers Received in Chat + +**Timestamp**: 2026-10-30T10:00:00Z + +**User Input**: "kan je de vragen hier sturen?" — answers via the chat question dialog: unit 2 — Q1 "In de blokken (Recommended)", Q2 "2 foto's (Recommended)", Q3 "Nee (Recommended)", Q4 "Eigen band (Recommended)", Q5 "Allemaal dicht", Q6 "Tekstlink (Recommended)", Q7 "Uitsnede shootfoto (Recommended)", Q8 "Ja, uitbreiden (Recommended)"; unit 3 — Q1 "Klik/tik/toetsenbord (Recommended)", Q2 "Zoals hoofdmenu (Recommended)", Q3 "Dicht, open op shootpagina (Recommended)", Q4 "Ja, sluiten (Recommended)", Q5 "Korte animatie (Recommended)", Q6 "Ja, reducer (Recommended)". + +**AI Response**: "Questions asked in chat at the user's request (deviation from the file-based question format, answers written back into the question files). Only change from the provisional designs: all FAQ items closed on load. Haiku sub-agent records the answers, finalises the FD artifacts, and adds the approved deviations (MediaText mediaSize, CallToAction tone, lib/navMenuState.ts) to the application design ownership table." + +**Context**: Functional Design units 2 and 3 — finalising before approval. + +--- + +## Functional Design (units 2 and 3) — Approval Prompt + +**Timestamp**: 2026-10-30T10:15:00Z + +**User Input**: "(none)" + +**AI Response**: "Answers recorded in both question files; FD artifacts finalised (unit 2 FAQ all closed on load, faqInitiallyOpen dropped); approved deviations added to application-design.md and services.md. Presented the Functional Design completion messages for shoot-page-ui and navigation-submenu." + +**Context**: Functional Design units 2 and 3 — awaiting approval. + +--- + +## Functional Design (units 2 and 3) — Approval + +**Timestamp**: 2026-10-30T10:25:00Z + +**User Input**: "continue to next stage" + +**AI Response**: "Both functional designs approved. Starting Code Generation Part 1 (plans) for units 2 and 3 in parallel with sonnet sub-agents; unit 3 keeps its test generators out of test/arbitraries.ts to avoid a shared file." + +**Status**: Approved + +**Context**: Functional Design complete for units 2 and 3. + +--- + +## Code Generation (units 2 and 3) — Plan Approval Prompt + +**Timestamp**: 2026-10-30T10:50:00Z + +**User Input**: "(none)" + +**AI Response**: "Sonnet sub-agents wrote shoot-page-ui-code-generation-plan.md (27 steps, incl. a STOP for OG crop approval) and navigation-submenu-code-generation-plan.md (20 steps, incl. the D5 bundle gate, a real-browser 1024 px check via puppeteer-core outside the repo, and a Lighthouse median-of-three comparison against the unit-1 baseline). Orchestrator corrected unit 2 Step 22: the branch already contains the seroval patch (1416497, seroval@1.7.3), so audit:deps is part of the gate. Findings: router `exact` is case-sensitive and includes search by default → plan uses { exact: true, includeSearch: false }; Gezin OG source changed to f41a7138-groot (f41a1579 is already og-portfolio.jpg); no image tool installed → System.Drawing/Pillow in the scratchpad. Presented both plans for approval." + +**Context**: Code Generation units 2 and 3 — Part 1 Planning, awaiting approval. + +--- + +## Code Generation (units 2 and 3) — Plan Approved +**Timestamp**: 2026-10-30T12:27:54Z +**User Input**: "approve plan" +**AI Response**: Both plans approved. Part 2 started: unit 2 (shoot-page-ui) Steps 1–2 by a Sonnet agent, stopping for OG-crop approval; unit 3 (navigation-submenu) Steps 1–16 by a Sonnet agent in parallel, stopping before the port-4173 steps 17–18. Only unit 3 runs builds in the shared worktree. +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation — Commit, push and test deploy authorised +**Timestamp**: 2026-10-30T12:32:38Z +**User Input**: "je mag wel meteen committen, pushen en deployen naar test. Ik zit nu niet thuis dus dan kan ik het via de testomgeving bekijken. dat is prima" +**AI Response**: Committed unit 1 as e5f4348 (OG crops of unit 2 left out, awaiting approval), pushed feature/shoot-type-pages, dispatched CI run 585 with deploy_test=true. Units 2 and 3 will be committed and deployed to test the same way once each reaches a green, coherent state. No merge to master (DRAFT gate still open). +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation (unit 2) — OG crops approved +**Timestamp**: 2026-10-30T12:49:25Z +**User Input**: "akkoord op alle 5 de deelafbeeldingen. De volgende deploy naar test hoef je pas te doen als beide units klaar zijn. Tussendoor hoeft niet" +**AI Response**: All five OG crops approved as produced (contact sheet in scratchpad og-crops). Unit 2 resumes at Step 3. Next commit, push and test deploy only once units 2 and 3 are both complete. CI run 585 (unit 1, e5f4348): check and deploy-test succeeded. +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation — Requirement added: FR-ST-14 (404 inside the shoot section) +**Timestamp**: 2026-10-30T12:58:10Z +**User Input**: "oh ik weet niet of dit goed te fixen is. Ik zou het hier wel bij willen doen namelijk. Maar als je naar /soorten-fotohoots/niet-bestaande-shoot gaat dan krijg je een 404 met \"Terug naar home\". Kan hier iets komen van \"Terug naar Soorten Fotoshoots of Terug naar Home\"?" +**AI Response**: Root cause: unmatched paths fall to the root notFoundComponent (no soorten-fotoshoots layout route), and StatusPage defaults to one home button. Added FR-ST-14: NotFound reads the pathname and, under /soorten-fotoshoots/, shows "Terug naar Soorten fotoshoots" (accent) + "Terug naar home" (outline), same pattern as ErrorPage. No layout route, so unit 3 matching and the bundle are unaffected. Delegated to a Sonnet agent; files (components/StatusPage/*) are disjoint from units 2 and 3; no builds (unit 3 owns them). +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation — FR-ST-14 implemented +**Timestamp**: 2026-10-30T13:00:55Z +**AI Response**: NotFound reads the pathname via useRouterState (same as NavigationBar) and uses new pure helper lib/isShootSectionPath.ts (case-insensitive prefix '/soorten-fotoshoots/'); unit + PBT tests and 3 StatusPage tests (two links in order + axe, mixed case, single link elsewhere). Scoped vitest 18/18, tsc and lint clean on these files. Reviewed by orchestrator. Full verification runs with the unit 2/3 gates. +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation (unit 3) — Steps 1–16 complete +**Timestamp**: 2026-10-30T13:01:52Z +**AI Response**: Unit 3 Steps 1–16 done; D5 bundle gate passed (main chunk gzip 150.69 → 152.58 kB, +1.89 kB, limit 2.5 kB); lint/format/tsc green; 801 tests passing. Its reported coverage failure on lib/isShootSectionPath.ts was a mid-run race with the FR-ST-14 agent (source written 13:59:04, test 13:59:05); re-run alone gives 9 tests and 100% coverage. Steps 19–20 (docs) delegated to Haiku. Steps 17–18 (real browser, Lighthouse on port 4173) deferred until unit 2 finishes Step 21, so they measure a coherent build. +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation (unit 2) — Steps 3–21 complete; cross-unit test fix +**Timestamp**: 2026-10-30T13:17:14Z +**AI Response**: Unit 2 Steps 3–21 done (113 files / 883 tests, 1 failing). Root cause of the failure: unit 3's case-variant test counted every aria-current on the page; unit 2's breadcrumb legitimately marks its last item aria-current="page" (BR-SP-01), and the router renders the page on /soorten-fotoshoots/Newborn. Orchestrator narrowed the assertion: exactly one mark, a non-link inside the "Kruimelpad" nav (no nav/footer link marked). navSubmenu.test.tsx 18/18. LAYOUT.md Prettier warnings are pre-existing on HEAD and outside web/'s format check; left as is. Sequential gates delegated to one Sonnet agent: unit 2 Step 22 → unit 3 Step 17 → unit 3 Step 18 → unit 2 Step 23 → unit 2 Step 26 (sole owner of port 4173). +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation (units 2 and 3) — Sequential gates +**Timestamp**: 2026-10-30T13:43:43Z +**AI Response**: Unit 2 Step 22 pass (lint, format, tsc, build, audit:deps with seroval 1.7.3, 113 files / 883 tests, main gzip 152.56 kB = +1.87 kB vs unit 1, DRAFT markers 98). Unit 3 Step 17 pass (110/110 browser checks, 1024/1100/1280 fit, keyboard, reduced motion, short phones). Unit 3 Step 18 pass (mobile / pooled median 0.77 vs baseline 0.77). Unit 2 Step 26 done (exactly three aria-current per shoot page: breadcrumb, header submenu link, mobile sub-link; 888 tests). Unit 2 Step 23 NOT green: mobile gezin 0.84–0.85 and loveshoot 0.83 below the 0.85 budget (unit 1 shell-only 0.90); LCP render delay ~2.9 s after the main bundle, photo itself fast; / and /contact below budget as on master. Desktop 0.99–1.00. Decision on mitigation goes to the user. Per the user's instruction (deploy when both units are done; CI deploy-test does not wait on Lighthouse) units 2 and 3 plus FR-ST-14 are committed, pushed and deployed to test now. +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation (unit 2) — Lighthouse mitigation declined for now +**Timestamp**: 2026-10-30T14:15:20Z +**User Input**: "laat de fade-in nog maar even staan" +**AI Response**: Reveal fade-in on story 0 stays. Unit 2 Step 23 stays open as a known item: mobile gezin 0.84–0.85 and loveshoot 0.83 below the 0.85 budget; to be revisited (Build and Test / follow-up). CI run 586 (7af2069): check and deploy-test succeeded. Unit 2 Steps 24–25 (docs) delegated to Haiku. +**Context**: CONSTRUCTION - Code Generation Part 2 + +--- + +## Code Generation (units 2 and 3) — Complete, approval prompt +**Timestamp**: 2026-10-30T14:21:07Z +**AI Response**: Unit 2 Steps 24–25 (code summary, RE lines) done by Haiku and reviewed; Step 27 hand-back done by orchestrator. Code Generation complete for all three units. Presented completion message with "Request Changes" / "Continue to Next Stage" (Build and Test). Docs committed and pushed (no deploy, per the user's instruction). +**Context**: CONSTRUCTION - Code Generation + +--- + +## Code Generation — Approved; Build and Test started +**Timestamp**: 2026-10-30T23:28:05Z +**User Input**: "ga verder naar de volgende stage. de teksten en extra foto's komen later die zijn nog niet gereed dus dat moeten we even ergens vastleggen zodat andere sessies dat eventueel ook kunnen oppakken." +**AI Response**: Code Generation approved. Build and Test started: Haiku runs the full checks at d3bc1d7 and writes construction/build-and-test/*. Content pending recorded for other sessions: Sonnet writes content-pending.md (pick-up guide for texts, open questions, 25 photos, merge gate) and sets the active-features row to "⏸️ Waiting for content"; orchestrator added a project memory pointing to it. +**Context**: CONSTRUCTION - Build and Test + +--- + +## Build and Test Stage +**Timestamp**: 2026-10-30T23:33:42Z +**Build Status**: Success (pnpm build at d3bc1d7; main chunk 152.56 kB gzip) +**Test Status**: Pass (113 files, 888 tests, seed 1594855861; coverage thresholds met; lint, format, tsc, audit:deps clean). Lighthouse from 2026-10-30 combined-unit runs: known items open (mobile / and /contact as on master; gezin/loveshoot < 0.85, owner keeps fade-in). +**Files Generated**: +- build-instructions.md +- unit-test-instructions.md +- integration-test-instructions.md +- performance-test-instructions.md +- security-test-instructions.md +- e2e-test-instructions.md +- build-and-test-summary.md +- ../../content-pending.md (pick-up guide for the pending texts and photos) +**Operations Phase Decision**: No (Decided At: Requirements Analysis) +**User Input**: "je mag alles committen en pushen en dan een PR aanmaken" +**AI Response**: Unit-3 code summary corrected (Steps 17–18 passed, not pending); content-pending.md corrected (branch already contains master 1416497). active-features status "⏸️ Waiting for content" instead of "✅ Complete" because the merge is blocked on content (CON-ST-03). Committing, pushing and opening a WIP PR to master; the WIP title keeps it from being merged before the content is final. + +--- + +## Build and Test — WIP pull request opened +**Timestamp**: 2026-10-30T23:34:26Z +**AI Response**: Opened PR #13 "WIP: Adds the shoot-type pages" (feature/shoot-type-pages → master). The WIP prefix blocks merging until the content in content-pending.md is final; remove it then. +**Context**: CONSTRUCTION - Build and Test complete, waiting for content + +--- + +## Build and Test — Approved; workflow complete +**Timestamp**: 2026-10-30T23:40:07Z +**User Input**: "ga verder. de content moet later in een aparte feature worden opgepakt. Dan kunnen we deze feature gewoon afronden" +**AI Response**: Asked what to do with PR #13; the user chose "Nu mergen". Content (98 DRAFT, 7 OPEN, 25 photos) moves to a separate future feature; content-pending.md is its input. The CON-ST-03 gate becomes: no DRAFT/OPEN marker in production (release/* branch). active-features status ✅ Complete with a link to the follow-up; state Complete. Next: commit, push, remove WIP from the PR #13 title, merge after green CI. +**Operations Phase Decision**: No (Decided At: Requirements Analysis) +**Context**: Workflow Complete + +--- diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/build-and-test-summary.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/build-and-test-summary.md new file mode 100644 index 0000000..c17f838 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/build-and-test-summary.md @@ -0,0 +1,88 @@ +# Build and Test Summary + +Feature: shoot-type-pages. Branch `feature/shoot-type-pages`, worktree `AndreaSlopFotografie-shoot-type-pages`. +Verified at HEAD `d3bc1d7` (Build and Test stage, run with pnpm 12.11.2, Node v24.16.0, Windows 11 / Git Bash). +Lighthouse was not run in this stage; its figures are the measurements from two days ago (see Performance). + +## Build Status +- **Build Tool**: Vite 8 with `tsc` (`pnpm build` = `tsc && vite build`), pnpm 12.11.2 +- **Build Status**: Success (exit 0; `pnpm install --frozen-lockfile` also exit 0) +- **Build Artifacts**: `web/dist/` (gitignored) + - Main chunk `dist/assets/index-C65n6UdK.js`: 536.65 kB raw, 152.56 kB gzip + - Main chunk against unit 1 (`index-D0huvRmx.js`, 150.69 kB gzip): +1.87 kB gzip, limit 2.5 kB (NFR-ST-03): pass + - Five shoot route chunks plus `-shootPageSources-*.js`; five OG images (`og-.jpg`, 88.9 to 97.6 kB) +- **Build Time**: Vite `built in 1.24s`; 7.8 s wall-clock including `tsc` +- **Warning**: Vite chunk-size warning (main chunk above 500 kB). Accepted for this stage. + +## Test Execution Summary + +### Unit Tests (full suite, all three units) +- **Command**: `pnpm test` (`vitest run --coverage`) +- **Total Tests**: 888 in 113 files +- **Passed**: 888 +- **Failed**: 0 +- **fast-check seed**: 1594855861 (replay: `FC_SEED=1594855861 pnpm test`) +- **Coverage** (v8): statements 96.5% (1161/1203), branches 93.94% (854/909), functions 95.61% (436/456), lines 96.81% (1033/1067). Thresholds 100% for `src/lib/**`, `seo.ts`, `sitemap.ts`: met. +- **Status**: Pass + +### Integration Tests (cross-unit scenarios) +- **Test Scenarios**: 6 (submenu from shootTypes to the shoot routes; exactly three `aria-current` per shoot page; overview "Lees meer" links; sitePages/sitemap/lighthouserc sync; OG images in the registry; FR-ST-14 404 under `/soorten-fotoshoots/`) +- **Passed**: 6 (run inside the full suite above) +- **Failed**: 0 +- **Real-browser navigation check**: 110/110 checks pass (Step 17 of the navigation-submenu plan, recorded in `audit.md`) +- **Status**: Pass +- **Details**: `integration-test-instructions.md` + +### Performance Tests (Lighthouse CI, measured two days ago, not re-run) +- **Desktop performance**: 0.99 to 1.00 on every page (budget 0.9). Target: 0.9. Status: pass. +- **Mobile performance, below budget (known, open)**: + - `/` home: pooled median 0.77 (budget 0.8; master 0.78; unit-1 baseline 0.77) + - `/contact`: 0.87 (budget 0.9; master 0.87) + - `/soorten-fotoshoots/loveshoot`: 0.83 (budget 0.85) + - `/soorten-fotoshoots/gezin`: 0.84 to 0.85 (budget 0.85, borderline) +- **Mobile performance, passing**: newborn 0.86, zwangerschap 0.85, portret 0.85 (budget 0.85) +- **Cause of the shoot-page misses**: the `Reveal` fade-in on the first story photo paints about 2.9 s after the main bundle. The owner decided on 2026-10-30 to keep the fade-in for now. +- **Status**: Fail (known, open). `pnpm check` is not green because of these budgets. +- **Details**: `performance-test-instructions.md` + +### Additional Tests +- **Contract Tests**: N/A (no API or service boundary; static site) +- **Security Tests**: Pass for the production audit and the headers and input tests. Development-tool audit: 22 advisories (2 low, 9 moderate, 11 high), non-blocking under NFR-SEC-05 and unchanged from master. Details: `security-test-instructions.md`. +- **E2E Tests**: Not run in this stage. Manual checklist for the test environment (five shoot pages, submenu on desktop and mobile, keyboard path, `/soorten-fotoshoots/bestaat-niet`): `e2e-test-instructions.md`. + +## Static Checks (run in this stage) + +| Check | Result | +|---|---| +| `pnpm install --frozen-lockfile` | Pass | +| `pnpm lint` (eslint .) | Pass | +| `pnpm format:check` (prettier) | Pass | +| `pnpm exec tsc --noEmit` | Pass | +| `pnpm test` | Pass (888 tests, 113 files) | +| `pnpm build` | Pass | +| `pnpm audit:deps` (prod, high) | Pass (no known vulnerabilities) | +| `pnpm audit:dev` | 22 advisories, exit 0 by design (script has an echo fallback), non-blocking | +| `DRAFT(CON-ST-03)` markers in `web/src` | 98 | +| `OPEN(CON-ST-04)` markers in `web/src` | 7 | + +## Content Status (blocks merge) +- **DRAFT(CON-ST-03)**: 98 markers, awaiting Andrea's approval. Per file: newborn 15, zwangerschap 14, gezin 13, loveshoot 13, portret 13, shared 19, overview 1, registry (`sitePages.ts`) 10. +- **OPEN(CON-ST-04)**: 7 open facts for Andrea (deposit scope and remainder timing, online gallery for Loveshoot and Portret, Loveshoot and Portret durations, Portret locations). Per file: loveshoot 1, portret 3, shared 3. +- Full list and status: [content-pending.md](../../content-pending.md) + +## Overall Status +- **Build**: Success +- **All Tests**: Pass (888 unit and integration tests, 0 failures) +- **Ready for Operations**: N/A (Include Operations Phase = No, `aidlc-state.md`) +- **Ready to Merge**: **No** + - Content is pending: 98 DRAFT and 7 OPEN markers (see Content Status). + - Lighthouse items are open: mobile `/` (0.77 vs 0.8), mobile `/contact` (0.87 vs 0.9, same on master), mobile loveshoot (0.83) and gezin (0.84 to 0.85) against 0.85. The fade-in decision is recorded; the items stay open. + - `pnpm check` is not green because of the Lighthouse assertions. + +## Next Steps +Build and test passes. The branch is not ready to merge until: +1. Andrea reviews the 98 drafts and answers the 7 open facts ([content-pending.md](../../content-pending.md)). +2. The Lighthouse items are resolved or re-accepted by the owner: `/` and `/contact` (known baseline on master), loveshoot and gezin (fade-in decision). +3. Commit and push happen only when the user asks (none in this stage). + +Operations is not included, so the workflow completes after this stage once the above is settled. diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/build-instructions.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/build-instructions.md new file mode 100644 index 0000000..44c81d6 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/build-instructions.md @@ -0,0 +1,59 @@ +# Build Instructions + +Feature: shoot-type-pages (branch `feature/shoot-type-pages`, worktree `AndreaSlopFotografie-shoot-type-pages`). +Verified at HEAD `d3bc1d7`. + +## Prerequisites +- **Build Tool**: pnpm 12.11.2 (`packageManager` in `web/package.json`), run from `web/`. Vite 8, TypeScript ~6.0.2 (`tsc` runs as the first step of `pnpm build`). +- **Runtime**: Node.js v24.16.0 (verified on the build machine). +- **Dependencies**: installed from `web/pnpm-lock.yaml` only. Do not run an unfrozen install. The `postinstall` hook runs `chakra typegen ./src/theme.ts`. +- **Environment Variables**: none are needed for a build. Optional: + - `FC_SEED=`: replays a fast-check run (tests only, see `unit-test-instructions.md`). + - `LIGHTHOUSE_PERFORMANCE=warn`: Lighthouse performance reports a warning instead of failing (CI only, see `performance-test-instructions.md`). + - `LIGHTHOUSE_CHROME_FLAGS`: Chrome flags for the CI container (`--no-sandbox`). +- **System Requirements**: Windows 11 with Git Bash (the commands below are Git Bash syntax). Disk: the pnpm store may sit on another drive (at verification it was `K:\.pnpm-store\v11`, a harmless pnpm warning). No Docker, no database, no external service. + +## Build Steps + +### 1. Install Dependencies +```bash +cd web +pnpm install --frozen-lockfile +``` +- Expected: `Lockfile is up to date, resolution step is skipped`, `Done`, exit 0. +- Harmless messages: the store-location warning, and `Agent skills awaiting approval: @tanstack/router-plugin` (informational; no approval needed for this build). + +### 2. Configure Environment +No configuration is needed for a local build. Do not copy or create `.env` files for this stage. + +### 3. Build All Units +```bash +cd web +pnpm build +``` +`pnpm build` runs `tsc && vite build`. The type check covers all five shoot routes, the navigation submenu and the shared components together, because they are built as one app. + +### 4. Verify Build Success +- **Expected Output**: `✓ built in ~1.2s` from Vite; exit 0. +- **Build Artifacts**: `web/dist/` (gitignored). Routes are split into chunks. The main chunk is `dist/assets/index-C65n6UdK.js`: + - 536.65 kB raw, 152.56 kB gzip (verified at HEAD). + - Against unit 1 (`index-D0huvRmx.js`, 528.98 kB / 150.69 kB gzip): +1.87 kB gzip, under the 2.5 kB limit of NFR-ST-03. + - Shoot page route chunks (`newborn-*.js`, `zwangerschap-*.js`, `gezin-*.js`, `loveshoot-*.js`, `portret-*.js`, `-shootPageSources-*.js`) are separate files, so the shoot pages are not in the main chunk. + - The five OG images (`og-.jpg`, 88.9 to 97.6 kB each) are copied to `dist/`. +- **Common Warnings** (acceptable): + - Vite: `Some chunks are larger than 500 kB after minification`. The main chunk is 536.65 kB. Accepted for this stage; splitting it is a follow-up (see the Lighthouse notes in `performance-test-instructions.md`). + - jsdom `Not implemented: HTMLCanvasElement's getContext()` and `Not implemented: navigation to another Document` lines appear in test output, not in the build. + +## Troubleshooting + +### Build Fails with Dependency Errors +- **Cause**: lockfile out of date, or `node_modules` from another branch. +- **Solution**: run `pnpm install --frozen-lockfile` again. If it still fails, do not change the lockfile in this stage. Report the failure with its output. + +### Build Fails with Compilation Errors +- **Cause**: `tsc` errors. The shoot routes import `routeTree.gen.ts`, which is generated by the TanStack router plugin during `vite build`. +- **Solution**: read the first `error TS` line. If it is in `src/routeTree.gen.ts`, run `pnpm exec vite build` once to regenerate it, then run `pnpm build` again. Do not hand-edit the generated file. + +### Build Fails on the Route Tree Check +- **Cause**: a shoot route file was added or renamed without regenerating the tree. +- **Solution**: as above. The route tree was regenerated in unit 1 and has no diff after the build at HEAD. diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/e2e-test-instructions.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/e2e-test-instructions.md new file mode 100644 index 0000000..dad26f2 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/e2e-test-instructions.md @@ -0,0 +1,66 @@ +# End-to-End Test Instructions (Manual Check) + +## Purpose +A short manual check of the complete user paths on the test environment, after the CI deploy-test. There is no automated browser suite for this feature. The checks below cover what the jsdom tests cannot: real layout, real keyboard focus in the browser, and the real 404 response. + +## Environment +- **Target**: the test deployment of `feature/shoot-type-pages` (CI deploy-test job). Base URL: `` (fill in from the CI run; not recorded in this stage). +- **Browsers**: desktop Chrome or Edge at 1280 px wide; mobile emulation at 375 × 667 in the browser's device mode (touch on). +- **Prerequisite**: the deploy-test job of the CI run is green, and the URL loads the home page. + +## Test Steps + +### 1. Five shoot pages +Open each page and check: one `h1`, the breadcrumb "Kruimelpad" at the top with the current page last, the process section "Zo werkt het", the package block (price or on-request variant), the FAQ (all items closed at load), and the closing call to action. + +| # | URL | Expected | +|---|---|---| +| 1 | `/soorten-fotoshoots/newborn` | Photo mosaic with 3 tiles; package with price | +| 2 | `/soorten-fotoshoots/zwangerschap` | No mosaic; package with price | +| 3 | `/soorten-fotoshoots/gezin` | No mosaic; package with price | +| 4 | `/soorten-fotoshoots/loveshoot` | No mosaic; on-request package | +| 5 | `/soorten-fotoshoots/portret` | No mosaic; on-request package | + +Also check the draft text is visible (the content is still in review, see `aidlc-docs/features/shoot-type-pages/content-pending.md`); this is not a failure of the check. + +### 2. Submenu on desktop (1280 px) +1. Open `/` and hover or click "Soorten fotoshoots" in the header. The panel is not opened by hover; it opens by click. +2. Check the panel shows five items, in this order: Newborn, Zwangerschap, Gezin, Loveshoot, Portretten. +3. Click "Gezin". The page `/soorten-fotoshoots/gezin` opens, the header item "Soorten fotoshoots" has the section underline, and the "Gezin" link in the panel has `aria-current="page"` (check with the browser's inspector). +4. Click outside the panel or press Escape: the panel closes. + +### 3. Submenu on mobile (375 × 667) +1. Open the menu with the hamburger. Expand "Soorten fotoshoots". +2. Check the five sub-links are listed under it. +3. Tap "Loveshoot". The menu closes and `/soorten-fotoshoots/loveshoot` opens. +4. Reopen the menu on the shoot page: the group is expanded, and the "Loveshoot" sub-link is the current one. +5. Press the browser back button: the menu closes. + +### 4. Keyboard path through the desktop submenu +Use only the keyboard (Tab, Enter, Escape, no mouse): +1. Tab until the "Soorten fotoshoots" toggle is focused. Press Enter: the panel opens. +2. Tab through the five links in order: Newborn, Zwangerschap, Gezin, Loveshoot, Portretten. Each has a visible focus ring. +3. Press Escape: focus returns to the toggle and the panel closes. +4. Open the panel again with Enter, Tab out of the last link: the panel closes. +5. Arrow keys do nothing in the submenu (no arrow-key menu pattern). + +### 5. Not-found under the section +Open `/soorten-fotoshoots/bestaat-niet`. +- Expected: the 404 page (not the overview, not the shell's generic error). Two buttons in this order: "Terug naar Soorten fotoshoots" (links to `/soorten-fotoshoots`) and "Terug naar home". +- Check the HTTP response status of the page (browser network panel): the app is a single-page app, so the status is from the host's SPA fallback. Record the actual status as observed; the page itself is a client-side 404. +- Check the page title has the 404 title and the page is not indexed (`noindex` in the head). + +### 6. Overview links +Open `/soorten-fotoshoots`. Each shoot block has a "Lees meer over de …" link. Click one: it opens the shoot page. + +## Expected Results +- All five shoot pages load and show their sections in the order of the page structure. +- Desktop and mobile submenu open, navigate and close as described. +- The keyboard path reaches all items and returns focus correctly. +- `/soorten-fotoshoots/bestaat-niet` shows the 404 with the two buttons. + +## Record the Result +For each step, write pass or fail and the URL and browser used. For a failure, record the URL, a screenshot and the browser console message. Do not fix anything in this stage; log it for the next change. + +## Cleanup +None. The check creates no data. diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/integration-test-instructions.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/integration-test-instructions.md new file mode 100644 index 0000000..f44f1d1 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/integration-test-instructions.md @@ -0,0 +1,98 @@ +# Integration Test Instructions + +## Purpose +Test the interactions between the three units: the content and SEO foundation (unit 1), the shoot page UI (unit 2) and the navigation submenu (unit 3). Each scenario below runs the real app through `renderApp(path)` (`web/src/test/renderApp.tsx`) or the real navigation, not a single component in isolation. + +The scenarios run inside `pnpm test` (see `unit-test-instructions.md`). There is no separate integration command and no service to start. All tests run in jsdom, so no browser, server or database is needed. The real-browser navigation check is recorded in the navigation-submenu plan (see Scenario 2 below). + +## Test Scenarios + +### Scenario 1: Shoot types (unit 1 content) → submenu → shoot routes +- **Description**: `shootTypes` in `web/src/content/shootTypes.ts` is the single source. The desktop and mobile submenu items are built from it (`shootNavItems`, `navigation.ts`), and each item links to the route of that shoot (`/soorten-fotoshoots/`). A new or renamed shoot must appear in the menu and resolve to its page. +- **Setup**: none (uses the content as it is). +- **Test Steps**: the test renders the app on each shoot route and on the overview, opens the desktop submenu and checks the panel items against `shootTypes`. +- **Expected Results**: the panel has one item per shoot, in `shootTypes` order, with the shoot name as its label and the route as its target. Every target renders its page without a 404. +- **Cleanup**: none. +- **Test files**: + - `web/src/navSubmenu.test.tsx`: "keeps the panel in step with the shoot types (single source)" and "desktop submenu and the router" tests. + - `web/src/navigation.test.ts`: "heeft de vijf shoots als kinderen, in de volgorde van de shoottypes" and "heeft een menu-item voor elk shoottype en niets extra". + - `web/src/components/NavigationBar/NavSubmenu.test.tsx` (desktop panel) and `MobileNav.test.tsx` (mobile group). + +### Scenario 2: Exactly three `aria-current` per shoot page +- **Description**: on a shoot page, the current page is marked in three places and nowhere else: the breadcrumb (in `main`), the desktop header submenu link, and the mobile sub-link in `#mobile-nav`. The footer has none. The parent item is marked by `data-section-current` only, not by `aria-current`. +- **Setup**: none. +- **Test Steps**: for each of the five shoot ids, render the page, query `[aria-current]` in `main`, the header, the footer and `#mobile-nav`, and check the value. +- **Expected Results**: exactly one `aria-current="page"` in `main` (breadcrumb), one in the header submenu, one in `#mobile-nav`, none in the footer. In total, `document.querySelectorAll('[aria-current="page"]')` returns 3 items. +- **Cleanup**: none. +- **Test files**: + - `web/src/shootPages.test.tsx`: "%s marks only the page itself as current: once in main (breadcrumb) and once in each menu (submenu link)" (`it.each` over the five shoots). + - `web/src/shootPages.test.tsx`: "$id has a breadcrumb that ends at the page itself, and nothing else in main is current". + - `web/src/navSubmenu.test.tsx`: "current page in the navigation (D4)" block (marks the parent and the footer on the overview, no panel link on another page, trailing slash, case variant). + - Router rule: `web/src/components/NavigationBar/activeOptions.test.tsx` (exact matching with `includeSearch: false`). + +### Scenario 3: Overview "Lees meer" links → shoot pages +- **Description**: each shoot block on `/soorten-fotoshoots` has a "Lees meer over de …" link to its page, first in its row, with a unique accessible name. +- **Setup**: none. +- **Test Steps**: render the overview, find the link per shoot by name (`readMoreLabel(shoot)`), check its href and position in the row, and check that no shoot path is linked more than once. +- **Expected Results**: five links, one per shoot, each to `/soorten-fotoshoots/`. The overview anchors and the old links still work. No other `/soorten-fotoshoots/…` path is linked. +- **Cleanup**: none. +- **Test files**: + - `web/src/shootPages.test.tsx`: "overview page" describe, tests "gives every shoot a \"Lees meer\" link to its page, first in its row, with a unique name", "keeps the anchors and the old links" and "links to each shoot page exactly once and to no other shoot path". + - `web/src/components/shoots/ShootBlock/ShootBlock.test.tsx` and `ShootList.test.tsx`. + +### Scenario 4: sitePages, sitemap and Lighthouse lists stay in sync +- **Description**: the five shoot pages must be in the router, in `sitePages.ts` (registry), in the sitemap, and in the Lighthouse URL lists (`web/lighthouserc.cjs`, `indexedPaths` and `photoPagePaths`). A missing entry in one place must fail a test. +- **Setup**: none. +- **Test Steps**: compare the route ids, the registry keys, the sitemap output and `lighthouseConfig.indexedPaths`. +- **Expected Results**: identical sets of the five shoot paths in all four places. `photoPagePaths` contains the five shoot paths (mobile budget 0.85). +- **Cleanup**: none. +- **Test files**: + - `web/src/app.test.tsx`: "has every shoot page in the router, registry, sitemap and Lighthouse lists" (line ~594), and the `it.each(Object.keys(sitePages))` head test. + - `web/src/sitemap.test.ts`: "contains the indexed pages" and "bevat precies de geindexeerde pagina, elk een keer (oracle)". + - `web/src/seo.test.ts` (service ids and page graph match the route paths). + +### Scenario 5: OG images are registered and used +- **Description**: each shoot page has `ogImage` in `sitePages.ts` (1200 × 630, JPEG, at most 150 KB, Dutch alt text) and the page emits that image as `og:image`. No image is used twice in the registry. +- **Setup**: none. Files: `web/public/og-newborn.jpg`, `og-zwangerschap.jpg`, `og-gezin.jpg`, `og-loveshoot.jpg`, `og-portret.jpg`. +- **Test Steps**: for each shoot, read the registry entry, check the file (dimensions, JPEG marker and size), and render the page to check `og:image`. +- **Expected Results**: the `og:image` of each page equals the registered path. Every file exists and passes the size and dimension checks. The five paths are unique. +- **Cleanup**: none. +- **Test files**: + - `web/src/shootPages.test.tsx`: "preview images of the shoot pages" describe (`%s has a registered 1200 x 630 JPEG of at most 150 KB`, "uses no preview image twice in the registry"). + - `web/src/app.test.tsx`: "%s has its own head and structured data" (`og:image` per shoot, `ogImage!.path`). + +### Scenario 6: FR-ST-14 404 under `/soorten-fotoshoots/` +- **Description**: an unknown path under `/soorten-fotoshoots/` shows the 404 page with two buttons in fixed order: "Terug naar Soorten fotoshoots" (`/soorten-fotoshoots`) and "Terug naar home". Outside that section there is only one button (home). The prefix match is case-insensitive, like the router. +- **Setup**: none. +- **Test Steps**: render `/soorten-fotoshoots/niet-bestaande-shoot`, `/soorten-fotoshoots/onzin`, `/soorten-fotoshoots/newborn/extra`, `/bestaat-niet`, and a case variant of the prefix. +- **Expected Results**: under the section: two links in the order above, the first to `/soorten-fotoshoots`. Elsewhere: one link, to home. Status page keeps its own title and `noindex`. The `/soorten-fotoshoots/Newborn` case renders the Newborn page with the lowercase canonical (router rule, see Scenario 2). +- **Cleanup**: none. +- **Test files**: + - `web/src/components/StatusPage/StatusPage.test.tsx`: "toont onder /soorten-fotoshoots/ twee knoppen in vaste volgorde", "herkent het prefix hoofdletterongevoelig", "houdt buiten de sectie één knop", "biedt een link naar home en zet noindex". + - `web/src/app.test.tsx`: "toont een onbekende URL als 404 binnen de shell" (`/bestaat-niet`) and "%s … /soorten-fotoshoots/onzin, /soorten-fotoshoots/newborn/extra" (`it.each`). + - `web/src/lib/isShootSectionPath.test.ts` (property-based). + +## Setup Integration Test Environment +None. The tests run in jsdom with the app's router. Do not start `pnpm dev` or `pnpm preview` for these tests. + +## Run Integration Tests + +### 1. Execute Integration Test Suite +```bash +cd web +pnpm test +``` +Run the scenario files only, for a quick check: +```bash +cd web +pnpm exec vitest run src/navSubmenu.test.tsx src/shootPages.test.tsx src/app.test.tsx src/sitemap.test.ts src/components/StatusPage/StatusPage.test.tsx +``` + +### 2. Verify Service Interactions +- **Test Scenarios**: 6 cross-unit scenarios above (Scenarios 1 to 6). +- **Expected Results**: all pass in the full run at HEAD `d3bc1d7` (113 files, 888 tests, 0 failures). +- **Real-browser check (navigation submenu)**: recorded in `construction/navigation-submenu/plans/navigation-submenu-code-generation-plan.md` (Step 17, 110/110 checks pass). It covers widths 1024, 1100 and 1280 px, the open panel, keyboard, reduced motion and mobile at 375 × 480 and 360 × 560. The unit-3 code summary still says Step 17 is pending; the plan and `audit.md` record it as passed. +- **Logs Location**: terminal output of `pnpm test`; per-file HTML coverage in `web/coverage/`. + +### 3. Cleanup +None. Test runs leave only the gitignored `web/coverage/` folder. diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/performance-test-instructions.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/performance-test-instructions.md new file mode 100644 index 0000000..b3a442e --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/performance-test-instructions.md @@ -0,0 +1,98 @@ +# Performance Test Instructions + +## Purpose +Check the Lighthouse performance budgets of the site with the three units combined, and record the bundle size against the limit. This is a static site: there is no load or stress test, because there is no server-side work to load. + +## Performance Requirements +- **Lighthouse performance (mobile)**, budgets from `web/lighthouserc.cjs`: + - `/` (home): 0.8 (exception, NFR-P-01, returns to 0.9 with responsive images and prerendering). + - Photo pages (`photoPagePaths`: `/over-mij`, `/soorten-fotoshoots`, and the five shoot pages): 0.85 (exception: the photo paints after the main bundle, see Results). + - All other indexed pages: 0.9. + - `/privacyverklaring` and `/bestaat-niet`: no performance budget in the mobile matrix (the noindex and 404 entries check SEO and best practices only). +- **Lighthouse performance (desktop)**: 0.9 on every URL (`web/lighthouserc.desktop.cjs` raises all entries to 0.9). +- **Accessibility and best practices**: 1.0 on every checked URL (`quality` in `lighthouserc.cjs`). +- **SEO**: 1.0 on indexed pages. +- **Main bundle (NFR-ST-03)**: at most +2.5 kB gzip against unit 1. + +## Setup Performance Test Environment + +### 1. Prepare Test Environment +- Build first (`pnpm build`, see `build-instructions.md`). Lighthouse runs against the built site. +- Port 4173 must be free. The server is started by Lighthouse CI itself: `pnpm preview --port 4173 --strictPort`. `--strictPort` makes the run fail instead of moving to another port. +- Chrome must be installed (Lighthouse CI uses it). In the CI container Chrome runs as root and needs `LIGHTHOUSE_CHROME_FLAGS` with `--no-sandbox`. Locally this is not needed. +- No other process may use 4173 (the navigation check and a dev server use the same port). + +### 2. Configure Test Parameters +- **Runs**: `numberOfRuns: 1` per URL in `lighthouserc.cjs`. Shoot pages were re-measured three times in unit 2 because the scores vary by 0.01 to 0.02. +- **Urls**: the indexed paths, the noindex path and `/bestaat-niet` from `lighthouserc.cjs` (12 URLs). +- **Strictness**: locally `LIGHTHOUSE_PERFORMANCE` is unset, so a performance miss is an error and fails the run. In CI `LIGHTHOUSE_PERFORMANCE=warn` reports misses without failing. +- **Reports**: `web/lighthouse-reports/mobile/` and `web/lighthouse-reports/desktop/` (HTML and JSON). + +## Run Performance Tests + +### 1. Execute Lighthouse (mobile and desktop) +```bash +cd web +pnpm build +pnpm lighthouse +``` +`pnpm lighthouse` runs `lhci autorun` (mobile) and then `lhci autorun --config=lighthouserc.desktop.cjs`. + +Full gate, which also runs lint, format, tests, build and both audits: +```bash +cd web +pnpm check +``` +Note: `pnpm check` ends with `pnpm lighthouse`. At HEAD the mobile Lighthouse assertions fail on `/` and `/soorten-fotoshoots/loveshoot` (and `/soorten-fotoshoots/gezin` on some runs), so `pnpm check` is not green. This is the open item below, not a setup error. + +### 2. Execute the Bundle Check +```bash +cd web +pnpm build +``` +Read `dist/assets/index-*.js` from the build output: the gzip size of the main chunk is compared with unit 1 (`index-D0huvRmx.js`, 150.69 kB gzip). + +### 3. Analyze Performance Results +- **Desktop**: performance 0.99 to 1.00 on every page (budget 0.9). Pass. +- **Mobile, indexed pages**: see the table below. +- **Bundle**: main chunk `index-C65n6UdK.js` 152.56 kB gzip, +1.87 kB gzip against unit 1 (limit 2.5 kB). Pass. +- **Results Location**: `web/lighthouse-reports/mobile/`, `web/lighthouse-reports/desktop/`. + +## Results (measured before this stage, not re-run here) + +Per the stage instructions, Lighthouse was not run in Build and Test. These are the measurements from two days ago on the combined units (unit 1 + unit 2 + unit 3), recorded in `audit.md` and the unit code summaries. + +### Desktop +| Page group | Performance | Budget | Status | +|---|---|---|---| +| All URLs | 0.99 to 1.00 | 0.9 | Pass | + +### Mobile +| Page | Performance (measured) | Budget | Master | Status | +|---|---|---|---|---| +| `/` (home) | pooled median 0.77 | 0.8 | 0.78 | Below budget. Same as the unit-1 baseline (0.77). Known, open. | +| `/contact` | 0.87 | 0.9 | 0.87 | Below budget. Same as master. Known, open. | +| `/soorten-fotoshoots/newborn` | 0.86 | 0.85 | n/a | Pass | +| `/soorten-fotoshoots/zwangerschap` | 0.85 | 0.85 | n/a | Pass | +| `/soorten-fotoshoots/portret` | 0.85 | 0.85 | n/a | Pass | +| `/soorten-fotoshoots/gezin` | 0.84 to 0.85 | 0.85 | n/a | Below or at the budget (borderline). Open. | +| `/soorten-fotoshoots/loveshoot` | 0.83 | 0.85 | n/a | Below budget. Open. | + +Note on `/`: the unit-2 code summary lists a single run at 0.75 (unit-1 baseline 0.76). The pooled median of 0.77 is the figure recorded at the unit-3 Lighthouse step (`audit.md`, Unit 3 Step 18) and is the one used here. + +### Diagnosis of the shoot pages (open item) +- The first story photo is not the bottleneck: it is 153 kB on loveshoot and 117 kB on gezin and loads in about 15 to 24 ms. +- The cause is the `Reveal` fade-in on the first story photo. The photo paints after the main bundle has run, about 2.9 s after the render starts (LCP about 3.7 to 3.8 s, FCP 2.6 s on every page). The shoot pages dropped 0.05 to 0.07 against unit 1's shell-only numbers because the first story now renders through `MediaText` and `Reveal` inside the lazy route chunk. +- Decision (owner, 2026-10-30, `audit.md`): keep the fade-in for now. The item stays open. +- Mitigations listed in the code summary, none applied: remove the fade-in on the first story; cap the first photo's column to reduce its pixels (the earlier notes say fewer image bytes do not move the score); prerendering or a smaller main bundle (the same route as `/` and the photo pages, NFR-P-01). + +### Bundle +- Main chunk: 536.65 kB raw, 152.56 kB gzip (unit 1: 150.69 kB gzip). +1.87 kB gzip, under the 2.5 kB limit. Pass. + +## Performance Optimization + +If a budget fails: +1. Open the HTML report for the URL in `web/lighthouse-reports/mobile/`. +2. Check the LCP element and the render delay. For the shoot pages it is the first story photo. +3. Make one change, rebuild (`pnpm build`), and re-run that URL three times, because single runs vary by 0.01 to 0.02. +4. Do not lower a budget in `lighthouserc.cjs` to make a run pass. Record the miss as an open item instead. diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/security-test-instructions.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/security-test-instructions.md new file mode 100644 index 0000000..a74622f --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/security-test-instructions.md @@ -0,0 +1,73 @@ +# Security Test Instructions + +## Purpose +Check the dependencies, the HTTP security headers and the code-level risks of the shoot pages, navigation and SEO data for this feature. The Security Baseline extension is enabled for this project (`aidlc-state.md`, Extension Configuration: Security Baseline = Yes, decided at Requirements Analysis). The per-rule compliance tables are in the code summaries (`construction/*/code/code-summary.md`). + +## Security Test Scope +- **Dependency audit (production)**: `pnpm audit:deps`. +- **Dependency audit (development tools)**: `pnpm audit:dev` (non-blocking by design, NFR-SEC-05). +- **HTTP security headers and CSP**: unit tests in `web/config/securityHeaders.test.ts` and `web/config/serverConfig.test.ts`. The headers file (`web/config/securityHeaders.ts`) is unchanged by this feature. +- **Raw HTML injection**: grep for `dangerouslySetInnerHTML`. +- **Input handling**: route parameters and the `?pakket=` query are checked against known values (unit tests, see below). +- **Lockfile**: `pnpm install --frozen-lockfile` (no change to `package.json` or `pnpm-lock.yaml` by this feature). + +## Run Security Tests + +### 1. Dependency Audits +```bash +cd web +pnpm audit:deps +pnpm audit:dev +``` + +- **`pnpm audit:deps`** (`pnpm audit --prod --audit-level high`): verified at HEAD: `No known vulnerabilities found`, exit 0. Pass. The earlier `seroval` advisories from unit 1 are gone (the lockfile resolves `seroval@1.7.3`, patched). +- **`pnpm audit:dev`** (`pnpm audit || echo ...`): verified at HEAD: `22 vulnerabilities found`, `Severity: 2 low | 9 moderate | 11 high`. The script exits 0 by design because of the `|| echo` (NFR-SEC-05: development tools do not block). These findings are in devDependencies only (paths under `@testing-library/jest-dom>vitest`, `@vitest/coverage-v8>vitest`, `@lhci/cli`, and the Vite dev server). None is in the production bundle. Status: accepted for this stage; see the open items. + - Vite (`GHSA-9jrq-w75r-8gcw`, low): vulnerable `>=8.3.0 <=8.3.2`, patched `>=8.3.3`. Dev server only. + - `tmp` via `@lhci/cli` (`GHSA-52f5-9888-hmc6`): build-time tool, not shipped. +- **Result**: production audit pass; development audit reports 22 advisories (non-blocking, as on master). + +### 2. Security Headers and CSP Tests +```bash +cd web +pnpm exec vitest run config/securityHeaders.test.ts config/serverConfig.test.ts +``` +- **Expected**: both files pass (they are included in the 888 passing tests of `pnpm test`). +- **What they check**: the security headers that `config/securityHeaders.ts` defines and the server config that applies them. The shoot pages add no inline script and no new external resource, so no CSP change was needed. JSON-LD is the only script-like content, and it goes through `StructuredData` (see below). +- **Lighthouse**: best practices 1.0 on every URL (the real headers of the built site are checked through Lighthouse, see `performance-test-instructions.md`). + +### 3. Raw HTML Injection Check +From `web/`: +```bash +cd web +grep -rn "dangerouslySetInnerHTML" src config public index.html +``` +- **Expected**: one code use, the JSON-LD script of `StructuredData`. +- **Verified at HEAD**: + - `src/components/StructuredData/StructuredData.tsx:8` (comment: the only place the shoot pages use `dangerouslySetInnerHTML`, and only with the escaped JSON-LD of `jsonLdScript`). + - `src/components/StructuredData/StructuredData.tsx:15` (`dangerouslySetInnerHTML={{ __html: jsonLdScript(data) }}`). + - No match in `config`, `public` or `index.html`. +- **Result**: pass. Any new use outside `StructuredData` is a finding and must be reviewed. +- **Note**: `rg` was not on PATH in the verification shell; `grep -rn` was used. The same result with `rg -n` if it is installed. + +### 4. Input Validation (unit tests) +- Shoot ids and slugs accept only known values: `shootIdFromSlug` and `shootIdFromPath` (`web/src/lib/shootPages.ts`). Hostile slugs (`onzin`, `%3Cscript%3E`, `newborn/extra`) give the 404, tested in `web/src/app.test.tsx` (`it.each(['onzin', 'loveshoot', '%3Cscript%3E'])`) and `web/src/app.test.tsx` (`/soorten-fotoshoots/onzin`, `/soorten-fotoshoots/newborn/extra`). +- The `?pakket=` value comes only from `shootPackage` (`web/src/lib/shootPackage.ts`), so an unknown value is ignored. +- Heading ids are built with `headingId` (`web/src/lib/headingId.ts`) from known prefixes; hostile strings are covered by property-based tests (`headingId.test.ts`). +- The pathname used by the navigation is only compared (`navCurrent`), never rendered; the comparison is property-tested with hostile strings. + +### 5. Security Baseline Extension +- **Status**: enabled (`aidlc-docs/features/shoot-type-pages/aidlc-state.md`, Extension Configuration table: Security Baseline = Yes, Requirements Analysis). +- **Compliance** (from the code summaries, final tables): SECURITY-04 (headers), -05 (input validation), -09 (hardening: no debug output, no placeholders), -10 (supply chain: frozen lockfile, unchanged `package.json`), -11 (secure design), -13 (no external asset), -15 (fail-safe). The backend and infrastructure rules are N/A (front-end only). +- **Open**: none under the Security Baseline. The dev-tool advisories above are accepted under NFR-SEC-05. + +## Analyze Security Test Results +- **Dependencies (prod)**: 0 known vulnerabilities. Pass. +- **Dependencies (dev)**: 22 advisories (2 low, 9 moderate, 11 high), non-blocking, unchanged from master. +- **Headers and CSP**: unit tests pass; no change to the headers file. +- **Raw HTML**: one use, in `StructuredData`. Pass. +- **Input handling**: unit tests pass. + +## Remediation +- For a production advisory: update the package, rerun `pnpm install --frozen-lockfile`, rerun `pnpm audit:deps`. Do not edit the lockfile by hand. +- For a new `dangerouslySetInnerHTML`: move the content to a typed React element, or pass it through `jsonLdScript` in `StructuredData`. +- Development-tool advisories: track them, update when a patched version is available in the same major version. diff --git a/aidlc-docs/features/shoot-type-pages/construction/build-and-test/unit-test-instructions.md b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/unit-test-instructions.md new file mode 100644 index 0000000..ec072f2 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/build-and-test/unit-test-instructions.md @@ -0,0 +1,53 @@ +# Unit Test Execution + +Runs the full suite of all three units together (unit 1 content and SEO, unit 2 shoot page UI, unit 3 navigation submenu). Verified at HEAD `d3bc1d7`. + +## Run Unit Tests + +### 1. Execute All Unit Tests +```bash +cd web +pnpm test +``` +`pnpm test` is `vitest run --coverage` (Vitest 5.0.5, jsdom, Testing Library, axe-core, fast-check 4). Watch mode for development: `pnpm test:watch`. + +### 2. Review Test Results +- **Expected**: 113 test files, 888 tests, 0 failures. Verified at HEAD: `Test Files 113 passed (113)`, `Tests 888 passed (888)`, exit 0. Duration about 65 s. +- **fast-check seed** (printed on the second line of output, from `web/config/testSeed.ts`): verified run `fast-check seed: 1594855861 (opnieuw: FC_SEED=1594855861 pnpm test)`. +- **Test Coverage** (v8, verified at HEAD): + +| Metric | Result | +|---|---| +| Statements | 96.5% (1161/1203) | +| Branches | 93.94% (854/909) | +| Functions | 95.61% (436/456) | +| Lines | 96.81% (1033/1067) | + + Coverage thresholds (`web/vite.config.ts`): 100% for `src/lib/**`, `src/seo.ts` and `src/sitemap.ts`. The run passed these thresholds (no threshold error in the output). +- **Test Report Location**: `web/coverage/` (gitignored). Open `web/coverage/index.html` for the per-file report; `web/coverage/coverage-final.json` and `clover.xml` for tools. + +### 3. Property-Based Tests (fast-check) and Seed Replay +The PBT tests (for example `shootPageBands`, `storyLayout`, `mosaicLayout`, `headingId`, `isShootSectionPath`, `navCurrent`, `navMenuState` with a model-based stateful run, `shootNavItems`) use a seed that is printed on every run. If a property fails, replay the same run with that seed: + +```bash +cd web +FC_SEED=1594855861 pnpm test +``` + +PowerShell equivalent: `$env:FC_SEED=1594855861; pnpm test`. Use the seed from the failing run, not the one above. Shrinking is on, so the failure output includes the minimal counterexample. + +### 4. Accessibility Tests (axe) +- axe-core runs in the component tests for the new components and on the five shoot pages (`src/shootPages.test.tsx`, test "%s has a clean heading outline and the sections its data says" and the axe checks in the same file). The navigation submenu and mobile menu have axe checks in both the open and closed state (`src/components/NavigationBar/NavigationBar.test.tsx`, `MobileNav.test.tsx`). +- There is no separate axe command. A failing axe check fails `pnpm test`. +- The Lighthouse accessibility score (1.0 on the indexed pages) is a separate check, see `performance-test-instructions.md`. + +### 5. Fix Failing Tests +If tests fail: +1. Review test output in the terminal, or re-run one file: `pnpm exec vitest run src/shootPages.test.tsx`. +2. For a PBT failure, replay with `FC_SEED=`. +3. Fix code issues. Do not edit tests to make them pass unless the test is wrong, and say so in the change. +4. Rerun `pnpm test` until all pass. + +## Known Notes +- The jsdom messages `Not implemented: HTMLCanvasElement's getContext()` and `Not implemented: navigation to another Document` are expected and do not fail tests. +- Vitest suggests a faster pool for jsdom (`pool: 'vmThreads'`). This is a speed note only. diff --git a/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/code-summary.md b/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/code-summary.md new file mode 100644 index 0000000..5519997 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/code-summary.md @@ -0,0 +1,164 @@ +# Code Summary — Unit 1: Content and SEO foundation + +Plan: [content-and-seo-foundation-code-generation-plan.md](../../plans/content-and-seo-foundation-code-generation-plan.md). Branch `feature/shoot-type-pages` (from master `18e81d0`), worktree `AndreaSlopFotografie-shoot-type-pages`. + +## Status +- Steps 1–23 done (checked in the plan). Step 24 (full gate with Lighthouse) is **not green**: `pnpm check` stops at `audit:deps` and two mobile Lighthouse budgets fail; both also fail on master (see Checks). +- Steps 25–26 done with this summary and the reverse-engineering lines. + +## Commits +None. The unit is uncommitted in the worktree. A commit (and a push) is made only when the user asks. + +## Files + +### Routes +- Moved: `web/src/routes/soorten-fotoshoots.tsx` → `web/src/routes/soorten-fotoshoots/index.tsx` (overview; anchors unchanged; WebPage JSON-LD via `StructuredData`) +- Created: `web/src/routes/soorten-fotoshoots/{newborn,zwangerschap,gezin,loveshoot,portret}.tsx` (`/soorten-fotoshoots/`; `shootPageView` in the component, `NotFound` when it returns `undefined`, one `StructuredData` per object of `shootPageGraph`) +- Created: `web/src/routes/soorten-fotoshoots/-shootPageSources.ts` (`shootPageSources`, shared by the five shoot routes; `portfolioShoots` computed as the overview does) +- Regenerated: `web/src/routeTree.gen.ts` (`pnpm exec vite build`, not hand-edited) + +### Content +- Modified: `web/src/content/types.ts` (added `StoryBlock`, `FaqItem`, `ProcessStepId`, `ProcessStepContent`, `DepositInfo`, `ShootPageShared`, `ShootPageContent`; no existing type changed) +- Created: `web/src/content/shootPageShared.ts` (breadcrumb, process, deposit, photos/FAQ/offer texts, shared FAQ items `deliveryFaq`, `bookingFaq`, `replyFaq`) +- Created: `web/src/content/shootPages/{newborn,zwangerschap,gezin,loveshoot,portret}.ts` (one `ShootPageContent` per shoot) +- Created: `web/src/content/shootPages/shootPages.test.ts` (content consistency over the five pages) +- Modified: `web/src/content/shootTypes.ts` (draft marker replaces the old comment; no data change) + +### Lib +- Created: `web/src/lib/shootPages.ts` (+ `.test.ts`): `SHOOT_TYPES_PATH`, `SHOOT_TYPE_IDS`, `shootPagePath`, `shootIdFromSlug`, `shootIdFromPath`, `EveryShootHasARoute` (compile-time guard) +- Created: `web/src/lib/shootPackage.ts` (+ test): the visible package of a shoot, else `undefined` +- Created: `web/src/lib/fillPlaceholders.ts` (+ test): `fillPlaceholders`, `fillRichText` +- Created: `web/src/lib/richTextToPlain.ts` (+ test) +- Created: `web/src/lib/shootPageView.ts` (+ test): `shootPageView(id, page, sources)`, `MOSAIC_MIN_PHOTOS`, `PROCESS_STEP_ORDER`, view types +- Modified: `web/src/lib/shootLinks.ts` (+ test): `shootContactLink` takes `pakket` from `shootPackage`; existing tests unchanged + +### SEO and page registry +- Modified: `web/src/seo.ts` (+ test): `shootServiceId`, `shootService`, `breadcrumbList`, `faqPage`, `shootPageGraph`; `shootServices` keeps its signature (Service `@id` now `…/soorten-fotoshoots/#service`, D2) +- Modified: `web/src/sitePages.ts`: five entries after `/soorten-fotoshoots` (draft titles and descriptions, `indexed: true`, no `ogImage`) +- Modified: `web/lighthouserc.cjs` (five paths in `indexedPaths` and `photoPagePaths`), `web/lighthouserc.d.cts` (declares `photoPagePaths`) +- Modified: `web/src/sitemap.test.ts` (five URLs in the indexed list) + +### Components +- Created: `web/src/components/StructuredData/StructuredData.tsx` (+ test): the only `dangerouslySetInnerHTML` of the shoot pages (`jsonLdScript`) +- Created: `web/src/components/shoots/ShootPage/ShootPage.tsx` (+ test): shell with `PageIntro` only (the one h1); unit 2 adds the sections + +### Tests +- Modified: `web/src/app.test.tsx` (per-page shell, head, JSON-LD, not-found and registry tests; imports `renderApp`/`expectShell`) +- Created: `web/src/test/renderApp.tsx` (`renderApp(path)`, `expectShell()`) +- Modified: `web/src/test/arbitraries.ts` (appended generators; `image` exported as `contentImage`, definition unchanged) +- Modified: `web/src/seo.test.ts` (old anchor-id tests rewritten for the D2 ids; examples and PBT for the new builders) + +### Documentation +- Created: `aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/{draft-list,open-list}.txt` (grep output, Step 23) +- Modified: `aidlc-docs/_shared/reverse-engineering/{api-documentation,code-structure,architecture}.md` (own lines only, Step 26) + +## Requirement coverage +| Requirement | Where | Status | +|---|---|---| +| FR-ST-01 Routes, path helpers, not-found | `routes/soorten-fotoshoots/*`, `lib/shootPages.ts`, app tests | Done | +| FR-ST-02..08 Data and view (intro, stories, timeline, photos, FAQ, package, CTA) | `content/shootPages/*`, `lib/shootPageView.ts` | Done (UI sections are unit 2) | +| FR-ST-09 Overview anchors kept | `routes/soorten-fotoshoots/index.tsx` | Done | +| FR-ST-11 Content model | `content/types.ts`, `content/shootPageShared.ts`, `content/shootPages/*` | Done | +| FR-ST-12 Registry, sitemap, Lighthouse | `sitePages.ts`, `lighthouserc.cjs`, `sitemap.test.ts`, `app.test.tsx` | Done | +| SEO-ST-01, SEO-ST-02 (title/description drafts) | `seo.ts`, `sitePages.ts` | Done (drafts) | +| SEO-ST-03 Service, Offer, BreadcrumbList, FAQPage | `seo.ts`, `StructuredData` | Done | +| NFR-ST-03 Code splitting | Shoot pages in their route chunks (Step 23 check) | Done | +| NFR-ST-04 One source per fact | Placeholders (D8), `shootPackage`, `shootPageView` | Done | +| NFR-ST-05 Security | See the compliance table | Done, one open finding (seroval, pre-existing) | +| NFR-ST-06 Testing | PBT plus example tests, 100 % coverage of `src/lib/**`, `seo.ts`, `sitemap.ts` | Done | +| CON-ST-01..05 Content rules | Drafts and open facts (below), no invented facts | Open items for Andrea | + +## Route tree check (Step 18) +- `web/src/routeTree.gen.ts` regenerated with `pnpm exec vite build`. Keys: `'/soorten-fotoshoots'` (index, trimmed) and `'/soorten-fotoshoots/'` for the five ids, all children of the root route (no layout). +- `pnpm exec tsc` is clean; `EveryShootHasARoute` (every `ShootPagePath` is a `RoutePath`) compiles. + +## Test results (Step 23) +- Baseline (Step 1, before the unit): 82 files, 460 tests, fast-check seed 801597296. +- After the unit: `pnpm test`, 90 files, 595 tests, all passing, fast-check seed 1143769900. Coverage thresholds met (overall 94.92 % statements, 91.48 % branches; 100 % on `src/lib/**`, `seo.ts`, `sitemap.ts`). +- `pnpm lint`, `pnpm format:check`, `pnpm exec tsc`: clean. +- `pnpm build`: ok. + +## Bundle check (Step 23, NFR-ST-03) +- Main chunk `index-D0huvRmx.js`: 528.98 kB / 150.69 kB gzip. Master dist (possibly stale) was about 512.6 KiB, so the increase is about +4 kB for the route tree and `sitePages`. Step 24 measured master fresh at 527.27 kB / 150.31 kB gzip (+1.7 kB raw, +0.38 kB gzip), within single-run noise. +- A Newborn-only string ("Uit eerdere newbornshoots") appears only in `newborn-*.js`, not in `index-*.js`. +- Lockfile, `package.json` and `config/securityHeaders.ts` unchanged (`git diff --exit-code`). + +## Checks and Lighthouse (Step 24, not green) +- `pnpm check` stops at `audit:deps`: `seroval@1.6.7` gives 3 high and 2 moderate advisories (via `@tanstack/react-router` → `router-core`; patched in ≥ 1.6.8). `pnpm-lock.yaml` and `package.json` are identical to master, so master fails the same way. Fix pending the user's choice (separate fix from master, or on this branch). +- Lighthouse, desktop: exit 0; all pages 99–100; the five shoot pages 100 in all four categories. +- Lighthouse, mobile: the five shoot pages 0.90 performance (budget 0.9 met), accessibility, best practices and SEO 1.0 on every indexed page. Failing budgets: `/` 0.76 (budget 0.8) and `/contact` 0.85 (budget 0.9). Master measured the same way: `/` 0.78 and `/contact` 0.87, so these are the known baseline issue. This branch is about 0.01–0.02 lower on the old pages; to re-measure after unit 3 (D5). +- The shell has no photo yet, so the shoot-page scores are not representative of unit 2. + +## Deviations from the plan +- **Case-insensitive path matching (known, not changed):** TanStack Router matches paths case-insensitively by default, so `/soorten-fotoshoots/Newborn` renders the Newborn page instead of a 404. The canonical URL stays lowercase. The router-wide `caseSensitive` option is left unchanged (decision for the orchestrator; setting it would also change the other routes). `app.test.tsx` asserts the current behaviour for this slug; the other two invalid slugs give the 404. +- Step 8: `shootPageContent(id?, reuse = [])` takes the shoot's main and detail images as an optional second argument (the generator cannot know the shoot's `src` otherwise). Stray `{` in generated text is opening only (a stray `{` and `}` around a filled placeholder could form a new one). +- Step 14: `seo.test.ts` example and PBT titles renamed to the D2 ids ("gives every service the id and URL of its own shoot page (invariant)"). +- Step 17: the comment above `StructuredData` says "StructuredData escapes" instead of "jsonLdScript escapes". +- Step 20: the `photoPagePaths` comment grew by two lines instead of one. +- Steps 12, 14 and 18: type errors that existed only until the routes existed (`BreadcrumbItem.to`, `faqPage`/`webPage` paths) resolved in Step 18; no cast was added. + +## For review (content) +- Story 4 of Newborn keeps design E's "1 tot 2 uur" (the same figure as the package feature "1-2 uur fotografie"). It was kept because the plan says design E headings and paragraphs; Andrea may want it removed. +- Design E's "Na afloop krijg je minstens 40 … foto's" and "Ik neem alles mee wat ik nodig heb" were dropped (package figure as free text, CON-ST-04). + +## Draft inventory (CON-ST-03, for Andrea's review) +Every line below is an `// DRAFT(CON-ST-03): awaiting Andrea's approval` marker in `web/src` (98 in total, from the Step 23 grep). The marker sits directly above the drafted field or block. Line numbers are those of the marker. + +- **Newborn** (`content/shootPages/newborn.ts`, 15): lines 27, 34, 51, 67, 87, 109, 111, 117, 144, 147, 155, 163, 171, 180, 185 +- **Zwangerschap** (`content/shootPages/zwangerschap.ts`, 14): lines 30, 37, 54, 66, 78, 91, 94, 100, 108, 111, 119, 127, 139, 144 +- **Gezin** (`content/shootPages/gezin.ts`, 13): lines 31, 38, 55, 67, 79, 92, 95, 101, 109, 112, 120, 132, 137 +- **Loveshoot** (`content/shootPages/loveshoot.ts`, 13): lines 23, 30, 42, 53, 64, 77, 79, 86, 102, 105, 113, 125, 130 +- **Portret** (`content/shootPages/portret.ts`, 13): lines 23, 30, 42, 53, 65, 78, 81, 88, 104, 107, 115, 127, 132 +- **Shared** (`content/shootPageShared.ts`, 19): lines 7, 17, 29, 46, 48, 50, 55, 60, 65, 70, 75, 80, 89, 94, 98, 100, 108, 110, 114 (process eyebrow/title and steps, photos/FAQ/offer texts, shared FAQ items, deposit note, button labels) +- **Overview** (`content/shootTypes.ts`, 1): line 70 (Gezin overview text, Step 7) +- **Registry** (`sitePages.ts`, 10): lines 65, 67, 73, 75, 81, 83, 89, 91, 97, 99 (title and description of the five shoot pages) + +## Open facts (CON-ST-04) +Seven `// OPEN(CON-ST-04)` markers in `web/src` (Step 23 grep). Each one is a question for Andrea; the text is in the code. +1. **Deposit scope and remainder timing:** does the deposit also apply to Loveshoot and Portret, and when exactly is the remainder paid after the shoot (before delivery)? `content/shootPageShared.ts` lines 18 and 90 (the deposit note and the booking FAQ). +2. **Online gallery:** is there an online gallery for Loveshoot and Portret too (confirmed only for the three packages)? `content/shootPageShared.ts` line 81 (process step "oplevering"). +3. **Loveshoot duration:** `content/shootPages/loveshoot.ts` line 80 (`process.duration` has no figure yet). +4. **Portret duration:** `content/shootPages/portret.ts` line 82. +5. **Portret locations (natuur / zakelijk):** `content/shootPages/portret.ts` lines 54 (`process.location`) and 79 (story on the location). + +## Interfaces for units 2 and 3 +- `ShootPageView`, `shootPageView(id, page, sources)`, `ShootPageSources`, `MOSAIC_MIN_PHOTOS` (= 2, confirmed in FD unit 2), `PROCESS_STEP_ORDER` (`lib/shootPageView.ts`). Shape per component-methods.md, unchanged. +- `ShootPage` shell (`components/shoots/ShootPage/ShootPage.tsx`, `{ view }`): unit 2 adds the sections in the order of the page structure. +- `renderApp(path)`, `expectShell()` (`test/renderApp.tsx`). +- Generators (`test/arbitraries.ts`): `placeholderName`, `textWithPlaceholders`, `inlineLink`, `richText`, `storyBlock`, `faqItem`, `shootPageShared`, `shootPageContent(id?, reuse?)`, `slugInput`, `contentImage`. +- `shootPageSources` (route sources), `shootServiceId`, `shootPageGraph`, `shootPagePath`, `EveryShootHasARoute`. +- Not in this unit: OG images, LAYOUT.md and the "Lees meer" links (unit 2); navigation submenu (unit 3). + +## Consistency facets left to units 2 and 3 +- Nav-child facet of the registry consistency (NFR-ST-06): unit 3, `navigation.test.ts`. +- "Lees meer" facet: unit 2, `shootPages.test.tsx`. +- The rest of the registry consistency (route, `sitePages`, sitemap, Lighthouse lists, no other `/soorten-fotoshoots/…` path) is tested in `app.test.tsx` (Step 22). + +## Open decisions for the orchestrator and user +1. Case-sensitive routing (`caseSensitive: true` in `main.tsx` and `renderApp`) or keep the current behaviour. +2. The seroval advisory: separate fix from master, or on this branch. +3. Re-run the Lighthouse gate on `/` and `/contact` (baseline failures on master). +4. Andrea's review of the 98 drafts and 7 open facts. +5. Commit and push, when the user asks. + +## Security and PBT compliance (final) +| Rule | Status | Evidence | +|---|---|---| +| SECURITY-04 HTTP headers | Compliant | `securityHeaders.ts` unchanged (Step 23); JSON-LD only through `StructuredData`/`jsonLdScript` | +| SECURITY-05 Input validation | Compliant | No route parameters; `shootIdFromSlug`/`shootIdFromPath` accept only known ids (Step 9); `?pakket=` only from `shootPackage` (Steps 10, 12) | +| SECURITY-09 Hardening | Compliant | No `console.` in new code (Step 23 grep); no bracketed design placeholders (Step 13 test); 98 drafts marked and to be gated (D3) | +| SECURITY-10 Supply chain | Compliant for this unit | `--frozen-lockfile`; lockfile and `package.json` unchanged. Open: `audit:deps` fails on `seroval` (pre-existing on master, Step 24) | +| SECURITY-11 Secure design | Compliant | Text and typed links only; `dangerouslySetInnerHTML` only in `StructuredData`; no e-mail address in structured data (Step 14 PBT) or content (Step 13) | +| SECURITY-13 Integrity | Compliant | Only bundled photos; no CDN | +| SECURITY-15 Fail-safe | Compliant | Unknown slug → 404 (Step 22); missing shoot or id mismatch → `NotFound` (Steps 12, 18); invalid package → "Prijs op aanvraag" data (Steps 10, 12); too few photos → no mosaic (Step 12). `/soorten-fotoshoots/Newborn` renders the page (case deviation above) | +| SECURITY-01, -02, -03, -06, -07, -08, -12, -14 | N/A | No data stores, intermediaries, server code, IAM, network, auth or alerting | +| PBT-01 Identification | Compliant | Properties from services.md mapped to steps 9–14 | +| PBT-02 Round trip | Compliant | Slug/path ↔ id (Step 9); `JSON.parse ∘ jsonLdScript` for every new builder (Step 14) | +| PBT-03 Invariants | Compliant | `shootIdFromSlug/Path`, `shootPackage`, `shootContactLink`, `fillPlaceholders`, `richTextToPlain`, `shootPageView`, `breadcrumbList`, `faqPage`, `shootService(s)` (Steps 9–14) | +| PBT-04 Idempotency | Compliant | `fillPlaceholders`/`fillRichText` (Step 11) | +| PBT-05 Oracle | N/A | No reference implementation (oracle-style per-piece check for `fillRichText` only) | +| PBT-06 Stateful | N/A | No state in unit 1 | +| PBT-07 Generators | Compliant | Domain generators in `src/test/arbitraries.ts` (Step 8), reused by units 2 and 3 | +| PBT-08 Shrinking/reproducibility | Compliant | fast-check shrinking untouched; global seed from `config/testSeed.ts`, logged every run | +| PBT-09 Framework | Compliant | fast-check already a dependency | +| PBT-10 Complementary | Compliant | Example tests per helper, content tests (Step 13), route and registry tests (Step 22) alongside the PBT; tests labelled "(invariant)", "(round trip)", "(idempotency)" | diff --git a/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/draft-list.txt b/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/draft-list.txt new file mode 100644 index 0000000..0bc2506 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/draft-list.txt @@ -0,0 +1,98 @@ +src\sitePages.ts:65: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:67: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:73: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:75: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:81: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:83: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:89: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:91: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:97: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\sitePages.ts:99: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:27: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:34: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:51: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:67: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:87: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:109: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:111: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:117: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:144: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:147: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:155: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:163: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:171: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:180: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\newborn.ts:185: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:23: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:30: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:42: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:53: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:64: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:77: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:79: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:86: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:102: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:105: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:113: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:125: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\loveshoot.ts:130: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:23: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:30: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:42: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:53: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:65: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:78: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:81: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:88: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:104: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:107: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:115: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:127: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\portret.ts:132: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootTypes.ts:70: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:30: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:37: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:54: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:66: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:78: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:91: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:94: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:100: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:108: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:111: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:119: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:127: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:139: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\zwangerschap.ts:144: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:7:// DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:17:// DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:29:// DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:46: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:48: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:50: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:55: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:60: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:65: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:70: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:75: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:80: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:89: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:94: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:98: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:100: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:108: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:110: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPageShared.ts:114: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:31: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:38: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:55: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:67: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:79: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:92: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:95: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:101: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:109: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:112: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:120: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:132: // DRAFT(CON-ST-03): awaiting Andrea's approval +src\content\shootPages\gezin.ts:137: // DRAFT(CON-ST-03): awaiting Andrea's approval diff --git a/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/open-list.txt b/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/open-list.txt new file mode 100644 index 0000000..5713d1c --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/open-list.txt @@ -0,0 +1,7 @@ +src\content\shootPages\portret.ts:54: // OPEN(CON-ST-04): locations for the portrait shoot (natuur / zakelijk) +src\content\shootPages\portret.ts:79: // OPEN(CON-ST-04): locations for the portrait shoot (natuur / zakelijk) +src\content\shootPages\portret.ts:82: // OPEN(CON-ST-04): shoot duration for the portrait shoot +src\content\shootPages\loveshoot.ts:80: // OPEN(CON-ST-04): shoot duration for the loveshoot +src\content\shootPageShared.ts:18:// OPEN(CON-ST-04): does the deposit also apply to Loveshoot and Portret, and when exactly is the remainder paid after the shoot (before delivery)? +src\content\shootPageShared.ts:81: // OPEN(CON-ST-04): is there an online gallery for Loveshoot and Portret too (confirmed only for the three packages)? +src\content\shootPageShared.ts:90: // OPEN(CON-ST-04): does the deposit also apply to Loveshoot and Portret, and when exactly is the remainder paid after the shoot (before delivery)? diff --git a/aidlc-docs/features/shoot-type-pages/construction/content-review/andrea-review.md b/aidlc-docs/features/shoot-type-pages/construction/content-review/andrea-review.md new file mode 100644 index 0000000..60e0dc9 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/content-review/andrea-review.md @@ -0,0 +1,376 @@ +# Teksten en foto's voor de nieuwe shootpagina's + +*Voor Andrea Slop Fotografie – om door te nemen en goed te keuren* + +## 1. Waar gaat dit over? + +Hoi Andrea, + +Er komen vijf nieuwe pagina's op je website: één voor elke soort fotoshoot (Newborn, Zwangerschap, Gezin, Loveshoot en Portret). Op elke pagina vertel je wat bezoekers kunnen verwachten, hoe een shoot verloopt, wat de veelgestelde vragen zijn en hoe ze kunnen boeken. + +Alle teksten op deze pagina's zijn concepten. Ze zijn geschreven in jouw toon en gebaseerd op de teksten die al op je website staan. Er is niets verzonnen dat je zelf nog niet hebt gezegd: waar we iets niet weten (bijvoorbeeld hoe lang een loveshoot duurt), staat er een vraag voor jou in hoofdstuk 2. Voordat de pagina's live gaan, wil ik dat jij elke tekst hebt gezien. + +#### Zo kun je het doornemen + +- Hoofdstuk 2 bevat de vragen waar ik jouw antwoord op nodig heb. +- Hoofdstuk 3 en 4 bevatten alle teksten. Bij elke tekst staat een tabelrij. Zet bij "Akkoord?" een kruisje bij Akkoord als de tekst goed is, of bij Aanpassen als je iets anders wilt. +- Wil je iets aanpassen? Schrijf dan in de laatste kolom jouw eigen woorden, of een opmerking (bijvoorbeeld "te lang" of "zo zeg ik dat niet"). Jouw eigen formulering gebruik ik dan zoals je hem schrijft. +- Hoofdstuk 5 laat zien welke foto's er op elke pagina komen en hoeveel foto's er nog nodig zijn. +- Het ontwerp van een shootpagina kun je hier bekijken (de voorbeeldpagina is Newborn; de andere vier pagina's hebben dezelfde indeling): https://claude.ai/artifact/BdXmEgsTPK2567g9AFQCXa + +#### Wat je in de teksten tegenkomt + +- Bedragen en termijnen vul ik niet per pagina in, maar worden automatisch ingevuld. Zo staat overal hetzelfde: de aanbetaling is € 50, je reageert binnen 1-2 werkdagen en de opleverduur is 2–3 weken. In de tabellen staan die waarden al ingevuld. Verandert er ooit iets, dan hoeft het maar op één plek aangepast te worden. +- In hoofdstuk 3 staan twee woorden tussen accolades: {locatie} en {duur}. Die worden automatisch vervangen door de zin over de locatie en de duur van de betreffende shoot, die je in hoofdstuk 4 bij elke shoot vindt. Wijzig de zin daar, dan verandert hij ook in de tijdlijn. +- Onderstreepte woorden zijn een link naar je contactpagina. +- Sommige teksten staan op alle pagina's (hoofdstuk 3). Een wijziging daar geldt dus voor alle vijf de shoots. +- Teksten die hangen aan een openstaande vraag hebben onder de tekst een korte verwijzing, bijvoorbeeld "Zie vraag 3". + +In totaal gaat het om 98 teksten of tekstgroepen. De laatste kolom ("Ref.") is alleen voor mij, zodat ik de tekst terugvind; die kun je negeren. + +## 2. Vragen voor jou + +Dit zijn de dingen die ik niet zelf kan of wil invullen. Zonder jouw antwoord laat ik de tekst zoals hij nu is staan of vermeld ik de feiten niet. + +| Nr. | Vraag | Jouw antwoord | +|---|---|---| +| **1** | **Hoe lang duurt een loveshoot?**
Op de pagina staat nu alleen "We stemmen de duur samen af." Bij Gezin en Zwangerschap staat bijvoorbeeld "1 uur fotografie, zonder haast." Welke duur wil je bij de loveshoot noemen? | | +| **2** | **Hoe lang duurt een portretshoot?**
Ook hier staat nu "We stemmen de duur samen af." Welke duur wil je noemen (eventueel verschillend voor natuur en zakelijk)? | | +| **3** | **Welke locaties bied je aan voor portretshoots?**
Nu staat er alleen "We kiezen samen een plek die past bij jou of bij je bedrijf." Zijn er vaste plekken of soorten plekken die je wilt noemen, voor portretten in de natuur en voor zakelijke portretten? | | +| **4** | **Geldt de aanbetaling van € 50 ook voor de loveshoot en de portretshoot?**
Voor Newborn, Zwangerschap en Gezin staat de aanbetaling van € 50 vast. Op de pagina's van Loveshoot en Portret staat die nu ook, maar dat weten we niet zeker. | | +| **5** | **Wanneer betaal je het restbedrag precies?**
Nu staat er "het restbedrag betaal je na de shoot". Is dat direct na de shoot, of voordat je de foto's oplevert? Staat er liever een andere formulering? | | +| **6** | **Krijgen klanten van de loveshoot en de portretshoot ook een persoonlijke online fotogalerij?**
Voor de drie pakketten (Newborn, Zwangerschap, Gezin) is dat bevestigd. Bij stap 6 "Oplevering" staat nu op alle pagina's: "Je foto's staan klaar in je persoonlijke online fotogalerij." | | +| **7** | **Newborn, blok 4: wil je het getal "1 tot 2 uur" in de titel houden?**
De titel van blok 4 is nu "1 tot 2 uur, op het ritme van je baby". Dat is hetzelfde getal als in het pakket ("1-2 uur fotografie"), en het stond zo in het ontwerp. Laat je dit staan, of liever zonder getal? | | + +#### Twee extra vragen (niet verplicht) + +Deze staan niet in de teksten, maar je kunt ze meteen beantwoorden als je ze wilt noemen. + +| Nr. | Vraag | Jouw antwoord | +|---|---|---| +| **8** | **Extra (niet verplicht): hoeveel foto's krijgen klanten bij de loveshoot en de portretshoot?**
Bij de drie pakketten staat "Minstens 30 of 40 zorgvuldig nabewerkte foto's". Voor Loveshoot en Portret noemen de teksten nu geen aantal. | | +| **9** | **Extra (niet verplicht): wat is de beste periode voor een loveshoot of portretshoot?**
Bij Newborn en Zwangerschap noemen we een periode (12 weken, 30 tot 34 weken). Voor Loveshoot en Portret staat er nu niets over. | | + +## 3. Teksten die op elke shootpagina staan + +Deze teksten zijn voor alle shoots hetzelfde. De namen van de zes stappen (Aanvragen, Datum & locatie kiezen, Aanbetaling, De shoot, Bewerking, Oplevering) staan al vast en zijn hier niet opnieuw voorgelegd. + +Waar je "{locatie}" en "{duur}" ziet, komt de zin uit hoofdstuk 4 van de betreffende shoot te staan. Bij de pakketten zelf (inhoud en prijs: Newborn € 185, Zwangerschap € 175, Gezin € 175) staan de teksten al vast. Loveshoot en Portret hebben nog geen pakket en tonen "Prijs op aanvraag". + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Vraag "Wanneer krijg ik de foto's?" (staat op alle vijf de pagina's)** | **Vraag:** Wanneer krijg ik de foto's?
**Antwoord:** Reken op 2–3 weken na de shoot. In die tijd selecteer en bewerk ik de mooiste foto's. | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:7 | +| **Vraag "Hoe leg ik de datum vast?" (staat op Zwangerschap, Gezin, Loveshoot en Portret)** | **Vraag:** Hoe leg ik de datum vast?
**Antwoord:** [Stuur een berichtje](/contact), dan kiezen we samen een moment. Met een aanbetaling van € 50 staat je datum vast. De aanbetaling wordt verrekend met het totaalbedrag; het restbedrag betaal je na de shoot.
*Zie vraag 4 en 5 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:17 | +| **Vraag "Hoe snel hoor ik iets van je?" (staat nu op geen enkele pagina, ligt klaar voor later)** | **Vraag:** Hoe snel hoor ik iets van je?
**Antwoord:** Ik reageer binnen 1-2 werkdagen op je berichtje. | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:29 | +| **Zo werkt het – klein kopje** | Zo werkt het | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:46 | +| **Zo werkt het – titel** | Van aanvraag tot online galerij | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:48 | +| **Zo werkt het – inleiding boven de stappen** | Elke shoot volgt dezelfde zes stappen, zodat je precies weet waar je aan toe bent. | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:50 | +| **Stap 1 "Aanvragen" – tekst** | Stuur een berichtje. Ik reageer binnen 1-2 werkdagen. | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:55 | +| **Stap 2 "Datum & locatie kiezen" – tekst** | We kiezen samen een moment. {locatie} | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:60 | +| **Stap 3 "Aanbetaling" – tekst** | Met een aanbetaling van € 50 staat je datum vast. | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:65 | +| **Stap 4 "De shoot" – tekst** | {duur} | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:70 | +| **Stap 5 "Bewerking" – tekst** | Ik selecteer en bewerk de mooiste foto's. Opleverduur: 2–3 weken. | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:75 | +| **Stap 6 "Oplevering" – tekst** | Je foto's staan klaar in je persoonlijke online fotogalerij.
*Zie vraag 6 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:80 | +| **Regel over de aanbetaling in het pakketblok** | Aanbetaling € 50, restbedrag na de shoot.
*Zie vraag 4 en 5 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:89 | +| **Fotomozaïek – klein kopje** | Impressie | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:94 | +| **Veelgestelde vragen – klein kopje** | Veelgestelde vragen | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:98 | +| **Veelgestelde vragen – tekst onder de vragen** | Staat je vraag er niet tussen? [Stuur gerust een berichtje](/contact). | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:100 | +| **Knop "Boek dit pakket" (pakketblok)** | Boek dit pakket | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:108 | +| **Knop "Eerst een vraag stellen" (pakketblok)** | Eerst een vraag stellen | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:110 | +| **Blok "Prijs op aanvraag" (Loveshoot en Portret)** | **Prijs:** Prijs op aanvraag
**Tekst:** Stuur me een berichtje met wat je in gedachten hebt, dan vertel ik je graag meer over de mogelijkheden en de prijs.
**Linktekst:** Vraag naar de mogelijkheden | ☐ Akkoord
☐ Aanpassen | | shootPageShared.ts:114 | + +Aantal teksten in dit hoofdstuk: 19. + +## 4. De teksten per shoot + +Per shoot staan de teksten in de volgorde waarin ze op de pagina komen: introductie, vier blokken, de twee zinnen in de tijdlijn, de titel boven de foto's, de veelgestelde vragen, het pakketblok en de afsluiting. Daarna volgen de titel en beschrijving die Google toont. + +### 4.1 Newborn (/soorten-fotoshoots/newborn) + +Teksten in dit onderdeel: 17. Pakket (staat al vast): € 185 – 1-2 uur fotografie, minstens 40 zorgvuldig nabewerkte foto's, persoonlijke online fotogalerij. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Introductie bovenaan de pagina** | **Klein kopje:** Newbornfotograaf in Huizen
**Titel:** Newbornshoot bij jou thuis
**Tekst:** Ben je in verwachting? Boek een newbornshoot om de 'kleinste' momenten voor altijd te bewaren. Ik fotografeer bij jou thuis in Huizen, Bussum, Hilversum en omgeving, in het rustige ritme van jullie baby. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:27 | +| **Blok 1 – label, titel en tekst** | **Klein kopje:** Wat kun je verwachten
**Titel:** De kleinste momenten, voor altijd bewaard
**Tekst:** Een newbornshoot is rustig en ontspannen. Ik fotografeer jullie baby in de eerste weken, slapend en wakker, alleen en in jullie armen. Geen haast en geen ingewikkelde opstellingen: de kleine details en de warmte van jullie eerste weken staan centraal. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:34 | +| **Blok 2 – label, titel en tekst** | **Klein kopje:** De beste periode
**Titel:** Tot 12 weken na de geboorte
**Tekst:** De ideale periode voor een newbornshoot is tot 12 weken na de geboorte van je baby. In die eerste weken slapen baby's veel en zijn ze nog heerlijk klein.
Boek je shoot het liefst al tijdens je zwangerschap. Dan zetten we een voorlopige datum rond je uitgerekende datum en schuiven we mee als jullie baby eerder of later komt. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:51 | +| **Blok 3 – label, titel en tekst** | **Klein kopje:** Bij jou thuis
**Titel:** In jullie eigen vertrouwde omgeving
**Tekst:** De fotoshoot vindt bij jou thuis plaats. Je hoeft nergens heen met een baby van een paar weken oud, en jullie huis maakt de foto's persoonlijk.
Je kunt tussendoor gewoon je baby voeden en verschonen als dat nodig is. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:67 | +| **Blok 4 – label, titel en tekst** | **Klein kopje:** Hoe lang duurt het
**Titel:** 1 tot 2 uur, op het ritme van je baby
**Tekst:** We nemen alle tijd en volgen het ritme van jullie baby. Reken op 1 tot 2 uur fotografie, inclusief pauzes om te voeden, te troosten of even te knuffelen.
Wil je broertjes, zusjes of jezelf ook op de foto? Dat plannen we gewoon in.
*Zie vraag 7 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | newborn.ts:87 | +| **Tijdlijn, stap 2 – zin over de locatie** | Een newbornshoot is bij jou thuis. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:109 | +| **Tijdlijn, stap 4 – zin over de duur** | 1-2 uur fotografie, in het tempo van jullie baby.
*Zie vraag 7 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | newborn.ts:111 | +| **Fotomozaïek – titel** | Uit eerdere newbornshoots | ☐ Akkoord
☐ Aanpassen | | newborn.ts:117 | +| **Veelgestelde vragen – titel** | Vragen over de newbornshoot | ☐ Akkoord
☐ Aanpassen | | newborn.ts:144 | +| **Veelgestelde vraag 1 – vraag en antwoord** | **Vraag:** Wanneer boek ik de newbornshoot het beste?
**Antwoord:** Het liefst al tijdens je zwangerschap. We zetten een voorlopige datum rond je uitgerekende datum en schuiven mee als jullie baby eerder of later komt. De shoot vindt plaats binnen 12 weken na de geboorte. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:147 | +| **Veelgestelde vraag 2 – vraag en antwoord** | **Vraag:** Wat als mijn baby niet wil slapen?
**Antwoord:** Geen probleem. We volgen het ritme van jullie baby en nemen pauzes om te voeden, te verschonen of te troosten. Wakkere momenten leveren ook prachtige foto's op. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:155 | +| **Veelgestelde vraag 3 – vraag en antwoord** | **Vraag:** Mogen wij en broertjes of zusjes ook op de foto?
**Antwoord:** Ja, heel graag. Foto's met papa, mama en broertjes of zusjes horen er wat mij betreft gewoon bij. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:163 | +| **Veelgestelde vraag 4 – vraag en antwoord** | **Vraag:** Wat moet ik thuis voorbereiden?
**Antwoord:** Weinig. Een warme kamer met wat daglicht is fijn. | ☐ Akkoord
☐ Aanpassen | | newborn.ts:171 | +| **Pakketblok – klein kopje en titel** | **Klein kopje:** Pakket newborn
**Titel:** Wat zit er in een newbornshoot | ☐ Akkoord
☐ Aanpassen | | newborn.ts:180 | +| **Afsluiting met knop – titel, tekst en knoptekst** | **Titel:** Op zoek naar een newbornfotograaf in Huizen?
**Tekst:** Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een datum rond je uitgerekende datum.
**Knoptekst:** Boek je newbornshoot | ☐ Akkoord
☐ Aanpassen | | newborn.ts:185 | + +Na de eigen vragen volgt automatisch de vraag "Wanneer krijg ik de foto's?" (hoofdstuk 3). + +#### Voor Google (Newborn) + +Dit is de titel en beschrijving die in de zoekresultaten van Google verschijnen. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Titel in Google** | Newbornshoot in Huizen | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:65 | +| **Beschrijving in Google** | Newbornshoot in Huizen en omgeving, bij jou thuis in het rustige ritme van je baby. Warme, spontane foto's van Andrea Slop Fotografie. | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:67 | + +### 4.2 Zwangerschap (/soorten-fotoshoots/zwangerschap) + +Teksten in dit onderdeel: 16. Pakket (staat al vast): € 175 – 1 uur fotografie, minstens 30 zorgvuldig nabewerkte foto's, persoonlijke online fotogalerij. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Introductie bovenaan de pagina** | **Klein kopje:** Zwangerschapsfotograaf in Huizen
**Titel:** Je zwangerschap, voor altijd vastgelegd
**Tekst:** Met een zwangerschapsshoot leg je deze bijzondere periode vast voor altijd. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving, op een plek die bij jullie past. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:30 | +| **Blok 1 – label, titel en tekst** | **Klein kopje:** Wat kun je verwachten
**Titel:** Deze bijzondere periode, voor altijd bewaard
**Tekst:** Een zwangerschapsshoot is ontspannen en ongedwongen. Ik leg jullie vast zoals jullie zijn: geen ongemakkelijke poses, maar spontane momenten van jou, je buik en, als je wilt, je partner. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:37 | +| **Blok 2 – label, titel en tekst** | **Klein kopje:** De beste periode
**Titel:** Tussen 30 en 34 weken
**Tekst:** De mooiste periode voor een zwangerschapsshoot is tussen de 30 en 34 weken. Stuur gerust op tijd een berichtje, dan plannen we de shoot samen in die weken. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:54 | +| **Blok 3 – label, titel en tekst** | **Klein kopje:** De locatie
**Titel:** Op een plek die bij jullie past
**Tekst:** We kiezen samen een locatie uit die bij jullie past, denk aan de Soesterduinen of de heide. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:66 | +| **Blok 4 – label, titel en tekst** | **Klein kopje:** Hoe lang duurt het
**Titel:** Rustig de tijd
**Tekst:** We nemen de tijd, zodat jullie je op je gemak voelen. Zo ontstaan de mooiste, spontane momenten. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:78 | +| **Tijdlijn, stap 2 – zin over de locatie** | En een plek die bij jullie past, zoals de Soesterduinen of de heide. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:91 | +| **Tijdlijn, stap 4 – zin over de duur** | 1 uur fotografie, zonder haast. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:94 | +| **Fotomozaïek – titel** | Uit eerdere zwangerschapsshoots | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:100 | +| **Veelgestelde vragen – titel** | Vragen over de zwangerschapsshoot | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:108 | +| **Veelgestelde vraag 1 – vraag en antwoord** | **Vraag:** Wanneer plan ik de zwangerschapsshoot?
**Antwoord:** De mooiste periode is tussen de 30 en 34 weken. Stuur gerust al eerder een berichtje, dan zoeken we samen een moment in die weken. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:111 | +| **Veelgestelde vraag 2 – vraag en antwoord** | **Vraag:** Mag mijn partner ook op de foto?
**Antwoord:** Ja, heel graag. Samen op de foto of alleen jij: we doen wat bij jullie past. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:119 | +| **Veelgestelde vraag 3 – vraag en antwoord** | **Vraag:** Waar vindt de zwangerschapsshoot plaats?
**Antwoord:** We kiezen samen een locatie uit die bij jullie past, denk aan de Soesterduinen of de heide. | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:127 | +| **Pakketblok – klein kopje en titel** | **Klein kopje:** Pakket zwangerschap
**Titel:** Wat zit er in een zwangerschapsshoot | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:139 | +| **Afsluiting met knop – titel, tekst en knoptekst** | **Titel:** Op zoek naar een zwangerschapsfotograaf in Huizen?
**Tekst:** Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een plek die bij jullie past.
**Knoptekst:** Boek je zwangerschapsshoot | ☐ Akkoord
☐ Aanpassen | | zwangerschap.ts:144 | + +Na de eigen vragen volgen automatisch "Hoe leg ik de datum vast?" en "Wanneer krijg ik de foto's?" (hoofdstuk 3). + +#### Voor Google (Zwangerschap) + +Dit is de titel en beschrijving die in de zoekresultaten van Google verschijnen. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Titel in Google** | Zwangerschapsshoot in Huizen | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:73 | +| **Beschrijving in Google** | Zwangerschapsshoot in Huizen en omgeving: leg deze bijzondere periode vast in spontane foto's. Ontdek de mogelijkheden van Andrea Slop Fotografie. | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:75 | + +### 4.3 Gezin (/soorten-fotoshoots/gezin) + +Teksten in dit onderdeel: 16. Pakket (staat al vast): € 175 – 1 uur fotografie, minstens 30 zorgvuldig nabewerkte foto's, persoonlijke online fotogalerij. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Introductie bovenaan de pagina** | **Klein kopje:** Gezinsfotograaf in Huizen
**Titel:** Gezinsshoot vol echte momenten
**Tekst:** Met een gezinsshoot leggen we vast hoe jullie nu samen zijn. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving, bij jullie thuis of buiten in de natuur. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:31 | +| **Blok 1 – label, titel en tekst** | **Klein kopje:** Wat kun je verwachten
**Titel:** Spelen, knuffelen en lachen
**Tekst:** Met een gezinsshoot leggen we vast hoe jullie nu samen zijn: spelen, knuffelen en lachen. Geen stijve poses, maar echte momenten die je later met plezier terugkijkt. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:38 | +| **Blok 2 – label, titel en tekst** | **Klein kopje:** Het hele gezin
**Titel:** Iedereen hoort erbij
**Tekst:** Papa, mama, broertjes en zusjes: op een gezinsshoot hoort iedereen erbij. Ook als jullie gezin net een kleintje rijker is. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:55 | +| **Blok 3 – label, titel en tekst** | **Klein kopje:** Thuis of buiten
**Titel:** Een plek die bij jullie past
**Tekst:** We kiezen samen een plek die bij jullie past, bij jullie thuis of buiten in de natuur. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:67 | +| **Blok 4 – label, titel en tekst** | **Klein kopje:** Hoe lang duurt het
**Titel:** Rustig de tijd
**Tekst:** We nemen de tijd, zodat iedereen zich op zijn gemak voelt. Ook de kleinsten: is er even een pauze nodig, dan is daar gewoon ruimte voor. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:79 | +| **Tijdlijn, stap 2 – zin over de locatie** | En een plek die bij jullie past: bij jullie thuis of buiten in de natuur. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:92 | +| **Tijdlijn, stap 4 – zin over de duur** | 1 uur fotografie, zonder haast. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:95 | +| **Fotomozaïek – titel** | Uit eerdere gezinsshoots | ☐ Akkoord
☐ Aanpassen | | gezin.ts:101 | +| **Veelgestelde vragen – titel** | Vragen over de gezinsshoot | ☐ Akkoord
☐ Aanpassen | | gezin.ts:109 | +| **Veelgestelde vraag 1 – vraag en antwoord** | **Vraag:** Wie mogen er op de foto?
**Antwoord:** Het hele gezin: papa, mama, broertjes en zusjes. Geen stijve poses, maar echte momenten met elkaar. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:112 | +| **Veelgestelde vraag 2 – vraag en antwoord** | **Vraag:** Fotograferen we bij ons thuis of buiten?
**Antwoord:** Allebei kan. We kiezen samen een plek die bij jullie past, bij jullie thuis of buiten in de natuur. | ☐ Akkoord
☐ Aanpassen | | gezin.ts:120 | +| **Pakketblok – klein kopje en titel** | **Klein kopje:** Pakket gezin
**Titel:** Wat zit er in een gezinsshoot | ☐ Akkoord
☐ Aanpassen | | gezin.ts:132 | +| **Afsluiting met knop – titel, tekst en knoptekst** | **Titel:** Op zoek naar een gezinsfotograaf in Huizen?
**Tekst:** Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een plek die bij jullie past.
**Knoptekst:** Boek je gezinsshoot | ☐ Akkoord
☐ Aanpassen | | gezin.ts:137 | + +Na de eigen vragen volgen automatisch "Hoe leg ik de datum vast?" en "Wanneer krijg ik de foto's?" (hoofdstuk 3). + +#### Voor Google (Gezin) + +Dit is de titel en beschrijving die in de zoekresultaten van Google verschijnen. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Titel in Google** | Gezinsshoot in Huizen | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:81 | +| **Beschrijving in Google** | Gezinsshoot in Huizen en omgeving: echte momenten die laten zien hoe jullie nu samen zijn. Ontdek de mogelijkheden van Andrea Slop Fotografie. | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:83 | + +#### Overzichtspagina "Soorten fotoshoots": tekst over Gezin + +Deze tekst staat al op de bestaande overzichtspagina en was ook nog een concept. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Tekst over Gezin op de overzichtspagina "Soorten fotoshoots"** | Met een gezinsshoot leggen we vast hoe jullie nu samen zijn: spelen, knuffelen en lachen. Geen stijve poses, maar echte momenten die je later met plezier terugkijkt. We kiezen samen een plek die bij jullie past, bij jullie thuis of buiten in de natuur. | ☐ Akkoord
☐ Aanpassen | | shootTypes.ts:70 | + +### 4.4 Loveshoot (/soorten-fotoshoots/loveshoot) + +Teksten in dit onderdeel: 15. Geen vast pakket: de pagina toont "Prijs op aanvraag" met de teksten uit hoofdstuk 3. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Introductie bovenaan de pagina** | **Klein kopje:** Loveshoot in Huizen
**Titel:** Loveshoot voor jullie twee
**Tekst:** Een loveshoot is een prachtige manier om jullie liefde vast te leggen. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:23 | +| **Blok 1 – label, titel en tekst** | **Klein kopje:** Wat kun je verwachten
**Titel:** Jullie liefde, vastgelegd
**Tekst:** Een loveshoot is een prachtige manier om jullie liefde vast te leggen. Mijn stijl is natuurlijk en ongedwongen: geen ongemakkelijke poses, maar spontane momenten van jullie samen. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:30 | +| **Blok 2 – label, titel en tekst** | **Klein kopje:** Verloofd?
**Titel:** Voor jullie trouwkaart
**Tekst:** Zijn jullie verloofd? Dan kan je de foto's gebruiken voor de trouwkaart. Vertel het me gerust bij je aanvraag, dan houden we daar rekening mee. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:42 | +| **Blok 3 – label, titel en tekst** | **Klein kopje:** De locatie
**Titel:** Samen een plek kiezen
**Tekst:** We kiezen samen een plek die bij jullie past. Vertel me gerust wat jullie mooi vinden of waar jullie graag samen komen. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:53 | +| **Blok 4 – label, titel en tekst** | **Klein kopje:** Gewoon jullie zelf
**Titel:** Ontspannen voor de camera
**Tekst:** Spannend om samen voor de camera te staan? Dat hoeft niet. We nemen de tijd, zodat jullie je op je gemak voelen en ik jullie kan vastleggen zoals jullie zijn. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:64 | +| **Tijdlijn, stap 2 – zin over de locatie** | En een plek die bij jullie past. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:77 | +| **Tijdlijn, stap 4 – zin over de duur** | We stemmen de duur samen af.
*Zie vraag 1 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:79 | +| **Fotomozaïek – titel** | Uit eerdere loveshoots | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:86 | +| **Veelgestelde vragen – titel** | Vragen over de loveshoot | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:102 | +| **Veelgestelde vraag 1 – vraag en antwoord** | **Vraag:** Kunnen we de foto's gebruiken voor onze trouwkaart?
**Antwoord:** Ja, zeker. Zijn jullie verloofd? Dan kan je de foto's van jullie loveshoot gebruiken voor de trouwkaart. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:105 | +| **Veelgestelde vraag 2 – vraag en antwoord** | **Vraag:** We staan niet graag op de foto. Is dat erg?
**Antwoord:** Helemaal niet. We nemen de tijd, zodat jullie je op je gemak voelen. Geen ongemakkelijke poses, maar spontane momenten van jullie samen. | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:113 | +| **Pakketblok – klein kopje en titel** | **Klein kopje:** Loveshoot boeken
**Titel:** Benieuwd naar de mogelijkheden? | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:125 | +| **Afsluiting met knop – titel, tekst en knoptekst** | **Titel:** Op zoek naar een fotograaf voor jullie loveshoot?
**Tekst:** Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een plek die bij jullie past.
**Knoptekst:** Boek je loveshoot | ☐ Akkoord
☐ Aanpassen | | loveshoot.ts:130 | + +Na de eigen vragen volgen automatisch "Hoe leg ik de datum vast?" en "Wanneer krijg ik de foto's?" (hoofdstuk 3). + +#### Voor Google (Loveshoot) + +Dit is de titel en beschrijving die in de zoekresultaten van Google verschijnen. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Titel in Google** | Loveshoot in Huizen | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:89 | +| **Beschrijving in Google** | Loveshoot in Huizen en omgeving: leg jullie liefde vast in spontane, kleurrijke foto's. Ontdek de mogelijkheden van Andrea Slop Fotografie. | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:91 | + +### 4.5 Portret (/soorten-fotoshoots/portret) + +Teksten in dit onderdeel: 15. Geen vast pakket: de pagina toont "Prijs op aanvraag" met de teksten uit hoofdstuk 3. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Introductie bovenaan de pagina** | **Klein kopje:** Portretfotograaf in Huizen
**Titel:** Portretshoot in de natuur of zakelijk
**Tekst:** Van portretshoots in de natuur tot zakelijke shoots voor de branding van je bedrijf. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving. | ☐ Akkoord
☐ Aanpassen | | portret.ts:23 | +| **Blok 1 – label, titel en tekst** | **Klein kopje:** Wat kun je verwachten
**Titel:** Jij, zoals je bent
**Tekst:** Mijn stijl is natuurlijk en ongedwongen. Geen ongemakkelijke poses, maar foto's waarop je jezelf herkent. | ☐ Akkoord
☐ Aanpassen | | portret.ts:30 | +| **Blok 2 – label, titel en tekst** | **Klein kopje:** Natuur of zakelijk
**Titel:** Persoonlijk of voor je bedrijf
**Tekst:** Van portretshoots in de natuur tot zakelijke shoots voor de branding van je bedrijf. Vertel me waarvoor je de foto's wilt gebruiken, dan stemmen we de shoot daarop af. | ☐ Akkoord
☐ Aanpassen | | portret.ts:42 | +| **Blok 3 – label, titel en tekst** | **Klein kopje:** De locatie
**Titel:** Samen een plek kiezen
**Tekst:** We kiezen samen een plek die past bij jou of bij je bedrijf.
*Zie vraag 3 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | portret.ts:53 | +| **Blok 4 – label, titel en tekst** | **Klein kopje:** Gewoon jezelf
**Titel:** Op je gemak voor de camera
**Tekst:** Niet gewend om op de foto te gaan? Geen zorgen. We nemen de tijd, zodat je je op je gemak voelt. | ☐ Akkoord
☐ Aanpassen | | portret.ts:65 | +| **Tijdlijn, stap 2 – zin over de locatie** | En een plek die bij jou past.
*Zie vraag 3 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | portret.ts:78 | +| **Tijdlijn, stap 4 – zin over de duur** | We stemmen de duur samen af.
*Zie vraag 2 in hoofdstuk 2.* | ☐ Akkoord
☐ Aanpassen | | portret.ts:81 | +| **Fotomozaïek – titel** | Uit eerdere portretshoots | ☐ Akkoord
☐ Aanpassen | | portret.ts:88 | +| **Veelgestelde vragen – titel** | Vragen over de portretshoot | ☐ Akkoord
☐ Aanpassen | | portret.ts:104 | +| **Veelgestelde vraag 1 – vraag en antwoord** | **Vraag:** Kan ik ook zakelijke foto's laten maken?
**Antwoord:** Ja. Naast portretshoots in de natuur doe ik ook zakelijke shoots voor de branding van je bedrijf. | ☐ Akkoord
☐ Aanpassen | | portret.ts:107 | +| **Veelgestelde vraag 2 – vraag en antwoord** | **Vraag:** Ik sta niet graag op de foto. Is dat erg?
**Antwoord:** Helemaal niet. We nemen de tijd, zodat je je op je gemak voelt. Geen ongemakkelijke poses, maar foto's waarop je jezelf herkent. | ☐ Akkoord
☐ Aanpassen | | portret.ts:115 | +| **Pakketblok – klein kopje en titel** | **Klein kopje:** Portretshoot boeken
**Titel:** Benieuwd naar de mogelijkheden? | ☐ Akkoord
☐ Aanpassen | | portret.ts:127 | +| **Afsluiting met knop – titel, tekst en knoptekst** | **Titel:** Op zoek naar een portretfotograaf in Huizen?
**Tekst:** Stuur gerust een berichtje voor de mogelijkheden. Vertel me waarvoor je de foto's wilt gebruiken.
**Knoptekst:** Boek je portretshoot | ☐ Akkoord
☐ Aanpassen | | portret.ts:132 | + +Na de eigen vragen volgen automatisch "Hoe leg ik de datum vast?" en "Wanneer krijg ik de foto's?" (hoofdstuk 3). + +#### Voor Google (Portret) + +Dit is de titel en beschrijving die in de zoekresultaten van Google verschijnen. + +| Onderdeel | Concepttekst | Akkoord? | Aanpassing / opmerking | Ref. | +|---|---|---|---|---| +| **Titel in Google** | Portretshoot in Huizen | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:97 | +| **Beschrijving in Google** | Portretshoot in Huizen en omgeving, in de natuur of zakelijk. Spontane portretfoto's van Andrea Slop Fotografie. | ☐ Akkoord
☐ Aanpassen | | sitePages.ts:99 | + +## 5. Foto's + +Elke shootpagina is opgebouwd uit een vaste indeling met plekken voor foto's (het ontwerp zie je via de link in hoofdstuk 1). Een foto mag maar één keer op dezelfde pagina staan. Dezelfde foto op twee plekken van één pagina wordt dus niet gebruikt. De voorbeeldpagina in het ontwerp is Newborn. Voor de andere vier gebruik ik dezelfde indeling. + +#### De plekken voor foto's op een pagina + +| Plek | Vorm | Opmerking | +|---|---|---| +| Introductie | Geen foto | Alleen tekst bovenaan. | +| Blok 1 (wat kun je verwachten) | Staand, 4:5 | De hoofdfoto van de shoot. | +| Blok 2 (de beste periode) | Liggend, 3:2 | | +| Blok 3 (locatie) | Staand, 4:5 | | +| Blok 4 (duur) | Staand, 4:5 | | +| Fotomozaïek: 4 foto's | 1 grote staande (links, twee kolommen breed en twee rijen hoog), 1 brede liggende (rechtsboven), 2 kleine bijna vierkante (rechtsonder) | De foto's worden bijgesneden zodat ze de plek vullen. De mozaïek verschijnt vanaf 2 foto's die niet al elders op de pagina staan. | +| Pakketblok | Vierkant, 1:1 | Een detailfoto naast het pakket (of naast "Prijs op aanvraag"). | + +Een volledige pagina heeft zo 9 foto's nodig: 4 bij de blokken, 4 in de mozaïek en 1 bij het pakket. + +### Overzicht per shoot + +| Shoot | Nodig | Nu beschikbaar | Nog nodig | Welke foto's | +|---|---|---|---|---| +| **Newborn** | 9 | 8 | **1** | staand of liggend (kleine mozaïektegel) | +| **Zwangerschap** | 9 | 4 | **5** | 1 staand (blok 4), 1 staand + 1 liggend + 2 vrij (mozaïek) | +| **Gezin** | 9 | 4 | **5** | 1 staand (blok 4), 1 staand + 1 liggend + 2 vrij (mozaïek) | +| **Loveshoot** | 9 | 2 | **7** | 1 liggend (blok 2), 2 staand (blok 3 en 4), 1 staand + 1 liggend + 2 vrij (mozaïek) | +| **Portret** | 9 | 2 | **7** | 1 liggend (blok 2), 2 staand (blok 3 en 4), 1 staand + 1 liggend + 2 vrij (mozaïek) | + +In totaal ontbreken er 25 foto's om alle vijf de pagina's zo te vullen als in het ontwerp. Je hoeft niet alles in één keer te leveren: de pagina's werken ook met minder foto's, ze zien er alleen minder vol uit. Het meeste effect heb je bij Loveshoot en Portret (nu maar 2 foto's per pagina). + +#### Wat er nu gebeurt zonder de extra foto's + +- **Newborn:** De mozaïek toont nu 3 foto's (de vierde plek blijft leeg). Alle vier de blokken en het pakketblok zijn gevuld. +- **Zwangerschap:** Blok 4 toont alleen tekst. De fotomozaïek is verborgen: de twee foto's die er zouden komen staan al in blok 2 en 3. Een of twee nieuwe foto's zijn al genoeg om hem weer te tonen (minimaal 2). +- **Gezin:** Blok 4 toont alleen tekst. De fotomozaïek is verborgen: de twee foto's die er zouden komen staan al in blok 2 en 3. Met minimaal 2 nieuwe foto's verschijnt hij weer. Let op: de huidige foto's bij Gezin tonen gezinnen met een pasgeboren baby. +- **Loveshoot:** Er zijn maar 2 foto's (hoofdfoto en detailfoto). Blok 2, 3 en 4 tonen alleen tekst en de fotomozaïek is verborgen. +- **Portret:** Er zijn maar 2 foto's (hoofdfoto en detailfoto). Blok 2, 3 en 4 tonen alleen tekst en de fotomozaïek is verborgen. + +#### Wat voor foto's en in welk formaat? + +- Lever bij voorkeur de originele (of licht bewerkte) foto's zonder bijsnijden. Ik snijd ze op de pagina bij naar de vorm van de plek. De bestaande foto's op de site zijn 800 pixels breed (staand 800 x 1200, liggend 800 x 534) met een grote versie van 1067 x 1600 (staand) of 1600 x 1067 (liggend). Haal je foto's ten minste op die grootte; groter mag. +- Staande plekken (blok 1, 3, 4) hebben de vorm 4:5, de liggende plek (blok 2) 3:2. Een gewone staande foto (2:3) past: er gaat wat van boven en onderkant af, dus laat het onderwerp niet te dicht tegen de rand staan. +- De detailfoto's in de pakketblokken zijn nu vierkant en klein (480 x 480 pixels). Voor een scherpe weergave is een vierkante uitsnede van minstens 960 x 960 pixels beter. +- Geef bij elke foto aan bij welke shoot hij hoort. Als je een foto bij een andere shoot wilt gebruiken dan nu, hoor ik dat graag. +- Foto's met herkenbare mensen: ik ga ervan uit dat daar toestemming voor is om ze op de site te tonen, zoals bij je bestaande portfolio. + +### Per shoot: de plekken en welke foto nu gebruikt wordt + +#### Newborn + +| Plek | Vorm | Foto nu | Status | +|---|---|---|---| +| Blok 1 | Staand 4:5 | Pasgeboren baby in gestreept pakje slaapt met het hoofdje opzij | Aanwezig | +| Blok 2 | Liggend 3:2 | Slapende baby in bruin-wit gestreept pakje | Aanwezig | +| Blok 3 | Staand 4:5 | Moeder drukt haar gezicht tegen het hoofdje van haar baby | Aanwezig | +| Blok 4 | Staand 4:5 | Baby in wit pakje op de onderarm van een ouder, kijkt in de camera | Aanwezig | +| Mozaïek groot | Staand | Vader kust zijn baby op het hoofd | Aanwezig | +| Mozaïek breed | Liggend | Babyvuistje tussen gebreide deken en geruite doek | Aanwezig | +| Mozaïek klein 1 | Bijna vierkant | Blote babyvoetjes in gestreept gebreid broekje | Aanwezig | +| Mozaïek klein 2 | Bijna vierkant | Geen (in het ontwerp staat hier de slapende baby, die al in blok 2 staat) | **Ontbreekt – 1 foto, staand of liggend** | +| Pakketblok | Vierkant 1:1 | Babyvoetjes die onder een gestreept gebreid pakje uitsteken | Aanwezig | + +#### Zwangerschap + +| Plek | Vorm | Foto nu | Status | +|---|---|---|---| +| Blok 1 | Staand 4:5 | Zwangere vrouw en partner kijken elkaar lachend aan op een zandvlakte | Aanwezig | +| Blok 2 | Liggend 3:2 | Zwangere buik in zwarte jurk, omarmd door twee handen | Aanwezig | +| Blok 3 | Staand 4:5 | Aanstaande vader omarmt zijn zwangere partner op een zandvlakte in de avondzon | Aanwezig | +| Blok 4 | Staand 4:5 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 staande foto** | +| Mozaïek groot | Staand | Geen | **Ontbreekt – 1 staande foto** | +| Mozaïek breed | Liggend | Geen | **Ontbreekt – 1 liggende foto** | +| Mozaïek klein 1 en 2 | Bijna vierkant | Geen | **Ontbreekt – 2 foto's, staand of liggend** | +| Pakketblok | Vierkant 1:1 | Zwangere vrouw in lichte jurk houdt haar buik vast op een zandvlakte | Aanwezig | + +#### Gezin + +| Plek | Vorm | Foto nu | Status | +|---|---|---|---| +| Blok 1 | Staand 4:5 | Vader en moeder kijken samen naar hun pasgeboren baby in de armen van de vader | Aanwezig | +| Blok 2 | Liggend 3:2 | Grote broer kust zijn pasgeboren broertje of zusje op een wit bed | Aanwezig | +| Blok 3 | Staand 4:5 | Jonge ouders kijken samen naar hun slapende pasgeboren baby | Aanwezig | +| Blok 4 | Staand 4:5 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 staande foto** | +| Mozaïek groot | Staand | Geen | **Ontbreekt – 1 staande foto** | +| Mozaïek breed | Liggend | Geen | **Ontbreekt – 1 liggende foto** | +| Mozaïek klein 1 en 2 | Bijna vierkant | Geen | **Ontbreekt – 2 foto's, staand of liggend** | +| Pakketblok | Vierkant 1:1 | Een jongetje geeft de pasgeboren baby een kus op het bed | Aanwezig | + +#### Loveshoot + +| Plek | Vorm | Foto nu | Status | +|---|---|---|---| +| Blok 1 | Staand 4:5 | Stel ligt in de zon op een plaid in het gras, hoofden tegen elkaar | Aanwezig | +| Blok 2 | Liggend 3:2 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 liggende foto** | +| Blok 3 | Staand 4:5 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 staande foto** | +| Blok 4 | Staand 4:5 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 staande foto** | +| Mozaïek groot | Staand | Geen | **Ontbreekt – 1 staande foto** | +| Mozaïek breed | Liggend | Geen | **Ontbreekt – 1 liggende foto** | +| Mozaïek klein 1 en 2 | Bijna vierkant | Geen | **Ontbreekt – 2 foto's, staand of liggend** | +| Pakketblok | Vierkant 1:1 | Man schuift een ring om de vinger van zijn partner, met paarse heide | Aanwezig | + +#### Portret + +| Plek | Vorm | Foto nu | Status | +|---|---|---|---| +| Blok 1 | Staand 4:5 | Vrouw met lang bruin haar in witte blouse kijkt glimlachend omlaag, bomen op de achtergrond | Aanwezig | +| Blok 2 | Liggend 3:2 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 liggende foto** | +| Blok 3 | Staand 4:5 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 staande foto** | +| Blok 4 | Staand 4:5 | Geen: dit blok toont nu alleen tekst | **Ontbreekt – 1 staande foto** | +| Mozaïek groot | Staand | Geen | **Ontbreekt – 1 staande foto** | +| Mozaïek breed | Liggend | Geen | **Ontbreekt – 1 liggende foto** | +| Mozaïek klein 1 en 2 | Bijna vierkant | Geen | **Ontbreekt – 2 foto's, staand of liggend** | +| Pakketblok | Vierkant 1:1 | Vrouw met lang blond haar in jurk met bloemenprint houdt een takje heide vast | Aanwezig | + +## 6. Hoe gaat het verder? + +- Je stuurt je ingevulde document (of je opmerkingen) terug. Alleen de teksten waar je Aanpassen hebt gekozen, hoef je van een opmerking te voorzien. +- Ik verwerk je antwoorden op de vragen in hoofdstuk 2 en je aanpassingen in de teksten, en laat je de pagina's zien zoals ze er in het echt uitzien. +- Teksten waar je Akkoord bij hebt gezet, worden definitief. Teksten waarover een vraag openstaat, blijven staan tot je antwoordt. +- Zodra jij alles goedkeurt gaan de pagina's live. Foto's kun je altijd later nog aanleveren; ze komen dan op de pagina's zonder dat de teksten opnieuw nagekeken hoeven te worden. + +Voor de ontwikkelaar: dit document bevat alle 98 teksten met een DRAFT(CON-ST-03)-markering in de code (zie draft-list.txt) en de 7 OPEN(CON-ST-04)-markeringen (open-list.txt). + diff --git a/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/code/code-summary.md b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/code/code-summary.md new file mode 100644 index 0000000..647e0bb --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/code/code-summary.md @@ -0,0 +1,137 @@ +# Code Summary — Unit 3: Navigation submenu + +Plan: [navigation-submenu-code-generation-plan.md](../../plans/navigation-submenu-code-generation-plan.md). Branch `feature/shoot-type-pages` (from master `18e81d0`), worktree `AndreaSlopFotografie-shoot-type-pages`. Unit 2 (shoot page UI) is built in the same worktree; its files are not described here. + +## Status +- Steps 1–16 and 19–20 done (checked in the plan). +- Step 17 (real-browser check: 1024 px fit, transparent header, short phone): **passed** (110/110 checks, 2026-10-30). +- Step 18 (Lighthouse, needs the port 4173 claim): **passed** (mobile `/` pooled median 0.77 = unit-1 baseline 0.77). +- Gates (Step 15): lint, format:check and `tsc` green. `pnpm test`: 106 files, 801 tests passing, fast-check seed 1525740974. The coverage failure reported at that moment came from a file written mid-run by another task. `lib/isShootSectionPath.ts` has 100 % coverage when run on its own, and a full re-run happens at the joint verification. + +## Commits +None. The unit is uncommitted in the worktree. A commit (and a push) is made only when the user asks. + +## Files + +### Created (unit 3) +- `web/src/lib/shootNavItems.ts` (+ `.test.ts`): submenu items from the shoot types +- `web/src/lib/navCurrent.ts` (+ `.test.ts`): `isItemCurrent`, `isSectionCurrent` +- `web/src/lib/navMenuState.ts` (+ `.test.ts`): `navMenuReducer`, `NavMenuState`, `NavMenuEvent`, `initialNavMenuState`, `FocusRequest` +- `web/src/hooks/useDismiss.ts` (+ `useDismiss.test.tsx`) +- `web/src/components/NavigationBar/NavSubmenu.tsx` (desktop disclosure panel), `MobileNavGroup.tsx` (expandable shoot list), `ChevronIcon.tsx` (inline SVG) +- `web/src/components/NavigationBar/NavSubmenu.test.tsx`, `MobileNav.test.tsx`, `NavLink.test.tsx`, `activeOptions.test.tsx` (the exact-matching probe of Step 2, kept as a regression test) +- `web/src/navSubmenu.test.tsx` (real app, `renderApp`) +- `web/src/test/navArbitraries.ts` (unit 3's own fast-check generators; in `test/`, not `lib/`, so the 100 % threshold does not apply to them) +- `web/src/test/navViewport.ts` (test helper: `matchMedia` stub plus the `lg` display rules, because jsdom ignores `@media`) + +### Modified (unit 3) +- `web/src/navigation.ts`: `NavItem.children`, `hasChildren`, `mainNav` parent gets `children: shootNavItems(shootTypes)`; `footerNav` unchanged +- `web/src/navigation.test.ts` (6 tests added, 10 in total) +- `web/src/components/NavigationBar/NavigationBar.tsx`: `useReducer(navMenuReducer)`, effects for `viewport`, `routeChanged` and `focusRequest` +- `web/src/components/NavigationBar/NavigationBar.test.tsx` (extended; the "vaste volgorde" test now asserts the top level and the five children separately) +- `web/src/components/NavigationBar/NavLink.tsx`: `sectionCurrent` prop (`data-section-current`, underline) +- `web/src/components/NavigationBar/MobileNav.tsx`: props `{ id, open, groupOpen, pathname, dispatch }`, scrolls (`overflowY="auto"`), centring wrapper, reduced-motion reveal +- `web/src/components/Footer/Footer.tsx` (exact matching), `Footer.test.tsx` (5 tests added, 11 in total) + +### Not touched by unit 3 +`components/shoots/*`, the page section components, `MediaText`, `CallToAction`, `routes/soorten-fotoshoots/*`, `content/*`, `sitePages.ts`, `LAYOUT.md`, `.ai/`, `test/arbitraries.ts`, `theme.ts`, `package.json`, `pnpm-lock.yaml`. + +## Interfaces +- `NavItem.children?: readonly NavItem[]` (one level; an empty array counts as none); `hasChildren(item)` (`navigation.ts`) +- `shootNavItems(shoots: readonly ShootType[]): NavItem[]` (`lib/shootNavItems.ts`): `{ to: shootPagePath(id), label: name }` in input order +- `isItemCurrent(item, pathname)`, `isSectionCurrent(item, pathname)` (`lib/navCurrent.ts`): lower case, one trailing slash ignored (not for `/`); pure string comparison +- `NavMenuState { isDesktop, menuOpen, groupOpen, submenuOpen, focusRequest }`, `NavMenuEvent` (`viewport`, `toggleMenu`, `toggleGroup`, `toggleSubmenu`, `escape`, `outside`, `focusLeave`, `linkChosen`, `routeChanged`, `focusHandled`), `navMenuReducer(state, event)`, `initialNavMenuState` (`lib/navMenuState.ts`). Invariants I1–I4: `submenuOpen` implies desktop; `menuOpen` implies mobile; `groupOpen` implies `menuOpen`; a focus request fits the width. An event that does not apply returns the same object. +- `useDismiss(ref, active, onDismiss(reason: 'escape' | 'outside'))` (default export, `hooks/useDismiss.ts`) +- Component props: + - `NavSubmenu({ item, id, open, pathname, transparent, toggleRef, dispatch })` + - `MobileNavGroup({ item, id, open, pathname, dispatch })` + - `MobileNav({ id, open, groupOpen, pathname, dispatch })` (`onClose` removed) + - `NavLink(RouterLink props & { sectionCurrent?: boolean })` + - `ChevronIcon()` +- Footer links: `activeOptions={{ exact: true, includeSearch: false }}` (see the truth table below) + +## Requirement and rule traceability +| Requirement / rule | Where | Tests | +|---|---|---| +| FR-ST-10 Navigation submenu | `navigation.ts`, `shootNavItems.ts`, `NavigationBar/*`, `Footer.tsx`, `navMenuState.ts` | `navigation.test.ts`, `shootNavItems.test.ts`, `navMenuState.test.ts`, `NavigationBar.test.tsx`, `NavSubmenu.test.tsx`, `MobileNav.test.tsx`, `navSubmenu.test.tsx`, `Footer.test.tsx` | +| NFR-ST-01 Accessibility (disclosure pattern, keyboard, focus, 44 px, reduced motion, axe) | `NavSubmenu`, `MobileNavGroup`, `MobileNav`, `NavLink`, `ChevronIcon`, `useDismiss` | `NavigationBar.test.tsx` and `MobileNav.test.tsx` (axe open and closed, focus, Escape, keyboard), `useDismiss.test.tsx`, `NavLink.test.tsx`; the visual part is Step 17 (passed) | +| NFR-ST-03 Performance (D5 gate) | `navigation.ts` imports `shootTypes` | Step 16 bundle check; Steps 17–18 passed | +| NFR-ST-06 Testing (PBT + example + registry consistency) | `test/navArbitraries.ts`, `test/navViewport.ts` | PBT in `shootNavItems`, `navCurrent`, `navMenuState` (model-based stateful run); registry "a nav child per shoot" in `navigation.test.ts`; example tests as listed | +| D4 current state | `navCurrent.ts`, `NavLink` (`sectionCurrent`), exact `activeOptions` in every nav and footer link | `activeOptions.test.tsx` (12 tests), `navCurrent.test.ts` (20), `navSubmenu.test.tsx` (18), `Footer.test.tsx` | +| D5 nav source | `navigation.ts` → `shootNavItems(shootTypes)` (single source) | `navigation.test.ts`, `navSubmenu.test.tsx` (every panel name matches `shootTypes`) | +| BR-NAV-01..05 current state, exact matching, case, query, hash | `navCurrent.ts`, `activeOptions` (Step 2) | `activeOptions.test.tsx`, `navCurrent.test.ts`, `navSubmenu.test.tsx` | +| BR-NAV-10..12 content | `shootNavItems.ts`, `navigation.ts` | `shootNavItems.test.ts`, `navigation.test.ts` | +| BR-NAV-20..29 desktop submenu (click, Escape, outside, Tab out, no hover, no arrow keys, closed panel not reachable) | `NavSubmenu.tsx`, `useDismiss.ts`, `navMenuState.ts` | `NavSubmenu.test.tsx` (13), `NavigationBar.test.tsx` (27), `useDismiss.test.tsx` (9), `navMenuState.test.ts` (27) | +| BR-NAV-30..36 mobile menu (group state, collapse, close on choice, Escape to hamburger, scroll, scroll lock) | `MobileNav.tsx`, `MobileNavGroup.tsx`, `navMenuState.ts` | `MobileNav.test.tsx` (18), `navSubmenu.test.tsx` (back navigation, group expanded on a shoot page) | +| BR-NAV-40..43 layout, touch targets, motion, focus ring | `NavSubmenu`, `MobileNavGroup`, `MobileNav` (`_motionReduce`) | `NavigationBar.test.tsx` and `MobileNav.test.tsx` (reduced-motion rules via `cssRulesFor`); the browser measurements are Step 17 (passed) | +| BR-NAV-50 bundle and Lighthouse | Step 16, Step 18 | Steps 16 and 18 done | + +## Test results +- Step 15 gate: lint, format:check, tsc green; `pnpm test` 106 files, 801 tests, seed 1525740974 (see Status for the coverage remark). +- New and extended unit 3 test files, with the counts from their steps: `activeOptions.test.tsx` 12; `shootNavItems.test.ts` 7 (5 properties); `navCurrent.test.ts` 20; `navMenuState.test.ts` 27 (incl. the model-based stateful run); `navigation.test.ts` 10 in total; `useDismiss.test.tsx` 9; `NavLink.test.tsx` 4; `NavigationBar.test.tsx` 27; `NavSubmenu.test.tsx` 13; `MobileNav.test.tsx` 18; `navSubmenu.test.tsx` 18; `Footer.test.tsx` 11 in total. + +## Coverage of the new lib files +- `lib/shootNavItems.ts`, `lib/navCurrent.ts`, `lib/navMenuState.ts`: 100 % (statements, branches, functions, lines), in the Step 15 run. +- `hooks/` and components are only reported, not thresholded. +- `test/navArbitraries.ts` and `test/navViewport.ts` are test code (excluded from coverage). + +## Router truth table (Step 2, router 1.170) +Verified by `activeOptions.test.tsx`: +- Trailing slash is ignored: `/soorten-fotoshoots/` is active with plain `exact` and with `exact` plus `includeSearch: false`. +- Case is not ignored: `/Soorten-Fotoshoots/Newborn` is not active in either variant. +- A query breaks plain `exact`: on `/soorten-fotoshoots?x=1` the link loses `aria-current` with `{ exact: true }` (`includeSearch` defaults to `true`). `{ exact: true, includeSearch: false }` keeps it. +- The parent is never active on a child path (`/soorten-fotoshoots/newborn`). + +Decision: every nav and footer link that gets `exact` also gets `includeSearch: false`. This deviates from the FD text (`{ exact: true }` only, BR-NAV-01, BR-NAV-04) and keeps today's behaviour for `/portfolio?shoot=…`, where the footer's Portfolio link is active. + +Consequence for the case variant: on `/soorten-fotoshoots/Newborn` the page renders (the route matches case-insensitively, unit 1 summary), no link has `aria-current`, and the parent keeps `data-section-current` through `isSectionCurrent` (case-insensitive). Accepted: `aria-current` is the router's output and the canonical URL is lowercase. + +## Bundle check (Step 16, D5 gate) +- Baseline (unit 1, Step 1): `index-D0huvRmx.js` 528.98 kB raw / 150.69 kB gzip. +- After unit 3 (Step 16): `index-Dtz2mqhH.js` 536.68 kB raw / 152.58 kB gzip. +- Delta: +7.70 kB raw, **+1.89 kB gzip** against the 2.5 kB limit. The delta may include small unit 2 changes made since Step 1. +- Shoot photos still emitted as files: 50 `.jpg` (same as Step 1), 0 `.webp`. `data:image` count in the index 1 (same as Step 1). +- The Newborn-only string ("Uit eerdere newbornshoots") is only in `newborn-*.js`; the five shoot page chunks are still separate files. +- The separate `shootTypes` chunk is gone (now in the main chunk); `dist/assets` has 119 files (121 at baseline). + +## Browser check (Step 17) — passed +110/110 checks with `puppeteer-core` from a scratchpad script outside the repo, on the combined build of units 2 and 3. Desktop at 1024, 1100 and 1280 px on `/`, `/portfolio` and a shoot page: the five items fit on one row (711 px, at 1024 px from 180 to 890 of 848 px client width), no overlap with the logo. The panel opens visible inside the viewport with a solid background; the chevron is white on the transparent header. Keyboard: Enter, Tab, Escape and Tab-out all work. Reduced motion gives 0 s transitions. On mobile (375 × 480 and 360 × 560) the expanded group scrolls to Contact. The `mx` fallback was not needed. + +## Lighthouse (Step 18) — passed +Mobile `/`, two batches of three runs per build, alternated in one session. The current build has a pooled median of 0.77 (batch medians 0.78 and 0.76); the unit-1 baseline has 0.77. That is no regression beyond the 0.02 limit. Both builds are below the absolute 0.8 budget, as master is (0.78). Accessibility, best practices and SEO are 1.0. + +## Deviations from the design +- **Exact matching:** `{ exact: true, includeSearch: false }` instead of `{ exact: true }` (router truth table above). +- **Test helper:** `src/test/navViewport.ts` (new, not in the plan's file list): a `matchMedia` stub and a style element with the `lg` display rules, because jsdom ignores `@media`. +- **Hamburger lookup:** `MobileNav` finds the hamburger by `aria-controls` (the id `mobile-nav`) for the Escape focus return, not by a test id in production code. +- **Focus request:** `linkChosen` and `routeChanged` also clear a pending `focusRequest`. +- **Pathname normalisation:** `navCurrent` treats `'//'` as `'/'` (one trailing slash removed). Harmless: the pathname is never rendered. +- **Real-app case-variant check:** moved to `navSubmenu.test.tsx` (the pre-Step-9 app still prefix-matched, so the check could not run in Step 2). + +## Open points for the orchestrator +1. **No focus trap in the mobile menu** (BR-NAV-35): not added in this unit; the menu is a full-screen overlay with Escape and the hamburger return. +2. **Desktop `NavLink` box height:** the existing desktop `NavLink` boxes are about 35 px high. Outside this unit (existing styling of the header). +3. **Case-insensitive route vs exact `aria-current`:** see the consequence above; the router matches case-insensitively but `aria-current` is exact, so `/soorten-fotoshoots/Newborn` shows the page with no `aria-current` on the links. Decision for the orchestrator together with the unit-1 open decision on `caseSensitive`. +4. Steps 17 and 18 (browser check, Lighthouse) passed, see above. + +## Security and PBT compliance (final) +| Rule | Status | Evidence | +|---|---|---| +| SECURITY-04 HTTP headers | Compliant | `config/securityHeaders.ts` untouched; no inline script or handler string; no new external resource | +| SECURITY-05 Input validation | Compliant | The pathname is only compared (`navCurrent`, never throws on hostile strings, property-tested), never rendered; link targets are typed `RoutePath`s; labels are React text | +| SECURITY-09 Hardening | Compliant | No debug output or placeholders; Step 15 greps `console.` and `debugger` in the unit 3 files: none | +| SECURITY-10 Supply chain | Compliant | No dependency added; `package.json` and `pnpm-lock.yaml` unchanged (Step 15); the browser check (Step 17) uses a transitive `puppeteer-core` only from a script outside the repo | +| SECURITY-11 Secure design | Compliant | Menu logic in a pure, invariant-tested reducer; no `dangerouslySetInnerHTML`, no new `target="_blank"` (Step 15 greps) | +| SECURITY-13 Integrity | Compliant | Inline SVG chevron, no CDN or external asset | +| SECURITY-15 Fail-safe | Compliant | Impossible events return the same state; the reducer never opens a menu that cannot exist at the width; empty `children` renders a plain link; exhaustive `switch` with a `never` check; null refs and non-Node targets ignored | +| SECURITY-01, -02, -03, -06, -07, -08, -12, -14 | N/A | Front-end navigation only: no data store, intermediary, server code, IAM, network, auth or alerting | +| PBT-01 Identification | Compliant | Properties per function in the FD, mapped to Steps 3–5 | +| PBT-02 Round trip | Compliant | `shootIdFromPath(shootNavItems(...)[i].to)` equals the shoot id (Step 3) | +| PBT-03 Invariants | Compliant | Order, labels, known routes (Step 3); exactness, section implication, no look-alikes, normalisation (Step 4); I1–I4 (Step 5) | +| PBT-04 Idempotency | Compliant | `routeChanged`, `linkChosen`, `escape`, `outside` applied twice equal once; trailing slash (Steps 4, 5) | +| PBT-05 Oracle | N/A | No reference implementation (the Step 5 model is a second check of the transition table, not an oracle for a different algorithm) | +| PBT-06 Stateful | Compliant | Model-based event sequences on `navMenuReducer`, invariants after every step (Step 5) | +| PBT-07 Generators | Compliant | `navMenuEvent(s)`, `navMenuState`, `pathname` in `test/navArbitraries.ts`; domain generators reused from `test/arbitraries.ts` (import only) | +| PBT-08 Shrinking/reproducibility | Compliant | Seed from `config/testSeed.ts`, logged each run (seed 1525740974 at Step 15); shrinking untouched | +| PBT-09 Framework | Compliant | fast-check already a dependency | +| PBT-10 Complementary | Compliant | Example tests for keyboard, focus, outside click, route change, axe, real-app `aria-current`, named apart from the PBT | diff --git a/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/business-logic-model.md b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/business-logic-model.md new file mode 100644 index 0000000..5681807 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/business-logic-model.md @@ -0,0 +1,160 @@ +# Business Logic Model — navigation-submenu (unit 3) + +> Final — answers recorded in ../../plans/navigation-submenu-fd-questions.md (2026-10-30). + +## Findings in the existing code that shape the design + +| Finding | Consequence | +|---|---| +| `NavigationBar` keeps `open` in `useState` and derives `menuOpen = open && !isDesktop`; the hamburger sets `!menuOpen`. `MobileNav` closes only on a link click and on Escape, and locks `body` overflow in an effect | Open state moves into one reducer in `NavigationBar` (see below). The body lock and the Escape listener stay where they are; Escape now also returns focus to the hamburger | +| Nothing closes the mobile menu on a route change that did not come from clicking a menu link (browser back button) | New `routeChanged` event from the router pathname closes every menu | +| `MobileNav` is a fixed box with `justifyContent="center"` and no overflow; five extra rows are cut off on short phones (risk 6) | Box gets `overflow-y: auto`, content centred with auto margins so it scrolls from the top when taller | +| `MobileNav` closes via `visibility` + `clip-path` and has no reduced-motion rule | Add `_motionReduce` transition none | +| No focus trap or focus return exists; the hamburger stays above the overlay and the overlay starts below the header | Not a dialog, no trap added (BR-NAV-35); only Escape focus return is added | +| TanStack `Link` uses prefix matching for `aria-current` (risk 1) | `activeOptions={{ exact: true }}` on the parent, the submenu links and the footer links; the visual parent mark comes from `isSectionCurrent` | +| The header is transparent with white text on `/` from `lg` until scrolled 150 px (`overlay`) | The toggle takes `currentColor`; the panel sets its own solid colours so it is never white-on-photo | +| Desktop header `lg` height 92 px, 68 px after scroll; `NavLink` has `mx=4`, eyebrow text 0.72rem, tracking 0.22em, weight 300 | Fit calculation in frontend-components.md | + +## Pure units (PBT targets) + +| Function | Signature | Rule | +|---|---|---| +| `shootNavItems` (`lib/shootNavItems.ts`) | `(shoots: readonly ShootType[]) => NavItem[]` | One item per shoot in input order, `label = name`, `to = shootPagePath(id)` | +| `isItemCurrent` (`lib/navCurrent.ts`) | `(item: NavItem, pathname: string) => boolean` | Normalised equality (BR-NAV-04) | +| `isSectionCurrent` (`lib/navCurrent.ts`) | `(item: NavItem, pathname: string) => boolean` | Exact for the item, or for any child | +| `navMenuReducer` (`lib/navMenuState.ts`, new file owned by unit 3) | `(state: NavMenuState, event: NavMenuEvent) => NavMenuState` | Transition table below | +| `initialNavMenuState` | `NavMenuState` | All closed | + +The reducer is the one addition to the application design's file list: `src/lib/navMenuState.ts` + `navMenuState.test.ts`. No other unit touches `lib/` names starting with `nav`. + +## Transition table of `navMenuReducer` + +| Event | Condition | Result | +|---|---|---| +| `viewport(d)` | always | `isDesktop = d`; if `d`: `menuOpen = groupOpen = false`; if `!d`: `submenuOpen = false`; `focusRequest` cleared if it no longer fits (I4) | +| `toggleMenu(inSection)` | `!isDesktop` | flip `menuOpen`; when it becomes open `groupOpen = inSection`; when it becomes closed `groupOpen = false` | +| `toggleGroup` | `menuOpen` | flip `groupOpen` | +| `toggleSubmenu` | `isDesktop` | flip `submenuOpen` | +| `escape(focusInside)` | `menuOpen` | close menu and group; `focusRequest = focusInside ? 'menuToggle' : null` | +| `escape(focusInside)` | `submenuOpen` | close submenu; `focusRequest = focusInside ? 'submenuToggle' : null` | +| `outside`, `focusLeave` | `submenuOpen` | close submenu, no focus request | +| `linkChosen`, `routeChanged` | always | `menuOpen = groupOpen = submenuOpen = false`, no focus request | +| `focusHandled` | always | `focusRequest = null` | +| any event | condition not met | state unchanged (same object returned) | + +## State diagram: desktop submenu + +```mermaid +stateDiagram-v2 + [*] --> SubClosed + SubClosed --> SubOpen : toggle click, Enter or Space + SubOpen --> SubClosed : toggle click, focus stays + SubOpen --> SubClosed : Escape, focus to toggle if inside + SubOpen --> SubClosed : pointer down outside + SubOpen --> SubClosed : focus leaves the group + SubOpen --> SubClosed : link chosen + SubOpen --> SubClosed : route changed + SubOpen --> SubClosed : viewport below lg + classDef closed fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000 + classDef open fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000 + class SubClosed closed + class SubOpen open +``` + +Text alternative: the desktop dropdown is closed or open; a toggle activation opens it, and the toggle, Escape, an outside click, focus leaving, a link choice, a route change or a narrower viewport close it. + +## State diagram: mobile menu and group + +```mermaid +stateDiagram-v2 + [*] --> MenuClosed + MenuClosed --> GroupCollapsed : hamburger, page not in section + MenuClosed --> GroupExpanded : hamburger, page in section + GroupCollapsed --> GroupExpanded : group chevron + GroupExpanded --> GroupCollapsed : group chevron + GroupCollapsed --> MenuClosed : hamburger, Escape, link, route change, viewport lg + GroupExpanded --> MenuClosed : hamburger, Escape, link, route change, viewport lg + classDef closed fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000 + classDef open fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000 + class MenuClosed closed + class GroupCollapsed,GroupExpanded open +``` + +Text alternative: the mobile menu opens with its shoot list collapsed or, on a page of that section, expanded; the chevron flips the list; the hamburger, Escape, a link, a route change or a wider viewport closes the whole menu. + +## Flow: opening the desktop submenu from the keyboard + +```mermaid +graph TD + Start["Tab reaches the toggle"] --> Press["Enter or Space"] + Press --> Open["submenuOpen is true, panel visible"] + Open --> Tab["Tab moves into the panel links"] + Tab --> Choice{"what next"} + Choice -->|"Enter on a link"| Nav["navigate, menus close, focus to main"] + Choice -->|"Escape"| Back["panel closes, focus on toggle"] + Choice -->|"Tab past last link"| Leave["focus leaves group, panel closes"] + classDef step fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + classDef decision fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef result fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + class Start,Press,Open,Tab step; + class Choice decision; + class Nav,Back,Leave result; +``` + +Text alternative: Enter or Space on the toggle opens the panel, Tab enters its links, and then Enter navigates, Escape returns to the toggle, or tabbing past the last link closes the panel. + +## Sequence: component interplay on a click and a route change + +```mermaid +sequenceDiagram + box rgba(246,224,94,0.4) Visitor + participant V as Visitor + end + box rgba(99,179,237,0.4) Components + participant Sub as NavSubmenu + participant Bar as NavigationBar + participant Dis as useDismiss + end + box rgba(154,230,180,0.4) Logic + participant Red as navMenuReducer + participant Rt as Router + end + V->>Sub: click toggle + Sub->>Bar: dispatch toggleSubmenu + Bar->>Red: reduce state with toggleSubmenu + Red-->>Bar: submenuOpen true + Bar->>Dis: active is true + V->>Sub: click a shoot link + Sub->>Bar: dispatch linkChosen + Sub->>Rt: navigate to the shoot page + Rt-->>Bar: pathname changed + Bar->>Red: reduce state with routeChanged + Red-->>Bar: everything closed + Bar->>Dis: active is false +``` + +Text alternative: the visitor's click on the toggle is reduced to an open state that activates useDismiss; choosing a link dispatches linkChosen, the router navigates, and the pathname change dispatches routeChanged, closing everything. + +## Where the pieces live + +- `NavigationBar` owns the reducer (`useReducer`) because the hamburger, the submenu, the mobile group and the route listener must agree (I1-I3). It passes `open`, `onToggle`, `onClose` style props down; there is no context. +- Effects in `NavigationBar`: `viewport` on `isDesktop` change; `routeChanged` when `useRouterState` pathname changes (skipped on first render); focus effect that reads `focusRequest`, focuses the matching toggle by ref and dispatches `focusHandled`. +- `useDismiss(ref, active, onDismiss)` only listens (document `keydown` Escape, `pointerdown` outside `ref`); it adds the listeners while `active`. The reducer decides what dismissal means. `focusLeave` comes from an `onBlur` handler on the group wrapper checking `relatedTarget`. + +## PBT properties (PBT-01, PBT-03, PBT-04, PBT-06) + +| Subject | Property | Kind | +|---|---|---| +| `shootNavItems` | length = input length; order preserved; label = name; `shootIdFromPath(to) = id`; every `to` is a known route | invariant, round trip | +| `isItemCurrent` | true iff normalised paths equal; unchanged by one added trailing slash or by letter case; false for any path outside the item | invariant | +| `isSectionCurrent` | implied by `isItemCurrent`; implied by any child exact; false for paths unrelated to the item and its children (including prefix look-alikes such as `/soorten-fotoshoots-extra`) | invariant | +| `mainNav` (all pathnames) | at most one item or child is exact at a time | invariant | +| `navMenuReducer` | after every event of a random sequence I1-I4 hold | stateful (model-based) | +| `navMenuReducer` | `routeChanged` and `linkChosen` end in the all-closed state from any state; twice equals once | invariant, idempotency | +| `navMenuReducer` | `outside` and `focusLeave` never change `menuOpen`, and never set `focusRequest` | invariant | +| `navMenuReducer` | `escape` twice equals once (apart from `focusRequest` already set) | idempotency | +| `navMenuReducer` | `toggleSubmenu` twice on desktop returns the original state | invariant | +| `navMenuReducer` | `viewport(true)` after any sequence leaves no mobile state open; `viewport(false)` leaves no submenu open | invariant | +| `navMenuReducer` | `toggleMenu(inSection)` from closed opens with `groupOpen = inSection` | example-backed property | + +Example-based (PBT-10): keyboard and focus behaviour, outside click, route change in the real router (`navSubmenu.test.tsx`), axe, aria-current on the shoot pages for nav and footer. diff --git a/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/business-rules.md b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/business-rules.md new file mode 100644 index 0000000..c4f82a9 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/business-rules.md @@ -0,0 +1,132 @@ +# Business Rules — navigation-submenu (unit 3) + +> Final — answers recorded in ../../plans/navigation-submenu-fd-questions.md (2026-10-30) (Q1 A, Q2 A, Q3 A, Q4 A, Q5 A, Q6 A; the reducer of Q6 is approved). Rules that depend on an answer are marked `[Qn]`. + +Rule IDs: `BR-NAV-xx`. Sources: FR-ST-10, NFR-ST-01, NFR-ST-03, D4, D5, D12. + +## Current state (D4) + +| ID | Rule | +|---|---| +| BR-NAV-01 | `aria-current="page"` is set only on a link whose target equals the current page. TanStack's default (prefix match) is switched off for every nav link that has children (`activeOptions={{ exact: true }}`), for the submenu links, and for all footer links. | +| BR-NAV-02 | While a shoot page is open, the parent "Soorten fotoshoots" has no `aria-current` but shows the same underline through `sectionCurrent` (`isSectionCurrent`). On the overview itself it has both. | +| BR-NAV-03 | The shoot link in the submenu (desktop panel and mobile sub-list) that matches the current page has `aria-current="page"` and the current styling (accent colour). | +| BR-NAV-04 | Path comparison ignores one trailing slash and letter case (router parity). Query and hash are ignored. | +| BR-NAV-05 | The breadcrumb (unit 2) also uses exact matching; this unit only guarantees nav and footer. | + +## Content of the menu + +| ID | Rule | +|---|---| +| BR-NAV-10 | The five children come from `shootNavItems(shootTypes)`: same order, label = shoot `name`, `to = shootPagePath(id)`. Nothing is typed twice, so a sixth shoot type appears automatically. | +| BR-NAV-11 | Only one nesting level. The submenu is a plain list of links (disclosure navigation), never `role="menu"`. | +| BR-NAV-12 | No "overview" duplicate inside the panel: the parent link already goes there. | + +## Desktop submenu (from `lg`) + +| ID | Rule | +|---|---| +| BR-NAV-20 | The parent stays a link. A separate toggle button follows it: `aria-expanded`, `aria-controls`, name "Submenu Soorten fotoshoots". | +| BR-NAV-21 | `[Q1]` Opens only by click/tap, Enter or Space on the toggle. No hover opening. | +| BR-NAV-22 | Clicking the toggle while open closes it; focus stays on the toggle. | +| BR-NAV-23 | Escape closes. If focus is inside the group (toggle or a panel link) it returns to the toggle; otherwise focus is not moved. | +| BR-NAV-24 | A pointer down outside the group closes it, without moving focus. | +| BR-NAV-25 | `[Q4]` Focus moving to an element outside the group (Tab, Shift+Tab) closes it. A focusout without a related target (window blur, click on a non-focusable area) is ignored; the outside pointer rule covers clicks. | +| BR-NAV-26 | Choosing a link, any route change (also back/forward) and a viewport change below `lg` close it. After a link choice focus is not restored to the toggle: `useRouteFocus` moves it to `main`. | +| BR-NAV-27 | Keys: Enter/Space (native button behaviour), Escape, Tab. Arrow keys are **not** bound: this is disclosure navigation, not a menu (NFR-ST-01); Tab walks the links in DOM order. | +| BR-NAV-28 | Closed panel links are not focusable and not read (`visibility: hidden`), while the panel stays in the DOM so `aria-controls` is always valid. | +| BR-NAV-29 | The panel is solid (`bg`, `fg`) at all times, also over the transparent header of the home hero. | + +## Mobile menu (below `lg`) + +| ID | Rule | +|---|---| +| BR-NAV-30 | The parent row is the link to the overview plus a chevron toggle (same name and `aria-expanded` pattern). Tapping the label navigates and closes the whole menu. | +| BR-NAV-31 | `[Q3]` When the menu opens, the sub-list starts expanded iff `isSectionCurrent(parent, pathname)`, otherwise collapsed. Toggling afterwards is free. | +| BR-NAV-32 | Choosing any link closes the whole menu. Route changes (including the browser back button, which today leaves the menu open) close it too. | +| BR-NAV-33 | Escape closes the menu and returns focus to the hamburger button when focus is inside the menu or on the hamburger. | +| BR-NAV-34 | The menu scrolls when its content is taller than the visible height; content is centred when shorter. The page behind stays locked (`body` overflow) as today. | +| BR-NAV-35 | No focus trap is added: the mobile menu is a disclosure, not a modal dialog, and the existing behaviour (Tab can leave the menu) is unchanged. Recorded as a follow-up in the risks, not a regression. | +| BR-NAV-36 | A collapsed sub-list is not focusable and not read. | + +## Layout, touch and motion + +| ID | Rule | +|---|---| +| BR-NAV-40 | Toggle buttons are at least 44 x 44 px; each panel link and each mobile sub-list link is at least 44 px high. | +| BR-NAV-41 | At 1024 px the five items plus the toggle must fit on one line without wrapping or overlapping the logo (see frontend-components.md for the calculation and the check). | +| BR-NAV-42 | `[Q5]` Motion: panel fade and 6 px slide in 0.3 s, mobile expand over 0.3 s, chevron rotation. With `prefers-reduced-motion: reduce` there is no transition and no rotation (state changes instantly). The mobile menu's existing clip-path reveal gets the same reduced-motion rule. | +| BR-NAV-43 | Visible focus ring everywhere. On the transparent header the toggle's ring is white (`--focus-ring-color`), as `iconControl` does on photos. | + +## Performance + +| ID | Rule | +|---|---| +| BR-NAV-50 | D5 gate: the main bundle's gzip size is measured on `/` before and after; the increase is expected at about 1.7 KB (`shootTypes.ts` gzips to 1.76 KB) and must stay at or below 2.5 KB. Mobile Lighthouse performance on `/` must not fall below its current 0.8. If either is exceeded, Code Generation stops and reports (the D5 alternative needs a user decision). | + +## Decision flowchart: what happens on an event + +```mermaid +graph TD + Ev["Event arrives"] --> IsView{"viewport event"} + IsView -->|"yes"| ViewAct["close what does not exist at this width"] + IsView -->|"no"| IsLink{"linkChosen or routeChanged"} + IsLink -->|"yes"| CloseAll["close menu, group and submenu, no focus move"] + IsLink -->|"no"| IsEsc{"escape"} + IsEsc -->|"yes"| WhichOpen{"which is open"} + WhichOpen -->|"mobile menu"| MenuEsc["close menu, focus hamburger if focus inside"] + WhichOpen -->|"submenu"| SubEsc["close submenu, focus toggle if focus inside"] + WhichOpen -->|"none"| Noop["no change"] + IsEsc -->|"no"| IsOut{"outside or focusLeave"} + IsOut -->|"yes"| SubClose["close submenu only, no focus move"] + IsOut -->|"no"| IsToggle{"toggle event"} + IsToggle -->|"toggleSubmenu"| DeskOnly{"desktop"} + DeskOnly -->|"yes"| FlipSub["flip submenuOpen"] + DeskOnly -->|"no"| Noop + IsToggle -->|"toggleMenu"| MobOnly{"mobile"} + MobOnly -->|"yes"| FlipMenu["flip menuOpen, on open groupOpen = inSection"] + MobOnly -->|"no"| Noop + IsToggle -->|"toggleGroup"| GroupOk{"menu open"} + GroupOk -->|"yes"| FlipGroup["flip groupOpen"] + GroupOk -->|"no"| Noop + classDef decision fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef action fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + classDef start fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + classDef none fill:#e9d5ff,stroke:#6b21a8,stroke-width:1px,color:#000; + class Ev start; + class IsView,IsLink,IsEsc,WhichOpen,IsOut,IsToggle,DeskOnly,MobOnly,GroupOk decision; + class ViewAct,CloseAll,MenuEsc,SubEsc,SubClose,FlipSub,FlipMenu,FlipGroup action; + class Noop none; +``` + +Text alternative: a decision flowchart that routes each menu event to closing everything (link or route change), closing the active menu on Escape, closing only the submenu on outside or focus leave, or flipping the matching toggle if it exists at the current width. + +## Security Baseline compliance summary (extension enabled) + +| Rule | Status | Rationale | +|---|---|---| +| SECURITY-01, 02, 03, 06, 07, 08, 12, 14 | N/A | Front-end navigation only: no data store, intermediary, server code, IAM, network, access control, authentication or alerting | +| SECURITY-04 HTTP headers | Compliant | No header or CSP change; no inline script or handler; Chakra/emotion styles as on every other component | +| SECURITY-05 Input validation | Compliant | No user input. The pathname is only compared, never rendered; link targets are typed `RoutePath`s from code, labels are rendered as React text | +| SECURITY-09 Hardening | Compliant | No debug output or placeholder content; the nav shows only the shoot names | +| SECURITY-10 Supply chain | Compliant | No new dependency; chevron as inline SVG; no Chakra `Menu`/`Popover` added | +| SECURITY-11 Secure design | Compliant | Menu logic is a pure reducer with invariants; no `dangerouslySetInnerHTML`; no new `target="_blank"` links | +| SECURITY-13 Integrity | Compliant | No CDN, no external resource | +| SECURITY-15 Fail-safe | Compliant | An impossible event for the current width is ignored; an empty `children` list renders a plain link; the reducer never opens a menu that cannot exist at the current width | + +No blocking findings. + +## Property-Based Testing compliance summary (extension enabled, full) + +| Rule | Status | Rationale | +|---|---|---| +| PBT-01 Identification | Compliant | Properties are listed per function in [business-logic-model.md](business-logic-model.md) (`shootNavItems`, `isItemCurrent`, `isSectionCurrent`, `navMenuReducer`) | +| PBT-02 Round trip | Compliant | `shootNavItems` children map back to shoot ids via `shootIdFromPath` | +| PBT-03 Invariants | Compliant | Order, labels, known routes; exactness; section implication; no unrelated paths; normalisation | +| PBT-04 Idempotency | Compliant | `routeChanged`, `linkChosen`, `escape` and `outside` applied twice equal once; a trailing slash does not change `isItemCurrent` | +| PBT-05 Oracle | N/A | No reference implementation | +| PBT-06 Stateful | Compliant (was N/A in the application design) | A reducer was introduced, so model-based sequence tests apply: random event sequences with invariants I1-I4 checked after every step | +| PBT-07 Generators | Planned | `navEvent` and `pathname` generators (shoot paths, trailing slash, case variants, hostile strings) appended to `src/test/arbitraries.ts` (append only; unit 2 also appends, kept sequential by the orchestrator) | +| PBT-08 Shrinking | Compliant | fast-check shrinks event sequences; seed logged by `config/testSeed.ts` | +| PBT-09 Framework | Compliant | fast-check already configured | +| PBT-10 Complementary | Compliant | Example tests for keyboard, focus, outside click, route change in the real app, and axe | diff --git a/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/domain-entities.md b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/domain-entities.md new file mode 100644 index 0000000..e3517d8 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/domain-entities.md @@ -0,0 +1,94 @@ +# Domain Entities — navigation-submenu (unit 3) + +> Final — answers recorded in ../../plans/navigation-submenu-fd-questions.md (2026-10-30) (Q1 click only, Q2 caps panel, Q3 collapsed unless in section, Q4 close on focus leave, Q5 short animation). + +Inputs: FR-ST-10, NFR-ST-01, application design D4, D5, D12 and the real code (`navigation.ts`, `NavigationBar`, `MobileNav`). + +## Entity relationships + +```mermaid +graph TD + MainNav["mainNav"] -->|"contains"| NavItem["NavItem"] + NavItem -->|"has optional"| Children["children NavItem list"] + ShootTypes["shootTypes"] -->|"mapped by shootNavItems to"| Children + NavItem -->|"to is a"| RoutePath["RoutePath"] + Pathname["current pathname"] -->|"compared with"| NavItem + Pathname -->|"gives"| Current["CurrentState"] + MenuState["NavMenuState"] -->|"changed by"| MenuEvent["NavMenuEvent"] + MenuState -->|"asks for"| FocusRequest["FocusRequest"] + Current -->|"drives"| AriaCurrent["aria-current on exact link"] + Current -->|"drives"| SectionMark["sectionCurrent underline on parent"] + Current -->|"seeds"| GroupDefault["mobile group default"] + classDef source fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + classDef entity fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + classDef state fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef output fill:#e9d5ff,stroke:#6b21a8,stroke-width:1px,color:#000; + class ShootTypes,RoutePath source; + class MainNav,NavItem,Children,Pathname entity; + class MenuState,MenuEvent,FocusRequest,Current state; + class AriaCurrent,SectionMark,GroupDefault output; +``` + +Text alternative: mainNav holds NavItems whose optional children come from shootTypes via shootNavItems; the current pathname yields a CurrentState that drives aria-current, the parent underline and the mobile group default, while NavMenuEvents change the NavMenuState, which can ask for focus. + +## NavItem (changed, `navigation.ts`) + +| Field | Type | Required | Description | +|---|---|---|---| +| `to` | `RoutePath` | yes | Route the item links to; a typo is a type error | +| `label` | `string` | yes | Visible text and link name | +| `children` | `readonly NavItem[]` | no | Sub-pages. Only one level is supported: a child never has children (`isNavParent` narrows on `children?.length`). An empty array counts as no children | + +- `mainNav`: the item `/soorten-fotoshoots` gets `children = shootNavItems(shootTypes)` at module load; all other items and all of `footerNav` have no children. +- Child order = `shootTypes` order. Child `label` = shoot `name` (for the fifth shoot that is "Portretten", the name, not the id). Child `to` = `shootPagePath(id)`. +- The parent is both a destination (overview) and a group: the link and the toggle are two controls for one item. + +## CurrentState (derived, never stored) + +| Name | Definition | Used for | +|---|---|---| +| `isItemCurrent(item, pathname)` | normalised pathname equals normalised `item.to` | `aria-current="page"` (via router `exact`) and tests | +| `isSectionCurrent(item, pathname)` | `isItemCurrent(item)` or any child is exact | `sectionCurrent` underline on the parent, mobile group default | + +Normalisation: remove one trailing slash (except for `/`), compare case-insensitively (the router matches case-insensitively, see the code summary of unit 1, so the underline must follow the page the router actually renders). Query and hash are not part of a pathname. + +## NavMenuState (new, `lib/navMenuState.ts`) + +| Field | Type | Description | +|---|---|---| +| `isDesktop` | `boolean` | Viewport is at or above `lg` (1024 px) | +| `menuOpen` | `boolean` | Mobile full-screen menu is open (only possible when `!isDesktop`) | +| `groupOpen` | `boolean` | Mobile "Soorten fotoshoots" sub-list is expanded (only possible when `menuOpen`) | +| `submenuOpen` | `boolean` | Desktop dropdown panel is open (only possible when `isDesktop`) | +| `focusRequest` | `'menuToggle' \| 'submenuToggle' \| null` | Set by the reducer when focus must move; cleared by the `focusHandled` event | + +Invariants (checked by PBT-06 in [business-logic-model.md](business-logic-model.md)): +- **I1** `submenuOpen` implies `isDesktop`. +- **I2** `menuOpen` implies `!isDesktop`. +- **I3** `groupOpen` implies `menuOpen`. +- **I4** `focusRequest === 'menuToggle'` implies `!isDesktop`; `'submenuToggle'` implies `isDesktop`. + +Initial state: everything `false`/`null`, `isDesktop` from the first `viewport` event. + +## NavMenuEvent (new) + +| Event | Payload | Raised by | +|---|---|---| +| `viewport` | `isDesktop` | `useBreakpointValue` effect in `NavigationBar` | +| `toggleMenu` | `inSection: boolean` | Hamburger button (below `lg`) | +| `toggleGroup` | none | Chevron button in `MobileNavGroup` | +| `toggleSubmenu` | none | Chevron button in `NavSubmenu` (from `lg`) | +| `escape` | `focusInside: boolean` | `useDismiss` (document keydown) | +| `outside` | none | `useDismiss` (pointer down outside the submenu) | +| `focusLeave` | none | `NavSubmenu` focusout to an element outside it | +| `linkChosen` | none | Click on any link in a menu | +| `routeChanged` | none | Effect on the router pathname | +| `focusHandled` | none | Effect after moving focus | + +## Constants + +| Name | Value | Where | +|---|---|---| +| Submenu toggle accessible name | `Submenu ${item.label}` ("Submenu Soorten fotoshoots"), constant; the state is carried by `aria-expanded` | `NavSubmenu`, `MobileNavGroup` | +| Panel id / group id | `submenu-${slug}` / `mobile-group-${slug}`, `slug = item.to.slice(1)` | `aria-controls` | +| Touch target minimum | 44 px | NFR-ST-01 | diff --git a/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/frontend-components.md b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/frontend-components.md new file mode 100644 index 0000000..7ec2a0e --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/navigation-submenu/functional-design/frontend-components.md @@ -0,0 +1,174 @@ +# Frontend Components — navigation-submenu (unit 3) + +> Final — answers recorded in ../../plans/navigation-submenu-fd-questions.md (2026-10-30) (Q1 click only, Q2 caps panel, Q3 collapsed unless in section, Q4 close on focus leave, Q5 short animation). + +No backend endpoints are used. No forms, so no form validation rules. + +## Component hierarchy + +```mermaid +graph TD + Bar["NavigationBar (owns reducer)"] --> Logo["Logo RouterLink"] + Bar --> DeskNav["nav Hoofdmenu, from lg"] + Bar --> Burger["Hamburger button, below lg"] + Bar --> Mobile["MobileNav"] + DeskNav --> NavLinkPlain["NavLink for items without children"] + DeskNav --> Submenu["NavSubmenu"] + Submenu --> ParentLink["NavLink with sectionCurrent"] + Submenu --> Toggle["Toggle button with ChevronIcon"] + Submenu --> Panel["Panel with list of PanelLink"] + Submenu --> Dismiss["useDismiss"] + Mobile --> MobPlain["RouterLink for items without children"] + Mobile --> Group["MobileNavGroup"] + Group --> GParent["Parent RouterLink"] + Group --> GToggle["Chevron button with ChevronIcon"] + Group --> GList["Sub-list of RouterLinks"] + Bar --> Reducer["navMenuReducer"] + Submenu --> Current["navCurrent"] + Group --> Current + Footer["Footer"] --> FooterLinks["RouterLink exact"] + Nav["navigation.ts mainNav"] --> ShootNav["shootNavItems"] + Bar --> Nav + classDef root fill:#4CAF50,stroke:#2e7d32,stroke-width:2px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef hook fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + classDef logic fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + class Bar root; + class Logo,DeskNav,Burger,Mobile,NavLinkPlain,Submenu,ParentLink,Toggle,Panel,MobPlain,Group,GParent,GToggle,GList,Footer,FooterLinks ui; + class Dismiss hook; + class Reducer,Current,Nav,ShootNav logic; +``` + +Text alternative: NavigationBar owns the menu reducer and renders the logo, the desktop nav with plain NavLinks and NavSubmenu (parent link, toggle, panel, useDismiss), the hamburger and MobileNav with plain links and MobileNavGroup; the Footer only gets exact links; mainNav is built from shootNavItems. + +## Components, props and state + +### `navigation.ts` (changed) +`NavItem` gets `children?: readonly NavItem[]`. `mainNav[3].children = shootNavItems(shootTypes)`. Export a type guard `hasChildren(item): item is NavItem & { children: readonly NavItem[] }` (non-empty). + +### `NavigationBar` (changed) +- State: `useReducer(navMenuReducer, initialNavMenuState)`. `isDesktop` from the existing `useBreakpointValue`, pushed with `viewport`. +- `pathname` via `useRouterState` (the existing `isHome` selector is extended to return the pathname; `isHome = pathname === '/'`). +- Passes to `NavSubmenu`: `open`, `onToggle`, `onEscape/onOutside/onFocusLeave` via one `dispatch`, `toggleRef`, `transparent` (= `!isSolid`, for the white focus ring), `pathname`. +- Hamburger: `onClick -> dispatch({ type: 'toggleMenu', inSection })`, `aria-expanded={state.menuOpen}`, ref for focus return. `inSection = isSectionCurrent(parentItem, pathname)`. +- Keeps `data-testid="nav-menu-toggle"` and the accessible names "Menu openen"/"Menu sluiten". +- Desktop list: `chakra.li` per item; `hasChildren(item) ? : `. + +### `NavSubmenu` (new) +```ts +type NavSubmenuProps = { + item: NavItem & { children: readonly NavItem[] }; + id: string; // panel id, 'submenu-soorten-fotoshoots' + open: boolean; + pathname: string; + transparent: boolean; + toggleRef: RefObject; + dispatch: (event: NavMenuEvent) => void; +}; +``` +- Wrapper `li` content: `Box` (`position: relative; display: flex; align-items: center`) with `ref` for `useDismiss` and `onBlur` (focus leave). +- Parent: `NavLink to={item.to} activeOptions={{ exact: true }} sectionCurrent={isSectionCurrent(item, pathname)}`; its right margin is 0 so the toggle sits right next to it. +- Toggle: `chakra.button type="button"`, 44 x 44 px, `aria-expanded`, `aria-controls={id}`, `aria-label="Submenu Soorten fotoshoots"`, `color: currentColor` (white over the hero, ink after), `ChevronIcon` 12 px, rotates 180 degrees when open. Focus ring `--focus-ring-color: white` while `transparent`. +- Panel (`div#id`): `position: absolute; top: calc(100% + 0.75rem); left: 1rem` (aligned with the parent text), `min-width: 15rem`, `bg="bg" color="fg"`, 1 px `line` border, `shadow="panel"`, `zIndex` inside the header's stacking context. It contains `ul` with `li > RouterLink` (`PanelLink`): `textStyle="eyebrow"`, `color="fg"` (explicit, so it never inherits header white), `min-height 44px`, `display flex align-items center`, `px 5`, hover `bg="paper.alt"`, `_currentPage={{ color: 'accent.deep' }}` with a 2 px accent bar on the left, `activeOptions={{ exact: true }}`, `onClick -> dispatch({ type: 'linkChosen' })`. +- Closed: `visibility: hidden; opacity: 0; transform: translateY(-6px); pointer-events: none`. Open: visible, opacity 1, no translate. Transition `opacity, transform, visibility` over 0.3 s `smooth`, `_motionReduce: { transition: 'none' }` `[Q5]`. +- `useDismiss(ref, open, reason => dispatch(reason === 'escape' ? { type: 'escape', focusInside: ref.current.contains(document.activeElement) } : { type: 'outside' }))`. +- `onBlur`: if `event.relatedTarget` is a Node and not inside the wrapper, `dispatch({ type: 'focusLeave' })` `[Q4]`. + +### `MobileNav` (changed) +```ts +type MobileNavProps = { id: string; open: boolean; groupOpen: boolean; pathname: string; dispatch: (e: NavMenuEvent) => void }; +``` +- Outer box: as today plus `overflowY="auto"`, `overscrollBehavior="contain"`; `justifyContent` no longer `center`. An inner `Box` with `marginBlock="auto"` centres short content and lets tall content scroll from the top (a centred flex child would cut off the top). Bottom padding stays so the last link clears the browser bar. +- Existing effect keeps the body scroll lock; the keydown listener now dispatches `{ type: 'escape', focusInside }`; the `onClose` prop is replaced by `dispatch`. +- `_motionReduce: { transition: 'none' }` on the clip-path reveal `[Q5]`. +- Plain items as today (`onClick -> linkChosen`); items with children render `MobileNavGroup`. + +### `MobileNavGroup` (new) +```ts +type MobileNavGroupProps = { + item: NavItem & { children: readonly NavItem[] }; + id: string; // 'mobile-group-soorten-fotoshoots' + open: boolean; + pathname: string; + dispatch: (e: NavMenuEvent) => void; +}; +``` +- Row: `Flex` with the parent `RouterLink` (heading font 1.9rem, `activeOptions exact`, accent colour when `isSectionCurrent`) and a chevron `button` of 44 x 44 px (`aria-expanded`, `aria-controls`, `aria-label="Submenu Soorten fotoshoots"`). +- Sub-list wrapper: grid with `gridTemplateRows: open ? '1fr' : '0fr'` and inner `overflow: hidden`, `visibility: open ? visible : hidden` with the transition delayed on close so it is hidden only after collapsing. `_motionReduce` none. `ul` indented 1.25rem, links heading font 1.4rem, `min-height 44px`, `color="ink"`, `_currentPage={{ color: 'accent.deep' }}` (accent.deep, because 1.4rem is not "large text" and `accent` is below 4.5:1). +- Each sub-link: `activeOptions exact`, `onClick -> linkChosen`. + +### `NavLink` (changed, additive) +`sectionCurrent?: boolean` sets `data-section-current` and the existing underline selector gains `&[data-section-current]::after`. Optional, existing callers unchanged. `aria-current="page"` stays exclusively the router's output. + +### `ChevronIcon` (new) +Inline SVG, 12 x 12, `aria-hidden`, `focusable="false"`, `stroke: currentColor`. Rotates via a `data-open` attribute on its button; `_motionReduce` removes the rotation transition (rotation state itself still shows). + +### `useDismiss` (new, `hooks/useDismiss.ts`) +As specified in the application design (`(ref, active, onDismiss(reason))`). While `active`: `document` `keydown` for `Escape` and `pointerdown` whose target is not inside `ref`. Cleans up on `active` false and unmount. Contains no menu logic. + +### `Footer` (changed, one prop) +In the `footerNav` map, `RouterLink` gets `activeOptions={{ exact: true }}`. No visible change; on a shoot page the footer's "Soorten fotoshoots" has no `aria-current` (BR-NAV-01). + +### `lib/navMenuState.ts`, `lib/navCurrent.ts`, `lib/shootNavItems.ts` +Pure modules as specified in [business-logic-model.md](business-logic-model.md). + +## User interaction flows + +| Flow | Behaviour | +|---|---| +| Desktop mouse | Click chevron: panel opens; click a shoot: page opens and panel closes; click elsewhere: panel closes. Hover does nothing extra `[Q1]` | +| Desktop keyboard | Tab to the parent link, Tab to the toggle, Enter or Space opens, Tab walks the five links, Escape returns to the toggle, tabbing out closes `[Q4]` | +| Touch tablet at 1024 px and up | Same as mouse; toggle and panel links are 44 px | +| Mobile | Hamburger opens the menu (sub-list open only on a shoot page or the overview), chevron flips the list, any link closes the menu, Escape or the hamburger closes it and focus returns to the hamburger | +| Browser back or forward | Route change closes every menu | +| Resize across 1024 px | The menu that no longer exists is closed | + +## Layout at 1024 px (risk 7) + +Estimate (Jost 300 uppercase about 7.1 px + 2.5 px tracking per character, about 9.6 px, eyebrow 0.72rem): + +| Part | Width | +|---|---| +| Labels: HOME, OVER MIJ, PORTFOLIO, SOORTEN FOTOSHOOTS, CONTACT (4, 8, 9, 18, 7 characters) | about 430 px | +| Link margins (`mx=4`, 5 links) | 160 px | +| Toggle (44 px) minus the parent's removed right margin (16 px) | 28 px | +| Gaps (`gap=6`, 4 gaps) | 96 px | +| **Total** | **about 715 px** | +| Available: 1024 minus 2 x 41 px gutter minus logo 46 px minus 2 x 24 px flex gaps | about 848 px | + +About 130 px of slack. This is an estimate: the Code Generation unit measures the real widths in a browser at 1024 and 1100 px (the `run` skill or Lighthouse viewport) and records them in the code summary. If the nav does not fit, the fallback (no user decision needed) is to reduce the link margin from `mx=4` to `mx=3` at `lg` only; wrapping is not allowed (BR-NAV-41). + +## Transparent header (home hero, from `lg`) + +Over the hero the header is transparent with white text. The parent link and the chevron use `currentColor`, so both are white. The panel always has its own solid `bg` and `fg` (and an explicit link colour), so it is readable on the photo. The toggle's focus ring is white while transparent; the parent link keeps today's behaviour. After scrolling 150 px the header becomes solid and the ring returns to the theme colour. The panel is not tied to the header colour state, so crossing the 150 px threshold while it is open does not change it. + +## Bundle size and Lighthouse (D5, NFR-ST-03) + +`navigation.ts` imports `shootTypes` (which imports ten shoot photos as URLs), so the shoot type data moves into the main bundle. Measure in Code Generation: +1. Build before the unit 3 changes: record the gzip size of the main entry chunk (`pnpm build`, file listing). +2. Build after: record again. Expect about +1.7 KB (the file alone gzips to 1.76 KB); limit +2.5 KB (BR-NAV-50). Also check that the ten images are still emitted as files and not inlined (Vite inlines assets below `assetsInlineLimit`; the detail photos are 480 x 480 JPEGs). +3. Run Lighthouse mobile on `/` three times; the median performance score must stay at or above 0.8 (current exception). Record the numbers in the code summary. +4. If a limit is exceeded, stop and report; the D5 alternative (a small `{ id, name }` list) changes the content model and needs the user. + +## Accessibility summary (NFR-ST-01) + +- Disclosure navigation: `button` with `aria-expanded` and `aria-controls`; plain `ul` of links; no `role="menu"`; no Chakra `Menu`. +- Toggle name is constant ("Submenu Soorten fotoshoots"); state is conveyed by `aria-expanded`. +- Focus ring on every control (theme `*:focus-visible`); white on the transparent header. +- Touch targets 44 px for toggles and submenu links. Observation outside this unit's scope: the existing desktop `NavLink` boxes are about 35 px high (py 2 around an 11.5 px line); not changed here, listed in the risks. +- Contrast: `accent.deep` on paper for current sub-items (at least 4.5:1, per the link recipe note); `fg` on `bg` for the panel. +- Reduced motion: panel, mobile expand, chevron and the mobile reveal have no transition. +- Axe in `NavigationBar.test.tsx` runs with the panel closed and open. + +## Test plan (PBT-10 complement) + +| Test file | Content | +|---|---| +| `lib/shootNavItems.test.ts`, `lib/navCurrent.test.ts`, `lib/navMenuState.test.ts` | Properties from the business logic model (fast-check; event-sequence model for the reducer) | +| `navigation.test.ts` | `mainNav` has the five children in shoot order, `footerNav` has none, all `to` are routes | +| `hooks/useDismiss.test.tsx` | Escape and outside pointer down only while active; cleanup | +| `NavigationBar.test.tsx` (extended) | Toggle name and `aria-expanded`; Enter/Space opens; Escape closes and focuses the toggle; outside click closes without moving focus; Tab out closes; closed links not reachable; axe closed and open; no hover opening | +| `MobileNav` tests (new, in `NavigationBar/`) | Group default per path, chevron toggles, link closes menu, Escape returns focus to the hamburger, scroll container present | +| `Footer.test.tsx` (extended) | On `/soorten-fotoshoots/newborn` the footer link has no `aria-current` | +| `navSubmenu.test.tsx` (real app via `renderApp`) | On a shoot page the shoot link in the submenu has `aria-current="page"`, the parent has none but shows the section mark, the footer and (unit 2) breadcrumb are correct; route change closes an open submenu and the mobile menu; back button closes the mobile menu | +| Manual or browser check in Code Generation | 1024 px fit, transparent header panel, short-phone scrolling, bundle and Lighthouse numbers | diff --git a/aidlc-docs/features/shoot-type-pages/construction/plans/content-and-seo-foundation-code-generation-plan.md b/aidlc-docs/features/shoot-type-pages/construction/plans/content-and-seo-foundation-code-generation-plan.md new file mode 100644 index 0000000..66ed548 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/plans/content-and-seo-foundation-code-generation-plan.md @@ -0,0 +1,287 @@ +# Code Generation Plan — Unit 1: Content and SEO foundation + +This plan is the **single source of truth** for code generation of unit 1. Steps are run in order (a step may only start when the steps it depends on are checked), each by a sub-agent of the size given in brackets: **[small]** = mechanical (registry entries, moves, docs, running checks) → smaller model; **[large]** = logic, content drafting or tests → larger model. + +- **Workspace root**: `K:\Development\SlpSoftware\Projects\AndreaSlopFotografie-shoot-type-pages` (worktree); application code in `web/` only, never in `aidlc-docs/` +- **Branch**: `feature/shoot-type-pages` (from master `18e81d0`) +- **Commits**: none by this plan. A commit for the unit ("a commit per unit", execution plan) is made only when the user asks; push likewise. +- **Paths** below are relative to the workspace root. + +## Unit Context + +- **Requirements implemented**: FR-ST-01 (routes, path helpers, not-found), FR-ST-04/05/06/07/08 (data and view only; UI is unit 2), FR-ST-11 (content model), FR-ST-12 (registry, sitemap, Lighthouse), SEO-ST-01, SEO-ST-02 (title/description drafts), SEO-ST-03 (Service, Offer, BreadcrumbList, FAQPage), NFR-ST-03 (code splitting), NFR-ST-04, NFR-ST-05 (SECURITY-04/05/09/10/11/13/15), NFR-ST-06 (PBT + example-based), CON-ST-01..05 +- **Not in this unit**: all visible sections beyond the h1 shell (unit 2: Breadcrumb, StoryBlocks, ProcessTimeline, PhotoMosaic, FaqList, PackageBlock, PageIntro slot, "Lees meer" links, OG images, LAYOUT.md); navigation submenu (unit 3) +- **Design**: [application-design.md](../../inception/application-design/application-design.md) (D1–D6 confirmed A; D7–D15 as written), [component-methods.md](../../inception/application-design/component-methods.md) (types and signatures), [services.md](../../inception/application-design/services.md) (view rules and the PBT property list), [components.md](../../inception/application-design/components.md). No Functional Design for this unit (execution plan). +- **Copy source**: design E `E-Definitief.dc.html` (Newborn), `content/shootTypes.ts` and `content/packages.ts` (others) +- **Depends on**: nothing new. Reuses `visiblePackages`, `isShootTypeId` (`lib/portfolioFilters.ts`), `formatPrice`, `shootPortfolioLink`, `isPortfolioLive`, `shootTypesWithPhotos`, `webPage`, `canonicalUrl`, `absoluteUrl`, `areaServed`, `jsonLdScript`, `PageIntro`, `NotFound`. +- **Used by**: unit 2 (sections render `ShootPageView`; edits texts/photos, `MOSAIC_MIN_PHOTOS`, `ogImage`); unit 3 (reads `lib/shootPages.ts`, `content/shootTypes.ts`, `test/arbitraries.ts`). The interfaces in component-methods.md are the contract; unit 1 may not change their shape without telling the orchestrator. +- **Data entities owned**: `ShootPageContent`, `ShootPageShared`, `StoryBlock`, `FaqItem`, `ProcessStepId`, `ProcessStepContent`, `DepositInfo` (flat, CMS-shaped; no database). +- **Behavioural contract for existing pages**: every existing page renders as before. Only invisible changes: the overview's Service `@id`/`url` move to `…/soorten-fotoshoots/#service` / the shoot page (D2), and the overview's JSON-LD is rendered through `StructuredData` (same output). +- **Files** (exactly the unit-1 rows of the file ownership table, plus three test/type files the code requires, marked †): + - `web/src/routes/soorten-fotoshoots/index.tsx` (moved), `newborn.tsx`, `zwangerschap.tsx`, `gezin.tsx`, `loveshoot.tsx`, `portret.tsx`, `-shootPageSources.ts`; `web/src/routeTree.gen.ts` (regenerated) + - `web/src/content/types.ts`, `web/src/content/shootPageShared.ts`, `web/src/content/shootPages/{newborn,zwangerschap,gezin,loveshoot,portret}.ts`, `web/src/content/shootPages/shootPages.test.ts`, `web/src/content/shootTypes.ts` (marker only) + - `web/src/lib/{shootPages,shootPackage,fillPlaceholders,richTextToPlain,shootPageView}.ts` + `.test.ts`, `web/src/lib/shootLinks.ts` + test + - `web/src/seo.ts`, `web/src/seo.test.ts`, `web/src/sitePages.ts`, `web/lighthouserc.cjs`, † `web/lighthouserc.d.cts`, † `web/src/sitemap.test.ts` + - `web/src/app.test.tsx`, `web/src/test/renderApp.tsx` (new), `web/src/test/arbitraries.ts` + - `web/src/components/StructuredData/{StructuredData.tsx,StructuredData.test.tsx}`, `web/src/components/shoots/ShootPage/{ShootPage.tsx,ShootPage.test.tsx}` (shell) + - `aidlc-docs/features/shoot-type-pages/construction/content-and-seo-foundation/code/code-summary.md`, own lines in `aidlc-docs/_shared/reverse-engineering/{api-documentation,code-structure,architecture}.md` + +## Conventions for every step +- Prettier style, 4-space indent as in the repo; code comments in English; visitor-facing text in Dutch. +- Components never import content modules; routes pass content or a view as props. +- **Draft marker** (D3, CON-ST-03): the line `// DRAFT(CON-ST-03): awaiting Andrea's approval` directly above every drafted field or block (content files and `sitePages.ts`). Where a draft also touches an open fact from CON-ST-04, add one more comment line below the marker: `// OPEN(CON-ST-04): `. +- **Never invent facts** (CON-ST-04): no durations, photo counts, periods, locations, checklists or "ik neem … mee" that are not in `shootTypes.ts`, `packages.ts`, `siteContent.ts`, CON-ST-01 or design E's confirmed text. No bracketed design placeholders (`[…]`) in content. No figure that already exists as data (prices, features, photo counts, deposit, reply time, opleverduur) written as free text: use the placeholders (D8) or leave it to the package block. +- New `lib/*` and `seo.ts` code must keep the **100 % coverage threshold** (vite.config.ts). +- PBT: fast-check with the shared generators in `web/src/test/arbitraries.ts`; seed comes from `config/testSeed.ts` via `test/setup.ts` (do not pass seeds or disable shrinking). Name PBT tests with "(invariant)", "(round trip)" or "(idempotency)" as the existing tests do, so they are distinguishable from example-based ones (PBT-10). +- There is **no `pnpm typecheck` script**: type check is `pnpm exec tsc` (what `pnpm build` runs first). + +## Steps + +### Setup + +- [x] **Step 1 — Install and baseline** [small] — *NFR-ST-05 (SECURITY-10), NFR-ST-06* + - Done. `pnpm install --frozen-lockfile` ok (lockfile unchanged); `pnpm exec vite build` ok, `routeTree.gen.ts` no diff; `pnpm lint` clean; `pnpm exec tsc` clean; `pnpm test`: 82 files, 460 tests passed, fast-check seed 801597296. No pre-existing failures. (Tests/tsc ran after the Step 2 type additions, which are type-only.) + - In `web/`: `pnpm install --frozen-lockfile` (the worktree has no `node_modules`; `postinstall` runs `chakra typegen`). The lockfile must stay unchanged. + - Let the router plugin regenerate `web/src/routeTree.gen.ts`: `pnpm exec vite build`. Then `git diff --exit-code web/src/routeTree.gen.ts` must show no change on the untouched tree (proves the generator version matches the committed file). + - Baseline: `pnpm lint`, `pnpm exec tsc`, `pnpm test`. All green; note the number of tests and the logged fast-check seed in the step's hand-back. Delete nothing; `dist/` is git-ignored. + +### Content model and content + +- [x] **Step 2 — Content types** [small] — *FR-ST-11, FR-ST-04, FR-ST-06, FR-ST-07* + - Done, no deviation. Types inserted in `types.ts` after `ShootTypesPageContent`; trailing same-line comments of component-methods.md became comments above the field (repo style); `ProcessStepId` formatted as a leading-`|` union like `FrameColor`. + - `web/src/content/types.ts`: add `StoryBlock`, `FaqItem`, `ProcessStepId`, `ProcessStepContent`, `DepositInfo`, `ShootPageShared`, `ShootPageContent` exactly as in component-methods.md § Content types, each with a one-line English comment (requirement id). Document the five placeholders (`{reactietermijn}`, `{aanbetaling}`, `{locatie}`, `{duur}`, `{opleverduur}`) and where they may appear in a comment above `ShootPageShared`. No existing type changes. + +- [x] **Step 3 — Shared shoot page content** [large] — *FR-ST-04, FR-ST-06, FR-ST-07, FR-ST-11, CON-ST-01, CON-ST-02, CON-ST-04, NFR-ST-04* + - Done. Shared FAQ constants `deliveryFaq` ("Wanneer krijg ik de foto's?", `{opleverduur}`), `bookingFaq` ("Hoe leg ik de datum vast?", `{aanbetaling}`, settled against the total and remainder after the shoot per CON-ST-01; `OPEN(CON-ST-04)` as on the deposit note), `replyFaq` ("Hoe snel hoor ik iets van je?", `{reactietermijn}`). FAQ lead ends in a separate `'.'` piece after the link (design E's full stop). Process eyebrow/title and the button labels are marked as drafts too (the plan's exception list names only step titles, deposit amount and breadcrumb labels). + - New `web/src/content/shootPageShared.ts`, default export `shootPageShared: ShootPageShared`, plus named exports for the shared FAQ items (`FaqItem` constants, D7). + - Texts from design E, generic wording with placeholders (D8): + - breadcrumb `{ label: 'Kruimelpad', home: 'Home', overview: 'Soorten fotoshoots' }`; + - process: eyebrow "Zo werkt het", title "Van aanvraag tot online galerij", lead "Elke shoot volgt dezelfde zes stappen, zodat je precies weet waar je aan toe bent."; steps (record by `ProcessStepId`, titles per FR-ST-04): `aanvragen` "Stuur een berichtje. Ik reageer binnen {reactietermijn}.", `datum` "We kiezen samen een moment. {locatie}", `aanbetaling` "Met een aanbetaling van {aanbetaling} staat je datum vast.", `shoot` "{duur}", `bewerking` "Ik selecteer en bewerk de mooiste foto's. Opleverduur: {opleverduur}.", `oplevering` "Je foto's staan klaar in je persoonlijke online fotogalerij." (marker + `OPEN(CON-ST-04)`: online gallery confirmed only for the three packages); + - deposit `{ amount: 50, note: 'Aanbetaling {aanbetaling}, restbedrag na de shoot.' }` (CON-ST-01; design E's brackets are not copied; `OPEN(CON-ST-04)`: whether the deposit also applies to Loveshoot/Portret, and when the remainder is paid); + - photos eyebrow "Impressie"; faq eyebrow "Veelgestelde vragen", lead `RichText` "Staat je vraag er niet tussen? " + link "Stuur gerust een berichtje" → `{ to: '/contact' }`; + - offer `bookLabel` "Boek dit pakket", `askLabel` "Eerst een vraag stellen", `onRequest` `{ price: 'Prijs op aanvraag', text: , linkLabel: }`. + - Shared FAQ items (2–3, general, drafts), e.g. "Wanneer krijg ik de foto's?" → answer with `{opleverduur}`; "Hoe leg ik de datum vast?" → answer with `{aanbetaling}`. No cancellation/rescheduling content (Clarification 2 = B). + - Every text gets the draft marker except the fixed facts that come straight from the requirements (step titles, deposit amount, breadcrumb labels): those are not drafts. + +- [x] **Step 4 — Newborn page content** [large] — *FR-ST-02..08, FR-ST-11, CON-ST-01, CON-ST-02, CON-ST-04, CON-ST-05, SECURITY-09* + - Done as written. Shared item: `deliveryFaq` (5 items). Story 3's second paragraph is design E's sentence without "Ik neem alles mee …"; "Wat moet ik thuis voorbereiden?" keeps only "Weinig. Een warme kamer met wat daglicht is fijn." Image ContentImages are literal (asset import + the portfolio/shoot alt text and size; Step 13 checks they stay equal). Note for review: story 4's heading/paragraph keep design E's "1 tot 2 uur" (same figure as the package feature "1-2 uur fotografie"; kept because the plan says headings and paragraphs as design E). + - New `web/src/content/shootPages/newborn.ts`, default export `newbornPage: ShootPageContent`, `id: 'newborn'`. + - Copy from design E (Newborn) **without** its bracketed placeholders and without unconfirmed facts: + - intro: eyebrow "Newbornfotograaf in Huizen", title "Newbornshoot bij jou thuis", text as design E. + - stories (4, ids `verwachten`, `periode`, `locatie`, `duur`): headings and paragraphs as design E, except: drop "Na afloop krijg je minstens 40 zorgvuldig nabewerkte foto's …" (a package figure as free text, NFR-ST-04; the package block shows it) and drop "Ik neem alles mee wat ik nodig heb." (CON-ST-04). Keep the Newborn-specific "voorlopige datum … schuiven we mee" line (CON-ST-01 exception). + - process: `location` "Een newbornshoot is bij jou thuis.", `duration` "1-2 uur fotografie, in het tempo van jullie baby.", `deliveryTime` "2–3 weken". + - photos: title "Uit eerdere newbornshoots"; provisional selection (unit 2 finalises in FD): stories 1 `assets/shoots/newborn.jpg` (848×1060, shoot main photo), 2 `assets/portfolio/f41a8700.jpg` (800×534), 3 `f41a7176.jpg` (800×1200), 4 `f41a1916.jpg` (800×1200); mosaic images `f41a1922`, `f41a4650` (800×533), `f41a7284`, and `f41a8700` (kept in the data on purpose, as in design E; D14 drops it in the view). Alt texts: reuse the portfolio/shoot alt texts of the same photo. + - faq: title "Vragen over de newbornshoot"; items: "Wanneer boek ik de newbornshoot het beste?", "Wat als mijn baby niet wil slapen?", "Mogen wij en broertjes of zusjes ook op de foto?", "Wat moet ik thuis voorbereiden?" (answer without "Ik neem zelf dekens en doeken mee" and without the checklist sentence, CON-ST-04), plus one shared item from Step 3. Total 3–5. + - offer: eyebrow "Pakket newborn", title "Wat zit er in een newbornshoot"; closing: title "Op zoek naar een newbornfotograaf in Huizen?", lead as design E, buttonLabel "Boek je newbornshoot". + - Draft marker on every drafted field (all of the above except `id` and the image data). + +- [x] **Step 5 — Zwangerschap and Gezin page content** [large] — *FR-ST-02..08, FR-ST-11, CON-ST-02, CON-ST-04, CON-ST-05* + - Done. Stories: Zwangerschap verwachten/periode/locatie/duur, Gezin verwachten/samen ("Iedereen hoort erbij"; no best period exists for Gezin)/locatie/duur. Photo choice: story 1 main photo, stories 2–3 the two portfolio photos, story 4 text only; `photos.images` lists the two portfolio photos, so with D14 the view leaves the mosaic out until more photos arrive (comment in the file; FD unit 2 may instead move them to the mosaic). Story 4 avoids the duration figure ("Rustig de tijd"); the figure is only in `process.duration` "1 uur fotografie, zonder haast." (D6). FAQ: 3 own + `bookingFaq` + `deliveryFaq` (Zwangerschap 5), 2 own + the same two (Gezin 4). No `OPEN` needed: every fact comes from `shootTypes.ts`/`packages.ts`. + - New `web/src/content/shootPages/zwangerschap.ts` and `gezin.ts`, same shape as Step 4, drafted in Andrea's tone from `shootTypes.ts` (period 30–34 weken, Soesterduinen/heide for Zwangerschap; thuis of buiten for Gezin) and `packages.ts`. + - `process.duration`: "1 uur fotografie, …" (matches the package feature, D6); `deliveryTime` "2–3 weken"; `location` from the shoot type text. + - Photos (provisional): Zwangerschap `shoots/zwangerschap.jpg`, portfolio `f41a7883`, `f41a8206`; Gezin `shoots/gezin.jpg`, portfolio `f41a1579`, `f41a7138` (note in a comment: the `shoots/gezin*` photos show newborn families, CON-ST-05). A story block may have no image (FR-ST-03). The detail photo is used by the package block (view), so do not repeat it in stories. + - 3–5 FAQ items each (own + shared); four stories each with headings that fit the shoot. Only facts that exist in the current texts; everything else left out or marked `OPEN(CON-ST-04)`. + +- [x] **Step 6 — Loveshoot and Portret page content** [large] — *FR-ST-02..08, FR-ST-11, CON-ST-02, CON-ST-04, CON-ST-05* + - Done. Stories: Loveshoot verwachten/trouwkaart/locatie/ontspannen, Portret verwachten/natuur-zakelijk/locatie/ontspannen (4th theme "at ease in front of the camera" instead of duration; stories 2–4 text only). `process.duration` "We stemmen de duur samen af." + `OPEN(CON-ST-04)`; Portret also has `OPEN(CON-ST-04)` on its location story and `process.location` (locations unknown). `process.location` is "En een plek die bij jullie/jou past." (no places named). Offer eyebrow/title "Loveshoot boeken"/"Portretshoot boeken" + "Benieuwd naar de mogelijkheden?" (no "Pakket …", there is no package). FAQ: 2 own + `bookingFaq` + `deliveryFaq` each; no price, duration or photo-count question. + - New `web/src/content/shootPages/loveshoot.ts` and `portret.ts`, same shape. + - Unknown facts (CON-ST-04): duration, photo count, best period, Portret locations. They are **not** invented: story themes are chosen so they need none of them (e.g. "Wat kun je verwachten", "Voor jullie trouwkaart" / "Natuur of zakelijk" from the existing text, "Samen een plek kiezen" without naming places); `process.duration` gets a neutral sentence without a figure (e.g. "We stemmen de duur samen af.") with the draft marker **and** `// OPEN(CON-ST-04): shoot duration for `. + - Photos: only the shoot main photo (stories) and the detail photo (package); `photos.images` lists both so that adding photos later is data-only, and the view leaves the mosaic out (D14/D15). Comment says so. + - No price anywhere (variant "Prijs op aanvraag" is decided by data, FR-ST-07). + +- [x] **Step 7 — Gezin overview draft marker** [small] — *CON-ST-03, D3* + - Done, no deviation (one comment line replaced). + - `web/src/content/shootTypes.ts`: replace the comment `// Draft text, still to be approved by Andrea (FR-SF-02)` with the common marker. No data change. + +### Generators and pure logic + +- [x] **Step 8 — Generators** [large] — *NFR-ST-06, PBT-07* + - Done. Deviations: `shootPageContent(id?, reuse = [])` takes the shoot's main/detail images as an optional second argument (the generator cannot know the shoot's `src` otherwise); stray braces in generated text are opening ones only (a stray `{` and `}` around a filled placeholder could form a new one, which would break "no known placeholder remains"; a lone `}` is covered by examples). Also exported as building blocks: `knownPlaceholders`, `plainText` (hostile, brace-free; used for placeholder values), `knownRoutePath` (keys of `sitePages`), `faqItems` (unique ids). + - `web/src/test/arbitraries.ts` (append only; export the existing private `image` arbitrary as `contentImage` without changing its definition): + - `placeholderName` (the five known names plus unknown ones), `textWithPlaceholders`, `inlineLink` (known `RoutePath`s, optional hash), `richText` (strings and links, including hostile content: ``, `<`, `>`, `&`, U+2028, `{`/`}`), + - `storyBlock` (optional image), `faqItem` (unique ids, `RichText` answers with placeholders and links), + - `shootPageShared` (steps as a full `Record` generated in random key order, deposit amount 1–999), + - `shootPageContent(id?)` (stories 0–6, FAQ 0–6, photos 0–8 with deliberate duplicates of story `src` and of the shoot's detail/main `src`), + - `slugInput` (known ids, case variants, leading/trailing slashes, `..`, `%2F`, whitespace, ``, arbitrary strings and non-strings for `unknown`). + - Reuse `shootType`, `uniqueShootTypes`, `anyPackage`, `anySiteContent`; no duplicated generators. + +- [x] **Step 9 — Path helpers** [large] — *FR-ST-01, SECURITY-05, SECURITY-15, PBT-02, PBT-03* + - Done, no deviation. Path PBT input is built in the test from `slugInput` (prefix + slug + "", "/" or "//"), the overview paths and arbitrary strings. 9 tests, 100 % coverage of `shootPages.ts`. + - New `web/src/lib/shootPages.ts`: `SHOOT_TYPES_PATH`, `SHOOT_TYPE_IDS` (built from a `Record` so a new id is a compile error until listed), `ShootPagePath`, `shootPagePath`, `shootIdFromSlug` (via `isShootTypeId(value, SHOOT_TYPE_IDS)`), `shootIdFromPath` (exact `'/soorten-fotoshoots/'`, one trailing slash tolerated; never throws). The route guard type is added in Step 18, not here (the routes do not exist yet, so `tsc` would fail in between). + - New `web/src/lib/shootPages.test.ts`: examples (all five ids, `/soorten-fotoshoots/onzin`, `/soorten-fotoshoots`, `/soorten-fotoshoots/newborn/`, `/soorten-fotoshoots/Newborn`, `/soorten-fotoshoots/newborn/extra`, `%2F`); PBT per services.md: round trip `shootIdFromSlug(id) === id` and `shootIdFromPath(shootPagePath(id)) === id` (PBT-02); any `slugInput` → known id or `undefined`, never throws, and a defined result `r` satisfies `shootPagePath(r) === input` without its one trailing slash (PBT-03). + +- [x] **Step 10 — Package helper and contact link** [large] — *FR-ST-07, FR-ST-08, SECURITY-05, PBT-03* + - Done, no deviation. `shootContactLink` now takes `pakket` from `shootPackage(...).id` (equal to `shoot.packageId`); existing tests unchanged and green, plus "agrees with shootPackage (invariant)". 100 % coverage of both files. + - New `web/src/lib/shootPackage.ts` + test: `shootPackage(shoot, packages)` = the member of `visiblePackages(packages)` with `id === shoot.packageId`, else `undefined`. Examples: the three real shoots with a package, Loveshoot/Portret, a removed and an invalid package. PBT: result `undefined` or a visible package with the right id (PBT-03). + - `web/src/lib/shootLinks.ts`: `shootContactLink` uses `shootPackage` (same results, same return type). `web/src/lib/shootLinks.test.ts`: existing tests unchanged and green; add PBT "agrees with `shootPackage`": `search?.pakket === shootPackage(...)?.id` (PBT-03). + +- [x] **Step 11 — Placeholders and plain text** [large] — *FR-ST-04, FR-ST-06, SEO-ST-03, NFR-ST-04, PBT-03, PBT-04* + - Done. `Object.hasOwn` own-property check; values inserted literally (replace callback, so `$&` in a value is not special). Idempotency and "no known placeholder remains" are tested with `textWithPlaceholders` and brace-free values (see Step 8); "unchanged" with any brace-containing string that has no `{name}`. Also an oracle-style per-piece property for `fillRichText`. 100 % coverage. + - New `web/src/lib/fillPlaceholders.ts`: `fillPlaceholders(text, values)` replaces every `{name}` whose name is in `values` (own-property check, so `{constructor}` stays), other text unchanged; `fillRichText` maps string pieces and link `text`, keeps `to`/`hash`. `lib/withReplyTime.ts` (contact page) stays as it is. + - New `web/src/lib/richTextToPlain.ts`: string pieces as they are, links by their `text`, joined without separators. + - Tests (`fillPlaceholders.test.ts`, `richTextToPlain.test.ts`): examples (each placeholder, unknown placeholder kept, repeated placeholder, `{`/`}` alone); PBT per services.md: no placeholder → unchanged; fill twice = fill once when values contain no `{…}` (PBT-04); no known placeholder remains; links keep `to`/`hash`; plain text equals joined pieces, length = sum of piece lengths (PBT-03). + +- [x] **Step 12 — The page view** [large] — *FR-ST-01..08, FR-ST-11, NFR-ST-04, SECURITY-05, SECURITY-15, PBT-03* + - Done, types exactly per component-methods.md. Known ordering effect: `BreadcrumbItem.to: RoutePath` cannot hold the shoot page path until the routes exist, so `pnpm exec tsc` reports one error in `shootPageView.ts` (breadcrumb last item) until Step 18 adds the route files (no cast or widened type added). Placeholders are filled in story eyebrow/title/paragraphs, step texts, deposit note and FAQ question + answer (the generators put placeholders in exactly those); intro, closing and FAQ lead are passed through. 13 tests (4 examples on real content, 9 PBT), 100 % coverage. + - New `web/src/lib/shootPageView.ts`: `PROCESS_STEP_ORDER`, `MOSAIC_MIN_PHOTOS = 2` (comment: confirmed in FD unit 2), `BreadcrumbItem`, `ProcessStep`, `ShootPageSources`, `ShootPageView`, `shootPageView(id, page, sources)` exactly per component-methods.md and the rule table in services.md (shoot lookup / id mismatch → `undefined`; breadcrumb Home `/` → overview `/soorten-fotoshoots` → `shoot.name` at `path`; placeholder values `{reactietermijn}` ← `site.contactForm.replyTime`, `{aanbetaling}` ← `formatPrice(shared.deposit.amount)`, `{locatie}`/`{duur}`/`{opleverduur}` ← `page.process`, applied to steps, deposit note, stories and FAQ answers; six steps in fixed order; `offer.image` = detail photo else main photo; `pkg` via `shootPackage`; `bookLink`/closing `link` via `shootContactLink`; `askLink` `{ to: '/contact' }`; photos without any `src` used by a story block or the offer image, first occurrence kept, order kept, absent below `MOSAIC_MIN_PHOTOS`, `portfolioLink` iff `id ∈ portfolioShoots`; FAQ absent when no items). + - New `web/src/lib/shootPageView.test.ts`: examples with the real content for Newborn (package variant with `pkg.price` 185, deposit note filled to "Aanbetaling € 50, restbedrag na de shoot." with a non-breaking space, mosaic drops `f41a8700`) and Loveshoot (no `pkg`, no mosaic, `bookLink` `{ to: '/contact' }`), a missing shoot type and a mismatched `page.id` → `undefined`. PBT with the Step 8 generators, one test per property of services.md § `shootPageView` (PBT-03), including "no known placeholder left in any text" and "`bookLink.search?.pakket` only a visible package id". + +- [x] **Step 13 — Content consistency tests** [large] — *FR-ST-03, FR-ST-05, FR-ST-06, FR-ST-11, CON-ST-03, CON-ST-04, D6, D14, PBT-10* + - Done, no deviation (the two pending tests were added with the real `ShootPageSources`; `portfolioShoots: []`). Earlier part: `shootPages.test.ts` has the page table, ids, four stories, 3–5 FAQ, alt/size, D6, deliveryTime and the text checks (brackets, unknown placeholder or stray brace, `@`, annuler/verzet) over the five pages and `shootPageShared`; plus one extra check that a reused photo keeps the alt text and size it has in `shootTypes`/`portfolioContent`. **Pending** until Step 12 exists: "`shootPageView` returns a view for every shoot" and "no photo `src` twice on the view, stories + offer image + mosaic (D14)". + - New `web/src/content/shootPages/shootPages.test.ts` (example-based, real content; one table of the five page modules keyed by `ShootTypeId`, typed `Record` so a missing file is a type error): + - every page's `id` equals its key; exactly four stories with unique ids; 3–5 FAQ items with unique ids; + - `shootPageView` returns a view for every shoot with the real sources (fail-safe path never taken by real data); + - no photo `src` twice on the rendered view (stories + offer image + mosaic) (D14), every image has a non-blank alt and positive size; + - D6: for a shoot whose `shootPackage` exists, `process.duration` starts with the package feature that ends in "uur fotografie"; + - no text contains `[` or `]` (design placeholders), an unknown `{…}` placeholder, an e-mail address, "annuler" or "verzet" (no cancellation terms); + - `deliveryTime` is "2–3 weken" for all five (CON-ST-01). + +### SEO and structured data + +- [x] **Step 14 — SEO builders** [large] — *SEO-ST-01, SEO-ST-03, SECURITY-11, PBT-02, PBT-03* + - Done as written (builders return inferred types, like the existing ones; `faqPage` also sets `inLanguage: 'nl-NL'` like `webPage`). Ordering effect, not a code issue: `shootPageGraph` passes `view.path` to `webPage`/`faqPage` (`RoutePath`), so `tsc` reports two errors in `seo.ts` until Step 18, and `webPage` reads `sitePages[view.path]`, so the 4 `shootPageGraph` tests in `seo.test.ts` (Newborn/Loveshoot examples, two PBT) fail with "reading 'title'" until Step 19 adds the registry entries. Verified beforehand with a throw-away vitest config (scratchpad, not in the repo) that registers five stub entries: 57/57 green, `seo.ts` 100 % coverage. Renamed test: "gives every service the id and URL of its own shoot page (invariant)". + - `web/src/seo.ts`: add `shootServiceId(id)` (`${siteUrl}/soorten-fotoshoots/#service`, D2), `shootService(shoot, site, pkg?)` (Service: `@id`, `url` = canonical shoot page, `name`/`serviceType` = `shootLabel`, `description` = `paragraphs[0]`, `image` = `absoluteUrl(image.src)`, `provider`, `areaServed`; `offers: { '@type': 'Offer', price, priceCurrency: 'EUR' }` only when `pkg`), `breadcrumbList(items)`, `faqPage(path, items)` (`undefined` for no items; `isPartOf` the WebPage `@id`), `shootPageGraph(view, site)` (`webPage('WebPage', view.path, { mainEntity: shootService(view.shoot, site, view.offer.pkg), breadcrumb: breadcrumbList(view.breadcrumb.items) })` and, with FAQ items, the FAQPage). `shootServices` keeps its signature and builds each item with `shootService(shoot, site)` (no `pkg`, so no offers). Import `BreadcrumbItem`/`ShootPageView` as types only. + - `web/src/seo.test.ts`: + - update the existing `shootServices` tests that assert the old anchor ids (`${page}#${id}`) to the new `shootServiceId` and shoot page `url` (rename "gives every service its own anchor as @id" accordingly); the "no price" invariant stays; + - examples: Newborn graph (WebPage + FAQPage, Offer € 185 EUR, breadcrumb of three absolute URLs), Loveshoot graph (no `offers`); + - PBT per services.md: breadcrumb positions 1..n, absolute URLs under `siteUrl`, names in order; FAQPage one Question per item in order with answer = `richTextToPlain`; overview item and shoot page Service share `@id`, `url` = canonical shoot page, `offers` iff `pkg` (PBT-03); `JSON.parse(jsonLdScript(x))` deep-equals `x` for every new builder with hostile strings, output never contains `<`, `>`, `&`, never the e-mail address (PBT-02, PBT-03). + +- [x] **Step 15 — StructuredData component** [small] — *SEO-ST-03, SECURITY-04, SECURITY-11* + - Done, no deviation. The `` test checks the script text has no `<`, `>` or `&`, parses back to the data, and that the serialised markup parsed again as HTML still has one script and no injected element (a check on the DOM alone would pass even without escaping). Not yet used by the overview route (Step 17). + - New `web/src/components/StructuredData/StructuredData.tsx`: `{ data: unknown }` → `` in the data does not end the element. + +### Page shell and routes + +- [x] **Step 16 — ShootPage shell** [small] — *FR-ST-02 (h1 only), SEO-ST-04, NFR-ST-01* + - Done, no deviation. The test builds the view for Newborn from the real sources. + - New `web/src/components/shoots/ShootPage/ShootPage.tsx`: `{ view: ShootPageView }`; renders `PageIntro` with `view.intro.eyebrow`, `view.intro.title` (the only h1) and `view.intro.text`. Comment: unit 2 adds the sections in the order of the page structure. No content imports. + - New `ShootPage.test.tsx` (with `renderWithProviders`): one h1 with the title, eyebrow and intro text shown, no axe violations. + +- [x] **Step 17 — Move the overview route** [small] — *FR-ST-01, FR-ST-09, SEO-ST-03* + - Done. Only deviation: the comment above `StructuredData` now says "StructuredData escapes" instead of "jsonLdScript escapes". + - `git mv web/src/routes/soorten-fotoshoots.tsx web/src/routes/soorten-fotoshoots/index.tsx`; fix the relative imports (`../` → `../../`); route string `'/soorten-fotoshoots/'` (the generator writes it; check it did); replace the inline ``, `<`, `>`, `&`, very long words, empty-looking whitespace), and `shootPageViewArb` (a `ShootPageView` built by `shootPageView` from `shootPageContent(id, reuse)`, `shootPageShared`, a unique list of shoot types and packages, so stories 0–6, photos present or not and FAQ present or not all occur; it must never return `undefined`). + - Reuse `shootPageContent`, `shootPageShared`, `contentImage`, `storyBlock`, `faqItem`, `richText`, `uniqueShootTypes`, `anyPackage`; no duplicated generators. Smoke-check each new generator inside the tests of Steps 4–7 (no separate test file). + +- [x] **Step 4 — headingId and readMoreLabel** [sonnet] — *BR-SP-72, BR-SP-64, FR-ST-09, SECURITY-15, PBT-03* + - **Result**: `headingId.ts`, `readMoreLabel.ts` + tests, 100 % coverage. + - Depends on: Step 3. + - New `src/lib/headingId.ts`: `headingId(prefix: string, id: string): string` = `${prefix}-${id}` with the whole result lower-cased and every character outside `a-z 0-9 - _` replaced by `-` (BR-SP-72); pure, never throws for any string. The caller adds `-title` where needed. + - New `src/lib/readMoreLabel.ts`: `readMoreLabel(shoot: ShootType): string` = ``Lees meer over de ${shoot.shootLabel.toLowerCase()}`` (domain-entities.md § 6). + - Tests `headingId.test.ts`, `readMoreLabel.test.ts`: examples (the five real ids, spaces, uppercase, ``, empty string, non-ASCII); the five real labels ("Lees meer over de newbornshoot", "… zwangerschapsshoot", "… gezinsshoot", "… loveshoot", "… portretshoot") are unique; PBT per business-rules.md § 3: `headingId` output only `a-z0-9-_`, deterministic, never throws for arbitrary and hostile strings (invariant); `readMoreLabel` starts with "Lees meer over de " and is unique for any `uniqueShootTypes` list with unique `shootLabel` (invariant). 100 % coverage. + +- [x] **Step 5 — mosaicLayout** [sonnet] — *FR-ST-05, BR-SP-30b, BR-SP-31, BR-SP-35, PBT-03* + - **Result**: `mosaicLayout.ts` + test, 100 % coverage. The first tile is `1 / 3` x `1 / 3` for counts 2 to 4 only; the table gives count 1 (never shown) `1 / 5`, which the property respects. + - Depends on: Step 3. + - New `src/lib/mosaicLayout.ts`: `MOSAIC_MAX_PHOTOS = 4`, `MosaicTile` (`column`, `row`, `wide`, `phoneRatio`) and `mosaicLayout(count: number): MosaicTile[]` exactly per the table in domain-entities.md § 2 (0 or below none; 1 total-but-unused; 2, 3, 4; 5 or more = the layout for 4). Non-integer or `NaN` input: treat as no tiles (fail safe). + - Test `mosaicLayout.test.ts`: examples for 0, 1, 2, 3, 4, 5, −1; PBT over `mosaicCount` per business-rules.md § 3: `[]` for ≤ 0; exactly `min(count, 4)` tiles; desktop cells pairwise disjoint and, for 2 to 4, covering all eight cells of the 4 × 2 grid (compute cells from the `column`/`row` strings in the test); first tile always `1 / 3` × `1 / 3`; number of non-wide tiles even; pure (same output twice) (invariant). 100 % coverage. + +- [x] **Step 6 — storyLayout** [sonnet] — *FR-ST-03, BR-SP-11, BR-SP-12, BR-SP-13, BR-SP-14, BR-SP-40, PBT-03* + - **Result**: `storyLayout.ts` + test, 100 % coverage. + - Depends on: Step 3. + - New `src/lib/storyLayout.ts`: `StoryLayout` (`tone`, `spacing`, `reverse`, `priority`, `media?: { aspectRatio: '3 / 2' | '4 / 5'; mediaSize: 'half' | 'medium' }`) and `storyLayout(stories: readonly StoryBlock[]): StoryLayout[]` (domain-entities.md § 2): tone `paper` for even index and `alt` for odd, spacing `flushTop` for index 0, `reverse` for odd index, `priority` only for index 0 and only with an image, `media` absent without an image; orientation: `width >= 1.2 * height` → `3 / 2` and `half`, otherwise `4 / 5` and `medium`. Export the threshold as a named constant. + - Test `storyLayout.test.ts`: examples with the real Newborn stories (4/5 + medium for the portrait photos, 3/2 + half for `f41a8700`) and a text-only list (Loveshoot); boundary examples (exactly 1.2, 1.19); empty list; PBT over `storyBlock`/`imageWithOrientation` per business-rules.md § 3: tone and `reverse` alternate with the index; `priority` only at index 0 and only with an image; no image means no `media`; ratio `3 / 2` exactly when width ≥ 1.2 × height and `mediaSize` matches (invariant). 100 % coverage. + +- [x] **Step 7 — shootPageBands** [sonnet] — *BR-SP-70, BR-SP-71, BR-SP-73, FR-ST-02..08, PBT-03* + - **Result**: `shootPageBands.ts` + test, 100 % coverage. + - Depends on: Steps 3, 6. + - New `src/lib/shootPageBands.ts`: `SectionBand` (`id`: `` `story-${string}` `` | `'process'` | `'photos'` | `'faq'` | `'offer'` | `'closing'`, `tone`, `position`) and `shootPageBands(view: ShootPageView): SectionBand[]`: stories in index order, then process, `photos` iff `view.photos`, `faq` iff `view.faq`, offer, closing; positions consecutive from 0, tone `paper` at even and `alt` at odd positions (the intro is not a band, it is `paper`). Story tones must equal `storyLayout(...)[i].tone` (the same rule; a test pins it). + - Test `shootPageBands.test.ts`: examples with the real views (Newborn: 4 stories + process + photos + faq + offer + closing = 9 bands; Loveshoot: no photos = 8) and a view without FAQ; PBT over `shootPageViewArb` per business-rules.md § 3: tones alternate strictly starting with `paper`; ids in canonical order; length = stories + 1 + [photos] + [faq] + 2; no id twice; story band tone equals `storyLayout` tone (invariant). 100 % coverage. + +### Shared components + +- [x] **Step 8 — Additive changes: PageIntro, MediaText, CallToAction** [sonnet] — *BR-SP-05, BR-SP-12, BR-SP-63, FR-ST-02, FR-ST-03, FR-ST-08, NFR-ST-02* + - **Result**: `PageIntro` (`titleId`, `breadcrumb`), `MediaText` (`medium`), `CallToAction` (`tone`) with tests; existing tests unchanged and green. + - `src/components/PageIntro/PageIntro.tsx`: new optional `titleId?: string` (id of the h1; the section gets `aria-labelledby={titleId}`) and `breadcrumb?: ReactNode` (rendered above the eyebrow with `mb` 6 on phones and 7 from `md`). Existing callers render byte-identically (no `aria-labelledby`, no wrapper). Test: one test pins the existing markup (`container.innerHTML` equal to the output without the new props, e.g. with a stored expected structure), one for `titleId`/`breadcrumb`. + - `src/components/MediaText/MediaText.tsx`: `mediaSize` accepts `'medium'` in addition to `'half'` and `'small'`: photo column up to 30rem (480 px), text up to 36rem centred in the rest, laid out exactly as `small` does (reuse its branch; add a `MEDIUM_MEDIA = '30rem'` constant next to `SMALL_MEDIA`). Detail-image behaviour unchanged. Add the `medium` test to `MediaText.test.tsx`; existing tests unchanged and green. + - `src/components/CallToAction/CallToAction.tsx`: new optional `tone?: 'paper' | 'alt'`, default `'alt'`, passed to `PageSection`. Add one test; existing tests green. The overview page keeps its current output. + - Update the doc comments of the three components. Touch no other file. + +- [x] **Step 9 — Breadcrumb** [sonnet] — *FR-ST-02, BR-SP-01..04, NFR-ST-01, SEO-ST-04* + - **Result**: `Breadcrumb` + test (separators are `li[aria-hidden]` as in BR-SP-02). Tests render at the page's own path: at `/` the Home link is correctly current. + - New `src/components/Breadcrumb/Breadcrumb.tsx` (+ test): props `label: string`, `items: readonly BreadcrumbItem[]` (type import from `@/lib/shootPageView`), optional `data-testid`. Markup per frontend-components.md § 2: `nav[aria-label]` > `ol` > `li` per item; links through the router `Link` (`RouterLink`) with `activeOptions={{ exact: true }}` (so only the page itself can carry `aria-current`), accent.deep text, permanent underline, `minH` 44 px, inline-flex centred; the last item a `span[aria-current="page"]` in `ink`; between items a decorative `li[aria-hidden="true"]` "/"; `fontSize` 0.875rem, `color` `ink.soft`, centred, wrap, gap 2. No items: renders nothing; one item: only the current page. + - Tests: examples (3 items, 1 item, none); PBT for 1 to 5 generated items per business-rules.md § 3: exactly the last item is a non-link with `aria-current="page"`, the others are links in order, separators number items − 1 and are `aria-hidden` (component property, few runs); axe. + +- [x] **Step 10 — ProcessIcons** [sonnet] — *FR-ST-04, BR-SP-23, BR-SP-74, NFR-ST-01* + - **Result**: `ProcessIcons` + test. + - New `src/components/shoots/ProcessIcons/ProcessIcons.tsx` (+ test): `processIcons: Record JSX.Element>` with the six SVGs from domain-entities.md § 4 (envelope, calendar with heart, coin, camera, sliders, picture): `viewBox="0 0 24 24"`, `fill="none"`, `stroke="currentColor"`, `stroke-width="1.5"`, round caps and joins, `aria-hidden="true"`, `focusable="false"`, 24 × 24; shapes verbatim from design E (also in the domain-entities table). The `Record` type makes a missing id a compile error. + - Test: one icon per `PROCESS_STEP_ORDER` id, each `svg` is `aria-hidden`, not focusable, has no ``; axe. + +- [x] **Step 11 — ProcessTimeline** [sonnet] — *FR-ST-04, BR-SP-20..26, NFR-ST-01, NFR-ST-02* + - **Result**: `ProcessTimeline` + test. Deviation: the subgrid fallback is not expressible through Chakra style props (a nested `@supports` rule is dropped), so `gridTemplateRows: subgrid` from `lg` stands without a fallback (all current browsers support subgrid). + - Depends on: Step 10 (only for the page test; the component takes icons as props). + - New `src/components/ProcessTimeline/ProcessTimeline.tsx` (+ test): props `steps: readonly { id: string; title: string; text: string; icon?: ReactNode }[]`, `tone?: 'paper' | 'alt'` (default `paper`), `data-testid`. `Reveal` > `ol[role="list"]` > `li` per step (marker `div[aria-hidden]` with the icon, line segments `span[aria-hidden]`, text block with `h3` and `p`), layout exactly as frontend-components.md § 2 (below `lg`: grid `3.5rem | 1fr`, column gap 5, vertical line, list capped at `34rem` centred; from `lg`: grid of `repeat(<n>, minmax(0, 1fr))` by `auto 3.5rem auto` rows with `subgridRows` and fallback, text above for even indexes and below for odd, horizontal line through the markers from the first to the last centre). Markers hide the line with the band colour (`tone`); last marker filled (`accent.deep`, white icon), others outlined; no numbers; DOM order = `steps` order. Zero steps: renders nothing. Breakpoints via responsive props (`lg`), no pixel literals. + - If a CSS feature is not expressible with Chakra style props (subgrid with fallback), use a style prop `gridTemplateRows` with the `@supports`-free fallback in the same value list (`1fr 3.5rem 1fr` as the base, `subgrid` from `lg`); report if impossible. + - Tests: examples (6 steps; 1 step; 0 steps; last marker filled; an alternation check that does not depend on class names, e.g. a `data-text-position="above|below"` attribute set from the index parity); PBT for 1 to 8 `timelineSteps` per business-rules.md § 3: one `li` per step in input order, one h3 per `li`, every icon wrapper `aria-hidden`, no digit-only text added by the component (component property, few runs); axe. + +- [x] **Step 12 — PhotoMosaic** [sonnet] — *FR-ST-05, BR-SP-30b..35, BR-SP-41, BR-SP-42, NFR-ST-03* + - **Result**: `PhotoMosaic` + test. + - Depends on: Step 5. + - New `src/components/PhotoMosaic/PhotoMosaic.tsx` (+ test): props `images: readonly ContentImage[]`, `data-testid`. Takes the first `MOSAIC_MAX_PHOTOS`; `ul[role="list"]` as a grid (below `md` two columns; from `md` four columns by two rows of `clamp(12rem, 22vw, 18.75rem)`; gap `gridGap`) with `Reveal as li` (delay `index * 0.08`) per tile with the tile's `column`/`row` (from `md`) or span 2 when `wide` (below `md`), `aspectRatio` = `phoneRatio` below `md` and `auto` from `md`, `position: relative`, `overflow: hidden`, `bg paper.deep`, and a `DeferredImage` absolutely filling the cell (`objectFit: cover`, intrinsic width/height attributes kept by `DeferredImage`). Not interactive (Q3 = A): no link, no button, no hover effect. Empty list: renders nothing. + - Tests: examples with 2, 3, 4, 5 and 0 photos (tile counts 2, 3, 4, 4, none; alt texts present; no `a`/`button` inside); PBT for 2 to 6 generated images per business-rules.md § 3: `min(n, 4)` `img` elements with the given alt texts in order (component property); axe. + +- [x] **Step 13 — FaqList** [sonnet] — *FR-ST-06, BR-SP-50..53, NFR-ST-01, SECURITY-11* + - **Result**: `FaqList` + test. jsdom and user-event do not turn Enter/Space on a `summary` into the click that toggles `details` (the browser does); the test checks focusability, `summary` as first child, and the toggle on activation (click) instead. + - New `src/components/FaqList/FaqList.tsx` (+ test): props `items: readonly FaqItem[]`, `data-testid`. `Box` with a top hairline (`sand`) > per item one native `details` (bottom hairline) > `summary` (flex, space-between, `minH` 44 px, `py` 5, heading font 1.25rem, `ink`, `cursor pointer`, `listStyle none`, WebKit marker hidden, visible focus ring from the theme `focusRing` token with offset) holding the question and a decorative `svg[aria-hidden]` plus icon whose vertical stroke is hidden by CSS under `details[open]` (Chakra `css`/`_open`-style selector; no state), followed by `RichParagraph` for the answer with `mb` 6 and `maxW` 680 px. **No item has the `open` attribute** (Q5 = C); no React state, no JavaScript handler. Answers stay in the DOM when closed. Question text is the disclosure label, not a heading. Zero items: renders nothing. + - Tests: examples (3 items all closed at load, answers in the DOM, answer links present as links); keyboard: focus the `summary`, press Enter and Space with `userEvent` and check `open`; if jsdom does not toggle `details` on activation, diagnose the cause first (do not skip the assertion silently) and test the attribute through the documented jsdom behaviour or report; PBT for 0 to 6 `faqItem`s per business-rules.md § 3: one `details` per item, every answer text present in the DOM, no `details` with `open` (component property); axe. + +- [x] **Step 14 — PackageBlock** [sonnet] — *FR-ST-07, BR-SP-60..62, NFR-ST-01, SECURITY-11* + - **Result**: `PackageBlock` + test. + - Depends on: Step 8 (`MediaText` `small` already exists; no `medium` needed here). + - New `src/components/PackageBlock/PackageBlock.tsx` (+ test): props `titleId`, `eyebrow`, `title`, `image: ContentImage`, `frameColor?`, `pkg?: PricingPackage`, `onRequest: { price: string; text: string }`, `note?: string`, `children` (the actions), `data-testid`. `MediaText mediaSize="small"` (aspect `1 / 1`, deferred image, `frameColor`; **no priority**); text column: `Eyebrow`, `h2#titleId` (`sectionTitle`), price paragraph (heading font, 2.25rem, `accent.deep`, `formatPrice(pkg.price)` or `onRequest.price`), then the features `ul` (rows with a `sand` top border, the last also a bottom border; `role="list"`) when `pkg` exists or the `onRequest.text` paragraph (`ink.soft`) otherwise, the actions row (flex, wrap, gap 3 / 7, centred) with `children`, and the `note` paragraph (0.875rem, `mt` 5) when given. The variant is decided by `pkg` presence only, never by a shoot id. + - Tests: Newborn-style package (price `€ 185` with the non-breaking space from `formatPrice`, all features listed, note shown), on-request variant (price text and text paragraph, no list), no note, extra actions rendered; axe. + +### Shoot page parts + +- [x] **Step 15 — StoryBlocks** [sonnet] — *FR-ST-03, BR-SP-10..14, BR-SP-40, BR-SP-41, NFR-ST-03* + - **Result**: `StoryBlocks` + test. + - Depends on: Steps 4, 6, 8. + - New `src/components/shoots/StoryBlocks/StoryBlocks.tsx` (+ test): props `stories`, `frameColor`, `idPrefix`. One band per story, tone, spacing and media from `storyLayout`. With media: `PageSection` (`labelledBy`) > `MediaText` (`image`, `aspectRatio`, `mediaSize`, `reverse`, `priority`, `frameColor`) whose text column holds `Eyebrow`, `h2` (`sectionTitle`, id `headingId(idPrefix, story.id) + '-title'`) and a stack of `RichParagraph`s (gap 4, `ink.soft`). Without media (Q4 = A): the same `PageSection` (width `narrow`, tone and spacing from the layout) with the same text column inside a `Reveal`, `maxW` 36rem, centred; no `MediaText`, no frame, no empty column. `data-testid="story-<id>"`. Only index 0 may be a priority image; all other photos are deferred (BR-SP-40/41). Empty list: renders nothing. + - Tests: Newborn stories (4 sections, each named by its h2, first image is not lazy and carries `fetchpriority="high"`, the others lazy and deferred, tones alternate), Loveshoot stories (1 photo, 3 text-only bands), hostile story ids (spaces, uppercase) give valid `aria-labelledby` targets that exist in the DOM; axe. + +- [x] **Step 16 — ShootBlock "Lees meer"** [sonnet] — *FR-ST-09, BR-SP-64, Q6 = A, NFR-ST-01* + - **Result**: `ShootBlock` link first in the row; `ShootBlock.test` and `ShootList.test` extended; `app.test.tsx` overview tests green. + - Depends on: Step 4. + - `src/components/shoots/ShootBlock/ShootBlock.tsx`: new first link in the links row: `Link variant="underline" asChild` with `linkStyle` > `RouterLink to={shootPagePath(shoot.id)}` with the visible text `readMoreLabel(shoot)` and `data-testid={`shoot-${shoot.id}-readmore`}`; no `aria-label` (the visible text already differs per shoot). Props unchanged; `article` id, the other two links and their `aria-label`/test ids unchanged. Update the file comment. + - `ShootBlock.test.tsx` and `ShootList.test.tsx`: link text and `href` per shoot (all five), the link comes first, unique accessible names across the list, existing anchors and links still present, axe. Existing assertions stay unchanged and green; check the overview tests in `app.test.tsx` still pass. + +- [x] **Step 17 — ShootPage assembly** [sonnet] — *FR-ST-02..08, BR-SP-70, BR-SP-71, BR-SP-73, BR-SP-74, NFR-ST-01, NFR-ST-03, SEO-ST-04* + - **Result**: `ShootPage` assembled; test extended. The primary buttons use `Box asChild css={linkButton recipe}` around the router's own `Link` (as `PriceCard`), because `LinkButton` loses the typed `search`. The intro and the first story are both paper on purpose (the story is `flushTop`); from the first story on the bands alternate. Cross-check with design E (by reading): section order, eyebrows and tone alternation match; the five-section order intro, 4 stories, process, photos, FAQ, offer, closing is the same. + - Depends on: Steps 7, 8, 9, 10, 11, 12, 13, 14, 15. + - `src/components/shoots/ShootPage/ShootPage.tsx`: props `{ view }` unchanged; no content imports; no state. Composition in the order of `shootPageBands(view)` (frontend-components.md § 3): (1) `PageIntro` with `eyebrow`, `title`, `titleId="intro-title"`, `breadcrumb=<Breadcrumb label items/>`, text `view.intro.text`; (2) `StoryBlocks` (`frameColor = view.shoot.frameColor`, `idPrefix="story"`); (3) `PageSection id="zo-werkt-het" labelledBy="process-title" tone` with `SectionHeading` (eyebrow, h2 id `process-title`, lead) and `ProcessTimeline` (steps mapped with `processIcons[step.id]`, `tone` passed; an id without an icon yields none); (4) if `view.photos`: `PageSection id="impressie" labelledBy="photos-title" tone` with a head (eyebrow, h2 `photos-title`, "Bekijk meer {photosLabel}" link when `portfolioLink`, at least 44 px high, wrapping below the heading on narrow screens) and `PhotoMosaic`; (5) if `view.faq`: `PageSection id="vragen" labelledBy="faq-title" tone` in two columns from `lg` (eyebrow, h2 `faq-title`, `RichParagraph` of the lead | `FaqList`), stacked below; (6) `PageSection id="pakket" labelledBy="offer-title" tone` with `PackageBlock` (`titleId="offer-title"`, `view.offer` data, `note = depositNote`, actions: package variant "Boek dit pakket" (`bookLink`, accent `LinkButton`) + "Eerst een vraag stellen" (`askLink`, underline link); on-request variant one primary button `onRequest.linkLabel` to `bookLink`); (7) `CallToAction` (`titleId="closing-title"`, `tone` = next band tone, rich-text lead via `RichParagraph`, accent `LinkButton` to `closing.link`). `data-testid`s: `shoot-page`, `shoot-breadcrumb`, `story-<id>`, `process-timeline`, `photo-mosaic`, `faq-list`, `package-block`, `shoot-closing`. The portfolio link uses the same `shootPortfolioLink` data from the view. + - Update `ShootPage.test.tsx` (the unit-1 test stays valid; extend it): one h1, h2 per section, h3 per step, no level skipped (heading outline for Newborn with mosaic and FAQ, Loveshoot without mosaic, and a view without FAQ built by clearing `faq` in a copy of the content), every `aria-labelledby` target exists, section anchors `zo-werkt-het`, `impressie`, `vragen`, `pakket` exist when the section does, adjacent bands never share a tone (read from the `PageSection` backgrounds or a `data-tone` attribute added for the test), axe. + - Cross-check once with design E (side by side in a browser if one is available via the `run` skill; otherwise compare the structure by reading it): section order, eyebrows, story photo sizes and side alternation. Note differences in the summary; do not copy design E's bracketed placeholders. + +### Route-level tests + +- [x] **Step 18 — `src/shootPages.test.tsx` (page structure and links)** [sonnet] — *FR-ST-02..09, NFR-ST-01, NFR-ST-06, SEO-ST-04, PBT-10* + - **Result**: `src/shootPages.test.tsx` (23 tests at this step): outline, sections, breadcrumb, `aria-current` in `main` only, offer variants, priority photo, overview links and anchors, one-link-per-shoot facet. + - Depends on: Steps 16, 17. + - New `src/shootPages.test.tsx` using `renderApp` and `expectShell` from `src/test/renderApp.tsx` (copy the `vi.mock` and `beforeEach`/`afterEach` stubs that `app.test.tsx` needs for the same pages; mocks are per test file). Per shoot (`it.each` over `shootTypes`): heading outline (one h1; h2 per section; h3 = six steps), sections present or omitted as the data says (Newborn: mosaic with 3 tiles; Zwangerschap, Gezin, Loveshoot, Portret: no `#impressie`, no mosaic heading; FAQ and process always), the breadcrumb ("Kruimelpad", Home, Soorten fotoshoots, current page with `aria-current="page"`, three items), no `aria-current` anywhere in `main` other than the breadcrumb's last item (see the integration note in Step 26), package variant for Newborn/Zwangerschap/Gezin ("Boek dit pakket" `href` `/contact?pakket=<id>`, price from `formatPrice`) and "Prijs op aanvraag" for Loveshoot/Portret (no price, one primary button, `href` `/contact`), deposit note under the actions in both variants, closing band different tone from the package band, the first story photo is not lazy (priority) and no other photo has `loading="eager"`, axe on each of the five pages. + - Overview page: for every shoot a "Lees meer over de … " link to `/soorten-fotoshoots/<id>` that is first in the row and has a unique accessible name; the `article` anchors (`#newborn` … `#portret`) and the old links are still there (FR-ST-09). + - "Lees meer" facet of the registry consistency (NFR-ST-06, left to this unit by unit 1): for every `ShootTypeId` the overview has exactly one link to `shootPagePath(id)` and no link to any other `/soorten-fotoshoots/…` path. + - The OG facet is added in Step 20, not here. + +### OG wiring (only after the user approved the crops in Step 2) + +- [x] **Step 19 — Wire the OG images into the registry** [haiku] — *SEO-ST-05, BR-SP-80, BR-SP-81, FR-ST-12* + - **Result**: Done after the user approved the crops. Five `ogImage` entries in `sitePages.ts`; `app.test.tsx`: one assertion now reads `sitePages[path].ogImage!.path`. + - **Blocked until the orchestrator confirms the user approved the five crops from Step 2.** Do not start without that confirmation in the hand-over text. + - `src/sitePages.ts`: add to each of the five shoot entries, directly after `indexed: true`, `ogImage: { path: '/og-<id>.jpg', width: 1200, height: 630, alt: '<alt of the source photo, Dutch>' }` (alts as listed in Step 2, as approved). Existing entries and the `PageMeta` type unchanged. + - `src/app.test.tsx` (**not in unit 2's ownership table; one assertion**): the shoot-page head test currently expects `${siteUrl}/og-image.jpg` with the comment "The default image until unit 2 gives the pages their own" (around lines 519–522). Change it to `${siteUrl}${sitePages[path].ogImage!.path}` (or the equivalent that does not hardcode five names) and update the comment. Nothing else in the file; unit 3 does not edit this file (its tests live in `navSubmenu.test.tsx`). + - Run `pnpm exec tsc`, `pnpm lint`, `pnpm exec vitest run src/app.test.tsx src/seo.test.ts src/sitemap.test.ts`. + +- [x] **Step 20 — OG registry consistency test** [sonnet] — *SEO-ST-05, BR-SP-80, FR-ST-12, PBT-10* + - **Result**: OG registry consistency added to `src/shootPages.test.tsx` (file read via `import.meta.dirname`, SOF marker parsed from the bytes). The `og:image` meta facet is covered by the changed `app.test.tsx` assertion (not duplicated). + - Depends on: Step 19. + - In `src/shootPages.test.tsx`: for every `ShootTypeId` (finite set, example-based): `sitePages[shootPagePath(id)].ogImage` is defined, `path` is `/og-<id>.jpg`, width 1200, height 630, alt non-blank, and `web/public/og-<id>.jpg` exists (read with `node:fs`, resolved from the test file location); no two `ogImage.path` values in `sitePages` are equal across the whole registry; the file is a JPEG of 1200 × 630 (read the SOF0/SOF2 marker from the bytes in a small test helper, no image dependency) and at most 150 KB. Also assert the `og:image` meta of each shoot page in the app equals `siteUrl + ogImage.path` (one `renderApp` per shoot, or reuse the facet of `app.test.tsx` if it is enough; do not duplicate it). + +### Documentation + +- [x] **Step 21 — LAYOUT.md and layout conventions** [haiku] — *FR-ST-13, BR-SP-90* + - **Result**: `LAYOUT.md` section and `.ai/layout-conventions.md` updated. Root files are outside `web/`'s `prettier --check .`; a direct check flags LAYOUT.md (not checked for a pre-existing baseline). + - `LAYOUT.md`: new section **"Shoot page"** placed directly after "Types of shoots" (before "Contact"), the `block-beta` diagram from frontend-components.md § 9 (A Intro, B–E Story 1–4, F Process timeline, G Photos, H FAQ, I Package, J Book; style lines A–G as in the template, H `#9b6bb5`/`#745088`, I `#4cc3e0`/`#3992a8`, J `#8cb83f`/`#698a2f`, same `color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px`). Add a one-line note under the diagram that Photos is left out below the minimum number of photos. "Types of shoots", Shell and the other sections stay unchanged. + - `.ai/layout-conventions.md`: append the three `style` lines H, I, J to the template list and change the sentence "extend with a new letter using the same formula if an 8th block is ever needed" to name the ten letters (A–J) ("if an 11th block is ever needed"). No other change. + - Check the new colours: stroke = fill × 0.75 (H 155,107,181 → 116,80,136; I 76,195,224 → 57,146,168; J 140,184,63 → 105,138,47), all three distinct from A–G. Run `pnpm exec prettier --check` on the two files if prettier covers them (repo root files may be outside `web/`; if not, skip). + +### Verification + +- [x] **Step 22 — Unit verification** [haiku] — *NFR-ST-01, NFR-ST-03, NFR-ST-05, NFR-ST-06, NFR-ST-07* + - **Result (all green)**: lint, format:check, tsc clean; `pnpm test` 113 files / 883 tests pass, seed 1191455385, coverage thresholds pass (incl. `isShootSectionPath.ts`); `pnpm build` clean; `audit:deps` passes (seroval@1.7.3 in lockfile), `audit:dev` exit 0 (22 dev advisories, non-blocking by NFR-SEC-05, as on master). `package.json`, lockfile, `securityHeaders.ts`, `routeTree.gen.ts`: no diff. Bundle: `index-C65n6UdK.js` 536.65 kB / 152.56 kB gzip vs unit 1 528.98 / 150.69 (+7.67 kB raw, +1.87 kB gzip; the shoot-nav data now sits in main via unit 3 D5). "Kruimelpad", "Zo werkt het", `process-title`, `faq-title`, `offer-title` only in `-shootPageSources-*.js` (route chunk, not in main); "Uit eerdere newbornshoots" only in `newborn-*.js`. Five OG JPEGs in `dist/` (91-100 KB each). Greps: `dangerouslySetInnerHTML` only in `StructuredData`; the one `console.error` is the pre-existing `ErrorPage.tsx`; no new e-mail/mailto; no placeholders; no hex/rgb in new components; `DRAFT(CON-ST-03)` count 98 (unchanged). + - Depends on: Steps 1–21 (Step 20 only if the user approved the crops; otherwise run it without 19/20 and **run Steps 19, 20 and this step's test, build and bundle items again** after the approval). + - In `web/`, each on its own and all green: `pnpm lint`; `pnpm format:check`; `pnpm exec tsc`; `pnpm test` (coverage thresholds 100 % for `src/lib/**`, `src/seo.ts`, `src/sitemap.ts`; note test count, files and the fast-check seed; the unit-1 baseline is 90 files / 595 tests); `pnpm build`; `pnpm audit:deps` and `pnpm audit:dev` (the branch was fast-forwarded to master 1416497, which contains the seroval patch from PR #12 — lockfile resolves `seroval@1.7.3` — so `audit:deps` must pass; a failure is reported). Lighthouse is Step 23, not part of this step. + - `git diff --exit-code web/pnpm-lock.yaml web/package.json web/config/securityHeaders.ts` (no new dependency, headers unchanged; SECURITY-04/10). `git diff --stat web/src/routeTree.gen.ts` must show no change from unit 2's work (`pnpm exec vite build` regenerates it; no route files added). + - **Bundle check (NFR-ST-03)**: from `web/dist/assets`: main `index-*.js` size and gzip against unit 1's 528.98 kB / 150.69 kB (report the delta; unit 2 should add only `ShootBlock`'s link and `PageIntro`/`MediaText`/`CallToAction` props to shared chunks); the strings "Kruimelpad", "Zo werkt het", "Uit eerdere newbornshoots" and the `aria-labelledby` ids `process-title`/`faq-title`/`offer-title` must **not** appear in `index-*.js`; "Uit eerdere newbornshoots" appears in exactly one chunk (`newborn-*.js`); the new components (`Breadcrumb`, `ProcessTimeline`, `PhotoMosaic`, `FaqList`, `PackageBlock`, `StoryBlocks`) are in route or shared non-main chunks (list the chunk names). The OG JPEGs are in `dist/` (copied from `public/`) and each is ≤ about 100 KB. + - Security and quality greps on `web/src` (outside tests): `dangerouslySetInnerHTML` only in `components/StructuredData/` and the existing pre-feature uses; no `console.`; no e-mail address or `mailto:` in new files; no `[`…`]` design placeholders in any new visible text; no hard-coded colour value (`#`-hex, `rgb(`) in the new components; `rg -n "DRAFT\(CON-ST-03\)" web/src` count unchanged from unit 1's 98 (this unit adds no drafts; if it did, list them). + - If any item fails: diagnose the root cause, fix it (or hand a [sonnet] fix step to the orchestrator), re-run. Do not weaken a test or threshold. + +- [ ] **Step 23 — Lighthouse (mobile and desktop)** [haiku] — *NFR-ST-01, NFR-ST-03, FR-ST-12, SEO-ST-04* + - **Result (2026-10-30), NOT green (left unchecked): open — owner keeps fade-in (2026-10-30). Mobile performance budgets fail on four pages; everything else passes.** Build = Step 22 build with units 1+2+3; `pnpm lighthouse` equivalent (`lhci autorun`, then `lhci autorun --config=lighthouserc.desktop.cjs`, 1 run per URL; the mobile command exits 1 on the assertions, desktop exits 0). Accessibility, best practices 1.0 on all 12 URLs mobile and desktop; SEO 1.0 on all indexed pages (0.58 `/bestaat-niet`, 0.69 `/privacyverklaring` are the expected noindex values). Mobile performance (unit-1 Step 24 in brackets): `/` 0.75 (0.76) FAIL budget 0.8; `/contact` 0.87 (0.85) FAIL budget 0.9; `/over-mij` 0.87; `/portfolio` 0.91; `/soorten-fotoshoots` 0.85; newborn 0.86 (0.90); zwangerschap 0.85 (0.90); gezin 0.84 (0.90) FAIL budget 0.85; loveshoot 0.83 (0.90) FAIL budget 0.85; portret 0.85 (0.90); `/privacyverklaring` 0.90; `/bestaat-niet` 0.92. Re-measure of the two failing shoot pages, 3 runs each: gezin 0.85, 0.85, 0.85 (passes, borderline), loveshoot 0.83, 0.83, 0.83 (fails consistently). Desktop performance 0.99-1.00 on every page (shoot pages 0.99; budget 0.9). `/` and `/contact` fail on master too (0.78 / 0.87). Diagnosis (loveshoot, gezin): the first story photo is not the bottleneck (153 / 117 KB, load time 15-24 ms); LCP is 3.8 / 3.7 s with a render delay of ~2.9-3.0 s, FCP is 2.6 s on every page, i.e. the image is only painted after the main bundle (536 kB, +1.9 kB gzip from unit 3) has run, which matches the `photoPagePaths` comment in `lighthouserc.cjs`; the shoot pages dropped 0.05-0.07 from the shell-only unit-1 numbers because the page now renders the first story through `MediaText`/`Reveal` inside the lazy route chunk. Mitigations for the orchestrator, in the plan's order, none applied: (1) first story without the fade-in (`Reveal` removed for story 0), (2) fewer pixels for the first photo by capping its column, (3) report and keep the known limit. Preview port 4173 released (the lhci server stopped itself; free). + - Depends on: Step 22 green. **Needs the orchestrator's claim of port 4173** (`pnpm preview --port 4173 --strictPort`; `--strictPort` fails fast when taken: then wait, never change the port) and a quiet machine (performance is blocking locally). Do not start without the orchestrator's go. + - In `web/`: `pnpm lighthouse` (runs `lhci autorun` for mobile and then `lhci autorun --config=lighthouserc.desktop.cjs`; indexed pages incl. the five shoot pages). Run it **after Step 19** so the OG images and final markup are measured (if the crops are still unapproved, run now and re-run later). + - Expected: accessibility, best practices and SEO **1.0** on every page, mobile and desktop; the five shoot pages performance ≥ **0.85 mobile** (goal 0.9) and ≥ **0.9 desktop**. Unit 1 left the shoot pages at 0.90 mobile / 100 desktop with the shell only and the baseline failures `/` 0.76 (budget 0.8) and `/contact` 0.85 (budget 0.9) that also fail on master; report current numbers for all pages next to those. + - A performance failure is **reported with the numbers, not worked around**. Mitigation order if the largest paint of a shoot page regressed (frontend-components.md § 7), each as a separate suggested fix for the orchestrator: (1) first story without the fade-in (`Reveal` removed for story 0), (2) fewer pixels for the first photo by capping its column, (3) report and keep the known limit. Record scores in the code summary; release the port claim when done. + +- [x] **Step 24 — Code summary** [haiku] — *traceability, CON-ST-03* + - **Result**: `shoot-page-ui/code/code-summary.md` written, modelled on unit 3's summary. Units 2 and 3 are in commit `7af2069` (see the summary's Commits section); the summary and the Step 25 lines are not committed. Lighthouse is recorded as open. + - Depends on: Steps 22, 23. + - New `aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/code/code-summary.md` (same sections as unit 1's summary): status of each step; files created / changed (one line each, grouped as in "Files" above); requirement and business-rule coverage table (FR-ST-02..09, FR-ST-13, SEO-ST-04/05, NFR-ST-01/02/03/05/06, BR-SP-01..90 → files and tests); test count and seed (Step 22); bundle check numbers (Step 22); Lighthouse scores per page, mobile and desktop (Step 23); the OG images (sources, crops, sizes, approval date and who approved); deviations from this plan with reasons (the `app.test.tsx` assertion, the Gezin OG source, anything else); comparison notes against design E (Step 17); interfaces left for the orchestrator; open items (case-sensitive routing and the seroval advisory remain unit-1 decisions; whole-page `aria-current` integration facet, Step 26); the final Security and PBT compliance table below with evidence. State plainly that nothing is committed. + +- [x] **Step 25 — Reverse-engineering lines (unit 2's own)** [haiku] — *NFR-ST-07* + - **Result**: unit 2's lines added by targeted edits in `code-structure.md`, `api-documentation.md` and `architecture.md` (the StatusPage/NotFound and `isShootSectionPath` lines included); unit 1 and unit 3 lines untouched apart from the `ShootPage` line that unit 2 changes. No timestamp refresh. + - Only this unit's lines in `aidlc-docs/_shared/reverse-engineering/`, added with targeted edits next to unit 1's lines (never rewrite or re-flow a file: unit 3's lines go into the same files, so re-read the file immediately before editing and edit by unique anchor text; if it changed unexpectedly in the last minutes, tell the orchestrator instead of guessing): + - `code-structure.md`: `components/{Breadcrumb,ProcessTimeline,PhotoMosaic,FaqList,PackageBlock}/`, `components/shoots/{StoryBlocks,ProcessIcons}/`, the changed `ShootPage` line (sections instead of the shell), the `ShootBlock` link, the additive `PageIntro`/`MediaText`/`CallToAction` props, `lib/{headingId,readMoreLabel,mosaicLayout,storyLayout,shootPageBands}.ts`, `src/shootPages.test.tsx`, `public/og-<id>.jpg` ×5. + - `api-documentation.md`: lib section bullets for the five new helpers; the five shoot route rows now mention the sections and the `ogImage` per page (one short phrase each). + - `architecture.md`: one line on the shoot page composition (`shootPageBands` → sections) next to unit 1's Outlet line; no diagram restructure. + - No timestamp refresh. **Note**: the application design says the orchestrator writes both units' lines after both are done; this step follows the instruction for this plan (unit 2 writes its own lines). If the orchestrator prefers to write them, hand the lines over instead via the code summary and skip the edit. + +- [x] **Step 26 — Integration facet after unit 3 (orchestrator, conditional)** [sonnet] — *BR-SP-03, NFR-ST-01, NFR-ST-06* + - **Result**: one `it.each` test per shoot added to `src/shootPages.test.tsx` (5 tests; file now 34 tests). Decision recorded (unit 3's final markup): the mobile menu (`#mobile-nav`) is a sibling of the `header`, not inside it, and both menus carry the shoot's own link as current, so the whole page has exactly three `aria-current="page"` elements: the breadcrumb's last item (main), the header submenu link and the mobile-menu sub-link (both `href` = the shoot path; only one of the two menus is shown at a time). The rule is therefore "exactly one in main, exactly one in each menu, none in the footer, the parent 'Soorten fotoshoots' links (header and mobile menu) and the footer link never current". Full suite after the change: lint, format:check clean; 113 files / 888 tests pass, seed 1757660570. Record the decision in the code summary (Step 24). + - **Run only when unit 3 is built in the same worktree.** Currently the header link "Soorten fotoshoots" and the footer link receive TanStack's fuzzy `aria-current="page"` on a shoot page (unit 3 fixes both, application-design D4), so a **whole-page** "exactly one `aria-current="page"`" assertion cannot pass in unit 2 alone; Step 18 therefore checks `main` only. + - Add to `src/shootPages.test.tsx` (unit 2's file) one test per shoot: in the whole document exactly one element has `aria-current="page"` **and** it is the breadcrumb's last item or the nav's exact-page child (decide with unit 3's final markup; the intended rule is "only the exact page", D4), then re-run the unit's tests. If both header submenu child and breadcrumb mark the same page, the rule is "at most one in `main` and at most one in `header`", not one overall; record the decision in the code summary. + +- [x] **Step 27 — Hand back** [haiku] + - Result (2026-10-30): done by the orchestrator. The user authorised commit, push and test deploy during this stage: units 2 and 3 with FR-ST-14 are commit 7af2069, deployed to test by CI run 586. Step 23 stays open (owner keeps the fade-in). + - Report to the orchestrator: steps done and still blocked (Step 2 waits for the user's approval of the crops; Steps 19, 20 follow; Step 23 waits for the port claim; Step 26 waits for unit 3), check results, deviations from this plan, the changed shared components list, and the list of files outside unit 2's ownership that were touched (`src/app.test.tsx` one assertion). **No commit or push**; the orchestrator asks the user. A commit for the unit ("a commit per unit") is made only when the user asks. + +## Requirement / business-rule traceability + +| Requirement | Business rules | Steps | +|---|---|---| +| FR-ST-02 Intro with breadcrumb | BR-SP-01..05 | 8, 9, 17, 18 | +| FR-ST-03 Story blocks | BR-SP-10..14, 40, 41 | 6, 8, 15, 17, 18 | +| FR-ST-04 Process timeline | BR-SP-20..26 | 10, 11, 17, 18 | +| FR-ST-05 Photo mosaic | BR-SP-30a..35 | 5, 12, 17, 18 | +| FR-ST-06 FAQ | BR-SP-50..53 | 13, 17, 18 | +| FR-ST-07 Package block | BR-SP-60..62 | 14, 17, 18 | +| FR-ST-08 Closing call to action | BR-SP-63 | 8, 17, 18 | +| FR-ST-09 Overview links | BR-SP-64 | 4, 16, 18 | +| FR-ST-13 LAYOUT.md | BR-SP-90 | 21 | +| SEO-ST-04 Semantic structure | BR-SP-71, 72, 73 | 4, 7, 15, 17, 18 | +| SEO-ST-05 Preview image | BR-SP-80, 81 | 2, 19, 20 | +| NFR-ST-01 Accessibility | BR-SP-03, 20..25, 50..52 | 8–18, 22, 23 | +| NFR-ST-02 Reuse, responsive | all components | 8–17 | +| NFR-ST-03 Performance | BR-SP-40..42 | 15, 17, 22, 23 | +| NFR-ST-05 Security | BR-SP-72, 74 | 4, 9–17, 22 | +| NFR-ST-06 Testing | PBT list (business-rules.md § 3) | 3–7, 9–18, 20, 22 | +| NFR-ST-07 Coordination | file ownership | all, 25 | + +## Extension Compliance (unit 2, planning) + +### Security Baseline +| Rule | Status | Rationale | +|---|---|---| +| SECURITY-04 HTTP headers | Compliant (planned) | `securityHeaders.ts` untouched (Step 22 diff); no inline script or event handler; native `details` needs no JavaScript | +| SECURITY-05 Input validation | Compliant (planned) | No input added; ids in markup go through `headingId` (Step 4); link targets are typed routes or come from `shootContactLink`/`shootPagePath` | +| SECURITY-09 Hardening | Compliant (planned) | No debug output, no sample content, no bracketed placeholders (Step 22 greps); OG crops are real photos from the site's own assets | +| SECURITY-10 Supply chain | Compliant (planned) | No dependency added to `web/`; cropping uses a script outside the repository (Step 2); lockfile and `package.json` unchanged (Step 22) | +| SECURITY-11 Secure design | Compliant (planned) | Content is text and typed router links (`RichParagraph`); no `dangerouslySetInnerHTML`; no e-mail address (Step 22 greps) | +| SECURITY-13 Integrity | Compliant (planned) | Only bundled photos and `public/` OG images; no CDN or embed | +| SECURITY-15 Fail-safe | Compliant (planned) | Every component omits itself on empty input; `headingId` safe for any string; fewer photos than the minimum means no mosaic (Steps 4–17) | +| SECURITY-01, -02, -03, -06, -07, -08, -12, -14 | N/A | No data stores, intermediaries, server code, IAM, network, auth or alerting | + +### Property-Based Testing +| Rule | Status | Rationale | +|---|---|---| +| PBT-01 Identification | Compliant | The properties of business-rules.md § 3 are each mapped to a step (4–7, 9, 11, 12, 13) | +| PBT-02 Round trip | N/A | No parse/serialise or encode/decode pair is added | +| PBT-03 Invariants | Planned | `headingId`, `readMoreLabel`, `mosaicLayout`, `storyLayout`, `shootPageBands` (Steps 4–7) and four component properties (Steps 9, 11, 12, 13) | +| PBT-04 Idempotency | N/A | No operation with an idempotency contract is added | +| PBT-05 Oracle | N/A | No reference implementation | +| PBT-06 Stateful | N/A | No application state: FAQ state belongs to the browser, timeline and mosaic are stateless | +| PBT-07 Generators | Planned | Four generators appended in Step 3; unit 1's generators reused | +| PBT-08 Shrinking and reproducibility | Compliant | fast-check shrinking and seed logging untouched; seed reported in Step 22 | +| PBT-09 Framework | Compliant | fast-check already a dependency | +| PBT-10 Complementary | Planned | Example tests per helper and component, route-level tests (Steps 18, 20), axe everywhere; PBT tests labelled "(invariant)" | diff --git a/aidlc-docs/features/shoot-type-pages/construction/plans/shoot-page-ui-fd-questions.md b/aidlc-docs/features/shoot-type-pages/construction/plans/shoot-page-ui-fd-questions.md new file mode 100644 index 0000000..ea1d79b --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/plans/shoot-page-ui-fd-questions.md @@ -0,0 +1,84 @@ +# Vragen Functional Design - Unit 2 "Shoot page UI" + +Feature: shoot-type-pages. Hoort bij [shoot-page-ui-functional-design-plan.md](shoot-page-ui-functional-design-plan.md). + +Dit zijn alleen de keuzes over uiterlijk en gedrag van de shootpagina's die echt van jou zijn. Technische details (breakpoints, rastermaten, laadvolgorde van foto's, toegankelijkheid) heb ik zelf besloten en in het ontwerp vastgelegd. Bij elke vraag staat mijn aanbeveling als eerste optie. De ontwerpdocumenten zijn al geschreven op basis van die aanbevelingen en staan als **voorlopig** gemarkeerd; ze worden aangepast als je anders kiest. + +Vul je keuze in na de `[Answer]:`-tag. + +## Vraag 1 +Zwangerschap en Gezin hebben nu elk maar twee portfolio-foto's, en die staan in verhaalblok 2 en 3. Een foto mag maar één keer op een pagina staan, dus er blijven geen foto's over voor de "Impressie"-mozaïek: die wordt weggelaten en blok 4 is alleen tekst. Wat wil je zolang Andrea geen extra foto's levert? + +- A) Laat de twee foto's in blok 2 en 3 staan; geen "Impressie" tot er meer foto's zijn (aanbevolen: de pagina behoudt het ritme van afwisselend foto en tekst, en dit is ook wat Andrea in haar beoordelingsdocument is voorgelegd) +- B) Zet de twee foto's in de "Impressie"-mozaïek; blok 2, 3 en 4 worden dan alleen tekst (alleen blok 1 houdt een foto). De mozaïek toont dan twee grote vierkante foto's naast elkaar. +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 2 +Vanaf hoeveel foto's (die niet al elders op de pagina staan) tonen we de "Impressie"-sectie? Newborn heeft nu 3 foto's voor de mozaïek, de andere vier pagina's nu 0 of 2 (zie vraag 1). + +- A) Vanaf 2 foto's (aanbevolen: één foto alleen oogt als een verdwaalde afbeelding, maar met twee ziet het er nog als een bewuste compositie uit) +- B) Vanaf 3 foto's (Newborn houdt de mozaïek; een mozaïek van twee foto's verschijnt niet) +- C) Alleen met 4 foto's, de volledige compositie van het ontwerp (Newborn zou de mozaïek dan kwijtraken tot Andrea één extra foto levert) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 3 +Wat gebeurt er als een bezoeker op een foto in de "Impressie"-mozaïek tikt of klikt? + +- A) Niets: de mozaïek is een impressie, geen galerij; wie meer wil zien gebruikt de link "Bekijk meer …foto's" naast de titel (aanbevolen: eenvoudig en snel; die link bestaat al voor Newborn en verschijnt bij de andere shoots zodra er portfolio-foto's zijn) +- B) De foto opent vergroot in de bestaande lightbox van het portfolio (extra werk: er is dan per foto ook een grote versie nodig en de pagina laadt meer code) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 4 +Loveshoot en Portret hebben nu maar één foto in de verhaalblokken, dus blok 2, 3 en 4 zijn daar alleen tekst (drie tekstblokken onder elkaar). Hoe moeten blokken zonder foto eruitzien? + +- A) Elk blok blijft een eigen horizontale band (afwisselend papier en lichtere achtergrond) met een gecentreerde, smalle tekstkolom en zonder lege fotoplek (aanbevolen: voorspelbaar, dezelfde structuur als blokken met foto, en de pagina wordt vanzelf mooier zodra er foto's bijkomen) +- B) Opeenvolgende blokken zonder foto worden samengevoegd tot één band waarin de teksten naast elkaar in kolommen staan (kortere pagina, maar de rij blokken ziet er anders uit dan de rest en de kolommen worden smal op tablets) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 5 +Bij "Veelgestelde vragen" kan elke vraag open- en dichtklappen. Welke staan open als de pagina laadt? (De antwoorden staan altijd in de pagina, ook als ze dicht zijn; dit gaat alleen om wat je direct ziet.) + +- A) De eerste twee staan open, de rest is dicht (aanbevolen: dit is zoals in het gekozen ontwerp E; het laat zien dat je kunt uitklappen en toont meteen de belangrijkste antwoorden) +- B) Alleen de eerste staat open +- C) Alles is dicht (kortste lijst, maar bezoekers zien geen enkel antwoord zonder te klikken) +- D) Alles staat open +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: C + +## Vraag 6 +Op de overzichtspagina "Soorten fotoshoots" komt per shoot een link naar de nieuwe pagina, bijvoorbeeld "Lees meer over de newbornshoot". Hoe moet die eruitzien? + +- A) Een gewone onderstreepte tekstlink in dezelfde stijl als "Stuur een berichtje" en "Bekijk meer …foto's", als eerste in de rij (aanbevolen: de pagina blijft rustig en de nieuwe pagina's worden toch als eerste vervolgstap aangeboden) +- B) Een knop met rand (zoals de knoppen elders op de site) onder de tekst, met de twee bestaande tekstlinks eronder (valt meer op en levert waarschijnlijk meer bezoek aan de nieuwe pagina's, maar maakt de overzichtspagina drukker) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 7 +Elke shootpagina krijgt een eigen voorbeeldafbeelding (1200 x 630) voor als de link wordt gedeeld, bijvoorbeeld in WhatsApp of op Facebook. Hoe moet die eruitzien? Bij A laat ik je de vijf uitsneden zien voordat ze definitief worden. + +- A) Een liggende uitsnede uit een foto van de shoot, zoals de bestaande voorbeeldafbeeldingen van de andere pagina's (aanbevolen: sluit aan bij de rest van de site; bij Loveshoot en Portret is er alleen een staande foto, dus die uitsnede is iets minder scherp) +- B) Een samengestelde afbeelding: de foto links en rechts op een papierkleurig vlak de naam van de shoot (past goed bij staande foto's, maar is een nieuwe stijl die er nog niet is) +- C) Voor alle vijf de pagina's de bestaande standaardafbeelding van de site (geen extra werk, maar alle gedeelde links zien er hetzelfde uit) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Question 8 +Afwijking van de Application Design: twee gedeelde componenten krijgen een kleine, optionele uitbreiding (bestaande pagina's veranderen niet): +`MediaText` krijgt `mediaSize="medium"` (fotokolom tot 30rem, zoals in design E), en `CallToAction` een optionele `tone`, zodat de afsluitende balk op de lichte achtergrond kan staan naast het pakketblok op de donkerdere band. + +- A) Ja, beide optionele uitbreidingen toevoegen (aanbevolen) +- B) Nee, de componenten ongewijzigd laten; de shootpagina gebruikt de bestaande maten en de afsluitende balk blijft op de donkerdere achtergrond (dan wijkt de pagina iets af van design E) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A diff --git a/aidlc-docs/features/shoot-type-pages/construction/plans/shoot-page-ui-functional-design-plan.md b/aidlc-docs/features/shoot-type-pages/construction/plans/shoot-page-ui-functional-design-plan.md new file mode 100644 index 0000000..bfb1fde --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/plans/shoot-page-ui-functional-design-plan.md @@ -0,0 +1,23 @@ +# Functional Design Plan - Unit 2: Shoot page UI + +Feature: shoot-type-pages. Unit: 2 "Shoot page UI" (units/files: see [application-design.md](../../inception/application-design/application-design.md) § File ownership per unit). Questions: [shoot-page-ui-fd-questions.md](shoot-page-ui-fd-questions.md). Artifacts: [functional-design/](../shoot-page-ui/functional-design/). + +Status: **final**. Answers collected 2026-10-30 (recorded in the question file); the artifacts are finalised on those answers. + +## Steps + +- [x] Step 1: Analyse unit context (unit 2 rows of the file ownership table, items handed to Functional Design, unit 1 code summary and interfaces, design E and D, photo analysis in andrea-review.md, real code of the shared components and theme) +- [x] Step 2: Create this plan +- [x] Step 3: Generate context-appropriate questions (7 questions on look and behaviour; technical details decided and documented) +- [x] Step 3b: Validate the question file against the question format guide (multiple choice A/B/..., last option X, `[Answer]:` tag per question, options as list items) +- [x] Step 4: Store plan and question file +- [x] Step 5: Notify the user (the orchestrator relays the process notification) +- [x] Step 6: Collect and analyse the answers (check for contradictions, e.g. Q1 = B together with Q2 = C; add clarification questions if needed) +- [x] Step 7a: `business-logic-model.md` (page assembly, story, timeline, mosaic, FAQ, package, link and image-loading flows; pure functions) - provisional +- [x] Step 7b: `business-rules.md` (numbered rules with decision flowcharts, testable properties, Security Baseline and PBT compliance) - provisional +- [x] Step 7c: `domain-entities.md` (entity relationships, UI-level entities, constants, registry and OG data) - provisional +- [x] Step 7d: `frontend-components.md` (component hierarchy, props and state, interaction flows, responsive behaviour, a11y, Lighthouse, LAYOUT.md diagram and letter colours) - provisional +- [x] Step 7e: Revise the four artifacts for the answers and remove the "provisional" marking +- [x] Step 8: Present the completion message (in Dutch, the conversation language) +- [x] Step 9: Wait for explicit approval of the functional design +- [x] Step 10: Record the approval in audit.md and mark Functional Design (unit 2) complete in aidlc-state.md diff --git a/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/code/code-summary.md b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/code/code-summary.md new file mode 100644 index 0000000..26d938f --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/code/code-summary.md @@ -0,0 +1,229 @@ +# Code Summary — Unit 2: Shoot page UI + +Plan: [shoot-page-ui-code-generation-plan.md](../../plans/shoot-page-ui-code-generation-plan.md). Branch `feature/shoot-type-pages`, worktree `AndreaSlopFotografie-shoot-type-pages`. Unit 1 is the content and SEO foundation (commit `e5f4348`). Unit 3 (navigation submenu) is built in the same worktree and is described in [navigation-submenu/code/code-summary.md](../../navigation-submenu/code/code-summary.md); its files are not described here. + +## Status +- Steps 1–22 and 26 done (checked in the plan), except Step 23, which is open. Step 1 made no edits. The owner approved the five OG crops on 2026-10-30 (audit log, 12:49 UTC); Steps 19 and 20 followed that approval. +- Step 23 (Lighthouse): **open**, a known item, see [Lighthouse](#lighthouse-step-23--open). Desktop passes everywhere; mobile performance misses the budget on the loveshoot page (0.83) and the gezin page (0.84, then 0.85 on three re-runs). The owner decided on 2026-10-30 to keep the first-story fade-in for now (`open — owner keeps fade-in (2026-10-30)`). +- Step 24 (this summary) and Step 25 (reverse-engineering lines) done. Step 27 (hand-back) is the orchestrator's. +- Gates (Step 22): lint, format:check, `tsc` and `pnpm build` clean; `audit:deps` clean (`seroval@1.7.3`); `audit:dev` exit 0 (22 dev advisories, non-blocking under NFR-SEC-05, as on master). `pnpm test`: 113 files, 883 tests, seed 1191455385, coverage thresholds pass (100 % for `src/lib/**`). +- After Step 26 (the `aria-current` facet): 113 files, 888 tests, seed 1757660570, lint and format:check clean. + +## Commits +- Units 2 and 3 with FR-ST-14 are in commit `7af2069` ("Adds the shoot page layout and the shoot-type submenu") on `feature/shoot-type-pages`, after unit 1's `e5f4348`. The audit log records the push and the test deploy (CI run 586: check and deploy-test green). +- This summary and the reverse-engineering edits of Step 25 are **not committed**. A further commit is made only when the user asks. + +## Files + +### Created (unit 2) +- Components (each with a `.test.tsx`): + - `web/src/components/Breadcrumb/Breadcrumb.tsx`: "Kruimelpad" nav with the current page as `aria-current="page"` + - `web/src/components/ProcessTimeline/ProcessTimeline.tsx`: "Zo werkt het" ordered list, alternating text above and below the line from `lg` + - `web/src/components/PhotoMosaic/PhotoMosaic.tsx`: photo grid, up to four tiles, not interactive + - `web/src/components/FaqList/FaqList.tsx`: native `details`/`summary` list, all items closed at load + - `web/src/components/PackageBlock/PackageBlock.tsx`: package block (price and features) or the on-request variant + - `web/src/components/shoots/StoryBlocks/StoryBlocks.tsx`: one `PageSection` per story + - `web/src/components/shoots/ProcessIcons/ProcessIcons.tsx`: the six process icons as inline SVG +- Lib (each with a `.test.ts`, 100 % coverage): + - `web/src/lib/headingId.ts`: safe id from prefix and id (BR-SP-72) + - `web/src/lib/readMoreLabel.ts`: "Lees meer over de …" label per shoot + - `web/src/lib/mosaicLayout.ts`: tile positions for 0–4 photos (`MOSAIC_MAX_PHOTOS = 4`) + - `web/src/lib/storyLayout.ts`: tone, spacing, side and media ratio per story (1.2 threshold) + - `web/src/lib/shootPageBands.ts`: the section order of the page (`SectionBand`) + - `web/src/lib/isShootSectionPath.ts`: pathname under `/soorten-fotoshoots/` (FR-ST-14); its test is property-based +- Route test: `web/src/shootPages.test.tsx` (34 tests): outline, sections, breadcrumb, `aria-current`, package variants, priority photo, overview links, OG registry, axe on the five pages +- Assets: `web/public/og-newborn.jpg`, `og-zwangerschap.jpg`, `og-gezin.jpg`, `og-loveshoot.jpg`, `og-portret.jpg` (see [OG images](#og-images)) + +### Modified (unit 2) +- `web/src/components/PageIntro/PageIntro.tsx` (+ test): optional `titleId` (the section's `aria-labelledby`) and `breadcrumb`; callers without them render unchanged +- `web/src/components/MediaText/MediaText.tsx` (+ test): `mediaSize` accepts `'medium'` (photo column up to 30rem) +- `web/src/components/CallToAction/CallToAction.tsx` (+ test): optional `tone` (default `alt`, so the overview is unchanged) +- `web/src/components/shoots/ShootPage/ShootPage.tsx` (+ test): the sections in `shootPageBands` order; wrapper `data-testid="shoot-page"`; no content imports, no state +- `web/src/components/shoots/ShootBlock/ShootBlock.tsx` (+ test) and `ShootList.test.tsx`: "Lees meer over de …" link first in the row, to `/soorten-fotoshoots/<id>` +- `web/src/components/StatusPage/NotFound.tsx` (+ `StatusPage.test.tsx`): under `/soorten-fotoshoots/` two buttons, "Terug naar Soorten fotoshoots" and "Terug naar home" (FR-ST-14, decided by `isShootSectionPath`) +- `web/src/sitePages.ts`: an `ogImage` on each of the five shoot entries (`path`, 1200 × 630, Dutch `alt`) +- `web/src/app.test.tsx`: one assertion now reads `sitePages[path].ogImage!.path` for the shoot page `og:image` (file outside unit 2's table, approved in the plan) +- `web/src/test/arbitraries.ts`: appended only: one import line (`shootPageView`) and four generators (`imageWithOrientation`, `mosaicCount`, `timelineSteps`, `shootPageViewArb`) +- `LAYOUT.md`: section "Shoot page" after "Types of shoots" (Step 21, FR-ST-13) +- `.ai/layout-conventions.md`: template colours for blocks H, I, J; "ten letters (A–J)" + +### Not touched by unit 2 +Content modules (`web/src/content/*`), route files (`routes/soorten-fotoshoots/*`), `routeTree.gen.ts` (no diff after the build), `config/securityHeaders.ts`, `package.json`, `pnpm-lock.yaml`, `theme.ts`, and unit 3's files (`navigation.ts`, `NavigationBar/*`, `Footer/*`, `hooks/*`, `lib/navMenuState.ts`, `lib/shootNavItems.ts`, `lib/navCurrent.ts`, `navSubmenu.test.tsx`). + +## Interfaces +- `shootPageBands(view: ShootPageView): SectionBand[]` (`lib/shootPageBands.ts`): `SectionBand { id, tone, position }`; ids `story-<id>`, `process`, `photos`, `faq`, `offer`, `closing` +- `storyLayout(stories): StoryLayout[]` (`tone`, `spacing`, `reverse`, `priority`, `media?`) +- `mosaicLayout(count): MosaicTile[]` (`column`, `row`, `wide`, `phoneRatio`); `MOSAIC_MAX_PHOTOS = 4` +- `headingId(prefix, id): string`; `readMoreLabel(shoot): string`; `isShootSectionPath(pathname): boolean` +- Component props: + - `Breadcrumb({ label, items, data-testid? })` + - `ProcessTimeline({ steps: { id, title, text, icon? }[], tone?, data-testid? })` + - `PhotoMosaic({ images, data-testid? })` + - `FaqList({ items, data-testid? })` + - `PackageBlock({ titleId, eyebrow, title, image, frameColor?, pkg?, onRequest: { price, text }, note?, children, data-testid? })` + - `StoryBlocks({ stories, frameColor, idPrefix })` + - `ProcessIcons`: `processIcons: Record<ProcessStepId, () => JSX.Element>` + - `PageIntro` (+ `titleId?`, `breadcrumb?`), `MediaText` (`mediaSize: 'medium'`), `CallToAction` (+ `tone?`) + - `ShootPage({ view })`: unchanged +- Registry: `sitePages[shootPagePath(id)].ogImage = { path: '/og-<id>.jpg', width: 1200, height: 630, alt }` +- Test ids for the orchestrator and the browser checks: `shoot-page`, `shoot-breadcrumb`, `story-<id>`, `process-timeline`, `photo-mosaic`, `faq-list`, `package-block`, `shoot-closing`, `shoot-<id>-readmore` (overview), `status-page-section-link` and `status-page-home-link` (NotFound) + +## Requirement and business-rule coverage +| Requirement / rule | Where | Tests | +|---|---|---| +| FR-ST-02 Intro with breadcrumb | `PageIntro` (`titleId`, `breadcrumb`), `Breadcrumb.tsx`, `ShootPage.tsx` | `Breadcrumb.test.tsx` (PBT), `PageIntro.test.tsx`, `ShootPage.test.tsx`, `shootPages.test.tsx` | +| FR-ST-03 Story blocks | `StoryBlocks.tsx`, `storyLayout.ts`, `MediaText` (`medium`) | `StoryBlocks.test.tsx`, `storyLayout.test.ts` (PBT), `MediaText.test.tsx`, `shootPages.test.tsx` | +| FR-ST-04 Process timeline | `ProcessTimeline.tsx`, `ProcessIcons.tsx` | `ProcessTimeline.test.tsx` (PBT), `ProcessIcons.test.tsx`, `shootPages.test.tsx` | +| FR-ST-05 Photo mosaic | `PhotoMosaic.tsx`, `mosaicLayout.ts` | `PhotoMosaic.test.tsx` (PBT), `mosaicLayout.test.ts` (PBT), `shootPages.test.tsx` (3 tiles on Newborn, none elsewhere) | +| FR-ST-06 FAQ | `FaqList.tsx` | `FaqList.test.tsx` (PBT, keyboard via click), `shootPages.test.tsx` | +| FR-ST-07 Package block | `PackageBlock.tsx`, `ShootPage.tsx` (variant by `view.offer.pkg`) | `PackageBlock.test.tsx`, `shootPages.test.tsx` (price and on-request variants) | +| FR-ST-08 Closing call to action | `CallToAction.tsx` (`tone`), `ShootPage.tsx` | `CallToAction.test.tsx`, `shootPages.test.tsx` (tone differs from the package band) | +| FR-ST-09 Overview "Lees meer" | `ShootBlock.tsx`, `readMoreLabel.ts` | `readMoreLabel.test.ts` (PBT), `ShootBlock.test.tsx`, `ShootList.test.tsx`, `shootPages.test.tsx` (one link per shoot) | +| FR-ST-13 LAYOUT.md | `LAYOUT.md`, `.ai/layout-conventions.md` | documentation only, no automated test | +| FR-ST-14 404 under the section (added in the build, not in the plan) | `StatusPage/NotFound.tsx`, `lib/isShootSectionPath.ts` | `isShootSectionPath.test.ts` (PBT), `StatusPage.test.tsx` | +| SEO-ST-04 Semantic structure | `headingId.ts`, `ShootPage.tsx` (one h1, one h2 per section, h3 per step, `aria-labelledby`) | `headingId.test.ts` (PBT), `ShootPage.test.tsx`, `shootPages.test.tsx` (outline) | +| SEO-ST-05 Preview image | `sitePages.ts` (`ogImage`), `web/public/og-<id>.jpg` | `shootPages.test.tsx` (OG registry, `og:image` per shoot), `app.test.tsx` | +| NFR-ST-01 Accessibility | disclosure and nav patterns, 44 px targets, visible focus, reduced motion (`Reveal`), exact `aria-current` | axe in every component test and on the five pages (`shootPages.test.tsx`); keyboard tests in `FaqList` and `Breadcrumb`; Lighthouse accessibility 1.0 on all pages | +| NFR-ST-02 Reuse and responsive | shared blocks (`PageSection`, `MediaText`, `CallToAction`, `RichParagraph`, `Eyebrow`, `SectionHeading`, `FramedImage`, `DeferredImage`, `Reveal`, `LinkButton`) | component tests at phone and `lg` props | +| NFR-ST-03 Performance | `StoryBlocks` (only story 0 is priority), `PhotoMosaic` and the other photos via `DeferredImage`, code splitting by route | `shootPages.test.tsx` (priority photo not lazy, others not eager); Step 22 bundle check; Lighthouse (open, see below) | +| NFR-ST-05 Security | `headingId` (BR-SP-72), typed router links, no `dangerouslySetInnerHTML` | `headingId.test.ts` (hostile strings), grep checks in Step 22 | +| NFR-ST-06 Testing (PBT + examples) | PBT list in [business-rules.md § 3](../../shoot-page-ui/functional-design/business-rules.md); generators in `test/arbitraries.ts` | see Test results | +| NFR-ST-07 Coordination | ownership table, no edits outside unit 2 except `app.test.tsx` (one assertion) | Step 22 `git status` and diff checks | +| BR-SP-01, 02, 04 Breadcrumb items, separators, empty and one-item cases | `Breadcrumb.tsx` | `Breadcrumb.test.tsx` (PBT: 1–5 items) | +| BR-SP-03 Exact matching, 44 px, underline | `Breadcrumb.tsx` (`activeOptions={{ exact: true }}`) | `Breadcrumb.test.tsx`, `shootPages.test.tsx` (aria-current facet) | +| BR-SP-05 `PageIntro` props | `PageIntro.tsx` | `PageIntro.test.tsx` (existing markup unchanged) | +| BR-SP-10, 13 Story sections, text-only stories | `StoryBlocks.tsx` (Q4 = A: no frame, column of at most 36rem) | `StoryBlocks.test.tsx` (Newborn and Loveshoot) | +| BR-SP-11, 12, 14 Tone, side, ratio, priority | `storyLayout.ts`, `shootPageBands.ts`, `MediaText.tsx` | `storyLayout.test.ts` (PBT, boundaries 1.19 and 1.2), `shootPageBands.test.ts` (PBT) | +| BR-SP-20–26 Timeline structure, layout, line, markers, motion, any count | `ProcessTimeline.tsx` | `ProcessTimeline.test.tsx` (PBT: 1–8 steps; zero steps; last marker filled) | +| BR-SP-30a Minimum two photos | `shootPageView` (unit 1), `ShootPage.tsx` | `shootPages.test.tsx` (Zwangerschap, Gezin, Loveshoot, Portret have no mosaic) | +| BR-SP-30b, 31, 35 Maximum four photos, layouts, phone ratios | `PhotoMosaic.tsx`, `mosaicLayout.ts` | `mosaicLayout.test.ts` (PBT: disjoint cells, full 4 × 2 grid for 2–4), `PhotoMosaic.test.tsx` (PBT) | +| BR-SP-32, 33 Object fit, no interaction | `PhotoMosaic.tsx` | `PhotoMosaic.test.tsx` (no `a` or `button`) | +| BR-SP-34 Section head and portfolio link | `ShootPage.tsx` | `ShootPage.test.tsx`, `shootPages.test.tsx` | +| BR-SP-40, 41 Priority photo and deferred others | `StoryBlocks.tsx`, `PhotoMosaic.tsx` (`DeferredImage`) | `StoryBlocks.test.tsx`, `shootPages.test.tsx` | +| BR-SP-42 Bundled photos only | content imports, `public/` OG files | Step 22 grep (no remote image) | +| BR-SP-50–53 FAQ closed at load, summary, answers in the DOM | `FaqList.tsx` (no `open`, no state) | `FaqList.test.tsx` (PBT: 0–6 items, no `open`), keyboard test | +| BR-SP-60–62 Package variant, deposit note, image | `PackageBlock.tsx`, `ShootPage.tsx` | `PackageBlock.test.tsx`, `shootPages.test.tsx` | +| BR-SP-63 Closing band tone | `CallToAction.tsx`, `ShootPage.tsx` | `CallToAction.test.tsx`, `shootPages.test.tsx` | +| BR-SP-64 Overview link | `ShootBlock.tsx`, `readMoreLabel.ts` | `ShootBlock.test.tsx`, `ShootList.test.tsx`, `shootPages.test.tsx` | +| BR-SP-70 Page order and alternating tones | `shootPageBands.ts`, `ShootPage.tsx` | `shootPageBands.test.ts` (PBT), `ShootPage.test.tsx` (no equal adjacent tones) | +| BR-SP-71, 73 Heading outline, section anchors | `ShootPage.tsx`, `PageSection` (`id`) | `ShootPage.test.tsx`, `shootPages.test.tsx` (anchors `zo-werkt-het`, `impressie`, `vragen`, `pakket`) | +| BR-SP-72 Safe ids | `headingId.ts` | `headingId.test.ts` (PBT, hostile strings) | +| BR-SP-74 Props only, no content imports, fail-safe | every component | each component test (empty input omits the part) | +| BR-SP-80, 81 OG images and alt | `sitePages.ts`, `web/public/og-<id>.jpg` | `shootPages.test.tsx` (path, size, file, SOF marker, at most 150 KB, unique paths), `app.test.tsx` | +| BR-SP-90 LAYOUT.md section | `LAYOUT.md`, `.ai/layout-conventions.md` | documentation (Step 21), no test | + +## Test results +- Step 22 (before the Step 26 facet): `pnpm test` 113 files, 883 tests, all pass; seed 1191455385; coverage thresholds pass. +- Step 26 (after the `aria-current` facet): 113 files, 888 tests, all pass; seed 1757660570. Lint and format:check clean. +- `src/shootPages.test.tsx`: 34 tests at the end of the unit (23 at Step 18, plus the OG registry tests of Step 20 and the five `aria-current` tests of Step 26). +- Fast-check seed from `config/testSeed.ts`, logged each run; shrinking untouched. +- No new test helper beyond the generators appended to `test/arbitraries.ts`. + +## Bundle check (Step 22, NFR-ST-03) +- Main chunk `index-C65n6UdK.js`: 536.65 kB raw / 152.56 kB gzip. Unit 1 baseline: 528.98 kB / 150.69 kB. Delta: +7.67 kB raw, **+1.87 kB gzip** (unit 3's `shootTypes` data is in this delta, see its summary; unit 2's shared-component changes are small). +- The strings "Kruimelpad", "Zo werkt het", `process-title`, `faq-title` and `offer-title` are in the route chunk `-shootPageSources-*.js` only, not in the main chunk. "Uit eerdere newbornshoots" is in `newborn-*.js` only. +- The five OG JPEGs are in `dist/` (copied from `public/`), 88.9–97.6 KB each as listed in the worktree. +- `routeTree.gen.ts`: no diff. No route file added. `package.json`, the lockfile and `securityHeaders.ts`: no diff. +- `DRAFT(CON-ST-03)` count: 98, unchanged from unit 1 (unit 2 adds no drafts). +- Security greps (Step 22): `dangerouslySetInnerHTML` only in `components/StructuredData/` (pre-existing); the one `console.error` is in the pre-existing `ErrorPage.tsx`; no new e-mail address or `mailto:`; no design placeholders; no hard-coded hex or `rgb(` in the new components. + +## Lighthouse (Step 23) — open +Build of Step 22 (units 1, 2 and 3), `lhci autorun` for mobile (exits 1 on the assertions) and `lhci autorun --config=lighthouserc.desktop.cjs` for desktop, one run per URL; shoot pages re-measured with three runs. Port 4173 released afterwards. Owner decision (2026-10-30, audit log): **keep the fade-in on the first story for now**. + +| Page | Mobile performance (unit 1 in brackets) | Budget | Status | +|---|---|---|---| +| `/` | 0.75 (0.76) | 0.8 | below budget (master 0.78) | +| `/contact` | 0.87 (0.85) | 0.9 | below budget (master 0.87) | +| `/over-mij` | 0.87 | — | no failure recorded | +| `/portfolio` | 0.91 | — | no failure recorded | +| `/soorten-fotoshoots` | 0.85 | — | no failure recorded | +| `/soorten-fotoshoots/newborn` | 0.86 (0.90) | 0.85 | pass | +| `/soorten-fotoshoots/zwangerschap` | 0.85 (0.90) | 0.85 | pass | +| `/soorten-fotoshoots/gezin` | 0.84, then 0.85 × 3 (0.90) | 0.85 | borderline | +| `/soorten-fotoshoots/loveshoot` | 0.83 × 3 (0.90) | 0.85 | **below budget** | +| `/soorten-fotoshoots/portret` | 0.85 (0.90) | 0.85 | pass | +| `/privacyverklaring` | 0.90 | — | no failure recorded | +| `/bestaat-niet` | 0.92 | — | no failure recorded | + +- Desktop performance 0.99–1.00 on every page (shoot pages 0.99; budget 0.9). Accessibility and best practices 1.0 on all 12 URLs, mobile and desktop. SEO 1.0 on the indexed pages (0.58 for `/bestaat-niet` and 0.69 for `/privacyverklaring` are the expected noindex values). +- Diagnosis: the first story photo is not the bottleneck (153 KB on loveshoot and 117 KB on gezin, loaded in 15–24 ms). LCP is 3.7–3.8 s with a render delay of about 2.9–3.0 s; FCP is 2.6 s on every page. The photo is painted only after the main bundle has run, which matches the `photoPagePaths` comment in `lighthouserc.cjs`. The shoot pages dropped 0.05–0.07 from unit 1's shell-only numbers, because the first story now renders through `MediaText` and `Reveal` inside the lazy route chunk. +- Mitigations the plan lists, none applied: (1) first story without the `Reveal` fade-in, (2) fewer pixels for the first photo by capping its column, (3) report and keep the known limit. The owner chose to keep the fade-in; the item stays open and is to be revisited in Build and Test or a follow-up. + +## OG images +- Five JPEGs, 1200 × 630, sRGB, no EXIF or ICC profile, re-encoded from a fresh bitmap by a throw-away `System.Drawing` script kept outside the repository (no image tool or dependency in `web/`). +- Sources and crops (plan Step 2; the Gezin source is corrected from the design table): + +| Shoot | Source | Crop | Note | +|---|---|---|---| +| Newborn | `web/src/assets/portfolio/f41a4650-groot.jpg` (baby fist) | 1600 × 840 from 1600 × 1067, scaled down | | +| Zwangerschap | `web/src/assets/portfolio/f41a8206-groot.jpg` (belly in black dress) | 1600 × 840, scaled down | | +| Gezin | `web/src/assets/portfolio/f41a7138-groot.jpg` (parents with sleeping baby) | 1067 × 560 from 1067 × 1600, scaled up about 1.12× | not `f41a1579`, which is the photo of `og-portfolio.jpg` | +| Loveshoot | `web/src/assets/shoots/loveshoot.jpg` | 848 × 445 from 848 × 1060, scaled up about 1.42× | upscaled, soft; no landscape photo exists yet | +| Portret | `web/src/assets/shoots/portret.jpg` | 848 × 445 from 848 × 1060, scaled up about 1.42× | upscaled | + +- Vertical offsets were chosen by looking at each photo (faces and hands inside the crop); the offsets are not recorded in the plan. +- Approved as produced by the owner on 2026-10-30 (audit log, 12:49 UTC), together with the contact sheet in the scratchpad. +- Alt texts are the alt texts of the source photos (Dutch), as in `sitePages.ts`. + +## Deviations from the plan +- **`mosaicLayout` first tile**: for counts 2 to 4 the first tile is `1 / 3` × `1 / 3` (the table gives count 1, which is never shown, `1 / 5`). +- **`ProcessTimeline` subgrid**: `gridTemplateRows: subgrid` from `lg` without an `@supports` fallback, because a nested `@supports` rule cannot be expressed with Chakra style props. All current browsers support subgrid. +- **`FaqList` keyboard test**: jsdom and user-event do not turn Enter or Space on a `summary` into the click that toggles `details`, so the test checks focusability, `summary` as the first child, and the toggle on activation (click). +- **Package and closing buttons**: `Box asChild` with the `linkButton` recipe around the router's own `Link`, as `PriceCard` does, because `LinkButton` loses the typed `search` of the router link. +- **`ShootPage` wrapper testid**: `data-testid="shoot-page"` sits on the outer `Box` of the page. +- **Intro and first story**: both `paper` on purpose (the first story is `flushTop`); from the first story on the bands alternate. +- **`test/arbitraries.ts`**: one import line added (`shootPageView`); the rest is append only. +- **Gezin OG source**: `f41a7138-groot` instead of the design table's `f41a1579` (see OG images). +- **`app.test.tsx`**: one assertion changed (Step 19), the only edit outside unit 2's ownership table. +- **FR-ST-14** (404 under `/soorten-fotoshoots/`): added after the plan was written. `NotFound` offers "Terug naar Soorten fotoshoots" and "Terug naar home" under that path; `isShootSectionPath` is case-insensitive like the router. +- **Breadcrumb links** keep `{ exact: true }` (Step 9). Unit 3 added `includeSearch: false` to the nav and footer links only. +- **`aria-current` rule** (Step 26): see below. +- **Lighthouse mitigation**: not applied (owner decision). + +## Design E comparison (Step 17, by reading the design) +- Section order (intro, four stories, process, photos, FAQ, offer, closing), eyebrows and the side alternation of the photos match design E. The check was done by reading, not in a browser. +- Differences on purpose: the FAQ items all start closed (Q5 = C; design E has two open); the intro and the first story are both `paper`. +- The bracketed placeholders of design E are not copied into the visible text. + +## Interfaces left for the orchestrator +- Unit 3 imports nothing from unit 2; unit 2 imports nothing from unit 3. +- `shootPageBands` is the single source of the section order; `ShootPage` renders it. +- `PageIntro` `titleId` and `breadcrumb` are optional; existing callers are unchanged. +- `NotFound` depends on `lib/isShootSectionPath.ts`; the FR-ST-14 pair is not part of the plan's ownership table. +- The OG images are not yet listed in the plan's requirement-to-file table (they are in this summary). + +## Open items +- **Lighthouse (Step 23)**: open, see above; owner keeps the fade-in (2026-10-30). +- **Case-variant URL**: `/soorten-fotoshoots/Newborn` renders the page (the router matches case-insensitively), but no link carries `aria-current` (exact matching). The parent keeps its section marker through `isSectionCurrent`. Accepted for now; the case-sensitive routing decision stays with the orchestrator (unit 1). +- **seroval advisory**: resolved on master by PR #12 (`seroval@1.7.3`); `audit:deps` passes. +- **`audit:dev`**: 22 dev advisories, non-blocking under NFR-SEC-05, as on master. + +## aria-current decision (Step 26) +Unit 3's final markup gives each shoot page exactly three `aria-current="page"` elements: +1. the breadcrumb's last item (in `main`); +2. the header submenu link to the shoot page; +3. the mobile-menu sub-link to the shoot page (`#mobile-nav` is a sibling of the header; only one of the two menus is visible at a time). + +The parent "Soorten fotoshoots" links (header and mobile menu) and the footer link are never current. The rule is therefore: exactly one in `main`, exactly one in each menu, none in the footer, and none on the parents. Recorded in `shootPages.test.tsx` (one test per shoot). + +## Security and PBT compliance (final) +| Rule | Status | Evidence | +|---|---|---| +| SECURITY-04 HTTP headers | Compliant | `config/securityHeaders.ts` unchanged; no inline script or handler; no new external resource (Step 22 diff) | +| SECURITY-05 Input validation | Compliant | No input or search parameter added; ids in markup go through `headingId`; link targets are typed routes or derived by `shootContactLink` and `shootPagePath`; `isShootSectionPath` only compares | +| SECURITY-09 Hardening | Compliant | No debug output, no placeholders, no sample content (Step 22 greps); OG crops are the site's own photos | +| SECURITY-10 Supply chain | Compliant | No dependency added; lockfile and `package.json` unchanged; cropping done by a script outside the repository; `audit:deps` passes (`seroval@1.7.3`) | +| SECURITY-11 Secure design | Compliant | Content is text and typed router links (`RichParagraph`); no `dangerouslySetInnerHTML` in unit 2 files; no e-mail address or `mailto:` in new files | +| SECURITY-13 Integrity | Compliant | Only bundled photos and `public/` OG images; no CDN or embed; SVG icons inline | +| SECURITY-15 Fail-safe | Compliant | Every component omits itself or its part on empty input; `headingId` safe for any string; fewer photos than the minimum means no mosaic; `NotFound` shows the section buttons only under the section path | +| SECURITY-01, -02, -03, -06, -07, -08, -12, -14 | N/A | No data store, intermediary, server code, IAM, network, auth or alerting | +| PBT-01 Identification | Compliant | Properties per helper and component as in business-rules.md § 3 (Steps 3–13) and `isShootSectionPath` | +| PBT-02 Round trip | N/A | No parse/serialise or encode/decode pair (`headingId` is not reversed) | +| PBT-03 Invariants | Compliant | `headingId`, `readMoreLabel`, `mosaicLayout`, `storyLayout`, `shootPageBands`, `isShootSectionPath`, and the component properties (Breadcrumb, ProcessTimeline, PhotoMosaic, FaqList, StoryBlocks) | +| PBT-04 Idempotency | N/A | No operation with an idempotency contract (FAQ and timeline are stateless) | +| PBT-05 Oracle | N/A | No reference implementation | +| PBT-06 Stateful | N/A | No application state: FAQ state belongs to the browser | +| PBT-07 Generators | Compliant | Four generators appended to `test/arbitraries.ts`; unit 1's generators reused | +| PBT-08 Shrinking and reproducibility | Compliant | Seed from `config/testSeed.ts`, logged; seeds 1191455385 (Step 22) and 1757660570 (Step 26); shrinking untouched | +| PBT-09 Framework | Compliant | fast-check already a dependency | +| PBT-10 Complementary | Compliant | Example tests next to every property (keyboard, focus, boundaries, empty input, axe); PBT tests carry "(invariant)" in the name | diff --git a/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/business-logic-model.md b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/business-logic-model.md new file mode 100644 index 0000000..651ec1d --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/business-logic-model.md @@ -0,0 +1,244 @@ +# Business Logic Model - Unit 2: Shoot page UI + +> Final — answers recorded in ../../plans/shoot-page-ui-fd-questions.md (2026-10-30). Each decision that depends on an answer carries its question number, e.g. **[Q2]**. + +Inputs: [requirements.md](../../../inception/requirements/requirements.md) (FR-ST-02..09, FR-ST-13, SEO-ST-04/05, NFR-ST-01..03), [application-design.md](../../../inception/application-design/application-design.md), [component-methods.md](../../../inception/application-design/component-methods.md), the unit 1 [code summary](../../content-and-seo-foundation/code/code-summary.md), design E (`E-Definitief.dc.html`) and D (`D-Tijdlijn-Mobiel.dc.html`), [andrea-review.md § Foto's](../../content-review/andrea-review.md), and the real code (`shootPageView.ts`, `MediaText`, `FramedImage`, `PageSection`, `PageIntro`, `CallToAction`, `LinkButton`, `theme.ts`, recipes). + +Scope: unit 2 only. The navigation submenu is unit 3. The page is technology-agnostic here: rules are stated per visitor-visible behaviour and per pure function; the markup is in [frontend-components.md](frontend-components.md). + +## 1. Page assembly + +A shoot page is a function of one `ShootPageView` (unit 1). Unit 2 adds one more pure step, `shootPageBands`, that fixes the order of the sections that exist for this view and the background tone of each, so that adjacent bands always differ whichever optional sections (photos, FAQ) are present. + +```mermaid +graph TD + view["ShootPageView from shootPageView"] --> bands["shootPageBands: ordered sections with tones"] + bands --> intro["Intro: PageIntro with Breadcrumb"] + bands --> stories["Four story blocks via storyLayout"] + bands --> tl["Process timeline: six steps"] + bands --> hasPhotos{"view.photos present?"} + hasPhotos -->|"yes"| mosaic["Photo mosaic via mosaicLayout"] + hasPhotos -->|"no"| skipPhotos["No Impressie section"] + bands --> hasFaq{"view.faq present?"} + hasFaq -->|"yes"| faq["FAQ with details and summary"] + hasFaq -->|"no"| skipFaq["No FAQ section"] + bands --> offer["Package block or Prijs op aanvraag"] + bands --> cta["Closing call to action"] + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef omitted fill:#e9d5ff,stroke:#6b21a8,stroke-width:1px,color:#000; + class view,bands pure; + class intro,stories,tl,mosaic,faq,offer,cta ui; + class hasPhotos,hasFaq decision; + class skipPhotos,skipFaq omitted; +``` + +Text alternative: the view feeds shootPageBands, which orders intro, four stories, timeline, then the photo mosaic and the FAQ only when the view has them, then the package block and the closing call to action (purple = pure logic, blue = UI, orange = decision, lilac = omitted section). + +**Band rule.** The rendered sections after the intro are numbered 0, 1, 2, ... in page order; position `p` has tone `paper` when `p` is even and `alt` when odd. The first story block is position 0 (`paper`), directly below the `paper` intro, so it uses `spacing="flushTop"` as the first band of the overview page does. Because positions are consecutive over what is actually rendered, an omitted mosaic or FAQ never produces two equal neighbours. The closing call to action takes the next position like every other section (`CallToAction` gets an optional `tone`, see frontend-components.md). + +| View | Sections after the intro (position: tone) | +|---|---| +| Newborn today (3 mosaic photos, FAQ) | 0 story paper, 1 story alt, 2 story paper, 3 story alt, 4 timeline paper, 5 mosaic alt, 6 FAQ paper, 7 package alt, 8 closing paper | +| Zwangerschap/Gezin today, Loveshoot, Portret (no mosaic) | 0-3 stories paper/alt/paper/alt, 4 timeline paper, 5 FAQ alt, 6 package paper, 7 closing alt | + +## 2. Story block + +```mermaid +graph TD + s["Story block at index i"] --> img{"Has an image?"} + img -->|"no"| textOnly["Text-only band: narrow centred column, no frame"] + img -->|"yes"| orient{"Landscape: width at least 1.2 times height?"} + orient -->|"yes"| land["Aspect 3 / 2, half-width photo column"] + orient -->|"no"| port["Aspect 4 / 5, medium photo column up to 30rem"] + land --> media["MediaText with FramedImage in the shoot frame colour"] + port --> media + media --> side{"i is odd?"} + side -->|"yes"| rev["Photo right from lg"] + side -->|"no"| left["Photo left from lg"] + media --> prio{"i is 0?"} + prio -->|"yes"| hi["Photo loads at once, high priority"] + prio -->|"no"| lazy["Photo deferred until near the viewport"] + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + class img,orient,side,prio decision; + class textOnly,land,port,media,rev,left,hi,lazy ui; + class s pure; +``` + +Text alternative: a story block without an image becomes a text-only band; with an image its orientation chooses the aspect ratio and column width, its index chooses the photo side, and only index 0 loads its photo with high priority. + +- The orientation rule is by the photo itself (not by slot), so a photo delivered later in another orientation (Andrea's review document names 3:2 for block 2 and 4:5 for the others, which the current data matches) is still cropped sensibly. +- Text-only variant **[Q4 = A]**: same `PageSection` band and alternation as a block with a photo (the index still decides the tone), eyebrow, h2 and paragraphs in one column of at most 36rem (the line length used next to a photo), centred in the narrow content width. No frame, no empty grid column, no reserved space. Under Q4 = B consecutive text-only blocks would be grouped in one band with columns (see business-rules.md BR-SP-13). +- The photo side and the band tone follow the block index, not "blocks that have a photo", so rhythm is stable when photos are added later (a data-only change). +- Heading ids: `story-<story.id>-title` through `headingId` (BR-SP-72). + +## 3. Process timeline + +```mermaid +graph TD + steps["Six steps from the view, fixed order"] --> wide{"Viewport at least lg, 1024px?"} + wide -->|"yes"| hor["Horizontal: six columns, line through the icons"] + wide -->|"no"| ver["Vertical: icon column and text column, line between icons"] + hor --> parity{"Step index even?"} + parity -->|"yes, steps 1 3 5"| above["Text above the line"] + parity -->|"no, steps 2 4 6"| below["Text below the line"] + steps --> last["Last marker is filled to mark the delivery"] + steps --> dom["DOM: ordered list, the h3 and text of each step in reading order"] + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + class wide,parity decision; + class hor,ver,above,below,last,dom ui; + class steps pure; +``` + +Text alternative: from the lg breakpoint the six steps run horizontally with the odd steps' texts above the line and the even steps' texts below it; below lg they run vertically; in both layouts the DOM is one ordered list in step order and the last marker is filled. + +- **Breakpoint: the theme's `lg` (1024 px)**, not design E's 900 px. At `lg` content width (about 940 px after the page gutter) each of six columns is about 155 px, text about 130 px: the longest step titles ("Datum & locatie kiezen") wrap to two lines and the longest drafted step text stays under about 8 lines. At `md` (768 px) a column would be about 110 px, which design E avoided with its 900 px break; using a theme token (not a literal pixel value) is required by FR-ST-04. The cost is that tablets in portrait (768-1023 px) get the vertical layout, which is the one design D drew for mobile and reads well at that width (capped at 34rem, centred). +- **Alternation by index parity** (design E): steps 1, 3, 5 (index 0, 2, 4) above, steps 2, 4, 6 below. The icon row is shared, so the line runs straight through all six markers. +- **Line**: runs from the centre of the first marker to the centre of the last (design E let it overshoot half a cell on both ends). Decorative, `aria-hidden`. +- **Markers**: 56 px squares with a 1 px `accent.deep` border, band-coloured fill, `accent.deep` icon. Square, like the rest of the site (angular shapes). The last marker is filled `accent.deep` with a white icon (design E): "arrived". +- **No numbers** (Q7 of the requirements): order is carried by position and by the ordered list semantics. +- **Per-shoot text** (location, duration, opleverduur) arrives already filled in by `shootPageView`; the component never composes text. +- **Motion**: the list appears with the section's `Reveal` (one fade-up for the whole list, not per step: a `Reveal` wrapper per step would sit between the grid and the subgrid rows). `useReveal` shows it immediately under `prefers-reduced-motion`. No other animation exists, so there is nothing else to switch off. +- **Icons** (inline SVG, `aria-hidden`, 24x24, 1.5 stroke, `currentColor`, from design E): envelope (aanvragen), calendar with heart (datum), coin (aanbetaling), camera (shoot), sliders (bewerking), picture (oplevering). Paths in domain-entities.md. + +## 4. Photo mosaic + +```mermaid +graph TD + imgs["view.photos.images, already without photos used elsewhere"] --> cap["Take the first four"] + cap --> n{"How many?"} + n -->|"2"| two["Two equal tiles, each two columns by two rows"] + n -->|"3"| three["One large tile left, two wide tiles stacked right"] + n -->|"4"| four["One large left, one wide top right, two small bottom right"] + two --> phone + three --> phone + four --> phone + phone["Below md: two columns, wide tiles span both, small tiles side by side"] + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + class n decision; + class two,three,four,phone ui; + class imgs,cap pure; +``` + +Text alternative: the first four photos are laid out as two equal tiles, one large plus two stacked wide tiles, or one large plus one wide plus two small tiles depending on the count, and below md every layout becomes a two-column grid. + +Desktop grid (from `md`): **4 columns by 2 rows**, row height `clamp(12rem, 22vw, 18.75rem)` (300 px on wide screens as in design E), gap the theme's `gridGap`. Every layout fills all eight cells, so the mosaic is the same height for 2, 3 and 4 photos and the page does not jump when photos are added. + +| Count | Tile 1 | Tile 2 | Tile 3 | Tile 4 | +|---|---|---|---|---| +| 2 | columns 1-2, rows 1-2 | columns 3-4, rows 1-2 | | | +| 3 | columns 1-2, rows 1-2 (large) | columns 3-4, row 1 (wide) | columns 3-4, row 2 (wide) | | +| 4 (design E) | columns 1-2, rows 1-2 (large) | columns 3-4, row 1 (wide) | column 3, row 2 (small) | column 4, row 2 (small) | + +Phone grid (below `md`, two columns, gap `gridGap`): tiles that are `wide` span both columns. + +| Count | Tile 1 | Tile 2 | Tile 3 | Tile 4 | +|---|---|---|---|---| +| 2 | wide, 4 / 3 | wide, 4 / 3 | | | +| 3 | wide, 4 / 3 | wide, 3 / 2 | wide, 3 / 2 | | +| 4 | wide, 4 / 3 | wide, 3 / 2 | half, 1 / 1 | half, 1 / 1 | + +- Two photos on a phone are stacked, not side by side: at 320 px two side-by-side tiles would be about 145 px wide. +- **Order is content order**: tile 1 is the large slot (a portrait photo suits it), tile 2 the wide slot (a landscape photo suits it). Photos are cropped to their cell (`object-fit: cover`); the image's own ratio never decides a row height. There is no focal-point field in `ContentImage`, so crops are centred. With 3 photos, tile 3 is a wide cell: a portrait photo there shows its middle band (noted as a content tip for Andrea, not a rule). +- **Fewer than the minimum** ([Q2]: 2): the section is not rendered at all (the view already omits it). **More than four**: the first four are shown; the rest stay in the data. The "Bekijk meer ...foto's" link (shown only when the view has `portfolioLink`) is where more photos live. +- **Behaviour** [Q3 = A]: tiles are not interactive: no hover effect, not focusable, not links. They are a list of images (`ul`/`li`), each with its alt text. +- Reveal: each tile fades in with a small stagger (`delay = index * 0.08` s); reduced motion shows them immediately. +- Section head: eyebrow + h2 on the left, "Bekijk meer {photosLabel}" on the right (design E), wrapping under the heading on narrow screens; the link has a 44 px touch target. + +## 5. FAQ + +```mermaid +graph TD + items["view.faq.items, three to five"] --> render["One details and summary per item, in order, all closed"] + render --> dom["Answer is in the DOM also when closed"] + render --> toggle["Visitor toggles with click, tap, Enter or Space: the browser does it"] + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + class render,dom,toggle ui; + class items pure; +``` + +Text alternative: every FAQ item becomes a native details element with its answer always in the DOM; all items start closed and the visitor toggles them with the browser's own behaviour. + +- **Closed by default [Q5 = C]: all items.** No `details` carries the `open` attribute at load (design E's two open items are not used). There is no `FAQ_OPEN_COUNT` constant and no `openCount` prop; after load the browser owns the state (uncontrolled, no React state, no re-render side effects). +- Native `details` also means: find-in-page opens a closed item that contains the match, no JavaScript is needed, and there is nothing to animate, so `prefers-reduced-motion` is respected by construction. The plus/minus icon is switched by CSS on `details[open]`. +- The FAQPage structured data always lists every question, regardless of what is open (unit 1). +- Layout: from `lg` two columns (heading, lead and contact link left, list right, one third / two thirds as in design E); below `lg` stacked, heading first. + +## 6. Package block and "Prijs op aanvraag" + +```mermaid +graph TD + off["view.offer"] --> pkg{"view.offer.pkg present?"} + pkg -->|"yes"| price["Price via formatPrice, features list, button Boek dit pakket, link Eerst een vraag stellen"] + pkg -->|"no"| onreq["Prijs op aanvraag, short text, one button with the on-request label"] + price --> note["Deposit note below the actions"] + onreq --> note + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + class pkg decision; + class price,onreq,note ui; + class off pure; +``` + +Text alternative: the offer block shows the price, features and two actions when the view carries a package, otherwise "Prijs op aanvraag" with one action, and the deposit note appears in both variants. + +- The variant is decided only by `view.offer.pkg` (never by a shoot id); an invalid or removed package therefore falls back to "Prijs op aanvraag" without extra code (unit 1). +- Package variant actions: primary `LinkButton variant="accent"` "Boek dit pakket" to `view.offer.bookLink` (`/contact?pakket=<id>`), secondary underlined text link "Eerst een vraag stellen" to `/contact`. +- On-request variant: the price slot shows `onRequest.price` in the same type as a price, then `onRequest.text`; **one** primary button with `onRequest.linkLabel` ("Vraag naar de mogelijkheden") to `bookLink` (which resolves to plain `/contact` when there is no visible package). The secondary link is dropped, since it would lead to the same place. +- The photo is the shoot's detail photo (else its main photo), square, in the shoot's frame colour, in the narrow media column (20rem) so the 480 px source stays sharp. +- The deposit note ("Aanbetaling € 50, restbedrag na de shoot.") appears in both variants (A-ST-03). Whether it should appear for Loveshoot and Portret depends on Andrea's answer to open fact 4 (OPEN(CON-ST-04)); the `note` prop is optional, so removing it for the on-request variant is a one-line change in `ShootPage`. + +## 7. Closing call to action and "Lees meer" link + +- Closing band: `CallToAction` with `view.closing.title`, `view.closing.lead` (rich text through `RichParagraph`) and one `LinkButton variant="accent"` with `closing.buttonLabel` to `closing.link` (same destination as the package button when a package exists; different names, so no accessible-name clash). +- Overview "Lees meer" link **[Q6 = A]**: `ShootBlock` gains a link with the visible text "Lees meer over de {shootLabel lowercased}" (newbornshoot, zwangerschapsshoot, gezinsshoot, loveshoot, portretshoot) to `shootPagePath(shoot.id)`, as the first link of the row, same underline style as the others, same 44 px touch target. The text is unique per shoot, so it needs no `aria-label`. Anchors (`#newborn` ...) and the other links are untouched. Under Q6 = B it becomes an outline `LinkButton` below the text, with the two text links below it. + +## 8. Image loading and Largest Contentful Paint + +```mermaid +sequenceDiagram + box rgba(33,150,243,0.15) Browser + participant V as Visitor + participant B as Browser + end + box rgba(156,39,176,0.15) Page + participant R as RouteChunk + participant P as Story1Photo + participant D as DeferredPhotos + end + V->>B: Open a shoot page + B->>R: Load main bundle and the page chunk + R->>B: Render intro and story blocks + B->>P: Request photo at once with high priority + P->>B: Photo painted, likely the largest paint + B->>D: Wait for the load event + D->>B: Request each photo when it nears the viewport +``` + +Text alternative: after the page chunk renders, only the first story photo is requested immediately with high priority; every other photo waits for the page load event and for the viewport to come near it. + +- Only the photo of story block index 0 is the priority image (BR-SP-40). It is the likely largest paint on both desktop and phones: on a 412x823 phone the intro (breadcrumb, h1, intro text) ends around 550-600 px, so the photo's visible part is larger than any text block. +- If the first story has no photo (a data change), no image is priority: nothing else is likely to be the largest paint. +- All other photos (stories 2-4, mosaic tiles, package photo) use `DeferredImage` with intrinsic `width`/`height` plus a CSS aspect ratio or a fixed grid cell, so there is no layout shift. The mosaic tiles fill their cell by absolute positioning, so image size never changes the row height. +- Known limit: the shoot pages are in the `photoPagePaths` bucket (mobile performance budget 0.85, goal 0.9). The unit 1 shell measured 0.90 without any photo, so scores must be re-measured after the sections exist; any shortfall is reported with numbers, not worked around. A first mitigation to try if the largest paint regresses: render the first story without the `Reveal` fade, since the image is invisible until the fade starts. + +## 9. Pure functions added by this unit + +| Function | Module | Input to output | Notes | +|---|---|---|---| +| `mosaicLayout(count)` | `lib/mosaicLayout.ts` | number to tiles (`column`, `row`, `wide`, `phoneRatio`) | Total for any integer; at most `MOSAIC_MAX_PHOTOS` (4) tiles; `[]` for count 0 or below | +| `storyLayout(stories)` | `lib/storyLayout.ts` | stories to per-block layout (`tone`, `reverse`, `media?`, `priority`, `spacing`) | `media` is `{ aspectRatio, mediaSize }` and absent for text-only blocks | +| `shootPageBands(view)` | `lib/shootPageBands.ts` | view to ordered `{ id, tone }` list | Single source of the band rhythm | +| `readMoreLabel(shoot)` | `lib/readMoreLabel.ts` | shoot type to `Lees meer over de <shootLabel lowercased>` | Unique per shoot | +| `headingId(prefix, id)` | `lib/headingId.ts` | strings to a safe id | Only `a-z 0-9 - _`; used for `aria-labelledby` targets | + +Constants: `MOSAIC_MIN_PHOTOS = 2` **[Q2]** (already in `shootPageView.ts`, unit 2 may change the value only), `MOSAIC_MAX_PHOTOS = 4`, timeline breakpoint `lg`, mosaic breakpoint `md`. diff --git a/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/business-rules.md b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/business-rules.md new file mode 100644 index 0000000..ba8154c --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/business-rules.md @@ -0,0 +1,234 @@ +# Business Rules - Unit 2: Shoot page UI + +> Final — answers recorded in ../../plans/shoot-page-ui-fd-questions.md (2026-10-30). Rules that depend on an answer are tagged **[Q#]** and listed in the decision register at the end. + +Rule ids are `BR-SP-nn` (shoot page). "Source" points at the requirement or design decision the rule makes concrete. Flows: [business-logic-model.md](business-logic-model.md). + +## 1. Decision flowcharts + +### 1.1 Does a section appear, and what is the mosaic made of + +```mermaid +graph TD + start["Build the page from ShootPageView"] --> photoCount{"Photos left after removing the ones used in stories and the package block: at least MOSAIC_MIN_PHOTOS?"} + photoCount -->|"no"| noMosaic["No Impressie section, outline stays valid"] + photoCount -->|"yes"| cap{"More than MOSAIC_MAX_PHOTOS?"} + cap -->|"yes"| first4["Show the first four"] + cap -->|"no"| all["Show all"] + start --> faqCount{"At least one FAQ item?"} + faqCount -->|"no"| noFaq["No FAQ section, no FAQPage"] + faqCount -->|"yes"| faq["FAQ section"] + start --> pkgCheck{"Visible package?"} + pkgCheck -->|"yes"| pkgBlock["Price, features, Boek dit pakket"] + pkgCheck -->|"no"| reqBlock["Prijs op aanvraag"] + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + classDef omitted fill:#e9d5ff,stroke:#6b21a8,stroke-width:1px,color:#000; + class photoCount,cap,faqCount,pkgCheck decision; + class first4,all,faq,pkgBlock,reqBlock ui; + class noMosaic,noFaq omitted; + class start pure; +``` + +Text alternative: the mosaic needs at least MOSAIC_MIN_PHOTOS unused photos and shows at most four, the FAQ needs at least one item, and the offer block shows a price only when the view has a visible package. + +### 1.2 Story block media and loading priority + +```mermaid +graph TD + block["Story block at index i"] --> hasImg{"image defined?"} + hasImg -->|"no"| textOnly["Text-only band, no frame, no priority"] + hasImg -->|"yes"| isFirst{"i equals 0?"} + isFirst -->|"yes"| priority["Priority image: no lazy loading, fetchPriority high"] + isFirst -->|"no"| deferred["DeferredImage: loads near the viewport after page load"] + priority --> ratio + deferred --> ratio + ratio{"width at least 1.2 times height?"} -->|"yes"| land["3 / 2 and half-width column"] + ratio -->|"no"| port["4 / 5 and medium column"] + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + class hasImg,isFirst,ratio decision; + class textOnly,priority,deferred,land,port ui; + class block pure; +``` + +Text alternative: a story without an image is text only; with an image only index 0 is a priority image, and the photo's orientation picks 3:2 with a half-width column or 4:5 with a medium column. + +### 1.3 Timeline layout + +```mermaid +graph TD + vp{"Viewport at least lg?"} -->|"yes"| h["Horizontal: line through the markers, text alternates above and below by index parity"] + vp -->|"no"| v["Vertical: markers in a column, line between them, text beside"] + h --> same["Same ordered list and reading order"] + v --> same + classDef decision fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + class vp decision; + class h,v,same ui; +``` + +Text alternative: at lg and above the timeline is horizontal with alternating texts, below lg it is vertical, and the markup and reading order are the same in both. + +## 2. Rules + +### Intro and breadcrumb +| Id | Rule | Source | +|---|---|---| +| BR-SP-01 | The breadcrumb shows `view.breadcrumb.items` in order: every item except the last is a link, the last is plain text with `aria-current="page"`. It is a `nav` named by `view.breadcrumb.label` ("Kruimelpad") containing an `ol`. | FR-ST-02 | +| BR-SP-02 | Separators are a decorative `li` with `aria-hidden="true"` and the text "/" (as in design E), between items only; never after the last item. | FR-ST-02, design E | +| BR-SP-03 | Breadcrumb links use exact active matching, so only the page itself can ever carry `aria-current`. The links are at least 44 px high (touch target) and show an underline at rest (not colour alone). | application-design D4, NFR-ST-01 | +| BR-SP-04 | With no items the breadcrumb renders nothing (fail safe); with one item it shows only the current page. | SECURITY-15 | +| BR-SP-05 | `PageIntro` gets two optional props, `breadcrumb` (above the eyebrow) and `titleId` (h1 id; the section is named by it). Callers that pass neither render byte-identically to today. | application-design D10 | + +### Story blocks +| Id | Rule | Source | +|---|---|---| +| BR-SP-10 | Every story is a `section` named by its h2 (`aria-labelledby`), with eyebrow (decorative `p`), h2 (`sectionTitle`), and its paragraphs through `RichParagraph`, in a stack with the overview page's spacing. | FR-ST-03, SEO-ST-04 | +| BR-SP-11 | Band tone and photo side come from the block index: tone by `shootPageBands`, photo on the right from `lg` when the index is odd. Not from "has a photo". | FR-ST-03 | +| BR-SP-12 | Aspect ratio and column width come from the photo's orientation: width at least 1.2 x height gives `3 / 2` and `mediaSize="half"`, otherwise `4 / 5` and `mediaSize="medium"` (new, photo column up to 30rem, as design E's 480/440 px). The shoot's `frameColor` applies to every story photo. | design E | +| BR-SP-13 | A story without a photo is a text-only band **[Q4 = A]**: same `PageSection`, tone and h2 level, text in a column of at most 36rem centred in the narrow content width, no frame and no empty grid column. **[Q4 = B]** would instead place consecutive text-only stories in one band as columns (each still its own `section` with its own h2). | FR-ST-03 | +| BR-SP-14 | Only the story at index 0 may be a priority image, and only when it has a photo (see BR-SP-40). | NFR-ST-03 | + +### Process timeline +| Id | Rule | Source | +|---|---|---| +| BR-SP-20 | The timeline is an ordered list (`ol` with `role="list"` so that Safari keeps the list semantics when the bullets are removed) with one `li` per step, in the order given. Each `li` holds the decorative marker, an h3 with the title and a paragraph with the text. | FR-ST-04, NFR-ST-01 | +| BR-SP-21 | From `lg` the list is a grid with one column per step and three rows (text above, 56 px marker row, text below); the step at index `i` puts its text above when `i` is even and below when `i` is odd. Below `lg` it is one column: marker (56 px) beside the text, text top-aligned with the marker. | FR-ST-04, design E, D | +| BR-SP-22 | The line is decorative (`aria-hidden`): horizontal from the first to the last marker centre, vertical from each marker down to the next (none after the last). Markers hide the line behind them with the band's own background colour (the `tone` prop). | design E, D | +| BR-SP-23 | The last marker is filled (`accent.deep`, white icon); the others are outlined. Icons and the line carry no information beyond the order and are `aria-hidden`; there are no step numbers. | design E, Q7 requirements | +| BR-SP-24 | The vertical layout is capped at 34rem and centred, so line length stays readable on tablets. | design D | +| BR-SP-25 | The list fades in once, as a whole, via `Reveal`; no per-step or looping motion exists. Under `prefers-reduced-motion` it is visible at once (existing `useReveal` behaviour). | NFR-ST-01 | +| BR-SP-26 | The component is generic: any number of steps (1 or more) lays out correctly; zero steps render nothing. It never builds text or looks up a step by id except through its `icon` prop. | NFR-ST-02 | + +### Photo mosaic +| Id | Rule | Source | +|---|---|---| +| BR-SP-30a | `MOSAIC_MIN_PHOTOS = 2` **[Q2]**. Below it the view carries no `photos` and no section, heading or link is rendered. | FR-ST-05, D15 | +| BR-SP-30b | `MOSAIC_MAX_PHOTOS = 4`: the first four photos are shown; photos beyond four are ignored by the component (they stay in the content). | design E | +| BR-SP-31 | Layouts follow `mosaicLayout(count)`: 2 = two equal 2x2 tiles; 3 = large 2x2 plus two wide 2x1 tiles; 4 = design E (large 2x2, wide 2x1, two small 1x1). Always the full 4x2 grid, so the height is the same for all counts. Phones: two columns, wide tiles span both (BR-SP-35 for ratios). | FR-ST-05 | +| BR-SP-32 | The tiles are an unordered list of images in content order, each with its own alt text; tile 1 is the large slot, tile 2 the wide slot. The image fills its cell (`object-fit: cover`, absolutely positioned inside a relative cell), so its intrinsic size never sets a row height. | NFR-ST-03 | +| BR-SP-33 | Tiles are not interactive **[Q3 = A]**: no link, no focus stop, no hover effect, no lightbox. **[Q3 = B]** would make each tile a button that opens the shared `Lightbox` and needs a large version per photo (a content-model addition). | FR-ST-05 | +| BR-SP-34 | The section head shows the eyebrow and the h2 (`view.photos.title`) and, when `view.photos.portfolioLink` exists, "Bekijk meer {photosLabel}" on the right, wrapping below the heading on narrow screens, at least 44 px high. | FR-ST-05 | +| BR-SP-35 | Phone ratios: first tile 4 / 3 (wide); the second tile 3 / 2 (wide) when there are 3 or 4 photos, 4 / 3 when there are 2; the third tile 3 / 2 (wide) when there are 3 photos; with 4 photos tiles 3 and 4 are 1 / 1 and side by side. | design E | + +### Image loading (Lighthouse) +| Id | Rule | Source | +|---|---|---| +| BR-SP-40 | Exactly one image can be priority: the photo of the story at index 0 (`fetchPriority="high"`, not lazy). | NFR-ST-03 | +| BR-SP-41 | Every other photo is a `DeferredImage` with intrinsic width and height; no photo has `loading="eager"` without being the priority image. | NFR-ST-03 | +| BR-SP-42 | Photos come only from bundled assets (content imports); no remote image, no CDN. | SECURITY-13 | + +### FAQ +| Id | Rule | Source | +|---|---|---| +| BR-SP-50 | One native `details` per item with a `summary` holding the question (the question text is the disclosure label, not a heading), and the answer through `RichParagraph` below it. The answer is in the DOM when closed. | FR-ST-06 | +| BR-SP-51 | No FAQ item has the `open` attribute at load: all items start closed **[Q5 = C]** (the answers are in the DOM). After load the browser owns the state; there is no React state and no `FAQ_OPEN_COUNT` constant. | FR-ST-06, Q5 answer (design E had two open) | +| BR-SP-52 | The `summary` is at least 44 px high, has a visible focus ring (the theme's `focusRing` colour), keeps the plus/minus icon decorative (`aria-hidden`; the vertical stroke is hidden by CSS when `details[open]`), and hides the browser's own marker. | NFR-ST-01 | +| BR-SP-53 | The section is named by its h2; the contact lead ("Staat je vraag er niet tussen? ...") and its link sit under the h2. The list has hairline separators (the `sand` token). | design E | + +### Package block, closing, overview link +| Id | Rule | Source | +|---|---|---| +| BR-SP-60 | The package variant is chosen only by `view.offer.pkg`. With it: price via `formatPrice(pkg.price)`, `pkg.features` as a list, primary "Boek dit pakket" (`bookLink`), secondary "Eerst een vraag stellen" (`askLink`). Without it: `onRequest.price` in the price slot, `onRequest.text`, one primary button `onRequest.linkLabel` to `bookLink`; no features, no secondary link. | FR-ST-07 | +| BR-SP-61 | The deposit note is passed as `note` and shown below the actions in both variants (A-ST-03). Not shown when the view has no note text. | FR-ST-07, CON-ST-04 | +| BR-SP-62 | The package photo is `view.offer.image` (square, shoot frame colour, narrow `small` media column, deferred); the block's h2 id is `offer-title`. | FR-ST-07 | +| BR-SP-63 | The closing band is `CallToAction` (`title`, rich-text `lead`, one accent `LinkButton` to `closing.link`) and gets the next band tone; the component's default (`alt`) is unchanged for existing callers. | FR-ST-08 | +| BR-SP-64 | The overview `ShootBlock` shows `readMoreLabel(shoot)` ("Lees meer over de newbornshoot") as a link to `shootPagePath(shoot.id)`, first in the row **[Q6 = A]**, with a 44 px target; the visible text differs per shoot so no `aria-label` is used. The other links, the `article` id and the anchors do not change. | FR-ST-09 | + +### Structure, ids and fail-safe +| Id | Rule | Source | +|---|---|---| +| BR-SP-70 | Page order and bands are exactly `shootPageBands(view)`: intro, stories (index order), timeline, mosaic if present, FAQ if present, offer, closing. Positions are consecutive and tones alternate starting with `paper`, so two adjacent bands never share a tone. The first story is `flushTop`. | design E, NFR-ST-02 | +| BR-SP-71 | Heading outline: one h1 (intro), one h2 per section, one h3 per timeline step; FAQ questions are `summary` labels, so no level is skipped. Every section has `aria-labelledby` pointing at its h2 id; ids come from `headingId` (BR-SP-72). | SEO-ST-04, NFR-ST-01 | +| BR-SP-72 | `headingId(prefix, id)` maps any string to an id containing only `a-z`, `0-9`, `-` and `_` (everything else becomes `-`, letters lower-cased), so `aria-labelledby` can never break on spaces in content. | SECURITY-15 | +| BR-SP-73 | Section anchors: `zo-werkt-het`, `impressie`, `vragen`, `pakket` (design E has `#vragen`); a link to one lands below the sticky header (`PageSection` `id`). | design E | +| BR-SP-74 | Components receive everything as props and import no content module (existing rule). Fail-safe: no stories, no steps, no photos, no FAQ, an unknown step id for an icon, or an empty alt (content tests forbid it) never throws; the affected part is omitted or shown without its icon. | SECURITY-15 | + +### Preview images and registry +| Id | Rule | Source | +|---|---|---| +| BR-SP-80 | Each of the five `sitePages` entries gets `ogImage { path: '/og-<id>.jpg', width: 1200, height: 630, alt }` and the file exists in `web/public/`, 1200 x 630, JPEG, at most about 100 KB, in the style chosen in **[Q7]** (A: landscape crop of a shoot photo, proposed sources in domain-entities.md § OG images; B: composed card; C: no `ogImage`, the site default applies). | SEO-ST-05, A-ST-04 | +| BR-SP-81 | The `alt` of an OG image describes the photo, like the existing pages. | existing pages | + +### LAYOUT.md +| Id | Rule | Source | +|---|---|---| +| BR-SP-90 | New "Shoot page" section after "Types of shoots": blocks A Intro, B-E Story 1-4, F Process timeline, G Photos, H FAQ, I Package, J Book (diagram in frontend-components.md § 9). H, I, J get new template colours (stroke = fill x 0.75) added to `.ai/layout-conventions.md` too. | FR-ST-13 | + +## 3. Testable properties (PBT-01, unit 2) + +| Function or component | Property | Kind | +|---|---|---| +| `mosaicLayout(count)` | For every integer count (negative to 12): `[]` for count 0 or below; otherwise exactly `min(count, 4)` tiles; the desktop cells of the tiles are pairwise disjoint and, for 2 to 4, cover all eight cells of the 4x2 grid; the first tile is always columns 1-2, rows 1-2; the phone layout never leaves a half-empty row (the number of non-wide tiles is even); pure (same output twice) | Invariant | +| `storyLayout(stories)` | Tone and `reverse` alternate with the index; `priority` is true only at index 0 and only when that story has an image; a story without an image has no `media`; the aspect ratio is `3 / 2` exactly when width >= 1.2 x height, otherwise `4 / 5`, and the column width matches the ratio | Invariant | +| `shootPageBands(view)` | For any view built from generated content (stories 0-6, photos present or not, FAQ present or not): tones alternate strictly starting with `paper`; the section ids are in canonical order; the length equals `stories + timeline + [photos] + [faq] + offer + closing`; no section appears twice | Invariant | +| `readMoreLabel(shoot)` | Starts with "Lees meer over de "; for any set of shoot types with unique `shootLabel` the labels are unique; the five real labels are unique | Invariant / example | +| `headingId` | The output only contains `a-z 0-9 - _`; the same input gives the same output; never throws for any string (hostile strings included) | Invariant | +| `ProcessTimeline` | For any 1 to 8 generated steps: one `li` per step in input order, one h3 per `li`, every icon `aria-hidden`, no digit-only text added by the component | Component property (few runs) | +| `Breadcrumb` | For any 1 to 5 items: exactly the last is a non-link with `aria-current="page"`, the others are links in order, separators number items - 1 and are `aria-hidden` | Component property | +| `FaqList` | For any 0 to 6 items: one `details` per item, every answer text present in the DOM, no `details` has the `open` attribute (Q5 = C) | Component property | +| `PhotoMosaic` | For any 2 to 6 images: `min(n, 4)` `img`s with the given alt texts, in order | Component property | + +Not PBT (example-based, PBT-10): the page structure and heading outline per shoot; the package versus "Prijs op aanvraag" variant for Newborn and Loveshoot; Zwangerschap/Gezin without mosaic (or with it, depending on [Q1]); the overview "Lees meer" links and kept anchors; OG registry consistency; axe on every section component and on each of the five pages. + +Generators (PBT-07): reuse `shootPageContent`, `shootPageShared`, `contentImage`, `storyBlock`, `faqItem`, `richText`; append `imageWithOrientation` (width and height drawn around the 1.2 threshold), `mosaicCount` (integers -3 to 12) and `timelineSteps` (1 to 8 steps with hostile strings) to `src/test/arbitraries.ts` (append only). + +## 4. Extension compliance (functional design level) + +### Security Baseline +| Rule | Status | Rationale | +|---|---|---| +| SECURITY-01 Encryption | N/A | No data stores | +| SECURITY-02 Access logging | N/A | No intermediaries added | +| SECURITY-03 Application logging | N/A | No server-side component; no `console` output in the new code | +| SECURITY-04 HTTP headers | Compliant | `config/securityHeaders.ts` untouched; no inline event handlers or styles beyond Chakra's; no new script; native `details` needs no JavaScript | +| SECURITY-05 Input validation | Compliant | The unit adds no input: no route or search parameter, no form. Ids used in markup are normalised by `headingId` (BR-SP-72); link targets are typed routes or derived by `shootContactLink`/`shootPagePath` | +| SECURITY-06 Least privilege | N/A | No IAM | +| SECURITY-07 Network | N/A | No network configuration | +| SECURITY-08 Access control | N/A | Public content | +| SECURITY-09 Hardening | Compliant | No debug output; no placeholder content (draft markers stay gated by D3, bracketed design placeholders are not used); no sample photos | +| SECURITY-10 Supply chain | Compliant | No new dependency: Chakra primitives, inline SVG icons, native `details`; lockfile unchanged | +| SECURITY-11 Secure design | Compliant | All content is rendered as text or typed router links (`RichParagraph`); no `dangerouslySetInnerHTML`; no e-mail address; no mailto | +| SECURITY-12 Authentication | N/A | No authentication | +| SECURITY-13 Integrity | Compliant | Only bundled photos and `public/` OG images; no CDN or embed (design E's Google Fonts link is not part of the app, fonts are already self-hosted) | +| SECURITY-14 Alerting | N/A | No server-side component | +| SECURITY-15 Fail-safe | Compliant | Omitted sections instead of errors (BR-SP-04, 26, 30a, 74); `headingId` safe for any string; package fallback from unit 1 | + +No blocking findings. + +### Property-Based Testing (full enforcement) +| Rule | Status | Rationale / evidence | +|---|---|---| +| PBT-01 Property identification | Compliant | Section 3 lists the properties for every pure function and component of the unit | +| PBT-02 Round-trip | N/A | No parse/serialise or encode/decode pair is added by this unit (the slug/path and JSON-LD round trips are unit 1) | +| PBT-03 Invariants | Planned | `mosaicLayout`, `storyLayout`, `shootPageBands`, `readMoreLabel`, `headingId` plus four component properties (Section 3) | +| PBT-04 Idempotency | N/A | No operation with an idempotency contract is added (the placeholder idempotency is unit 1) | +| PBT-05 Oracle | N/A | No reference implementation | +| PBT-06 Stateful | N/A | The unit has no application state: FAQ state belongs to the browser (`details`), the timeline and mosaic are stateless, breakpoints are CSS | +| PBT-07 Generators | Planned | Reuse of unit 1's domain generators and three appended ones (Section 3) | +| PBT-08 Shrinking and reproducibility | Compliant | fast-check shrinking and the seed logging of `config/testSeed.ts` stay as they are | +| PBT-09 Framework | Compliant | fast-check is already a dependency | +| PBT-10 Complementary | Planned | Example-based, route-level and axe tests alongside (Section 3, "Not PBT") | + +## 5. Accessibility and Lighthouse acceptance (unit 2) + +- Lighthouse accessibility, best practices and SEO stay 1.0 on all five shoot pages, mobile and desktop; axe finds no violation in any new component or page test (NFR-ST-01). +- Contrast: all text uses existing tokens that pass on `paper` and `paper.alt` (`ink`, `ink.soft`, `accent.deep`); the filled last marker is white on `accent.deep` (about 5.7:1). `ink.muted` is not used for text. +- Touch targets of at least 44 x 44 px: breadcrumb links, FAQ `summary`, "Bekijk meer ...foto's", package and closing buttons, secondary links, "Lees meer". +- Keyboard: tab order equals reading order; the only new stops are links and `summary` elements; no keyboard trap; focus ring visible on every one. +- Performance: shoot pages stay in the photo-page bucket (mobile 0.85, goal 0.9; desktop 0.9). Measured after code generation and reported with numbers. + +## 6. Decision register (what changes with an answer) + +| Question | Provisional (recommended) | If the user chooses otherwise | +|---|---|---| +| Q1 Zwangerschap and Gezin photos | A: photos stay in stories 2 and 3; no mosaic | B: content edit only (`photos.images` order, stories 2 and 3 lose `image`); mosaic of two; no code change | +| Q2 Minimum photos | A: 2 | B: constant 3 (Newborn keeps its mosaic); C: constant 4 (Newborn loses it until one more photo); `mosaicLayout` unchanged | +| Q3 Mosaic click | A: not interactive | B: add `full` image per mosaic photo to the content type (unit 1 types touched), reuse `Lightbox`, tiles become buttons; BR-SP-33 and the `PhotoMosaic` props change | +| Q4 Text-only blocks | A: own band, narrow centred column | B: grouping of consecutive text-only stories; `storyLayout` returns groups and `shootPageBands` counts a group as one band | +| Q5 FAQ open | C: all closed (chosen 2026-10-30; recommended was A, first two) | Not applicable: answered. `FAQ_OPEN_COUNT` and `faqInitiallyOpen` are dropped (BR-SP-51, FaqList, PBT list) | +| Q6 "Lees meer" look | A: text link, first | B: outline `LinkButton` under the text; `ShootBlock` markup and tests change | +| Q7 OG images | A: landscape crop | B: composed card (needs a small generation script outside the repo, same output files); C: no `ogImage` entries, no files, BR-SP-80 and its test dropped | diff --git a/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/domain-entities.md b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/domain-entities.md new file mode 100644 index 0000000..b4bec07 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/domain-entities.md @@ -0,0 +1,157 @@ +# Domain Entities - Unit 2: Shoot page UI + +> Final — answers recorded in ../../plans/shoot-page-ui-fd-questions.md (2026-10-30); tags **[Q#]** mark values that depend on an answer. + +The data entities of the shoot pages (`ShootPageContent`, `ShootPageShared`, `ShootPageView`, `StoryBlock`, `FaqItem`, `ContentImage`, `PricingPackage`) exist since unit 1 and do not change; see [component-methods.md](../../../inception/application-design/component-methods.md). This document adds the UI-level entities of unit 2 (what the view is turned into before it is drawn) and the registry and image data the unit owns. Entity fields are in the tables below the diagram. + +## 1. Entity relationships + +```mermaid +graph TD + View["ShootPageView"] + Band["SectionBand"] + StoryL["StoryLayout"] + Story["StoryBlock"] + Tile["MosaicTile"] + Photo["ContentImage"] + Step["ProcessStep"] + Marker["TimelineMarker"] + Faq["FaqItem"] + Crumb["BreadcrumbItem"] + Offer["Offer block"] + Pkg["PricingPackage"] + Og["OgImage"] + Page["Registry entry sitePages"] + View -->|"orders into"| Band + View -->|"contains four"| Story + Story -->|"is laid out as"| StoryL + Story -->|"may have one"| Photo + View -->|"has six"| Step + Step -->|"is drawn with one"| Marker + View -->|"has zero or more"| Photo + Photo -->|"is placed in one"| Tile + View -->|"has three to five"| Faq + View -->|"has three"| Crumb + View -->|"has one"| Offer + Offer -->|"holds zero or one"| Pkg + Page -->|"has one per shoot"| Og + classDef entity fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef derived fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + classDef value fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + classDef registry fill:#4CAF50,stroke:#2e7d32,stroke-width:1px,color:#000; + class View,Story,Step,Faq,Crumb,Offer,Pkg entity; + class Band,StoryL,Tile,Marker derived; + class Photo value; + class Page,Og registry; +``` + +Text alternative: a ShootPageView orders into section bands and holds four story blocks, six process steps, photos, FAQ items, three breadcrumb items and one offer block; unit 2 derives a StoryLayout per story, a MosaicTile per mosaic photo and a TimelineMarker per step, and owns one OgImage per registry entry (blue = view data, purple = derived UI entities, orange = value entity, green = registry). + +## 2. New UI-level entities (all pure data, no identity of their own) + +### SectionBand (`lib/shootPageBands.ts`) +| Field | Type | Description | +|---|---|---| +| `id` | `'intro'`, `` `story-${string}` ``, `'process'`, `'photos'`, `'faq'`, `'offer'`, `'closing'` | Which section. The intro is not a band (it has no tone; it is always `paper`) | +| `tone` | `'paper' \| 'alt'` | Position even = `paper`, odd = `alt` | +| `position` | integer | 0 for the first story | + +Rules: consecutive positions over rendered sections only; optional sections (`photos`, `faq`) appear iff the view has them. + +### StoryLayout (`lib/storyLayout.ts`) +| Field | Type | Description | +|---|---|---| +| `tone` | `'paper' \| 'alt'` | From the story index (equal to its `SectionBand`) | +| `spacing` | `'flushTop' \| 'default'` | `flushTop` for index 0 | +| `reverse` | boolean | True for odd indexes: photo in the right column from `lg` | +| `priority` | boolean | True only for index 0 and only with an image | +| `media` | `{ aspectRatio: '3 / 2' \| '4 / 5'; mediaSize: 'half' \| 'medium' }` or absent | Absent for text-only stories | + +Orientation threshold: `width >= 1.2 * height` is landscape (the current data has 800x534 landscape = 1.50 and 800x1200 / 848x1060 portrait = 0.67 / 0.80, so there is a wide margin on both sides). + +### MosaicTile (`lib/mosaicLayout.ts`, shape fixed here) +| Field | Type | Description | +|---|---|---| +| `column` | string | CSS grid-column from `md`, e.g. `'1 / 3'` | +| `row` | string | CSS grid-row from `md`, e.g. `'1 / 3'` | +| `wide` | boolean | Spans both columns below `md` | +| `phoneRatio` | string | CSS aspect ratio of the tile below `md`: `'4 / 3'`, `'3 / 2'` or `'1 / 1'` | + +`mosaicLayout(count)` returns: + +| Count | Tiles (`column`, `row`, `wide`, `phoneRatio`) | +|---|---| +| 0 or below | none | +| 1 (never shown, kept total) | `'1 / 5'`, `'1 / 3'`, wide, `4 / 3` | +| 2 | (`1 / 3`, `1 / 3`, wide, `4 / 3`), (`3 / 5`, `1 / 3`, wide, `4 / 3`) | +| 3 | (`1 / 3`, `1 / 3`, wide, `4 / 3`), (`3 / 5`, `1 / 2`, wide, `3 / 2`), (`3 / 5`, `2 / 3`, wide, `3 / 2`) | +| 4 | (`1 / 3`, `1 / 3`, wide, `4 / 3`), (`3 / 5`, `1 / 2`, wide, `3 / 2`), (`3 / 4`, `2 / 3`, not wide, `1 / 1`), (`4 / 5`, `2 / 3`, not wide, `1 / 1`) | +| 5 or more | the layout for 4 (the caller shows the first four) | + +### TimelineMarker (inside `ProcessTimeline`) +| Field | Type | Description | +|---|---|---| +| `index` | integer | Position in the list; even = text above the line from `lg` | +| `isLast` | boolean | Filled marker, no vertical line below | +| `icon` | ReactNode | From `processIcons[step.id]`, or none for an unknown id | + +### Constants +| Name | Value | Where | Depends on | +|---|---|---|---| +| `MOSAIC_MIN_PHOTOS` | 2 | `lib/shootPageView.ts` (unit 2 may change the value only) | **[Q2]** (3 or 4 on other answers) | +| `MOSAIC_MAX_PHOTOS` | 4 | `lib/mosaicLayout.ts` | design | +| Timeline breakpoint | theme `lg` (64em, 1024 px) | responsive props, no pixel literal | decided | +| Mosaic breakpoint | theme `md` (48em, 768 px) | responsive props | decided | +| Text-only story column | 36rem | `StoryBlocks` | **[Q4]** | +| Marker size | 56 px (`14` in the spacing scale, 3.5rem) | `ProcessTimeline` | design E | +| Vertical timeline cap | 34rem | `ProcessTimeline` | decided | +| Mosaic row height | `clamp(12rem, 22vw, 18.75rem)` | `PhotoMosaic` | design E (300 px at wide screens) | + +## 3. Photo selection per shoot (from unit 1's data) + +"Page photos" are `ShootPageContent.photos.images`; the view removes any whose `src` is already used by a story or the package block (D14). Alts and sizes are unchanged from the portfolio/shoot data. + +| Shoot | Story 1 | Story 2 | Story 3 | Story 4 | Package photo | Mosaic (in order: large, wide, ...) | Result [Q1 = A] | +|---|---|---|---|---|---|---|---| +| Newborn | `shoots/newborn.jpg` 848x1060, 4 / 5 | `f41a8700` 800x534, 3 / 2 | `f41a7176` 800x1200, 4 / 5 | `f41a1916` 800x1200, 4 / 5 | `shoots/newborn-detail.jpg` | `f41a1922` (portrait), `f41a4650` (landscape), `f41a7284` (portrait) | 3-photo mosaic; the 4-layout appears when Andrea adds one photo | +| Zwangerschap | `shoots/zwangerschap.jpg` | `f41a8206` (3 / 2) | `f41a7883` (4 / 5) | text only | `shoots/zwangerschap-detail.jpg` | none left | no mosaic | +| Gezin | `shoots/gezin.jpg` | `f41a1579` (3 / 2) | `f41a7138` (4 / 5) | text only | `shoots/gezin-detail.jpg` | none left | no mosaic | +| Loveshoot | `shoots/loveshoot.jpg` | text only | text only | text only | `shoots/loveshoot-detail.jpg` | none left | no mosaic, three text-only bands | +| Portret | `shoots/portret.jpg` | text only | text only | text only | `shoots/portret-detail.jpg` | none left | no mosaic, three text-only bands | + +Under **[Q1 = B]** Zwangerschap and Gezin change to: story 2 and 3 text only, mosaic = the two portfolio photos (both listed in `photos.images`; the view then keeps them, since the stories no longer use them), result a 2-tile mosaic. This is a content edit in `content/shootPages/zwangerschap.ts` and `gezin.ts` (unit 2 owns the photo selection), not a code change. Note for Gezin: the `shoots/gezin*` photos show newborn families (CON-ST-05). + +Content tests (unit 1, `shootPages.test.ts`) keep guarding: no `src` twice on the rendered view, every image has an alt and positive size. + +## 4. Process icons (inline SVG, from design E) + +All: `viewBox="0 0 24 24"`, `fill="none"`, `stroke="currentColor"`, `stroke-width="1.5"`, `stroke-linecap="round"`, `stroke-linejoin="round"`, `aria-hidden="true"`, `focusable="false"`, 24 x 24 px. + +| Step id | Motif | Shapes (design E, verbatim) | +|---|---|---| +| `aanvragen` | Envelope | `<rect x="3" y="5.5" width="18" height="13"/>`, `<path d="M3.5 6.5l8.5 6.5 8.5-6.5"/>` | +| `datum` | Calendar with heart | `<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"/>` | +| `aanbetaling` | Coin | `<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"/>` | +| `shoot` | Camera | `<path d="M3 8h4l1.6-2.5h6.8L17 8h4v11H3z"/>`, `<circle cx="12" cy="13.5" r="3.5"/>` | +| `bewerking` | Sliders | `<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"/>` | +| `oplevering` | Picture | `<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"/>` | + +## 5. Registry and OG images (SEO-ST-05) [Q7] + +`PageMeta.ogImage?: { path; width; height; alt }` exists. Unit 2 adds, per shoot, `ogImage: { path: '/og-<id>.jpg', width: 1200, height: 630, alt }` and the file `web/public/og-<id>.jpg` (JPEG, 1200 x 630, at most about 100 KB; the existing ones are 54-92 KB). + +Proposed sources for **[Q7 = A]** (a landscape 1.91:1 crop; the five crops are shown to the user before they are fixed, as decided in Application Design): + +| Shoot | Proposed source | Source size | Crop | Note | +|---|---|---|---|---| +| Newborn | `assets/portfolio/f41a4650-groot.jpg` (baby fist; alternative `f41a8700-groot`, check it differs from `og-soorten-fotoshoots.jpg`) | landscape ~1600 x 1067 | ~1600 x 840, scaled down | Sharp | +| Zwangerschap | `assets/portfolio/f41a8206-groot.jpg` (belly in black dress) | landscape ~1600 x 1067 | ~1600 x 840, scaled down | Sharp | +| Gezin | `assets/portfolio/f41a1579-groot.jpg` (big brother kisses baby) | landscape ~1600 x 1067 | ~1600 x 840, scaled down | `og-portfolio.jpg` already uses this alt text; if it is the same photo, use `f41a7138-groot` (portrait, softer) instead | +| Loveshoot | `assets/shoots/loveshoot.jpg` | portrait 848 x 1060 | 848 x 445, scaled up about 1.4x | Slightly soft; no landscape photo exists yet | +| Portret | `assets/shoots/portret.jpg` | portrait 848 x 1060 | 848 x 445, scaled up about 1.4x | Same | + +Alt text = the alt of the source photo (Dutch, descriptive), like the existing entries. The files are produced once by a throw-away script outside the repository (no new dependency); only the five JPEGs and the `sitePages.ts` fields are committed. A test (registry consistency) asserts for every shoot: `ogImage` defined, path `/og-<id>.jpg`, 1200 x 630, non-blank alt, and the file exists in `web/public/`. + +## 6. Overview link entity + +`readMoreLabel(shoot: ShootType): string` = `Lees meer over de ${shoot.shootLabel.toLowerCase()}`. Real values: "Lees meer over de newbornshoot", "... zwangerschapsshoot", "... gezinsshoot", "... loveshoot", "... portretshoot". Target: `shootPagePath(shoot.id)`. diff --git a/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/frontend-components.md b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/frontend-components.md new file mode 100644 index 0000000..0d19f3d --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/construction/shoot-page-ui/functional-design/frontend-components.md @@ -0,0 +1,292 @@ +# Frontend Components - Unit 2: Shoot page UI + +> Final — answers recorded in ../../plans/shoot-page-ui-fd-questions.md (2026-10-30); tags **[Q#]** mark what an answer would change (register in [business-rules.md § 6](business-rules.md)). + +Props follow [component-methods.md](../../../inception/application-design/component-methods.md); this document fixes the details Application Design handed over and records the few additions (marked **new**). Rules: [business-rules.md](business-rules.md). Logic: [business-logic-model.md](business-logic-model.md). + +## 1. Component hierarchy + +```mermaid +graph TD + Route["Route newborn.tsx etc: StructuredData and ShootPage"] --> SP["ShootPage"] + SP --> Bands["lib shootPageBands"] + SP --> Intro["PageIntro with breadcrumb slot"] + Intro --> Crumb["Breadcrumb"] + SP --> Stories["StoryBlocks"] + Stories --> SL["lib storyLayout"] + Stories --> MT["MediaText medium or half"] + MT --> FI["FramedImage"] + Stories --> RP["RichParagraph"] + SP --> Proc["PageSection and SectionHeading"] + Proc --> TL["ProcessTimeline"] + TL --> Icons["ProcessIcons"] + SP --> Photos["PageSection with photo head"] + Photos --> Mosaic["PhotoMosaic"] + Mosaic --> ML["lib mosaicLayout"] + Mosaic --> DI["DeferredImage"] + SP --> Faq["PageSection with FAQ head"] + Faq --> FL["FaqList"] + FL --> RP + SP --> Pkg["PackageBlock"] + Pkg --> MT + Pkg --> LB["LinkButton"] + SP --> Cta["CallToAction with tone"] + Cta --> LB + Overview["Overview route"] --> SBlock["ShootBlock with Lees meer link"] + SBlock --> RL["lib readMoreLabel"] + classDef root fill:#4CAF50,stroke:#2e7d32,stroke-width:1px,color:#000; + classDef page fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + classDef pure fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + classDef reused fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + class Route,Overview root; + class SP,Intro,Crumb,Stories,Proc,TL,Icons,Photos,Mosaic,Faq,FL,Pkg,SBlock,Cta page; + class Bands,SL,ML,RL pure; + class MT,FI,RP,DI,LB reused; +``` + +Text alternative: the five shoot routes render ShootPage, which uses shootPageBands to compose the intro with Breadcrumb, StoryBlocks on MediaText, the timeline, the optional mosaic, the FAQ, the package block and the closing call to action; the overview ShootBlock gets a Lees meer link (green = routes, blue = unit 2 components, purple = pure helpers, yellow = reused components). + +## 2. Shared building blocks (`web/src/components/`) + +### Breadcrumb (new) +- **Props**: `label: string` (nav name), `items: readonly BreadcrumbItem[]`, optional `data-testid`. +- **State**: none. +- **Markup**: `nav[aria-label]` > `ol` (flex, wrap, centred, gap 2, `fontSize` 0.875rem, `color ink.soft`) > `li` per item; links are the router `Link` via `RouterLink` with `activeOptions={{ exact: true }}`, accent.deep text, permanent underline, `minH` 44 px, inline-flex centred; the last item is a `span` with `aria-current="page"` and `ink` colour; between items `li[aria-hidden="true"]` with "/". +- **Behaviour**: BR-SP-01..04. No items: renders nothing. +- **Used by**: `ShootPage` through the `PageIntro` slot. Generic (no shoot knowledge). + +### PageIntro (changed, additive) +- **New props**: `titleId?: string` (id of the h1; `aria-labelledby` of the section), `breadcrumb?: ReactNode` (rendered above the eyebrow, `mb` 6 on phones, 7 from `md`). +- Existing callers unchanged (BR-SP-05); one test pins their markup. + +### ProcessTimeline (new) +- **Props**: `steps: readonly { id: string; title: string; text: string; icon?: ReactNode }[]`, `tone?: 'paper' | 'alt'` (**new**, default `paper`, the band colour the markers use to hide the line), `data-testid`. +- **State**: none. +- **Markup**: `Reveal` > `ol[role="list"]` (no list style) > `li` per step > [decorative marker `div[aria-hidden]` containing the icon; decorative line segments `span[aria-hidden]`; text block with `h3` (heading font, `xl`, tight line height) and `p` (0.9375rem, line-height 1.6, `ink.soft`)]. +- **Layout**: below `lg` one column, `li` = grid `3.5rem | 1fr`, column gap 5 (20 px), padding-bottom 8 except the last, list capped at 34rem and centred, vertical line from the marker centre to the bottom of the `li` (hidden on the last), text top-aligned with `pt` 3. From `lg` the `ol` is `repeat(<n>, minmax(0, 1fr))` by `auto 3.5rem auto` rows, each `li` spans the three rows with `gridTemplateRows: subgrid` (fallback `1fr 3.5rem 1fr`), the marker in row 2 with the horizontal line behind it (first `li`: from the centre; last: to the centre), text in row 1 (end-aligned, `pb` 6) for even indexes and row 3 (start-aligned, `pt` 6) for odd, text centred, `px` 3. +- **Behaviour**: BR-SP-20..26. Last marker filled. Reading order = DOM order = `steps` order. +- **Not here**: no step numbering, no per-step motion, no knowledge of shoots, deposits or placeholders. + +### PhotoMosaic (new) +- **Props**: `images: readonly ContentImage[]`, `data-testid`. +- **State**: none. +- **Markup**: `ul[role="list"]` as a grid (below `md` two columns; from `md` four columns by two rows of `clamp(12rem, 22vw, 18.75rem)`; gap `gridGap`) > `Reveal as li` (delay `index * 0.08`) with the tile's `column`/`row` (from `md`) or span 2 when `wide` (below `md`), `aspectRatio` = `phoneRatio` below `md` and `auto` from `md`, `position: relative`, `overflow: hidden`, `bg paper.deep` > `DeferredImage` absolutely filling the cell (`objectFit: cover`, intrinsic width/height attributes kept). +- **Behaviour**: BR-SP-30b..35; takes the first `MOSAIC_MAX_PHOTOS`; renders nothing for an empty list. Not interactive **[Q3 = A]**. +- The section frame (eyebrow, h2, portfolio link) is composed by `ShootPage`; the component itself is only the grid. + +### FaqList (new) +- **Props**: `items: readonly FaqItem[]`, `data-testid`. +- **State**: none (the browser owns open/closed; no item has the `open` attribute at load **[Q5 = C]**). +- **Markup**: `Box` with a top hairline (`sand`) > per item `details` (bottom hairline) > `summary` (`display flex`, space-between, `minH` 44 px, `py` 5, heading font 1.25rem, `ink`, `cursor pointer`, `listStyle none`, WebKit marker hidden, focus ring from the theme `focusRing` token with offset) containing the question and the decorative icon (`svg[aria-hidden]`, plus; vertical stroke hidden by CSS under `details[open]`), followed by `RichParagraph` of the answer with `mb` 6 and `maxW` 680 px. +- **Behaviour**: BR-SP-50..52. No JavaScript, no animation. + +### PackageBlock (new) +- **Props** (as in component-methods.md): `titleId`, `eyebrow`, `title`, `image: ContentImage`, `frameColor?`, `pkg?: PricingPackage`, `onRequest: { price: string; text: string }`, `note?: string`, `children` (the actions), `data-testid`. +- **Markup**: `MediaText mediaSize="small"` with `image` (aspect `1 / 1`, deferred, `frameColor`); text column: `Eyebrow`, `h2#titleId` (`sectionTitle`), price paragraph (heading font, 2.25rem, `accent.deep`, `formatPrice(pkg.price)` or `onRequest.price`), then either the features `ul` (rows with `sand` top border, the last also with a bottom border) or the `onRequest.text` paragraph (`ink.soft`), the actions row (flex, wrap, gap 3 / 7, centred vertically, children), and the note paragraph (0.875rem, `mt` 5). +- **Behaviour**: BR-SP-60..62. Package or on-request is `pkg` presence only; never a shoot id. + +### MediaText (changed, additive) - **new addition to the file ownership table** +- `mediaSize` accepts `'medium'` in addition to `'half'` and `'small'`: photo column up to 30rem (480 px, design E's portrait width) with the text, up to 36rem, centred in the rest, exactly as `small` does. Existing sizes and callers unchanged; a test for `medium` is added to `MediaText.test.tsx`. +- Reason: with `half` the 4:5 photo would be about 580 x 725 px at 1240 px content (taller than design E's 480 x 600); with `small` (320 px) it would be much smaller than design E. Neither is a hard-coded override, and the overview page keeps `small`. + +### CallToAction (changed, additive) - **new addition to the file ownership table** +- New optional `tone?: 'paper' | 'alt'`, default `'alt'` (today's behaviour). `ShootPage` passes the band tone so the closing band never equals the package band (design E has it on paper). Existing callers unchanged; one test added. + +## 3. Shoot page parts (`web/src/components/shoots/`) + +### ShootPage (sections added to unit 1's shell) +- **Props**: `{ view: ShootPageView }`; no state, no content imports. +- **Composition** (order = `shootPageBands(view)`): + 1. `PageIntro` (`eyebrow`, `title`, `titleId="intro-title"`, `breadcrumb=<Breadcrumb/>`), text from `view.intro.text`. + 2. `StoryBlocks` (`stories`, `frameColor = view.shoot.frameColor`, `idPrefix="story"`). + 3. `PageSection id="zo-werkt-het" labelledBy="process-title" tone` with `SectionHeading` (eyebrow, h2, lead from `view.process`) and `ProcessTimeline` (steps with icons from `processIcons`). + 4. If `view.photos`: `PageSection id="impressie" labelledBy="photos-title" tone`: head (eyebrow, h2 `photos-title`, "Bekijk meer {photosLabel}" link when `portfolioLink`) and `PhotoMosaic`. + 5. If `view.faq`: `PageSection id="vragen" labelledBy="faq-title" tone`: two columns from `lg` (eyebrow, h2 `faq-title`, `RichParagraph` of the lead | `FaqList`), stacked below `lg`. + 6. `PageSection id="pakket" labelledBy="offer-title" tone` with `PackageBlock` and its actions (BR-SP-60). + 7. `CallToAction` (`titleId="closing-title"`, `tone`, rich-text lead, accent `LinkButton`). +- `data-testid`s: `shoot-page`, `shoot-breadcrumb`, `story-<id>`, `process-timeline`, `photo-mosaic`, `faq-list`, `package-block`, `shoot-closing`. + +### StoryBlocks (new) +- **Props**: `stories`, `frameColor`, `idPrefix`. +- **Behaviour**: `storyLayout(stories)` gives each block its tone, spacing, side, priority and media. Block with media: `PageSection` (labelled by its h2) > `MediaText` (`image`, `aspectRatio`, `mediaSize`, `reverse`, `priority`, `frameColor`) with the text column: `Eyebrow`, `h2` (`sectionTitle`), a stack of `RichParagraph`s (gap 4, `ink.soft`). Block without media **[Q4 = A]**: the same `PageSection` (width `narrow`) with the same text column inside a `Reveal`, `maxW` 36rem, centred; no `MediaText`, no frame. +- Heading id: `headingId(idPrefix, story.id)` plus `-title`. + +### ProcessIcons (new) +- `processIcons: Record<ProcessStepId, () => JSX.Element>` (six components, paths in domain-entities.md § 4). `ShootPage` maps `view.process.steps` through it; an id without an icon yields no icon (BR-SP-74). + +### ShootBlock (changed) +- New first link in the links row: `Link variant="underline"` > `RouterLink to={shootPagePath(shoot.id)}` with the text `readMoreLabel(shoot)` and the same `py` as the other links (44 px target), `data-testid="shoot-<id>-readmore"` **[Q6 = A]**. Props unchanged; tests: link text and href per shoot, unique accessible names across the list, existing anchors and links still present. + +## 4. Responsive behaviour + +| Width | Story blocks | Timeline | Mosaic | FAQ | Package | +|---|---|---|---|---|---| +| 320 - 767 px (base) | Photo above text, frame hidden by `FramedImage` below `sm` | Vertical | 2 columns, phone ratios | Stacked | Stacked, photo first | +| 768 - 1023 px (`md`) | Photo above text | Vertical, capped at 34rem | 4x2 grid, row 12rem or more | Stacked | Stacked | +| 1024 px and up (`lg`) | Two columns, side alternates | Horizontal, alternating texts | 4x2 grid, row up to 18.75rem | Two columns (1/3 and 2/3) | Two columns | +| Ultrawide | Content capped by `content` token (8xl) | Same | Same | Same | Same | + +- No horizontal scroll from 320 px: grids use `minmax(0, 1fr)`, text wraps, nothing has a fixed width above 100 %. +- 200 % zoom behaves like half the width: a 1280 px window at 200 % is 640 px wide, so the vertical timeline and stacked layouts apply (the vertical layout is also the reflow fallback required by WCAG 1.4.10). + +## 5. Interaction flows + +```mermaid +graph TD + visit["Visitor on a shoot page"] --> crumb["Taps a breadcrumb link: Home or Soorten fotoshoots"] + visit --> faq["Taps or presses Enter or Space on a question: details opens or closes"] + visit --> more["Taps Bekijk meer foto's: portfolio filtered on this shoot"] + visit --> book["Taps Boek dit pakket or the closing button: contact page with the package preselected"] + visit --> ask["Taps Eerst een vraag stellen or Vraag naar de mogelijkheden: contact page"] + overview["Visitor on the overview page"] --> readmore["Taps Lees meer over de newbornshoot: shoot page"] + classDef start fill:#4CAF50,stroke:#2e7d32,stroke-width:1px,color:#000; + classDef action fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; + class visit,overview start; + class crumb,faq,more,book,ask,readmore action; +``` + +Text alternative: on a shoot page the visitor can follow the breadcrumb, toggle FAQ items, open the portfolio, or go to the contact page from the package or closing buttons; on the overview page the Lees meer link leads to the shoot page. + +- Only links and FAQ toggles are interactive; there is no component state, no form, no modal. Focus handling on route change is the existing `useRouteFocus` behaviour of the shell and is unchanged. +- **Form validation rules**: none (no forms). **Error handling**: unknown shoots and mismatched content are handled in unit 1 (`NotFound`); every component omits itself on empty input (BR-SP-74). +- **API integration points**: none (static, flat content; the CMS API replaces the content modules 1-to-1 later). Link targets: `/`, `/soorten-fotoshoots`, `/portfolio?shoot=<id>` (`shootPortfolioLink`), `/contact?pakket=<id>` (`shootContactLink`), `/contact`, `/soorten-fotoshoots/<id>` (`shootPagePath`). + +## 6. Accessibility checklist (WCAG 2.1 AA, NFR-ST-01) + +| Item | Where | Check | +|---|---|---| +| One h1, h2 per section, h3 per step, no skipped level | `ShootPage` | Heading outline example test per shoot (with and without mosaic and FAQ) | +| Every section named by its heading | all sections | `aria-labelledby` ids via `headingId`; axe | +| Breadcrumb landmark and current page | `Breadcrumb` | `nav` "Kruimelpad", one `aria-current="page"`, nothing else current on the page | +| List semantics survive styling | timeline, mosaic | `role="list"` on the `ol`/`ul` | +| Decorative graphics hidden | icons, markers, line, separators, FAQ icon | `aria-hidden`, no focusable SVG | +| Disclosure operable by keyboard | `FaqList` | Native `summary`; visible focus ring; 44 px high | +| Touch targets | links, buttons, `summary` | At least 44 px high | +| Contrast | all text | Existing tokens only (`ink`, `ink.soft`, `accent.deep`); no `ink.muted` text | +| Motion | `Reveal` only | `prefers-reduced-motion` shows content at once; FAQ and timeline have no motion | +| Images | all | Non-empty alt (content test), intrinsic width and height | +| Reading order | timeline | DOM order = visual order in both layouts (texts above and below the line are separate grid rows, not reordered visually against the DOM) | +| Name clashes | overview and page | Package button and closing button have different names; "Lees meer" names unique per shoot | + +## 7. Lighthouse and performance checklist + +| Item | Decision | +|---|---| +| Largest contentful paint | Photo of story block 0 (priority, `fetchPriority="high"`, no lazy loading); fallback to text when block 0 has no photo | +| All other photos | `DeferredImage` (waits for the page load event and the viewport) | +| Layout shift | Width/height on every image; grid cells or aspect ratios reserve all photo space; `Reveal` only changes opacity and a transform | +| Code splitting | Unchanged from unit 1: each route imports its own content; the new components live in the shared shoot-page chunk, not in the main bundle | +| Bundle | No new dependency; six inline SVGs; native `details` | +| Budgets | Mobile 0.85 (goal 0.9) via `photoPagePaths`, desktop 0.9, accessibility / best practices / SEO 1.0; measured after code generation, reported with numbers, not worked around | +| Mitigation order if the largest paint regresses | (1) first story without the fade-in, (2) fewer pixels for the first photo by capping its column, (3) report and keep the known limit | + +## 8. Files for this unit (additions to the ownership table in application-design.md) + +| Path (under `web/` unless noted) | Action | +|---|---| +| `src/components/Breadcrumb/*`, `ProcessTimeline/*`, `PhotoMosaic/*`, `FaqList/*`, `PackageBlock/*` (component + test each) | create | +| `src/components/PageIntro/*` | change (additive) | +| `src/components/MediaText/*` | change (additive `medium`) | +| `src/components/CallToAction/*` | change (additive `tone`) | +| `src/components/shoots/ShootPage/*`, `StoryBlocks/*`, `ProcessIcons/*`, `ShootBlock/*` | create / change | +| `src/lib/mosaicLayout.ts`, `storyLayout.ts`, `shootPageBands.ts`, `readMoreLabel.ts`, `headingId.ts` (+ tests) | create | +| `src/lib/shootPageView.ts` | `MOSAIC_MIN_PHOTOS` value only **[Q2]** | +| `src/content/shootPages/*.ts` | photo selection and alt texts only **[Q1]** | +| `src/sitePages.ts` | five `ogImage` fields **[Q7]** | +| `public/og-<id>.jpg` x 5 | create **[Q7]** | +| `src/shootPages.test.tsx` | create: page structure per shoot, overview links, OG registry consistency, heading outline, axe | +| `src/test/arbitraries.ts` | append only | +| `LAYOUT.md`, `.ai/layout-conventions.md` (repo root) | change (section 9) | + +`MediaText` and `CallToAction` are not touched by unit 3, so the units stay disjoint. `theme.ts` is expected to need no change (all values use existing tokens or component-level rem values). + +## 9. LAYOUT.md "Shoot page" section + +Source to place after "Types of shoots" in `LAYOUT.md` (the repository's template: `block-beta`, one block per section, lettered A to J in page order; Photos is shown although it is omitted below the minimum, as the diagram is the abstract page). Letters A-G keep their colours; H, I and J are new, with stroke = fill x 0.75 (rounded) as the convention requires: + +| Letter | Block | Fill | Stroke | +|---|---|---|---| +| A | Intro (with breadcrumb) | `#e76f51` | `#ad533d` | +| B | Story 1 | `#f4a261` | `#b77a49` | +| C | Story 2 | `#2a9d8f` | `#20766b` | +| D | Story 3 | `#264653` | `#1d353e` | +| E | Story 4 | `#e9c46a` | `#af9350` | +| F | Process timeline | `#b56576` | `#884c59` | +| G | Photos | `#6d7fcc` | `#525f99` | +| H | FAQ | `#9b6bb5` (new) | `#745088` | +| I | Package | `#4cc3e0` (new) | `#3992a8` | +| J | Book | `#8cb83f` (new) | `#698a2f` | + +Calculation: H 155,107,181 x 0.75 = 116,80,136 = `#745088`; I 76,195,224 x 0.75 = 57,146,168 = `#3992a8`; J 140,184,63 x 0.75 = 105,138,47 = `#698a2f`. The new colours are distinct from the seven existing ones (purple, cyan, lime) with the same medium-high saturation. + +```text +block-beta +columns 1 + A["Intro"] + B["Story 1"] + C["Story 2"] + D["Story 3"] + E["Story 4"] + F["Process timeline"] + G["Photos"] + H["FAQ"] + I["Package"] + J["Book"] + + style A fill:#e76f51,stroke:#ad533d,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style B fill:#f4a261,stroke:#b77a49,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style C fill:#2a9d8f,stroke:#20766b,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style D fill:#264653,stroke:#1d353e,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style E fill:#e9c46a,stroke:#af9350,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style F fill:#b56576,stroke:#884c59,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style G fill:#6d7fcc,stroke:#525f99,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style H fill:#9b6bb5,stroke:#745088,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style I fill:#4cc3e0,stroke:#3992a8,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px + style J fill:#8cb83f,stroke:#698a2f,color:#fff,font-size:16px,width:400px,height:125px,stroke-width:2px +``` + +Preview of the same order (documentation colours with black text; D is lightened here so its label stays readable, the real LAYOUT.md block keeps `#264653`): + +```mermaid +graph TD + A["A Intro"] --> B["B Story 1"] + B --> C["C Story 2"] + C --> D["D Story 3"] + D --> E["E Story 4"] + E --> F["F Process timeline"] + F --> G["G Photos"] + G --> H["H FAQ"] + H --> I["I Package"] + I --> J["J Book"] + classDef a fill:#e76f51,stroke:#ad533d,color:#000; + classDef b fill:#f4a261,stroke:#b77a49,color:#000; + classDef c fill:#2a9d8f,stroke:#20766b,color:#000; + classDef d fill:#7fb3c8,stroke:#1d353e,color:#000; + classDef e fill:#e9c46a,stroke:#af9350,color:#000; + classDef f fill:#b56576,stroke:#884c59,color:#000; + classDef g fill:#6d7fcc,stroke:#525f99,color:#000; + classDef h fill:#9b6bb5,stroke:#745088,color:#000; + classDef i fill:#4cc3e0,stroke:#3992a8,color:#000; + classDef j fill:#8cb83f,stroke:#698a2f,color:#000; + class A a; + class B b; + class C c; + class D d; + class E e; + class F f; + class G g; + class H h; + class I i; + class J j; +``` + +Text alternative: the Shoot page runs from the intro through four story blocks, the process timeline, the photos, the FAQ and the package block to the booking band, each block keeping its permanent letter colour (H purple, I cyan and J lime are new). + +`.ai/layout-conventions.md` gets the same three `style` lines appended to the template list, and its sentence "extend with a new letter using the same formula if an 8th block is ever needed" is updated to name the 10 letters. "Types of shoots" and Shell stay unchanged (the new links add no section; the Shell diagram shows no menu items). The note under the photo block in LAYOUT.md may say that Photos is omitted when fewer than the minimum photos exist. + +## 10. Test plan summary (code generation input) + +- **Pure functions** (PBT + examples): `mosaicLayout`, `storyLayout`, `shootPageBands`, `readMoreLabel`, `headingId` (100 % coverage, `src/lib/**` threshold). +- **Component tests** (`renderWithProviders`, axe in each): `Breadcrumb`, `ProcessTimeline` (order, alternation by `data-` attribute or class-independent DOM order, last marker, `role="list"`), `PhotoMosaic` (2, 3, 4, 5 photos; empty), `FaqList` (all closed at load, answers in the DOM, keyboard toggle with `userEvent`), `PackageBlock` (both variants), `StoryBlocks` (photo and text-only; first priority image; others not), `PageIntro` (unchanged output without the new props), `MediaText` (`medium`), `CallToAction` (`tone`), `ShootBlock` (Lees meer). +- **Route-level** (`shootPages.test.tsx`, via `renderApp`): per shoot the heading outline, sections present or omitted (Newborn mosaic present; Loveshoot no mosaic, "Prijs op aanvraag"; Newborn "Boek dit pakket" to `/contact?pakket=newborn`), breadcrumb, a single `aria-current="page"` in the whole page including header and footer, OG registry (BR-SP-80), overview links and anchors. +- Existing tests stay green unchanged; `pnpm check` incl. Lighthouse as the unit gate. diff --git a/aidlc-docs/features/shoot-type-pages/content-pending.md b/aidlc-docs/features/shoot-type-pages/content-pending.md new file mode 100644 index 0000000..8c4cc83 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/content-pending.md @@ -0,0 +1,134 @@ +# Shoot-type pages: content still pending + +Date: 2026-10-31 + +The feature shoot-type-pages is **complete and merged to master** (PR #13) with draft texts. On 2026-10-31 the owner decided that the final texts, the open questions and the extra photos are handled in a **separate, later feature** (for example `shoot-type-pages-content`). That feature starts from master and uses this document as its input. **Gate:** no `DRAFT(CON-ST-03)` or `OPEN(CON-ST-04)` marker may reach production. Production deploys only from a `release/*` branch, so check the markers before the first release that contains these pages. + +## 1. Status and blocker + +| Item | State | +|---|---| +| Code for all three units (content/SEO foundation, shoot page UI, navigation submenu, FR-ST-14) | Done and committed. The test deploy was green (CI run 586) | +| OG images (5 x 1200x630) | Done, approved by the owner on 2026-10-30 | +| All draft texts (98 `DRAFT(CON-ST-03)` markers) | **Waiting**: Andrea has to approve or change them | +| Answers to the open questions (7 `OPEN(CON-ST-04)` markers) | **Waiting**: Andrea | +| Extra photos (25 in total) | **Waiting**: Andrea. The pages work without them, but look emptier | + +Blocker: Andrea has not returned approved texts, answers or photos ("they come later, they are not ready yet"). She delivers via Bryan (the owner). Nothing in the code is open; only content is (CON-ST-03 in `requirements.md`; NFR-ST-05 SECURITY-09: no draft markers in production). + +## 2. Where things are + +Paths are relative to `aidlc-docs/features/shoot-type-pages/` unless they start with `web/`. + +| What | Where | +|---|---| +| Review doc sent to Andrea (Dutch). The .docx in an earlier session's scratchpad is temporary; this is the durable copy | `construction/content-review/andrea-review.md`: ch. 2 questions (1-7 plus two optional), ch. 3 shared texts, ch. 4 texts per shoot, ch. 5 photos. The last column "Ref." gives the `file:line` of each text | +| Draft list (98 lines) | `construction/content-and-seo-foundation/code/draft-list.txt` | +| Open list (7 lines) | `construction/content-and-seo-foundation/code/open-list.txt` | +| Content sources | `web/src/content/shootPages/{newborn,zwangerschap,gezin,loveshoot,portret}.ts`, `web/src/content/shootPageShared.ts` (texts on all pages), `web/src/sitePages.ts` (page titles and descriptions), `web/src/content/shootTypes.ts` (Gezin overview text) | +| Rules | `inception/requirements/requirements.md` (CON-ST-01..05, FR-ST-05, FR-ST-14); D3 and D6 in `inception/application-design/application-design.md` | +| Code summaries | `construction/*/code/code-summary.md` (three units) | + +The `file:line` numbers in the two lists and the review doc date from commit time. Regenerate the lists after edits (run from `web/`): + +```bash +rg -n "DRAFT\(CON-ST-03\)" src +rg -n "OPEN\(CON-ST-04\)" src +``` + +A text can carry both markers (the DRAFT line with the OPEN line directly below it). + +## 3. Texts, step by step + +### 3.1 Apply an approved or changed text + +1. Find the text via the "Ref." column in `andrea-review.md` or via the `rg` command above. +2. Andrea marked "Akkoord": keep the string and delete the `// DRAFT(CON-ST-03): awaiting Andrea's approval` line directly above it. +3. Andrea marked "Aanpassen": replace the string with her wording exactly as she wrote it, then delete the DRAFT line. +4. One marker covers one field or one object (for example a whole story block with `eyebrow`, `title` and `paragraphs`). Check that every field below the marker is approved before removing it. +5. Keep placeholders: `{aanbetaling}`, `{opleverduur}`, `{locatie}`, `{duur}`. Never type 50 or "2-3 weken" into a text. +6. Texts in `shootPageShared.ts` appear on all five pages (breadcrumb, steps, FAQ "Wanneer krijg ik de foto's?" and "Hoe leg ik de datum vast?", button labels, "Prijs op aanvraag"). A change there changes every shoot; tell Andrea. +7. Other places with DRAFT markers: `shootTypes.ts` (the Gezin overview text, 1 marker) and `sitePages.ts` (titles and descriptions, 10 markers). +8. Run `pnpm test` from `web/`. `src/content/shootPages/shootPages.test.ts` checks, among others: unknown placeholders, bracket placeholders, e-mail addresses, cancellation text, 3 to 5 FAQ items, duration versus package (D6), photo alt text and size. + +### 3.2 Resolve the open questions (`OPEN(CON-ST-04)`) + +Question numbers are those of `andrea-review.md` chapter 2. Remove an OPEN line once its answer is processed. + +| Marker (file:line at commit time) | Question | What changes, depending on the answer | +|---|---|---| +| `loveshoot.ts:80` | Q1: duration of a loveshoot | Duration given: set `process.duration` to her wording, e.g. "N uur fotografie, ...", and fix any other text that mentions the duration. Loveshoot has no package, so the D6 test (`names the duration of its package`) does not apply; if a package is added later, its feature "N uur fotografie" must be the start of `process.duration`. No answer: keep "We stemmen de duur samen af." (only if Andrea accepts that text) | +| `portret.ts:82` | Q2: duration of a portrait shoot (possibly different for natuur and zakelijk) | As Q1, in `portret.ts` `process.duration`. For two durations use one sentence with both; do not invent one | +| `portret.ts:54` (story `locatie`) and `portret.ts:79` (`process.location`) | Q3: locations for portrait shoots (natuur / zakelijk) | Add only the places she names, to the story paragraph and to `process.location`, and keep the two consistent. No answer: the generic "We kiezen samen een plek ..." stays | +| `shootPageShared.ts:18` (`bookingFaq`) and `shootPageShared.ts:90` (`deposit.note`) | Q4: does the EUR 50 deposit also apply to Loveshoot and Portret? Q5: when exactly is the remainder paid (right after the shoot, or before delivery)? | Q4 yes: nothing changes, remove the OPEN lines. Q4 no: these texts are shared by all shoots, so they need a per-shoot variant (type change in `web/src/content/types.ts`, `web/src/lib/shootPageView.ts`, tests and fast-check generators); ask Bryan first. Q5: reword "het restbedrag betaal je na de shoot" with her wording in both places and keep them identical | +| `shootPageShared.ts:81` (step `oplevering`) | Q6: do Loveshoot and Portret also get a personal online gallery? | Yes: remove the OPEN line. No: the step text is shared, so add a per-shoot override or reword it so it is true for all five; ask Bryan first (type-level change as above) | + +Not in the open list: Q7 (Newborn block 4 title "1 tot 2 uur, op het ritme van je baby", `newborn.ts:91`) and the optional Q8/Q9 (photo counts for Loveshoot and Portret) have no `OPEN` marker. Treat Q7 as an ordinary text: keep or reword the title, and keep it consistent with `newborn.ts:112` and the package feature "1-2 uur fotografie". Q8/Q9: use only a number she actually gives (CON-ST-04: do not invent numbers) and discuss with Bryan where it would go. + +### 3.3 Newborn birth-date exception (CON-ST-01) + +Newborn keeps its sentence about a provisional date that moves with the birth ("We zetten een voorlopige datum rond je uitgerekende datum en schuiven mee als jullie baby eerder of later komt": FAQ 1 at `newborn.ts:147`; the closing text at `newborn.ts:189` also mentions the due date). It is a Newborn-only planning fact, decided by the owner on 2026-10-29. Do not copy it to other shoots and do not remove it as "cleanup". Other shoots say nothing about cancelling or rescheduling (Clarification 2 = B); a test enforces that. + +### 3.4 Fact rules (CON-ST-01, CON-ST-04) + +- No invented facts, prices, durations, photo counts, locations or equipment (the design's "ik neem dekens en doeken mee" and "korte checklist" were left out for this reason). +- Fixed facts: deposit EUR 50 (settled against the total, remainder after the shoot), delivery 2-3 weken, reply within 1-2 werkdagen, six steps, prices from `web/src/content/packages.ts` (Newborn 185, Zwangerschap 175, Gezin 175; Loveshoot and Portret "Prijs op aanvraag"). +- One source per fact (NFR-ST-04): use the placeholders and `packages.ts`, never retype a figure. +- Andrea's own wording wins over the draft. + +## 4. Photos, step by step + +### 4.1 What is needed + +Slot shapes (`andrea-review.md` ch. 5): blocks 1, 3 and 4 portrait 4:5; block 2 landscape 3:2; mosaic of up to 4 tiles (1 large portrait, 1 wide landscape, 2 small near-square, cropped to fill); package block square 1:1. A photo may appear **once per page** (D14: the view drops duplicates and a test fails on them). + +| Shoot | Extra photos | Which | +|---|---|---| +| Newborn | 1 | portrait or landscape, small mosaic tile (the mosaic shows 3 now) | +| Zwangerschap | 5 | 1 portrait (block 4 story); mosaic: 1 portrait, 1 landscape, 2 free | +| Gezin | 5 | same as Zwangerschap. The current Gezin photos (`assets/shoots/gezin*`) show families with a newborn | +| Loveshoot | 7 | 1 landscape (block 2), 2 portrait (blocks 3 and 4); mosaic: 1 portrait, 1 landscape, 2 free | +| Portret | 7 | same as Loveshoot | +| **Total** | **25** | | + +### 4.2 Mosaic rule + +The mosaic (FR-ST-05) is rendered only when at least `MOSAIC_MIN_PHOTOS = 2` (`web/src/lib/shootPageView.ts`) photos are left that the page does not use elsewhere. Zwangerschap and Gezin hide it now because their two mosaic photos are already in blocks 2 and 3, so **they get a mosaic as soon as 2 new photos are in `photos.images`**. Loveshoot and Portret list only their main and detail photo (both used by the story and the package), so they too need 2 photos beyond those. Maximum 4 tiles (`MOSAIC_MAX_PHOTOS`). + +### 4.3 Where files go and how they are imported + +1. Put the files in `web/src/assets/`: shoot photos in `assets/shoots/` (`<shoot>.jpg`, `<shoot>-detail.jpg`), portfolio photos in `assets/portfolio/` (`f41aNNNN.jpg`). +2. Import them at the top of the page file, like the current ones: `import f41a7883 from '../../assets/portfolio/f41a7883.jpg';`. Vite hashes and bundles them; there is no image pipeline or image library in `web/`. +3. Add a `ContentImage` `{ src, alt, width, height }` with the real pixel size in `web/src/content/shootPages/<shoot>.ts`: as `image:` of a story block for blocks 1-4, or appended to `photos.images` for the mosaic. The order in `photos.images` is the tile order (large portrait, wide landscape, two small; see `web/src/lib/mosaicLayout.ts`). Adding photos is a data-only change (FR-ST-11): no component changes. +4. The package-block photo is the shoot's `detailImage` in `web/src/content/shootTypes.ts` (square). Today 480x480; the review doc asks for at least 960x960 for sharpness. +5. Sizes: existing photos are 800 px wide (portrait 800x1200, landscape 800x534). `-groot` variants (1067x1600 / 1600x1067) are used **only by the portfolio Lightbox** (`web/src/content/portfolioContent.ts`); the shoot pages never import them. Only create a `-groot` file when the photo is also added to the portfolio, which is a separate change. Keep the files light: mobile Lighthouse on these pages is already at the budget (section 5). +6. If a file is already in the portfolio or the shoot list, reuse its exact `alt`, `width` and `height` (test `reuses the description and size a photo has elsewhere`). + +### 4.4 Alt text rules + +Dutch; describe what is in the photo (who, what, setting), not the shoot or keywords; identical wherever the same file appears; never empty (tests check this). The alt of a new photo is a text we write, so mark it with the DRAFT line and have Andrea approve it together with the photo (CON-ST-02). + +### 4.5 OG images + +The five `web/public/og-<shoot>.jpg` files (1200x630) were approved by the owner on 2026-10-30. New photos do not change them. **Changing any OG image needs the owner's approval.** Loveshoot and Portret are upscaled about 1.42x from the shoot photo because no landscape photo existed, so better sources may be wanted later. Method: take the largest source, crop to 1200:630 with a vertical offset chosen by eye (faces and hands inside the crop), scale with .NET `System.Drawing` (`HighQualityBicubic`) onto a fresh bitmap (this strips EXIF and ICC; sRGB), encode as JPEG, file at most 100 KB. The earlier script was a temporary scratchpad script and is gone. Show the result to the owner before committing, and check the `ogImage` alt in `web/src/sitePages.ts` still matches the photo. + +## 5. Definition of done for the content feature (before its merge and before a production release) + +- [ ] `rg -n "DRAFT\(CON-ST-03\)" web/src` returns nothing (from the repo root; from `web/` use `src`). +- [ ] `rg -n "OPEN\(CON-ST-04\)" web/src` returns nothing. +- [ ] Andrea's approval is logged in `audit.md` (what, when, via Bryan). +- [ ] The content branch starts from (and is up to date with) master, which contains this feature since PR #13. +- [ ] `pnpm check` from `web/` is green (lint, format, `tsc`, tests with 100 % coverage on `src/lib/**`, build, audits, Lighthouse). +- [ ] Known Lighthouse items, judged in context: + - mobile `/` (0.75, budget 0.8) and `/contact` (0.87, budget 0.9) are below budget on master as well, so not caused by this feature; + - mobile gezin (0.84-0.85) and loveshoot (0.83) are below the 0.85 budget because the owner keeps the `Reveal` fade-in on the first story (decision 2026-10-30), which delays the first photo. Real photos may shift these numbers, so re-measure after adding photos. If still below, the options in the unit 2 code summary are: no fade-in on the first story, cap the first photo's column, or accept the limit. That is the owner's decision. +- [ ] `LAYOUT.md` (section "Shoot page", block "Photos") is updated if the mosaic now appears on more shoots than it describes; follow `.ai/layout-conventions.md`. +- [ ] Test deploy checked: push, Gitea CI `deploy-test`, then look at the five pages on desktop and phone, the submenu, and `/soorten-fotoshoots/niet-bestaande-shoot` (404 with two buttons, FR-ST-14). +- [ ] PR to master on Gitea per the usual flow (source `~/.ssh/agent.env` before pushing; CI on the PR; merge when green). Commit and push only when the owner asks. + +## 6. How to pick it up + +- Worktree: `../AndreaSlopFotografie-shoot-type-pages` (`K:\Development\SlpSoftware\Projects\AndreaSlopFotografie-shoot-type-pages`), branch `feature/shoot-type-pages`. Work in the worktree, not in the main checkout. +- AI-DLC state is in `aidlc-state.md` (Construction, Build and Test). `audit.md` is append-only: add new entries at the end, never edit old ones. Overview row: `aidlc-docs/active-features.md` ("Waiting for content"). +- Content edits after approval are a small follow-up within this feature: no new stages and no new feature folder. Log each batch (what changed, who approved, date) in `audit.md`; update `aidlc-state.md` when the feature completes. +- Order: (1) get Andrea's review back via Bryan; (2) texts and answers (section 3); (3) photos (section 4); (4) checks (section 5); (5) PR. diff --git a/aidlc-docs/features/shoot-type-pages/inception/application-design/application-design-questions.md b/aidlc-docs/features/shoot-type-pages/inception/application-design/application-design-questions.md new file mode 100644 index 0000000..7c441d1 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/application-design/application-design-questions.md @@ -0,0 +1,57 @@ +# Ontwerpvragen — Application Design + +Zes keuzes uit [application-design.md](application-design.md) ("Decisions for the user"). Bij elke vraag staat de aanbeveling als optie A. + +## Vraag 1 — Hoe worden de routes opgebouwd? (D1) + +- A) Vijf losse routebestanden `routes/soorten-fotoshoots/{newborn,zwangerschap,gezin,loveshoot,portret}.tsx`, en het overzicht verhuist naar `soorten-fotoshoots/index.tsx`. Het paginaregister, de sitemap, Lighthouse en de getypte links werken zonder aanpassingen. Een ontbrekende pagina wordt een typefout, en de bestaande `#ankers` blijven werken. (aanbevolen) +- B) Eén dynamische route `soorten-fotoshoots/$id.tsx`. Minder bestanden, maar het register, de sitemap, Lighthouse en de typecheck kennen dan maar één sjabloon en moeten de vijf pagina's zelf opbouwen. +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 2 — Vaste ID van de dienst in de gestructureerde data (D2) + +- A) Naar `https://andreaslop.nl/soorten-fotoshoots/<id>#service`. Het overzicht en de shootpagina verwijzen naar dezelfde dienst, met de shootpagina als `url`. (aanbevolen) +- B) De huidige `…/soorten-fotoshoots#<id>` houden; alleen de `url` wijst naar de shootpagina +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 3 — Hoe worden conceptteksten gemarkeerd? (D3) + +- A) Een vaste commentaarregel `// DRAFT(CON-ST-03): awaiting Andrea's approval` boven elk concept. Uit die regels wordt de reviewlijst voor Andrea gemaakt. In Build and Test controleert een zoekopdracht dat er vóór de merge geen markering meer staat. (aanbevolen) +- B) Een test die faalt zolang er markeringen zijn (blokkeert dan elke `pnpm check` tot Andrea akkoord geeft) +- C) Een `status: 'draft'`-veld in de content zelf (ook zichtbaar voor een toekomstig CMS) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 4 — "Huidige pagina" in menu, footer en kruimelpad (D4) + +Zonder aanpassing kondigt een schermlezer op een shootpagina ook "Soorten fotoshoots" in het menu, in de footer en in het kruimelpad aan als huidige pagina. Dat komt doordat TanStack Router links standaard op het begin van de URL laat matchen. + +- A) Alleen de pagina zelf krijgt `aria-current="page"`. "Soorten fotoshoots" in het menu krijgt op shootpagina's alleen visueel het streepje eronder, en het kruimelpad en de footer matchen exact. (aanbevolen) +- B) "Soorten fotoshoots" krijgt op shootpagina's `aria-current="true"` (betekent: onderdeel van deze sectie) +- C) Het standaardgedrag van TanStack laten staan +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 5 — Bron van het submenu (D5) + +- A) Het submenu wordt opgebouwd uit `shootTypes`. Dat maakt de hoofdbundel ongeveer 1,5 KB (gzip) groter. In unit 3 meet ik het effect op de mobiele Lighthouse-score van `/`, die al op de 0.8-grens zit. (aanbevolen) +- B) Een aparte kleine lijst `{id, name}` voor het menu (kleinere bundel, maar de namen staan dan op twee plekken) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 6 — Duur van de shoot (D6) + +De duur staat nu als vrije tekst in de pakketonderdelen ("1-2 uur fotografie"). + +- A) Een eigen veld per shoot (voor de tijdlijn en de tekstblokken), plus een test die controleert dat het overeenkomt met het pakket. Loveshoot en portret wachten op Andrea. (aanbevolen) +- B) Een gestructureerde duur in `packages.ts`, waar de pakketkaarten ook uit lezen (één bron, maar dan veranderen de prijskaarten op de homepage mee) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A diff --git a/aidlc-docs/features/shoot-type-pages/inception/application-design/application-design.md b/aidlc-docs/features/shoot-type-pages/inception/application-design/application-design.md new file mode 100644 index 0000000..9895764 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/application-design/application-design.md @@ -0,0 +1,198 @@ +# Application Design — Shoot Type Pages + +Consolidated design. Details: [components.md](components.md), [component-methods.md](component-methods.md), [services.md](services.md), [component-dependency.md](component-dependency.md). Plan: [application-design-plan.md](../plans/application-design-plan.md). Inputs: [requirements.md](../requirements/requirements.md), [execution-plan.md](../plans/execution-plan.md), design E (`E-Definitief.dc.html`), and the code on master `18e81d0` (verified, not assumed). + +## Overview +Five static routes `/soorten-fotoshoots/<id>` render one template (`ShootPage`) from flat per-shoot content plus shared content. One pure function, `shootPageView`, resolves everything the page shows (steps in fixed order, placeholders, package or "Prijs op aanvraag", photos without repeats, links, breadcrumb). The visible page and the structured data are both built from that view, so they cannot drift. Navigation gets a disclosure submenu built from the shoot types. All new logic is pure and covered by PBT; all new building blocks are generic shared components, with the page-specific composition in `components/shoots/`. + +## Page composition + +```mermaid +graph TD + Intro["A PageIntro + Breadcrumb"] --> S1["B-E StoryBlocks: 4 MediaText bands"] + S1 --> TL["F ProcessTimeline: six steps"] + TL --> Mosaic["G PhotoMosaic, omitted below minimum"] + Mosaic --> Faq["H FaqList"] + Faq --> Pkg["I PackageBlock: price or Prijs op aanvraag"] + Pkg --> Cta["J CallToAction"] + classDef head fill:#e76f51,stroke:#ad533d,color:#000; + classDef story fill:#f4a261,stroke:#b77a49,color:#000; + classDef generic fill:#2a9d8f,stroke:#20766b,color:#000; + classDef perShoot fill:#e9c46a,stroke:#af9350,color:#000; + classDef cta fill:#b56576,stroke:#884c59,color:#000; + class Intro head; + class S1 story; + class TL generic; + class Mosaic,Faq,Pkg perShoot; + class Cta cta; +``` + +Text alternative: ShootPage stacks the intro with breadcrumb, four story bands, the six-step timeline, the photo mosaic (left out when too few photos), the FAQ, the package block and the closing call to action, lettered A–J as in LAYOUT.md. + +## Route mechanism (O-ST-01) — recommendation D1 + +**Recommended: five static route files in a folder, with the overview moved to the folder's index route.** + +```mermaid +graph TD + Root["__root.tsx"] --> Index["soorten-fotoshoots/index.tsx: overview"] + Root --> N["soorten-fotoshoots/newborn.tsx"] + Root --> Z["soorten-fotoshoots/zwangerschap.tsx"] + Root --> G["soorten-fotoshoots/gezin.tsx"] + Root --> L["soorten-fotoshoots/loveshoot.tsx"] + Root --> P["soorten-fotoshoots/portret.tsx"] + Root --> NF["notFoundComponent: unknown slugs"] + classDef root_node fill:#4CAF50,stroke:#2e7d32,stroke-width:2px,color:#000; + classDef route fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; + classDef page fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef guard fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000; + class Root root_node; + class Index page; + class N,Z,G,L,P route; + class NF guard; +``` + +Text alternative: all six pages are direct children of the root route (no layout route), so the overview never wraps a shoot page, and any other path under the folder falls through to the root not-found page. + +Why, checked against the code: +- **`Record<RoutePath, PageMeta>`**: `RoutePath = keyof FileRoutesByTo`. Static files give five concrete keys, so the compiler forces five `sitePages` entries and `pageHead('/soorten-fotoshoots/newborn')` just works. A `$id` route gives the key `'/soorten-fotoshoots/$id'`: the registry would need a template entry plus an expansion step, and `pageHead`, `webPage` and `canonicalUrl` take a `RoutePath` that would no longer be a real URL. +- **Registry test**: `app.test.tsx` compares `Object.keys(sitePages)` with `router.routesByPath`. With `$id` that list contains the template, so the test would need rewriting; with static files it passes unchanged (the index route's `'/soorten-fotoshoots/'` is trimmed to `'/soorten-fotoshoots'` by router-core). +- **Sitemap and Lighthouse**: `sitemapXml(pageList(sitePages))` and `indexedPaths` stay plain lists; nothing to expand. +- **Typed links**: `NavItem.to`, `LinkTarget.to` (used by `RichText` links in content) and `homeContent.about.link` are `RoutePath`. With static routes, `shootPagePath(id)` returns a literal that is a `RoutePath`; with `$id` every link would need `to` + `params`, and `NavItem`/`LinkTarget` would change shape for all pages. +- **Code splitting**: each static route's component (and its own content file) becomes its own chunk; the shared template and shared content form one shared chunk. A `$id` route would put all five pages' content in one chunk, or need a dynamic import per id. +- **Validation**: no route parameter exists, so there is nothing to validate (SECURITY-05); unknown slugs hit the root `notFoundComponent`. +- **Cost**: five ~20-line files, and adding a shoot type needs a route file. A compile-time check in `lib/shootPages.ts` (`ShootPagePath extends RoutePath`) turns a missing route file into a type error, so it cannot be forgotten (NFR-ST-04). + +Overview restructuring: `git mv routes/soorten-fotoshoots.tsx routes/soorten-fotoshoots/index.tsx`. No `route.tsx` layout (a layout with only `<Outlet/>` adds a level for nothing); not the `soorten-fotoshoots_.newborn.tsx` un-nesting syntax (it keeps the old file but spreads the pages over oddly named files with `_` in their route ids). The article ids stay, so `/soorten-fotoshoots#newborn` keeps working. + +## Decisions + +| # | Decision | Alternatives and rationale | +|---|---|---| +| D1 | Five static route files + overview as `soorten-fotoshoots/index.tsx` | See above. `$id`: one file but breaks the registry's and links' types. **For the user.** | +| D2 | Service `@id` = `https://andreaslop.nl/soorten-fotoshoots/<id>#service`, used by both the overview `ItemList` and the shoot page; `url` = the shoot page | Keep `/soorten-fotoshoots#<id>`: no change for crawlers, but the entity's id would point at the overview while its page is elsewhere. The site is new, so changing it now costs nothing. **For the user.** | +| D3 | Drafts marked with one fixed comment, `// DRAFT(CON-ST-03): awaiting Andrea's approval`, above each drafted field (content files and `sitePages.ts`); a review list for Andrea is generated from the content during Construction; the gate is a step in Build and Test: `rg "DRAFT\(CON-ST-03\)" web/src` must be empty before merge | (b) a test that fails while markers exist: blocks every `pnpm check` until approval, which the per-unit checks need to pass. (c) a typed `draft()` wrapper or `status` field: changes the content shape the API will deliver. The Gezin overview draft comment moves to the same marker. **For the user.** | +| D4 | Current state: `aria-current="page"` only on the exact page. The parent "Soorten fotoshoots" gets the same underline through `sectionCurrent` while a shoot page is open; the breadcrumb and footer links use exact matching | TanStack `Link` marks a link active (and adds `aria-current="page"`) when the location starts with its path, so today, unchanged, the nav parent, the footer link and the breadcrumb link would all say "current page" on a shoot page. Alternative: `aria-current="true"` on the parent. **For the user.** | +| D5 | Nav children derived from `shootTypes` in `navigation.ts` (single source); this moves the shoot type texts into the main bundle (~1.5 KB gzip); unit 3 measures `/` mobile Lighthouse (borderline 0.8) | A small `{ id, name }` list in content that `shootTypes` and the nav both use: smaller bundle, but splits the shoot type in two. **For the user.** | +| D6 | Shoot duration is a per-shoot field in the shoot page content; for shoots with a package a content test checks that the package's features name the same duration | Structured `duration` in `PricingPackage`: one source, but changes the price cards and the package shape. **For the user.** | +| D7 | Content: one file per shoot `content/shootPages/<id>.ts` + `content/shootPageShared.ts`; shared FAQ items are exported constants included in the per-shoot lists | One `Record<ShootTypeId, ShootPageContent>` file: compile-time completeness, but every page's chunk carries all five; completeness is covered by the registry test instead | +| D8 | Placeholders `{reactietermijn}`, `{aanbetaling}`, `{locatie}`, `{duur}`, `{opleverduur}` in shared texts, filled by `fillPlaceholders` | Composing texts in components would put Dutch wording in code; placeholders keep the wording in content and the figures in one place (NFR-ST-04), as the contact page already does | +| D9 | `shootPageView` resolves the whole page; `ShootPage` and its sections are presentational | Rules spread over components would be hard to test with PBT and could disagree with the JSON-LD | +| D10 | Reuse `PageIntro` with an optional `breadcrumb` slot and `titleId`; new generic `Breadcrumb`, `ProcessTimeline`, `PhotoMosaic`, `FaqList`, `PackageBlock`; page parts `ShootPage`, `StoryBlocks`, `ProcessIcons` in `components/shoots/` | Justified per component in components.md | +| D11 | FAQ as native `details`/`summary` | Chakra `Accordion`: more JS and a slot recipe, no a11y gain | +| D12 | Desktop submenu: parent stays a link, separate toggle button, disclosure pattern; no hover opening | Hover is optional (FR-ST-10) and easy to trigger by accident; can be added later on top of click | +| D13 | Structured data: one script with `WebPage` (`mainEntity` Service, `breadcrumb` BreadcrumbList) and one `FAQPage` script (`isPartOf` the WebPage) when there are FAQ items, all via `StructuredData` → `jsonLdScript` | One `@graph`: equally valid, but breaks the one-object-per-script pattern the other pages use | +| D14 | A photo appears once per page: `shootPageView` drops mosaic photos already used by a story block or the package block (design E repeats `f41a8700`) | Content discipline only: a later data change could repeat a photo; the content test still checks the real data | +| D15 | Mosaic minimum proposed at 2 photos; confirmed in FD unit 2. Loveshoot and Portret have only their main and detail photo, which the story and package blocks are likely to use, so with D14 their mosaic is left out until Andrea delivers more photos (the page still has a valid outline) | A minimum of 1 would show a lone photo as "Impressie" | + +## Content model in short +Per shoot (`ShootPageContent`): intro, four `StoryBlock`s (eyebrow, h2, `RichText` paragraphs, optional `ContentImage`), `process.location`/`duration`/`deliveryTime`, `photos.title` + ordered `images`, `faq.title` + 3–5 `FaqItem`s, `offer.eyebrow`/`title`, `closing`. Shared (`ShootPageShared`): breadcrumb labels, the six step titles and texts by `ProcessStepId`, `deposit.amount` (50) and note, eyebrows, FAQ lead, offer button labels and "Prijs op aanvraag" texts, shared FAQ items. Unchanged: `ShootType`, `packages`, `siteContent.contactForm.replyTime`. Adding photos is a data-only change (append a `ContentImage`). Drafts: D3. Full types: component-methods.md. + +## File ownership per unit +Units 2 and 3 run in parallel after unit 1; every file has one owner among them. "Edit" for a unit-1 file means a later sequential change by unit 2, which is safe because unit 3 never touches it. + +| Path (under `web/` unless noted) | Unit 1 | Unit 2 | Unit 3 | +|---|---|---|---| +| `src/routes/soorten-fotoshoots/index.tsx` (moved), `newborn/zwangerschap/gezin/loveshoot/portret.tsx`, `-shootPageSources.ts` | create | — | — | +| `src/routeTree.gen.ts` (generated) | regenerate | — | — | +| `src/content/types.ts` | add types | add a field only if FD needs it | — | +| `src/content/shootPages/*.ts`, `shootPageShared.ts` | create (drafts) | edit texts and photo selection | — | +| `src/content/shootTypes.ts` | draft marker only | — | — | +| `src/lib/shootPages.ts`, `shootPackage.ts`, `fillPlaceholders.ts`, `richTextToPlain.ts`, `shootPageView.ts` + tests; `shootLinks.ts` + test | create / change | `MOSAIC_MIN_PHOTOS` only | — | +| `src/seo.ts`, `src/seo.test.ts` | change | — | — | +| `src/sitePages.ts` | five entries | `ogImage` fields | — | +| `lighthouserc.cjs` | five paths ×2 lists | — | — | +| `src/app.test.tsx` | registry, not-found, extract `renderApp` | — | — | +| `src/test/renderApp.tsx` (new, extracted) | create | — | — | +| `src/test/arbitraries.ts` | add generators | append only | — | +| `src/components/StructuredData/*` | create | — | — | +| `src/components/shoots/ShootPage/*` | shell | sections | — | +| `src/components/shoots/{StoryBlocks,ProcessIcons}/*`, `ShootBlock/*` | — | create / change | — | +| `src/components/{Breadcrumb,ProcessTimeline,PhotoMosaic,FaqList,PackageBlock}/*`, `PageIntro/*` | — | create / change | — | +| `src/components/MediaText/*` (additive optional `mediaSize="medium"`; approved deviation, unit 2 FD Q8 = A) | — | change | — | +| `src/components/CallToAction/*` (additive optional `tone`; approved deviation, unit 2 FD Q8 = A) | — | change | — | +| `src/lib/mosaicLayout.ts` + test | — | create | — | +| `src/shootPages.test.tsx` (route-level tests) | — | create | — | +| `src/theme.ts` | — | only if a token is needed | — | +| `public/og-<id>.jpg` ×5 | — | create | — | +| `LAYOUT.md`, `.ai/layout-conventions.md` (repo root) | — | change | — | +| `src/navigation.ts`, `src/navigation.test.ts` | — | — | change | +| `src/lib/shootNavItems.ts`, `src/lib/navCurrent.ts` + tests | — | — | create | +| `src/lib/navMenuState.ts` + test (pure `navMenuReducer`; approved deviation, unit 3 FD Q6 = A) | — | — | create | +| `src/components/NavigationBar/*` (incl. new `NavSubmenu`, `MobileNavGroup`, `ChevronIcon`) | — | — | change / create | +| `src/components/Footer/Footer.tsx` + test (exact matching, D4) | — | — | change | +| `src/hooks/useDismiss.ts` + test | — | — | create | +| `src/navSubmenu.test.tsx` (route-change closing in the real app) | — | — | create | +| `aidlc-docs/_shared/reverse-engineering/*` (repo root) | own lines | lines handed to the orchestrator | lines handed to the orchestrator | +| `aidlc-docs/features/shoot-type-pages/construction/<unit>/` | own folder | own folder | own folder | +| `aidlc-state.md`, `audit.md`, `active-features.md` | orchestrator | orchestrator | orchestrator | + +**Disjointness of units 2 and 3**: no row has both a unit-2 and a unit-3 entry. Unit 3 reads `lib/shootPages.ts`, `content/shootTypes.ts`, `test/arbitraries.ts` (import only) and `theme.ts` tokens, and changes none of them. Unit 2 does not touch `navigation.ts`, `NavigationBar/`, `Footer/` or `hooks/`. The reverse-engineering files are the only shared documents; the orchestrator writes both units' lines after both are done. + +**Hot files** (NFR-ST-07): `sitePages.ts`, `lighthouserc.cjs`, `seo.ts`, `content/types.ts`, `shootTypes.ts`, `routeTree.gen.ts`, `app.test.tsx`, `test/arbitraries.ts` (unit 1, with unit 2 sequentially for a few); `navigation.ts`, `NavigationBar/` (unit 3 only); `LAYOUT.md` (unit 2 only); `_shared/reverse-engineering/`, `active-features.md` (orchestrator). + +## Risks found in the code +1. **Fuzzy active links** (`@tanstack/react-router` 1.170 `resolveIsActive`): without `exact`, a link is active when the location starts with its path plus `/`, and active links get `aria-current="page"`. On a shoot page the nav parent, the footer's "Soorten fotoshoots" and the breadcrumb's middle link would all announce "current page". Handled by D4 (exact matching where needed, `sectionCurrent` for the visual). +2. **Route moves need the generator**: `routeTree.gen.ts` is generated by the Vite plugin; moving the overview to `soorten-fotoshoots/index.tsx` changes its `createFileRoute` string to `'/soorten-fotoshoots/'`. The worktree has no `node_modules` yet, so unit 1 starts with `pnpm install` and lets the plugin rewrite the file rather than editing it by hand. +3. **Lighthouse sync test compares order**: `app.test.tsx` checks `lighthouseConfig.indexedPaths` with `toEqual` against `sitePages` order. The five entries go right after `'/soorten-fotoshoots'` in both files, in `shootTypes` order. +4. **Auto code splitting needs inline route options**: a factory such as `createFileRoute(...)(shootRoute('newborn'))` would keep the component and content in the main bundle. Each route file declares `component` itself. +5. **Main bundle growth** from the nav submenu (D5) while `/` mobile performance is at its 0.8 exception. +6. **Mobile menu overflow**: `MobileNav` centres its list in a fixed box with the body scroll locked; five extra items can be cut off on short phones (FR-ST-10). Unit 3 makes it scroll. +7. **Desktop nav width at `lg` (1024 px)**: five uppercase, letter-spaced items with `mx=4` plus a new toggle button; check that it fits at 1024 px in FD unit 3. +8. **Duration duplicated as free text**: package features ("1-2 uur fotografie") and the new per-shoot duration (D6). +9. **`MediaText` requires an image**: a story block without a photo cannot use it; `StoryBlocks` renders a text-only column instead (no change to `MediaText`). +10. **The overview's "no price" invariant** in `seo.test.ts` must keep holding for `shootServices`; the Offer exists only on the shoot page Service. +11. **CI duration**: ten more Lighthouse runs on the Raspberry Pi runner (accepted in NFR-ST-03). + +## Handed to Functional Design +- Unit 2: timeline breakpoint (proposed the theme's `lg`, since six columns at `md`, 768 px, leave ~110 px per step), mosaic layouts for 2–6 photos and `MOSAIC_MIN_PHOTOS`, which FAQ items start open, story image aspect ratios (design E mixes 4:5, 3:2 and 2:3), photo selection per slot, OG image crops (shown to the user before they are fixed). +- Unit 3: exact keyboard and focus rules, outside-click and route-change closing, panel position and the transparent-header case, mobile group default state and scrolling, 1024 px fit. + +## Decisions for the user + +> **Confirmed by the user (2026-10-30)**: D1–D6 all A, i.e. every recommendation below is accepted as written ([application-design-questions.md](application-design-questions.md)). +1. **D1 Route mechanism** — recommend five static route files under `routes/soorten-fotoshoots/` with the overview moved to `index.tsx`, instead of one `$id` route. +2. **D2 Service id** — recommend moving the Service `@id` to `…/soorten-fotoshoots/<id>#service` (shared by overview and shoot page), instead of keeping `…/soorten-fotoshoots#<id>`. +3. **D3 Draft marking and gate** — recommend one fixed comment marker per drafted field plus a pre-merge `rg` check in Build and Test, instead of a failing test or a `draft()`/`status` field in the content. +4. **D4 "Current page" in menus** — recommend `aria-current="page"` only on the exact page, with a visual-only highlight on the parent "Soorten fotoshoots" (and exact matching in breadcrumb and footer), instead of TanStack's default (parent, footer and breadcrumb all marked as current) or `aria-current="true"` on the parent. +5. **D5 Nav source vs bundle size** — recommend deriving the submenu from `shootTypes` (≈1.5 KB gzip more in the main bundle, measured against the `/` mobile score), instead of a separate small name list. +6. **D6 Shoot duration** — recommend a per-shoot duration field with a consistency test against the package features, instead of a structured duration in `packages.ts`. + +> **Approved deviations (2026-10-30)**: unit 2 adds the optional `mediaSize="medium"` to `MediaText` and the optional `tone` to `CallToAction` (unit 2 FD Q8 = A); unit 3 keeps the menu open/closed state in one pure reducer, `navMenuReducer` in `lib/navMenuState.ts`, instead of per-component `useState` (unit 3 FD Q6 = A). + +## Extension compliance (design level) + +### Security Baseline +| Rule | Status | Rationale | +|---|---|---| +| SECURITY-01 Encryption | N/A | No data stores | +| SECURITY-02 Access logging | N/A | No intermediaries added | +| SECURITY-03 Application logging | N/A | No server-side component; Sentry unchanged | +| SECURITY-04 HTTP headers | Compliant | `config/securityHeaders.ts` untouched; no inline handlers; the only inline scripts are JSON-LD via `StructuredData` (CSP `script-src 'self'` does not apply to `application/ld+json` data blocks, as on the existing pages) | +| SECURITY-05 Input validation | Compliant | No route parameters (D1); `shootIdFromSlug`/`shootIdFromPath` accept only known ids and never throw; outgoing `?pakket=` only from `shootPackage` (visible packages); the contact page's existing validation is unchanged | +| SECURITY-06 Least privilege | N/A | No IAM | +| SECURITY-07 Network | N/A | No network configuration | +| SECURITY-08 Access control | N/A | Public content | +| SECURITY-09 Hardening | Compliant | No debug output; no placeholder content in production: the D3 gate blocks the merge while draft markers exist; design E's bracketed placeholders ("[een korte checklist]") are not copied into content (CON-ST-04) | +| SECURITY-10 Supply chain | Compliant | No new dependencies; icons as inline SVG; native `details` instead of extra components; lockfile unchanged | +| SECURITY-11 Secure design | Compliant | Content rendered as text and typed router links (`RichText`); `dangerouslySetInnerHTML` only inside `StructuredData` with `jsonLdScript`; no e-mail address in structured data (PBT invariant) | +| SECURITY-12 Authentication | N/A | No authentication | +| SECURITY-13 Integrity | Compliant | All photos and OG images bundled or in `public/`; no CDN or embeds | +| SECURITY-14 Alerting | N/A | No server-side component | +| SECURITY-15 Fail-safe | Compliant | Unknown slug → root not-found; missing shoot type or mismatched content → `NotFound`; invalid/removed package → "Prijs op aanvraag"; too few photos → no mosaic; no FAQ items → no FAQ section and no FAQPage | + +No blocking security findings. + +### Property-Based Testing +| Rule | Status | Rationale | +|---|---|---| +| PBT-01 Identification | Compliant (unit 1), planned (units 2, 3) | Properties for every new pure function listed in services.md; units 2 and 3 confirm theirs in Functional Design | +| PBT-02 Round trip | Planned | `shootIdFromSlug`/`shootIdFromPath` ∘ `shootPagePath`; `JSON.parse ∘ jsonLdScript` for every new builder | +| PBT-03 Invariants | Planned | `shootPageView`, `shootPackage`, `breadcrumbList`, `faqPage`, `shootService`, `richTextToPlain`, `shootNavItems`, `navCurrent`, `mosaicLayout` (services.md) | +| PBT-04 Idempotency | Planned | `fillPlaceholders`/`fillRichText`: filling twice equals once | +| PBT-05 Oracle | N/A | No reference implementation; `richTextToPlain` is checked against its definition, not an oracle | +| PBT-06 Stateful | Planned (unit 3) | `navMenuReducer` (unit 3 FD Q6 = A, approved): model-based event sequences with invariants I1–I4 (services.md) | +| PBT-07 Generators | Planned | `shootPageContent`, `shootPageShared`, hostile slug strings in `src/test/arbitraries.ts` | +| PBT-08 Shrinking/reproducibility | Compliant | fast-check shrinking; seed logging in `config/testSeed.ts` | +| PBT-09 Framework | Compliant | fast-check already configured | +| PBT-10 Complementary | Compliant | Example-based route, component, axe and registry-consistency tests alongside (services.md "Not PBT") | diff --git a/aidlc-docs/features/shoot-type-pages/inception/application-design/component-dependency.md b/aidlc-docs/features/shoot-type-pages/inception/application-design/component-dependency.md new file mode 100644 index 0000000..6cef470 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/application-design/component-dependency.md @@ -0,0 +1,110 @@ +# Component Dependencies — Shoot Type Pages + +## Shoot page dependency graph + +```mermaid +graph TD + Route["routes/soorten-fotoshoots/id x5"] --> Sources["-shootPageSources"] + Route --> ViewFn["lib/shootPageView"] + Route --> Graph["seo: shootPageGraph"] + Route --> SD["StructuredData"] + Route --> ShootPage["shoots/ShootPage"] + ViewFn --> Paths["lib/shootPages"] + ViewFn --> Pkg["lib/shootPackage"] + ViewFn --> Links["lib/shootLinks"] + ViewFn --> Fill["lib/fillPlaceholders"] + Graph --> Rich2Plain["lib/richTextToPlain"] + Graph --> Paths + ShootPage --> Intro["PageIntro + breadcrumb slot"] + Intro --> Crumb["Breadcrumb"] + ShootPage --> Stories["shoots/StoryBlocks"] + Stories --> MediaText["MediaText"] + ShootPage --> Timeline["ProcessTimeline"] + ShootPage --> Icons["shoots/ProcessIcons"] + ShootPage --> Mosaic["PhotoMosaic"] + ShootPage --> Faq["FaqList"] + Faq --> RichP["RichParagraph"] + ShootPage --> PkgBlock["PackageBlock"] + PkgBlock --> MediaText + ShootPage --> Cta["CallToAction"] + ShootPage --> Section["PageSection + SectionHeading"] + Overview["routes/soorten-fotoshoots/index"] --> Block["shoots/ShootBlock"] + Block --> Paths + classDef route fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef logic fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + classDef newcomp fill:#FFA726,stroke:#E65100,stroke-width:1px,color:#000; + classDef changed fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + classDef existing fill:#e2e8f0,stroke:#4a5568,stroke-width:1px,color:#000; + class Route,Sources,Overview route; + class ViewFn,Paths,Pkg,Fill,Rich2Plain,Graph logic; + class SD,ShootPage,Crumb,Stories,Timeline,Icons,Mosaic,Faq,PkgBlock newcomp; + class Intro,Block,Links changed; + class MediaText,RichP,Cta,Section existing; +``` + +Text alternative: each shoot route uses the shared sources, the view builder (with the path, package, link and placeholder helpers) and seo's shootPageGraph, then renders StructuredData and ShootPage; ShootPage composes PageIntro with Breadcrumb, StoryBlocks on MediaText, ProcessTimeline with icons, PhotoMosaic, FaqList on RichParagraph, PackageBlock on MediaText and CallToAction; the overview's ShootBlock links to the shoot pages via the path helper (orange new, blue changed, grey reused, green pure logic, yellow routes). + +## Navigation dependency graph + +```mermaid +graph TD + Nav["navigation.ts mainNav"] --> NavItems["lib/shootNavItems"] + NavItems --> Shoots["content/shootTypes"] + NavItems --> Paths["lib/shootPages"] + Bar["NavigationBar"] --> Nav + Bar --> Submenu["NavSubmenu"] + Bar --> NavLink["NavLink sectionCurrent"] + Submenu --> NavLink + Submenu --> Dismiss["hooks/useDismiss"] + Submenu --> Chevron["ChevronIcon"] + Submenu --> Current["lib/navCurrent"] + Mobile["MobileNav"] --> Nav + Mobile --> Group["MobileNavGroup"] + Group --> Chevron + Group --> Current + Footer["Footer exact match"] --> FooterNav["navigation.ts footerNav"] + classDef logic fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + classDef newcomp fill:#FFA726,stroke:#E65100,stroke-width:1px,color:#000; + classDef changed fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + classDef existing fill:#e2e8f0,stroke:#4a5568,stroke-width:1px,color:#000; + class NavItems,Current,Paths logic; + class Submenu,Group,Dismiss,Chevron newcomp; + class Nav,Bar,NavLink,Mobile,Footer changed; + class Shoots,FooterNav existing; +``` + +Text alternative: mainNav gets its shoot children from shootNavItems (shoot types plus the path helper); NavigationBar renders NavSubmenu (NavLink, useDismiss, ChevronIcon, navCurrent) and MobileNav renders MobileNavGroup; the Footer only switches its links to exact matching. + +The only link between the two graphs is `lib/shootPages` (unit 1), which both units read and neither changes. + +## Dependency matrix + +| Component | Depends on | Used by | +|---|---|---| +| `lib/shootPages` | `ShootTypeId`, `RoutePath` (types), `isShootTypeId` | `shootPageView`, `seo.ts`, `ShootBlock`, `shootNavItems`, tests | +| `lib/shootPackage` | `visiblePackages` | `shootLinks`, `shootPageView` | +| `lib/fillPlaceholders` | — | `shootPageView` | +| `lib/richTextToPlain` | `RichText` (type) | `seo.faqPage` | +| `lib/shootPageView` | the four helpers above, `formatPrice`, `shootPortfolioLink` | shoot routes, tests | +| `seo.ts` additions | `canonicalUrl`, `webPage`, `areaServed`, `shootPages`, `richTextToPlain` | shoot routes, overview route | +| `StructuredData` | `jsonLdScript` | shoot routes, overview route | +| `ShootPage` | the section components, `ShootPageView` (type) | shoot routes | +| `StoryBlocks` | `PageSection`, `MediaText`, `RichParagraph`, `Eyebrow` | `ShootPage` | +| `Breadcrumb` | `RouterLink`, Chakra `Link` | `PageIntro` slot via `ShootPage` | +| `ProcessTimeline` | Chakra primitives, theme tokens | `ShootPage` | +| `PhotoMosaic` | `DeferredImage`, `mosaicLayout` | `ShootPage` | +| `FaqList` | `RichParagraph` | `ShootPage` | +| `PackageBlock` | `MediaText`, `formatPrice`, `Eyebrow` | `ShootPage` | +| `ShootBlock` | + `shootPagePath` | `ShootList` | +| `shootNavItems` | `shootPagePath`, `ShootType` | `navigation.ts` | +| `navCurrent` | `NavItem` (type) | `NavSubmenu`, `MobileNavGroup`, `NavigationBar` | +| `NavSubmenu` | `NavLink`, `useDismiss`, `ChevronIcon`, `navCurrent`, `useRouterState` | `NavigationBar` | +| `MobileNavGroup` | `RouterLink`, `ChevronIcon`, `navCurrent` | `MobileNav` | + +## Communication +Props only, top-down; no context and no global state, as on every page so far. The route builds one view object; components render it. Navigation reads the router's location for current state and route-change closing. Links are typed router links: shoot page paths are concrete `RoutePath` literals, so a wrong path is a type error, and `?pakket=` is only ever built from a visible package id. + +## Import cycles and bundles +- `content/types.ts` imports the `RoutePath` type from `navigation.ts`; `navigation.ts` will import `content/shootTypes.ts` (a value) and `lib/shootNavItems.ts`. Type-only imports are erased, so no runtime cycle exists; keep the `import type` in `types.ts`. +- `navigation.ts` is in the main bundle (header and footer), so importing `shootTypes` moves its texts (~4 KB raw, roughly 1.5 KB gzip; image imports are URL strings) into the main bundle (decision D5). +- Everything else new is reachable only from the shoot routes and is split off with them. diff --git a/aidlc-docs/features/shoot-type-pages/inception/application-design/component-methods.md b/aidlc-docs/features/shoot-type-pages/inception/application-design/component-methods.md new file mode 100644 index 0000000..7cea2bf --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/application-design/component-methods.md @@ -0,0 +1,285 @@ +# Component Methods — Shoot Type Pages + +Types, props and function signatures. Business rules in detail (timeline alternation and breakpoint, mosaic minimum and layouts, FAQ open state, submenu interaction) follow in Functional Design for units 2 and 3. Unit 1 has no Functional Design, so the rules of its pure functions are stated here in one line each, and its PBT properties are listed in services.md. + +## Content types (`content/types.ts`, unit 1) + +```ts +// One block of the shoot page story (FR-ST-03) +export interface StoryBlock { + id: string; // stable slug, e.g. 'verwachten'; used in the heading id + eyebrow: string; + title: string; + paragraphs: RichText[]; // one or more; RichText so a block can link inline + image?: ContentImage; // without one the block is text only +} + +// One question of the FAQ (FR-ST-06); answer pieces may contain placeholders +export interface FaqItem { + id: string; // stable slug, unique per page + question: string; + answer: RichText; +} + +// The six fixed steps, in this order (FR-ST-04) +export type ProcessStepId = + 'aanvragen' | 'datum' | 'aanbetaling' | 'shoot' | 'bewerking' | 'oplevering'; + +export interface ProcessStepContent { + title: string; + text: string; // may contain placeholders, see below +} + +export interface DepositInfo { + amount: number; // whole euros: 50 + note: string; // 'Aanbetaling {aanbetaling}, restbedrag na de shoot.' +} + +// The same on every shoot page (FR-ST-11, shared part) +export interface ShootPageShared { + breadcrumb: { label: string; home: string; overview: string }; // 'Kruimelpad', 'Home', 'Soorten fotoshoots' + process: { + eyebrow: string; // 'Zo werkt het' + title: string; // 'Van aanvraag tot online galerij' + lead: string; + steps: Record<ProcessStepId, ProcessStepContent>; + }; + deposit: DepositInfo; + photos: { eyebrow: string }; // 'Impressie' + faq: { eyebrow: string; lead: RichText }; + offer: { + bookLabel: string; // 'Boek dit pakket' + askLabel: string; // 'Eerst een vraag stellen' + onRequest: { price: string; text: string; linkLabel: string }; // 'Prijs op aanvraag', … + }; +} + +// One shoot page (FR-ST-11, per-shoot part); one file per shoot +export interface ShootPageContent { + id: ShootTypeId; // must match the route that imports it (test) + intro: { eyebrow: string; title: string; text: string }; + stories: StoryBlock[]; // four per shoot (content test) + process: { + location: string; // step 2: 'Een newbornshoot is bij jou thuis.' + duration: string; // step 4: '1-2 uur fotografie, in het tempo van jullie baby.' + deliveryTime: string; // step 5 and shared FAQ: '2–3 weken' + }; + photos: { title: string; images: ContentImage[] }; // ordered; adding one is a data-only change + faq: { title: string; items: FaqItem[] }; // 3–5, shared constants mixed in + offer: { eyebrow: string; title: string }; // 'Pakket newborn', 'Wat zit er in een newbornshoot' + closing: { title: string; lead: RichText; buttonLabel: string }; +} +``` + +**Placeholders** (one mechanism, extending the existing `{reactietermijn}` of the contact page): `{reactietermijn}` ← `siteContent.contactForm.replyTime`, `{aanbetaling}` ← `formatPrice(shared.deposit.amount)`, `{locatie}`, `{duur}`, `{opleverduur}` ← the shoot's `process` fields. They may appear in step texts, the deposit note and FAQ answers. Link targets are never stored in content (FR-ST-11); they are derived in `shootPageView`. + +**Draft marker** (CON-ST-03, decision D3): a line comment directly above each drafted field or block, always the same text: `// DRAFT(CON-ST-03): awaiting Andrea's approval`. `rg -n "DRAFT\(CON-ST-03\)" web/src` lists every draft. + +## Pure functions (`lib/`) + +```ts +// lib/shootPages.ts (unit 1) +export const SHOOT_TYPES_PATH = '/soorten-fotoshoots'; +export const SHOOT_TYPE_IDS: readonly ShootTypeId[]; // all five, checked exhaustive at compile time +export type ShootPagePath = `/soorten-fotoshoots/${ShootTypeId}`; +// Compile-time guard: every ShootTypeId needs a route file, otherwise ShootPagePath is no RoutePath +type EveryShootHasARoute = Assert<ShootPagePath extends RoutePath ? true : false>; + +export function shootPagePath(id: ShootTypeId): ShootPagePath; +// The inverse: a known id for exactly a known slug, else undefined; never throws +export function shootIdFromSlug(slug: unknown): ShootTypeId | undefined; // reuses isShootTypeId +// '/soorten-fotoshoots/<slug>' (one trailing slash tolerated) → id, anything else → undefined +export function shootIdFromPath(pathname: string): ShootTypeId | undefined; + +// lib/shootPackage.ts (unit 1) +// The visible package the shoot points to, else undefined (removed, invalid, none) +export function shootPackage( + shoot: ShootType, + packages: readonly PricingPackage[], +): PricingPackage | undefined; + +// lib/shootLinks.ts (unit 1, same results as today) +export function shootContactLink(shoot: ShootType, packages: readonly PricingPackage[]): + { to: '/contact'; search: { pakket: string } } | { to: '/contact' }; // now via shootPackage + +// lib/fillPlaceholders.ts (unit 1) +// Replaces every {name} whose name is in values; other text stays as it is +export function fillPlaceholders(text: string, values: Readonly<Record<string, string>>): string; +export function fillRichText(text: RichText, values: Readonly<Record<string, string>>): RichText; + +// lib/richTextToPlain.ts (unit 1) +// The visible text: string pieces as they are, links by their text +export function richTextToPlain(text: RichText): string; + +// lib/shootPageView.ts (unit 1; MOSAIC_MIN_PHOTOS confirmed in FD unit 2) +export const PROCESS_STEP_ORDER: readonly ProcessStepId[]; // the fixed order of FR-ST-04 +export const MOSAIC_MIN_PHOTOS: number; // proposed 2 + +export interface BreadcrumbItem { label: string; to: RoutePath } +export interface ProcessStep { id: ProcessStepId; title: string; text: string } + +export interface ShootPageSources { + shootTypes: readonly ShootType[]; + packages: readonly PricingPackage[]; + shared: ShootPageShared; + site: SiteContent; + portfolioShoots: readonly ShootTypeId[]; // types that link to the portfolio (live + has photos) +} + +export interface ShootPageView { + id: ShootTypeId; + path: ShootPagePath; + shoot: ShootType; + breadcrumb: { label: string; items: BreadcrumbItem[] }; // last item = this page + intro: ShootPageContent['intro']; + stories: StoryBlock[]; // placeholders filled + process: { eyebrow: string; title: string; lead: string; steps: ProcessStep[] }; // always six, in order + photos?: { // undefined below MOSAIC_MIN_PHOTOS + eyebrow: string; title: string; images: ContentImage[]; // no photo used elsewhere on the page + portfolioLink?: ReturnType<typeof shootPortfolioLink>; + }; + faq?: { eyebrow: string; title: string; lead: RichText; items: FaqItem[] }; // undefined when no items + offer: { + eyebrow: string; title: string; image: ContentImage; // the shoot's detail photo, else its main photo + pkg?: PricingPackage; // present iff shootPackage() is + onRequest: ShootPageShared['offer']['onRequest']; + bookLabel: string; askLabel: string; + bookLink: ReturnType<typeof shootContactLink>; + askLink: { to: '/contact' }; + depositNote: string; + }; + closing: { title: string; lead: RichText; buttonLabel: string; link: ReturnType<typeof shootContactLink> }; +} + +// undefined when the shoot type is missing from shootTypes or page.id !== id (fail safe → not-found) +export function shootPageView( + id: ShootTypeId, + page: ShootPageContent, + sources: ShootPageSources, +): ShootPageView | undefined; + +// lib/mosaicLayout.ts (unit 2, shape fixed in FD) +export type MosaicTile = { column: string; row: string; wide: boolean }; +export function mosaicLayout(count: number): MosaicTile[]; + +// lib/shootNavItems.ts (unit 3) +export function shootNavItems(shoots: readonly ShootType[]): NavItem[]; // one per shoot, in order + +// lib/navCurrent.ts (unit 3) +// exact: pathname is item.to; section: pathname is item.to or one of its children +export function isItemCurrent(item: NavItem, pathname: string): boolean; +export function isSectionCurrent(item: NavItem, pathname: string): boolean; +``` + +## SEO builders (`seo.ts`, unit 1) + +```ts +// One stable id per shoot service, shared by the overview's ItemList and the shoot page (SEO-ST-03, D2) +export function shootServiceId(id: ShootTypeId): string; // `${siteUrl}/soorten-fotoshoots/<id>#service` + +// The Service: name/serviceType = shootLabel, description = paragraphs[0], image, provider, areaServed, +// url = the shoot page; offers (Offer, price, 'EUR') only when pkg is given +export function shootService(shoot: ShootType, site: SiteContent, pkg?: PricingPackage): object; + +// Unchanged signature; its items now come from shootService(shoot, site) without pkg +export function shootServices(shoots: readonly ShootType[], site: SiteContent): object; + +// positions 1..n, item = absolute URL of each path, name = label +export function breadcrumbList(items: readonly BreadcrumbItem[]): object; + +// One Question per item in order, acceptedAnswer.text = richTextToPlain(answer); undefined for no items +export function faqPage(path: RoutePath, items: readonly FaqItem[]): object | undefined; + +// What a shoot page renders: WebPage (mainEntity = shootService with the view's pkg, +// breadcrumb = breadcrumbList) and, when there are FAQ items, a FAQPage (isPartOf the WebPage) +export function shootPageGraph(view: ShootPageView, site: SiteContent): object[]; +``` + +## Components + +```ts +// components/StructuredData (unit 1) +type StructuredDataProps = { data: unknown }; // rendered via jsonLdScript only + +// components/PageIntro (unit 2, additive) +type PageIntroProps = { + title: string; + eyebrow?: string; + titleId?: string; // new: id of the h1; the section is then named by it + breadcrumb?: ReactNode; // new: rendered above the eyebrow + children?: ReactNode; +}; + +// components/Breadcrumb (unit 2) +type BreadcrumbProps = { + label: string; // accessible name of the nav: 'Kruimelpad' + items: readonly BreadcrumbItem[]; // last one is the current page +}; + +// components/ProcessTimeline (unit 2) +type ProcessTimelineProps = { + steps: readonly { id: string; title: string; text: string; icon: ReactNode }[]; + 'data-testid'?: string; +}; + +// components/PhotoMosaic (unit 2) +type PhotoMosaicProps = { images: readonly ContentImage[]; 'data-testid'?: string }; + +// components/FaqList (unit 2) +type FaqListProps = { + items: readonly FaqItem[]; + openCount?: number; // how many items start open (FD decides the default) +}; + +// components/PackageBlock (unit 2) +type PackageBlockProps = { + titleId: string; + eyebrow: string; + title: string; + image: ContentImage; + frameColor?: FrameColor; + pkg?: PricingPackage; // present: price + features; absent: onRequest texts + onRequest: { price: string; text: string }; + note?: string; // the deposit note + children: ReactNode; // the actions: primary LinkButton + secondary link +}; + +// components/shoots/ShootPage (shell unit 1, sections unit 2) +type ShootPageProps = { view: ShootPageView }; + +// components/shoots/StoryBlocks (unit 2) +type StoryBlocksProps = { + stories: readonly StoryBlock[]; + frameColor: FrameColor; + idPrefix: string; // heading ids unique per page, e.g. 'newborn-story' +}; + +// components/shoots/ProcessIcons (unit 2) +export const processIcons: Record<ProcessStepId, () => JSX.Element>; + +// components/shoots/ShootBlock (unit 2, props unchanged; adds the "Lees meer" link) + +// navigation.ts (unit 3) +export interface NavItem { + to: RoutePath; + label: string; + children?: readonly NavItem[]; // new +} + +// components/NavigationBar/NavSubmenu (unit 3) +type NavSubmenuProps = { item: NavItem & { children: readonly NavItem[] }; id: string }; +// internal: open state (useState<boolean>), toggle(), close({ focusToggle }), closes on route change + +// components/NavigationBar/MobileNavGroup (unit 3) +type MobileNavGroupProps = { item: NavItem & { children: readonly NavItem[] }; id: string; onNavigate: () => void }; + +// components/NavigationBar/NavLink (unit 3, additive) +type NavLinkProps = React.ComponentProps<typeof RouterLink> & { sectionCurrent?: boolean }; + +// hooks/useDismiss (unit 3) +export default function useDismiss( + ref: RefObject<HTMLElement | null>, + active: boolean, + onDismiss: (reason: 'escape' | 'outside') => void, +): void; +``` diff --git a/aidlc-docs/features/shoot-type-pages/inception/application-design/components.md b/aidlc-docs/features/shoot-type-pages/inception/application-design/components.md new file mode 100644 index 0000000..8c86175 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/application-design/components.md @@ -0,0 +1,139 @@ +# Components — Shoot Type Pages + +Status per component: **new**, **changed** (backwards compatible) or **reused** (unchanged). The unit that owns each one is in brackets; see [application-design.md § File ownership](application-design.md#file-ownership-per-unit). Signatures are in [component-methods.md](component-methods.md). + +Rule carried over from the previous pages: components never import content modules. The route passes content (or a view built from it) as props, so tests can pass any content and the CMS API can replace the modules 1-to-1. + +## Routes (`web/src/routes/soorten-fotoshoots/`) [unit 1] + +### `index.tsx` (moved, behaviour unchanged) +- **Purpose**: the overview page `/soorten-fotoshoots`, moved from `routes/soorten-fotoshoots.tsx` with `git mv`. Without a `soorten-fotoshoots.tsx` or `route.tsx` next to the folder there is no layout route, so the overview never renders a child inside itself (FR-ST-01) and the article anchors `#newborn` … stay as they are (FR-ST-09). +- **Change**: only the route string (`createFileRoute('/soorten-fotoshoots/')`, written by the generator) and the JSON-LD, which now uses the shared Service `@id` (see services.md). The registry key stays `'/soorten-fotoshoots'`: TanStack's `FileRoutesByTo` and `router.routesByPath` both trim the index route's trailing slash (verified in router-core 1.171 `new-process-route-tree.js`), so the existing registry test keeps passing. + +### `newborn.tsx`, `zwangerschap.tsx`, `gezin.tsx`, `loveshoot.tsx`, `portret.tsx` (new) +- **Purpose**: one static route per shoot type, `/soorten-fotoshoots/<id>`. Each file is about 20 lines: `head: () => pageHead('/soorten-fotoshoots/<id>')` and a component that builds the page view from its own content file and renders `StructuredData` + `ShootPage`. +- **Why five files**: see the route decision in application-design.md (D1). The component is declared inline in each file so `autoCodeSplitting` can move it, and the shoot's content, out of the main bundle (a route options object produced by a factory function would not be split). + +### `-shootPageSources.ts` (new) +- **Purpose**: the inputs every shoot page shares (shoot types, packages, shared shoot page content, site content, which types link to the portfolio), assembled once. The `-` prefix keeps the route generator from treating it as a route. Only the five shoot routes import it. + +## Shared building blocks (`web/src/components/`) + +### `StructuredData` (new) [unit 1] +- **Purpose**: renders one `<script type="application/ld+json">` from a data object through `jsonLdScript`. +- **Why new**: today the overview and other routes each write `dangerouslySetInnerHTML` themselves. Five more pages would mean five more copies. One component keeps the only `dangerouslySetInnerHTML` use behind the escaping helper (SECURITY-11). Existing routes may move to it; the moved overview route does. + +### `PageIntro` (changed) [unit 2] +- **Purpose**: the page head (eyebrow, the only h1, intro). +- **Change**: optional `breadcrumb?: ReactNode` rendered above the eyebrow, and optional `titleId?: string` that puts an id on the h1 and names the section (`aria-labelledby`), as design E's intro section does. Existing callers pass neither and render exactly as before. +- **Why not a new `ShootPageIntro`**: design E's intro is the same centred block as `.page-head` (max 680 px, eyebrow, h1, intro text). Only the breadcrumb is extra, so a slot is enough. + +### `Breadcrumb` (new) [unit 2] +- **Purpose**: the visible trail Home › Soorten fotoshoots › <shoot> (FR-ST-02): `nav` named "Kruimelpad", an `ol`, links for every item but the last, the last item as text with `aria-current="page"`, and separators that are decorative (`aria-hidden`). +- **Why new**: nothing like it exists yet. It is generic (items in, no shoot knowledge), so future pages can use it. +- **Note**: the links pass `activeOptions={{ exact: true }}`. Without it TanStack's fuzzy matching marks "Soorten fotoshoots" with `aria-current="page"` on every shoot page (see the risks in application-design.md). + +### `ProcessTimeline` (new) [unit 2] +- **Purpose**: an ordered list of steps, each with a decorative icon, an h3 and a short text (FR-ST-04). Horizontal with the texts alternating above and below the line on wide screens, vertical below a theme breakpoint; the DOM order is the reading order in both. +- **Why new**: no step or timeline block exists. It is generic: it takes resolved steps and an icon per step; it knows nothing about shoots, deposits or placeholders. +- **Section frame**: rendered inside `PageSection` with `SectionHeading` (eyebrow "Zo werkt het", h2, lead) by `ShootPage`. + +### `PhotoMosaic` (new) [unit 2] +- **Purpose**: a grid of photos that adapts to their number (design E: one large, one wide, two small on desktop; two columns on phones). All photos use `DeferredImage` with intrinsic width and height. +- **Why new**: `PortfolioGrid` is a masonry grid in reading order for many photos with a lightbox; the mosaic is a fixed composition for 2–6 photos without interaction. Sharing one component would make both worse. + +### `FaqList` (new) [unit 2] +- **Purpose**: questions as native `details`/`summary` disclosures, answers as `RichParagraph` (inline links, no HTML). The answer is in the DOM when collapsed. +- **Why native `details`**: keyboard, state and focus come from the browser, no JavaScript, no new dependency, and nothing to animate (reduced motion is trivially respected). Chakra's `Accordion` would add a slot recipe and its JS to the page chunk for no gain. Which items start open is a Functional Design detail. + +### `PackageBlock` (new) [unit 2] +- **Purpose**: the package block of design direction B (FR-ST-07): detail photo, eyebrow, h2, then either the price (`formatPrice`) with the features, or "Prijs op aanvraag" with a short text; a primary link, a secondary link, and the deposit note. +- **Interface**: the variant is chosen by data (`pkg` present or not), never by a shoot id. Link targets come in as props, already derived. +- **Why new and not `PriceCard`**: `PriceCard` is a narrow centred card in a three-card grid that links to the homepage form. The block here is a two-column `MediaText` layout with two actions and a note. It reuses `formatPrice`, `MediaText` and `LinkButton`, not the card. + +### Reused unchanged +`PageSection`, `SectionHeading`, `MediaText` (`reverse`, `mediaSize`, `frameColor`, `priority`), `FramedImage`, `DeferredImage`, `Reveal`, `CallToAction`, `LinkButton` (`accent`), `RouterLink`, Chakra `Link` (`underline`), `RichParagraph`, `Eyebrow`, `VisuallyHidden`, `NotFound`. + +## Shoot page parts (`web/src/components/shoots/`) [unit 2, shell by unit 1] + +### `ShootPage` (new) +- **Purpose**: the page template for all five shoots, in the order of the page structure: intro with breadcrumb → story blocks → process timeline → photos → FAQ → package → closing call to action. +- **Responsibilities**: composition only. Everything it shows comes from a `ShootPageView` (built by `lib/shootPageView.ts`), so it has no rules of its own: which variant, which photos, which links and which texts are decided before it renders. It gives each section its heading id. +- **Unit split**: unit 1 creates a minimal shell (the intro with the h1, so routes, heads, registry and Lighthouse work end to end); unit 2 adds the sections. + +### `StoryBlocks` (new) +- **Purpose**: the four story blocks (FR-ST-03), each a `PageSection` named by its h2, bands alternating `paper`/`paper.alt`, photo side alternating, photo above the text on phones. +- **Responsibilities**: per block: `MediaText` when the block has a photo (frame colour from the shoot); a plain text column without an empty frame when it has none. The first block's photo gets `priority` (the likely largest paint, NFR-ST-03); all others are deferred. +- **Why new**: the same role as `ShootList` on the overview (a list of `MediaText` bands with alternation). Kept in `shoots/` because the alternation rule and eyebrow/h2 layout belong to this page. + +### `ProcessIcons` (new) +- **Purpose**: six inline SVG icon components, one per process step id (`aria-hidden`, `currentColor`), and a map from step id to icon. No icon library (NFR-ST-02), although `@iconify` is already a dependency. + +### `ShootBlock` (changed) +- **Change**: a third link "Lees meer over de <shootLabel lowercased>" (e.g. "Lees meer over de newbornshoot") to `shootPagePath(shoot.id)`. The visible text is unique per shoot, so no `aria-label` is needed (FR-ST-09). Anchors and the other links stay. + +### Reused unchanged +`ShootList`. + +## Navigation (`web/src/components/NavigationBar/`, `web/src/navigation.ts`) [unit 3] + +### `NavItem` / `mainNav` (changed) +- **Change**: `NavItem` gets `children?: readonly NavItem[]`. `mainNav`'s "Soorten fotoshoots" item gets the five shoot pages as children, built by `shootNavItems(shootTypes)` from the shoot types and `shootPagePath`, so a new shoot type cannot be missed. `footerNav` is unchanged and has no children. + +### `NavSubmenu` (new) +- **Purpose**: desktop (from `lg`) disclosure for an item with children: the parent stays a `NavLink` to the overview; next to it a toggle button (`aria-expanded`, `aria-controls`, accessible name "Submenu Soorten fotoshoots") opens a panel with a plain list of links. Not the ARIA `menu` pattern, not Chakra `Menu` (NFR-ST-01). +- **Responsibilities**: open on click/Enter/Space; close on Escape (focus back to the toggle), on a pointer down outside, on choosing a link and on a route change. Solid panel (`bg`/`fg` tokens) also when the header is transparent over the home hero. Motion only without `prefers-reduced-motion`. + +### `MobileNavGroup` (new) +- **Purpose**: inside `MobileNav`, the parent link plus a toggle that expands the sub-list (`aria-expanded`). Choosing any link closes the whole menu (existing `onClose`). + +### `NavigationBar` (changed) +- Renders `NavSubmenu` for items with children, `NavLink` otherwise. + +### `MobileNav` (changed) +- Renders `MobileNavGroup` for items with children. Scrolls when the content is taller than the screen (today it is centred with `justifyContent="center"` inside a fixed box and the body's overflow is locked, so extra items can be cut off on short phones). + +### `NavLink` (changed) +- Optional `sectionCurrent?: boolean`: the same underline as `aria-current="page"` via a data attribute, for the parent while a shoot page is open (decision D4). Existing callers unchanged. + +### `ChevronIcon` (new) +- Inline SVG for the toggles, rotates when open (no rotation with reduced motion). + +### `Footer` (changed, one prop) +- The footer links pass `activeOptions={{ exact: true }}`, so "Soorten fotoshoots" in the footer is not announced as the current page on a shoot page (decision D4). No visible change; the footer menu itself is unchanged (FR-ST-10). + +### `useDismiss` (new hook, `web/src/hooks/`) +- Calls a close callback on Escape and on a pointer down outside a given element while active. Used by `NavSubmenu`. + +## Content (`web/src/content/`) [unit 1] + +### Types in `types.ts` (new types, nothing existing changes) +`ShootPageContent`, `StoryBlock`, `FaqItem`, `ShootPageShared`, `ProcessStepId`, `ProcessStepContent`, `DepositInfo`. Flat API shape: strings, `RichText`, `ContentImage`, ids and numbers. See component-methods.md. + +### `shootPages/<id>.ts` × 5 (new) +- One file per shoot with that shoot's page content (`id`, intro, four story blocks, the three per-shoot process values, mosaic heading and photos, FAQ heading and items, package eyebrow/heading, closing texts). One file per shoot because each route imports only its own file, so a page's chunk carries only its own texts, the CMS will serve one page per request, and Andrea can review one shoot at a time. + +### `shootPageShared.ts` (new) +- Everything that is the same on every shoot page: breadcrumb labels, the six step titles and texts (with placeholders), the deposit amount (whole euros) and note, mosaic and FAQ eyebrows, the FAQ lead, the package button labels and the "Prijs op aanvraag" texts, plus the shared FAQ items (exported `FaqItem` constants that the per-shoot lists include). + +### `shootTypes.ts` (unchanged data) +- Only the Gezin draft comment changes to the common draft marker (CON-ST-03). + +## Logic (`web/src/lib/`, `web/src/seo.ts`) + +| Module | Status | Unit | Purpose | +|---|---|---|---| +| `lib/shootPages.ts` | new | 1 | Shoot page paths: id → path, slug → id, path → id; the compile-time check that every shoot id has a route | +| `lib/shootPackage.ts` | new | 1 | The visible package of a shoot, or `undefined` | +| `lib/shootLinks.ts` | changed | 1 | `shootContactLink` uses `shootPackage` (same results) | +| `lib/fillPlaceholders.ts` | new | 1 | `{name}` placeholders in text and in `RichText` | +| `lib/richTextToPlain.ts` | new | 1 | `RichText` as plain text (FAQ answers in JSON-LD) | +| `lib/shootPageView.ts` | new | 1 | Builds the complete, resolved view of one shoot page | +| `lib/mosaicLayout.ts` | new (if FD keeps it pure) | 2 | Tile spans for a given photo count | +| `lib/shootNavItems.ts` | new | 3 | Nav children from the shoot types | +| `lib/navCurrent.ts` | new | 3 | Whether a nav item or its section is current for a pathname | +| `seo.ts` | changed | 1 | Shared Service `@id`, `shootService`, `breadcrumbList`, `faqPage`, `shootPageGraph`; `shootServices` uses `shootService` | + +## Registry and CI configuration [unit 1, OG images unit 2] +- `sitePages.ts`: five entries, `indexed: true`, title and description drafts; `ogImage` added by unit 2 together with `public/og-<id>.jpg`. +- `lighthouserc.cjs`: the five paths in `indexedPaths` (same order as `sitePages`, the sync test compares with `toEqual`) and in `photoPagePaths`. `lighthouserc.desktop.cjs` derives from it and does not change. diff --git a/aidlc-docs/features/shoot-type-pages/inception/application-design/services.md b/aidlc-docs/features/shoot-type-pages/inception/application-design/services.md new file mode 100644 index 0000000..fe2383b --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/application-design/services.md @@ -0,0 +1,114 @@ +# Services — Shoot Type Pages + +The SPA has no service layer. As on the other pages, the route orchestrates: it collects static content (later the CMS API), lets pure functions derive everything that is decided, and hands the result to presentational components. What is new is one pure "view" builder per shoot page, so the five routes share one tested orchestration instead of five copies. + +## Shoot page route (`routes/soorten-fotoshoots/<id>.tsx`) + +- **`head()`**: `pageHead('/soorten-fotoshoots/<id>')`: title, description, canonical, `og:image`; no `noindex` (indexed). `head()` stays in the main bundle, so it reads only `sitePages`. +- **`component`** (split off by `autoCodeSplitting`): + 1. `view = shootPageView('<id>', <id>Page, shootPageSources)`. + 2. `view` is `undefined` → render `NotFound` (fail safe, SECURITY-15; cannot happen with today's content, guarded by a test). + 3. Otherwise render `StructuredData` once per object of `shootPageGraph(view, siteContent)`, then `ShootPage view={view}`. The JSON-LD lives in the component, not in `head()`, for the same reason as on the overview: the content stays in the page's chunk. + +```mermaid +sequenceDiagram + box rgba(246,224,94,0.4) Route + participant R as ShootRoute + end + box rgba(154,230,180,0.4) Pure logic + participant V as shootPageView + participant S as seo.shootPageGraph + end + box rgba(251,211,141,0.4) Content + participant C as content modules + end + box rgba(99,179,237,0.4) Components + participant P as ShootPage + end + R->>C: read own page content and shared sources + R->>V: build view for this shoot id + V-->>R: resolved view or undefined + R->>S: build WebPage and FAQPage data from the view + S-->>R: structured data objects + R->>P: render page from the view +``` + +Text alternative: the route reads its content, asks shootPageView for a resolved view (or undefined → not-found), asks seo.ts for the structured data built from that same view, and renders ShootPage from the view. + +Because the visible page and the structured data come from the same view, the breadcrumb, FAQ, price and Service `url` cannot disagree between markup and JSON-LD. + +## `shootPageView` — the orchestration in one pure function (unit 1) + +| Step | Rule (one line; detailed rules for photos in FD unit 2) | Requirement | +|---|---|---| +| Shoot lookup | `shoot = shootTypes.find(id)`; missing, or `page.id !== id` → `undefined` | FR-ST-01, SECURITY-15 | +| Path, breadcrumb | `path = shootPagePath(id)`; items Home `/`, overview `/soorten-fotoshoots`, `shoot.name` → `path` | FR-ST-02 | +| Placeholders | values from `site.contactForm.replyTime`, `formatPrice(deposit.amount)` and the page's `process` fields; applied to steps, deposit note, stories and FAQ answers | FR-ST-04, NFR-ST-04 | +| Steps | `PROCESS_STEP_ORDER.map(id => shared.process.steps[id])`: always six, fixed order, whatever the content order | FR-ST-04 | +| Package | `pkg = shootPackage(shoot, packages)`; `bookLink = shootContactLink(shoot, packages)` | FR-ST-07, SECURITY-05 | +| Photos | page photos without any `src` already used by a story block or the package block, first occurrence kept, order kept; fewer than `MOSAIC_MIN_PHOTOS` left → no photo section; portfolio link only when `id ∈ portfolioShoots` | FR-ST-05 | +| FAQ | items with placeholders filled; none → no FAQ section | FR-ST-06 | +| Closing | `link = shootContactLink(shoot, packages)` | FR-ST-08 | + +## Overview route (`routes/soorten-fotoshoots/index.tsx`) +Unchanged composition. Its JSON-LD keeps `webPage('WebPage', '/soorten-fotoshoots', { mainEntity: shootServices(shootTypes, siteContent) })`; `shootServices` now builds each item with `shootService`, so each Service has the shared `@id` and the shoot page as `url`. No `offers` on the overview (it shows no prices; the existing "no price" invariant stays). `ShootBlock` adds the "Lees meer" link (unit 2). + +## Navigation (unit 3) +`navigation.ts` builds the "Soorten fotoshoots" children with `shootNavItems(shootTypes)` at module load. `NavigationBar` and `MobileNav` read `mainNav` as today. Current state: `isItemCurrent` / `isSectionCurrent` with the router's `location.pathname` (`useRouterState`). The open state of the mobile menu, the mobile group and the desktop submenu is one pure reducer, `navMenuReducer` in `lib/navMenuState.ts` (unit 3 FD Q6 = A, approved 2026-10-30), held with `useReducer` in `NavigationBar`; closed by events (toggle, Escape, outside, link, route change, viewport change); no context. + +## Data flow + +```mermaid +graph LR + Content["content: shootPages, shootPageShared, shootTypes, packages, siteContent, portfolioContent"] + Sources["routes: -shootPageSources"] + View["lib: shootPageView"] + Helpers["lib: shootPages, shootPackage, shootLinks, fillPlaceholders, richTextToPlain"] + Seo["seo.ts: shootPageGraph, shootService, breadcrumbList, faqPage"] + Route["routes: soorten-fotoshoots/id"] + Page["components: ShootPage and sections"] + Registry["sitePages, lighthouserc"] + Content --> Sources + Sources --> Route + Route --> View + View --> Helpers + Route --> Seo + Seo --> Helpers + Route --> Page + Registry --> Route + classDef database fill:#fbd38d,stroke:#92400e,stroke-width:1px,color:#000; + classDef service fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000; + classDef client fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000; + classDef gateway fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000; + class Content,Registry database; + class View,Helpers,Seo service; + class Route,Sources client; + class Page gateway; +``` + +Text alternative: content modules feed the shared sources, which the shoot route passes to shootPageView (using the small helpers); the route also asks seo.ts for structured data and renders the page components; the registry supplies the head. + +## Pure functions with property-based tests (PBT-01 identification) + +Unit 1's properties are fixed here (no Functional Design for unit 1); units 2 and 3 confirm or extend theirs in Functional Design. Generators in `src/test/arbitraries.ts` (PBT-07): `shootPageContent` (stories 0–6 with optional image, FAQ 0–6 with `RichText` answers containing placeholders and links, photos 0–8 with deliberate duplicates of story/package `src`), `shootPageShared` (steps as a record, deposit amount 1–999), and arbitrary strings for slugs that include known ids, case variants, slashes, `..`, `%2F`, whitespace and `</script>`. + +| Function | Property | Rule | +|---|---|---| +| `shootPagePath` / `shootIdFromSlug` / `shootIdFromPath` | `shootIdFromSlug(id) === id` and `shootIdFromPath(shootPagePath(id)) === id` for every id | PBT-02 | +| `shootIdFromSlug`, `shootIdFromPath` | any input → a known id or `undefined`, never throws; a defined result `r` satisfies `shootPagePath(r) === input` without its one trailing slash | PBT-03 | +| `fillPlaceholders`, `fillRichText` | text without placeholders is unchanged; filling twice equals filling once when values contain no `{…}`; no known placeholder remains; links keep `to`/`hash` | PBT-03, PBT-04 | +| `richTextToPlain` | equals the joined string pieces and link texts; length is the sum of the piece lengths | PBT-03 | +| `shootPackage` | result is `undefined` or a member of `visiblePackages(packages)` with `id === shoot.packageId`; agrees with `shootContactLink(...).search?.pakket` | PBT-03 | +| `shootPageView` | `undefined` iff the shoot is missing or ids differ; exactly six steps in `PROCESS_STEP_ORDER`; no known placeholder left in any text; photos are an ordered subset of the page photos without duplicates and without any story/package `src`, or absent below the minimum; `offer.pkg` defined iff `shootPackage` is; `bookLink.search?.pakket` only a visible package id; breadcrumb ends with `path`; portfolio link iff `id ∈ portfolioShoots` | PBT-03 | +| `breadcrumbList` | positions are 1..n consecutive; every `item` is an absolute URL under `siteUrl`; names equal the labels in order | PBT-03 | +| `faqPage` | one `Question` per item in order; `name` = question; answer text = `richTextToPlain(answer)`; `undefined` for an empty list | PBT-03 | +| `shootService`, `shootServices` | the overview item and the shoot page Service have the same `@id` for every shoot; `url` = canonical shoot page; `offers` present iff `pkg` given, with that price and `EUR` | PBT-03 | +| `shootPageGraph` and all new builders through `jsonLdScript` | `JSON.parse(jsonLdScript(x))` deep-equals `x` for content with `</script>`, `<`, `>`, `&`, U+2028; the output never contains `<`, `>` or `&`; never the e-mail address | PBT-02, PBT-03 | +| `mosaicLayout` (unit 2) | one tile per photo; tiles never overlap; every count 1..n gets a layout | PBT-03 (FD unit 2) | +| `shootNavItems` (unit 3) | one item per shoot, in order; `to === shootPagePath(id)`; labels = names; every `to` is a known route | PBT-03 | +| `isItemCurrent`, `isSectionCurrent` (unit 3) | exact iff pathname equals `to` (trailing slash ignored); section iff exact for the item or a child; never true for unrelated paths | PBT-03 | +| `navMenuReducer` (unit 3) | after every event of a random `NavMenuEvent` sequence, invariants I1–I4 hold (model-based); `routeChanged` and `linkChosen` idempotent and close everything; `outside` and `focusLeave` never change `menuOpen` | PBT-03, PBT-06 | + +**Not PBT** (finite sets, example-based, PBT-10): the registry consistency (every shoot id has a route, a `sitePages` entry, a sitemap line, entries in `indexedPaths` and `photoPagePaths`, a nav child and a "Lees meer" link, nothing extra), the four-stories and 3–5 FAQ content checks, "no photo twice per page" on the real content, and "a shoot with a package names the same duration as the package's features" (D6). + +**PBT-06 stateful, `navMenuReducer` (unit 3, approved 2026-10-30)**: model-based sequence tests. Random sequences of `NavMenuEvent`s (open and close the mobile menu and group, toggle the submenu, Escape, outside click, focus leave, route change, link chosen, viewport change) are applied to the reducer, and after every step the invariants hold: I1 `submenuOpen` implies `isDesktop`; I2 `menuOpen` implies `!isDesktop`; I3 `groupOpen` implies `menuOpen`; I4 `focusRequest === 'menuToggle'` implies `!isDesktop`, and `'submenuToggle'` implies `isDesktop`. The rest of the reducer's properties are listed in the table above and in unit 3's business-logic-model.md. diff --git a/aidlc-docs/features/shoot-type-pages/inception/plans/application-design-plan.md b/aidlc-docs/features/shoot-type-pages/inception/plans/application-design-plan.md new file mode 100644 index 0000000..f473d29 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/plans/application-design-plan.md @@ -0,0 +1,27 @@ +# Application Design Plan — Shoot Type Pages + +Depth: standard. Per the orchestrator's instruction, no question file was created: where a genuine decision was needed, the design picks a recommendation, states alternatives and rationale, and lists it under "Decisions for the user" in [application-design.md](../application-design/application-design.md#decisions-for-the-user). Business rules for units 2 and 3 follow in their Functional Design; unit 1 is fully specified here. + +## Plan + +- [x] Analyse context + - [x] Read requirements.md (FR-ST, SEO-ST, NFR-ST, CON-ST), execution-plan.md (units 1, 2 ∥ 3), aidlc-state.md, audit.md + - [x] Read the shared reverse-engineering artifacts (architecture, component inventory, code structure) + - [x] Read the previous feature's application design as format template + - [x] Read design E (`E-Definitief.dc.html`): intro, story bands, timeline markup and breakpoint, mosaic, FAQ, package, CTA + - [x] Verify in code: routes, `routeTree.gen.ts`, `navigation.ts`, `sitePages.ts`, `sitemap.ts`, `seo.ts` + tests, content types and modules, `visiblePackages`, `shootLinks`, `components/shoots/*`, `MediaText`, `PageSection`, `PageIntro`, `CallToAction`, `PriceCard`, `NavigationBar`/`MobileNav`/`NavLink`/`FooterLink`, `lighthouserc*.cjs`, the registry/Lighthouse sync tests, and TanStack's `resolveIsActive` and `routesByPath` in `node_modules` +- [x] Resolve O-ST-01 route mechanism (five static files vs `$id`) and the overview restructuring (D1) +- [x] Define the content model: per-shoot and shared types, file layout, placeholders, draft markers (D3, D6, D7, D8) +- [x] Identify components with responsibilities and interfaces; justify each new one (D10–D12) +- [x] Define services/helpers: path helpers and inverse, `shootPackage`, placeholders, `richTextToPlain`, `shootPageView`, `seo.ts` additions (D2, D9, D13, D14) +- [x] Identify pure functions and their PBT properties (PBT-01) +- [x] Generate `components.md` with component definitions and high-level responsibilities +- [x] Generate `component-methods.md` with types, props and method signatures +- [x] Generate `services.md` with orchestration, data flow and PBT properties +- [x] Generate `component-dependency.md` with dependency graphs, matrix and communication patterns +- [x] Generate `application-design.md`: consolidated design, decisions, file ownership per unit (units 2 and 3 disjoint), hot files, risks, "Decisions for the user", extension compliance +- [x] Validate design completeness and consistency + - [x] Every FR-ST/SEO-ST/NFR-ST item has a component, helper or test home + - [x] Units 2 and 3 share no file (ownership table) + - [x] Mermaid diagrams use `classDef` with `color:#000`, safe node ids, a text alternative after each + - [x] Security Baseline and PBT compliance summarised; no blocking findings diff --git a/aidlc-docs/features/shoot-type-pages/inception/plans/execution-plan.md b/aidlc-docs/features/shoot-type-pages/inception/plans/execution-plan.md new file mode 100644 index 0000000..2e8eb66 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/plans/execution-plan.md @@ -0,0 +1,148 @@ +# Execution Plan — Shoot Type Pages + +## Detailed Analysis Summary + +### Transformation Scope (Brownfield) +- **Transformation Type**: Single component (front-end `web/`), multiple modules inside it; no back-end, infrastructure or deployment change +- **Primary Changes**: five new pages `/soorten-fotoshoots/<id>` built from design E; a navigation submenu; SEO additions (BreadcrumbList, FAQPage, Service URLs) +- **Related Components**: `routes/soorten-fotoshoots*`, `content/` (types, shootTypes, new shoot-page content), `seo.ts`, `sitePages.ts`, `navigation.ts`, `NavigationBar` + `MobileNav`, `components/shoots/ShootBlock`, `lighthouserc*.cjs`, `LAYOUT.md`, `.ai/layout-conventions.md` + +### Change Impact Assessment +- **User-facing changes**: Yes — five new pages, a submenu in the main navigation, a "Lees meer" link per shoot on the overview +- **Structural changes**: Yes (small) — the overview route gets child routes, so `soorten-fotoshoots.tsx` must be restructured (index route or layout + `<Outlet/>`) +- **Data model changes**: Yes — new flat content types (story blocks, timeline, FAQ, mosaic photos, opleverduur, deposit); `NavItem` gains optional children +- **API changes**: No (no back-end yet; content stays shaped for the future CMS API 1:1) +- **NFR impact**: Yes — Lighthouse (10 extra runs, photo-page bucket 0.85 mobile), a11y of the submenu (keyboard, Escape, focus), JSON-LD escaping, CI duration on the Pi + +### Component Relationships +- **Primary Component**: `web/src/routes` (new shoot page route(s)) + new page section components +- **Shared Components**: `PageSection`, `MediaText`, `FramedImage`, `CallToAction`, `LinkButton`, `PriceCard`/package logic (`visiblePackages`, `shootContactLink`), `seo.ts` helpers +- **Dependent Components**: `/soorten-fotoshoots` (links + JSON-LD Service `url`), `/portfolio?shoot=` links, `sitemap`, Lighthouse config +- **Supporting Components**: tests (`*.test.tsx`, `seo.test.ts`, registry tests, axe), CI (`pnpm check`) + +| Component | Change Type | Reason | Priority | +|---|---|---|---| +| content types + shoot page content | Major (new) | page data | Critical | +| routes + sitePages + lighthouserc | Minor | new pages | Critical | +| seo.ts | Minor | breadcrumb, FAQ, Service url | Important | +| new section components | Major (new) | design E | Critical | +| NavigationBar / MobileNav / navigation.ts | Major | submenu | Important | +| ShootBlock (overview) | Minor | "Lees meer" link | Important | +| LAYOUT.md / layout-conventions | Configuration-only | docs | Optional | + +### Risk Assessment +- **Risk Level**: Medium — several modules; the navigation is used on every page; route restructuring touches an existing page +- **Rollback Complexity**: Easy — one PR, front-end only +- **Testing Complexity**: Moderate — component + a11y tests, PBT for pure helpers, Lighthouse for 5 pages + +## Workflow Visualization + +```mermaid +flowchart TD + Start(["User Request"]) + + subgraph INCEPTION["🔵 INCEPTION PHASE"] + WD["Workspace Detection<br/><b>COMPLETED</b>"] + RE["Reverse Engineering<br/><b>SKIP</b>"] + RA["Requirements Analysis<br/><b>COMPLETED</b>"] + US["User Stories<br/><b>SKIP</b>"] + WP["Workflow Planning<br/><b>IN PROGRESS</b>"] + AD["Application Design<br/><b>EXECUTE</b>"] + UG["Units Generation<br/><b>SKIP</b>"] + end + + subgraph CONSTRUCTION["🟢 CONSTRUCTION PHASE"] + FD["Functional Design<br/><b>EXECUTE (units 2, 3)</b>"] + NFRA["NFR Requirements<br/><b>SKIP</b>"] + NFRD["NFR Design<br/><b>SKIP</b>"] + ID["Infrastructure Design<br/><b>SKIP</b>"] + CG["Code Generation<br/>(Planning + Generation)<br/><b>EXECUTE</b>"] + BT["Build and Test<br/><b>EXECUTE</b>"] + end + + Start --> WD + WD --> RA + RA --> WP + WP --> AD + AD --> FD + FD --> CG + CG -.->|Next Unit| FD + CG --> BT + BT --> End(["Complete"]) + + style WD fill:#4CAF50,stroke:#1B5E20,stroke-width:3px,color:#fff + style RA fill:#4CAF50,stroke:#1B5E20,stroke-width:3px,color:#fff + style WP fill:#4CAF50,stroke:#1B5E20,stroke-width:3px,color:#fff + style CG fill:#4CAF50,stroke:#1B5E20,stroke-width:3px,color:#fff + style BT fill:#4CAF50,stroke:#1B5E20,stroke-width:3px,color:#fff + style AD fill:#FFA726,stroke:#E65100,stroke-width:3px,stroke-dasharray: 5 5,color:#000 + style FD fill:#FFA726,stroke:#E65100,stroke-width:3px,stroke-dasharray: 5 5,color:#000 + style RE fill:#BDBDBD,stroke:#424242,stroke-width:2px,stroke-dasharray: 5 5,color:#000 + style US fill:#BDBDBD,stroke:#424242,stroke-width:2px,stroke-dasharray: 5 5,color:#000 + style UG fill:#BDBDBD,stroke:#424242,stroke-width:2px,stroke-dasharray: 5 5,color:#000 + style NFRA fill:#BDBDBD,stroke:#424242,stroke-width:2px,stroke-dasharray: 5 5,color:#000 + style NFRD fill:#BDBDBD,stroke:#424242,stroke-width:2px,stroke-dasharray: 5 5,color:#000 + style ID fill:#BDBDBD,stroke:#424242,stroke-width:2px,stroke-dasharray: 5 5,color:#000 + style INCEPTION fill:#BBDEFB,stroke:#1565C0,stroke-width:3px,color:#000 + style CONSTRUCTION fill:#C8E6C9,stroke:#2E7D32,stroke-width:3px,color:#000 + style Start fill:#CE93D8,stroke:#6A1B9A,stroke-width:3px,color:#000 + style End fill:#CE93D8,stroke:#6A1B9A,stroke-width:3px,color:#000 + + linkStyle default stroke:#333,stroke-width:2px +``` + +Text alternative: Inception runs Workspace Detection, Requirements Analysis, Workflow Planning and Application Design (Reverse Engineering, User Stories and Units Generation skipped); Construction runs Functional Design for units 2 and 3, Code Generation per unit and Build and Test (NFR and Infrastructure stages skipped); no Operations phase. + +## Phases to Execute + +### 🔵 INCEPTION PHASE +- [x] Workspace Detection (COMPLETED) +- [x] Reverse Engineering (SKIPPED — shared artifacts reused; only this feature's lines are updated) +- [x] Requirements Analysis (COMPLETED) +- [x] User Stories (SKIPPED — one visitor persona, concrete FRs with acceptance detail) +- [x] Execution Plan (IN PROGRESS) +- [ ] Application Design — EXECUTE (standard) + - **Rationale**: new components (Breadcrumb, StoryBlocks, ProcessTimeline, PhotoMosaic, FaqList, ShootPackage, nav submenu), new content model, route mechanism decision (O-ST-01: five static route files vs one `$slug` route against `Record<RoutePath, PageMeta>`), new `seo.ts` helpers and the shared `Service @id` +- [ ] Units Generation — SKIP + - **Rationale**: the split is fixed below; three units in one package need no separate decomposition stage + +### 🟢 CONSTRUCTION PHASE +- [ ] Functional Design — EXECUTE for unit 2 and unit 3, SKIP for unit 1 + - **Rationale**: unit 2 has real UI rules (timeline alternation and breakpoint, mosaic with 2–N photos, package vs "Prijs op aanvraag", FAQ open state, photo-once-per-page); unit 3 has interaction rules (disclosure, keyboard, Escape, route-change close, transparent hero, mobile scroll). Unit 1 is fully specified by Application Design +- [ ] NFR Requirements — SKIP + - **Rationale**: NFRs are set at requirements level (NFR-ST-01..07); stack unchanged +- [ ] NFR Design — SKIP + - **Rationale**: no new NFR patterns beyond existing Lighthouse/a11y/CSP setup +- [ ] Infrastructure Design — SKIP + - **Rationale**: static front-end assets only; CI/CD and hosting unchanged +- [ ] Code Generation — EXECUTE (ALWAYS, per unit) +- [ ] Build and Test — EXECUTE (ALWAYS) + +### 🟡 OPERATIONS PHASE +- [ ] Deployment Setup, Monitoring Setup, Production Readiness Validation — SKIP (Operations Configuration = No) + +## Units and Change Sequence + +| # | Unit | Contents | Depends on | +|---|---|---|---| +| 1 | Content and SEO foundation | content types; shoot page content for all five types (drafts marked); deposit/opleverduur data; route(s) for `/soorten-fotoshoots/<id>` with a minimal page shell; overview route restructuring; `sitePages`, sitemap, `lighthouserc*`; `seo.ts` (BreadcrumbList, FAQPage, Service `url` → shoot page, Offer only with a price); PBT for slug↔id, JSON-LD escaping, breadcrumb/FAQ invariants | — | +| 2 | Shoot page UI | Breadcrumb, intro, StoryBlocks, ProcessTimeline (horizontal with alternating texts, vertical on narrow screens), PhotoMosaic, FaqList, ShootPackage / "Prijs op aanvraag", CTA; "Lees meer" links on the overview; OG images; `LAYOUT.md` + layout conventions (letters H–J) | 1 | +| 3 | Navigation submenu | `NavItem` children; desktop disclosure (keyboard, Escape, close on route change, transparent hero); `MobileNav` expandable group with scrolling | 1 (route paths only) | + +- **Update approach**: hybrid — unit 1 first (critical path); units 2 and 3 can run in parallel afterwards (disjoint files), each by its own sub-agent; integration checkpoint at Build and Test +- **Orchestration** (user request): the main session orchestrates; complex work (Application Design, Functional Design, unit 2 and unit 3 code, reviews) → larger sub-agents (opus); mechanical work (registry entries, docs updates, LAYOUT.md, content inventories, running checks) → smaller sub-agents (sonnet/haiku) +- **Shared hot files**: `sitePages.ts`, `lighthouserc.cjs`, `active-features.md` — own entries only (team agreement) +- **Delivery**: branch `feature/shoot-type-pages`, a commit per unit, `pnpm check` per unit, one PR at the end; commit/push only when the user asks + +## Content Approval Gate +All drafted copy (story blocks, FAQ, timeline texts, titles/descriptions, alt texts) is marked as draft in the content files. Before the merge, the drafts plus the open facts of CON-ST-04 go to Andrea in one review; the PR is not merged with unapproved drafts. + +## Estimated Timeline +- **Total stages to execute**: 5 more (Application Design, Functional Design ×2, Code Generation ×3, Build and Test) +- **Estimated duration**: about 2–3 working sessions, plus Andrea's content review and CI runs (~20+ min each on the Pi, longer with 10 extra Lighthouse runs) + +## Success Criteria +- **Primary Goal**: five indexed shoot pages per design E that explain each shoot, show photos and the process, and link into booking +- **Key Deliverables**: shoot page route(s) and components, content data, SEO helpers, navigation submenu, overview links, LAYOUT.md update, tests +- **Quality Gates**: `pnpm check` green (types, lint, vitest incl. PBT and axe, build, Lighthouse: a11y/best-practices/SEO 1.0, performance ≥ 0.85 mobile / 0.9 desktop on the new pages); Security Baseline and PBT compliance per unit; Andrea's content approval before merge +- **Integration Testing**: overview ↔ shoot pages ↔ contact/portfolio links, navigation on every page, sitemap and JSON-LD consistent across registry, routes and Lighthouse lists diff --git a/aidlc-docs/features/shoot-type-pages/inception/requirements/requirement-clarification-questions.md b/aidlc-docs/features/shoot-type-pages/inception/requirements/requirement-clarification-questions.md new file mode 100644 index 0000000..0d7ae72 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/requirements/requirement-clarification-questions.md @@ -0,0 +1,25 @@ +# Verduidelijkingsvragen — Pagina per shoottype + +De antwoorden zijn compleet en spreken elkaar niet tegen. Over de aanbetaling (Vraag 6: A, € 50) is nog iets open, want het komt in de tijdlijn, bij het pakket en in de FAQ. + +Hoe ik de andere antwoorden samen lees (zeg het als dat niet klopt): + +- Vraag 1 (D + FAQ uit C) en Vraag 3 (A, alle vijf, zonder prijsblok bij loveshoot/portret): loveshoot en portret krijgen in plaats van het pakketblok een blok "Prijs op aanvraag" met een link naar contact. De fotomozaïek toont dan de 2 foto's die er zijn, tot Andrea meer aanlevert. +- Vraag 2 (A) en Vraag 4 (A): `/soorten-fotoshoots` blijft het overzicht; de shootpagina's komen eronder (`/soorten-fotoshoots/newborn`, …). De bestaande ankers (`/soorten-fotoshoots#newborn`) blijven werken. + +## Verduidelijkingsvraag 1 — Wat gebeurt er met de aanbetaling van € 50? + +- A) Wordt verrekend met het totaalbedrag; het restbedrag betaal je na de shoot +- B) Wordt verrekend met het totaalbedrag; het restbedrag betaal je vóór of op de dag van de shoot +- C) Komt bovenop de prijs (bijv. reserveringskosten) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Verduidelijkingsvraag 2 — Krijg je de aanbetaling terug bij annuleren of verzetten? + +- A) Verzetten kan kosteloos (bijv. bij een ziek kindje of een baby die later komt); bij annuleren vervalt de aanbetaling +- B) Niet noemen op de website (staat in de algemene voorwaarden of wordt persoonlijk afgesproken) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B diff --git a/aidlc-docs/features/shoot-type-pages/inception/requirements/requirement-verification-questions.md b/aidlc-docs/features/shoot-type-pages/inception/requirements/requirement-verification-questions.md new file mode 100644 index 0000000..405c501 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/requirements/requirement-verification-questions.md @@ -0,0 +1,171 @@ +# Verificatievragen — Pagina per shoottype + +Al vastgelegd (geen vraag nodig): + +- **Stijl**: de pagina's gebruiken de bestaande huisstijl (paper/alt-banden, Marcellus + Jost, heidegroen accent, hoekige vormen) en bestaande blokken waar dat kan: `PageIntro`, `PageSection`, `MediaText`, `CallToAction`, `LinkButton`, `PriceCard`. Er komen geen hardgecodeerde kleuren of nieuwe dependencies. +- **Inhoud als vaste data** in `web/src/content/`, plat en in de vorm die de API straks 1-op-1 levert (zoals `shootTypes.ts`). +- **SEO-basis per pagina**: een eigen entry in `sitePages.ts` (titel, description, eventueel OG-afbeelding), een canonical, een sitemapregel en JSON-LD via de gedeelde `webPage()`-helper. Ook komt elke pagina in `lighthouserc.cjs`, met dezelfde lat als de andere fotopagina's. +- **Toegankelijkheid**: één h1, secties met een toegankelijke naam, contrast ≥ 4.5:1, `prefers-reduced-motion`, axe in de tests en Lighthouse a11y 1.0. +- **LAYOUT.md** krijgt een diagram voor de shootpagina, en "Types of shoots" wordt bijgewerkt als die pagina verandert. +- **Feiten uit de code**: alleen newborn, zwangerschap en gezin hebben een pakket (€ 185 / € 175 / € 175). Loveshoot en portret hebben geen pakket en maar 2 foto's elk. Nergens staat iets over aanbetaling of opleverduur. + +De designvoorstellen staan op het canvas: https://claude.ai/artifact/BdXmEgsTPK2567g9AFQCXa + +--- + +## Vraag 1 — Designrichting + +Welke richting van het canvas wil je als basis? + +- A) A · Verhaal: redactioneel, tekst en foto wisselen elkaar af, horizontale tijdlijn +- B) B · Beeld eerst: grote foto-hero, vroeg een fotoreeks, verticale tijdlijn naast een foto +- C) C · Praktisch: balk met kerngegevens, tijdlijn als genummerde kaarten, FAQ +- D) D · Verhaal + pakket uit B + horizontale icoon-tijdlijn met tekst om en om boven/onder de lijn (gemaakt na jullie feedback op A) +- E) Een andere combinatie (beschrijf welke onderdelen uit welke richting na de [Answer]:-tag) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: D + de FAQ van optie C. Zet dat eventueel als Design E in de design asset zodat ik hem nog kan bekijken voordat het gebouwd wordt. + +## Vraag 2 — URL-structuur + +Welke URL krijgen de pagina's? + +- A) Onder het overzicht: `/soorten-fotoshoots/newborn`, `/soorten-fotoshoots/zwangerschap`, … (duidelijke hiërarchie, makkelijk een breadcrumb) +- B) Met zoekwoorden: `/newbornshoot`, `/zwangerschapsshoot`, `/gezinsshoot`, `/loveshoot`, `/portretshoot` (kort, met het woord waarop mensen zoeken) +- C) Met zoekwoord en plaats: `/newbornfotograaf-huizen`, … (lokale SEO, maar lange URL's en minder ruimte voor andere plaatsen) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 3 — Welke shoottypes krijgen nu een pagina? + +Loveshoot en portret hebben maar 2 foto's en geen pakket. + +- A) Alle vijf meteen; loveshoot en portret met de 2 foto's die er zijn (en zonder prijsblok) +- B) Alle vijf bouwen, maar loveshoot en portret pas live (geïndexeerd) zodra er meer foto's zijn +- C) Nu alleen newborn, zwangerschap en gezin; loveshoot en portret later +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 4 — Rol van de bestaande pagina /soorten-fotoshoots + +- A) Blijft zoals hij is, met per shoot een extra link "Lees meer over de …shoot" naar de nieuwe pagina +- B) Wordt een compacter overzicht (kaarten met foto, korte tekst en link); de uitgebreide tekst verhuist naar de shootpagina's +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 5 — Opleverduur per shoot + +Hoe lang duurt het van shoot tot oplevering van de foto's? + +- A) Ik vul de waarden zelf in na de [Answer]:-tag (bijv. newborn 3 weken, zwangerschap 2 weken, …) +- B) Gebruik voorlopige waarden die duidelijk als concept gemarkeerd zijn; Andrea bevestigt ze vóór de merge +- C) Noem geen termijn, alleen de stap "Bewerking" zonder duur +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: X, De termijn voor nu is voor alles 2-3 weken + +## Vraag 6 — Aanbetaling + +Wat moet er bij de stap "Aanbetaling" staan? + +- A) Een vast bedrag (vul het in na de [Answer]:-tag, bijv. € 50, en eventueel of het verrekend wordt) +- B) Een percentage van de prijs (vul het in na de [Answer]:-tag) +- C) Alleen dat er een aanbetaling is om de datum vast te leggen, zonder bedrag +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A, €50,- + +## Vraag 7 — Is de tijdlijn voor elke shoot gelijk? + +De stappen zijn aanvragen → datum & locatie kiezen → aanbetaling → shoot → bewerking → oplevering. + +- A) Ja, dezelfde stappen voor alle shoots; alleen de opleverduur (en eventueel de stap Locatie, zoals "bij jou thuis" bij newborn) verschilt per shoot +- B) Ja, volledig gelijk, inclusief de teksten +- C) Nee, per shoot kunnen er stappen bij of af (bijv. een voorgesprek bij newborn) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 8 — Uitgebreidere tekst per shoot + +Wie schrijft de verdiepende tekst (wat houdt de shoot in, beste periode, duur, locatie, wat neem je mee)? + +- A) Ik (Claude) schrijf concepten in Andrea's toon, op basis van de bestaande teksten; Andrea keurt ze goed vóór de merge +- B) Andrea levert de teksten aan; tot die tijd placeholders +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag 9 — Veelgestelde vragen (FAQ) + +Een FAQ per shoot helpt bij SEO (Google kan de vragen herkennen) en beantwoordt praktische vragen. + +- A) Ja, 3–5 vragen per shoot (concepten door Claude, Andrea keurt goed) +- B) Ja, maar één gedeelde FAQ op alle pagina's (algemene vragen) +- C) Nee, geen FAQ +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A, dit kan een mix zijn van specifieke vragen voor dat type shoot en algemene vragen. + +## Vraag 10 — Uitgelichte foto's + +- A) Kies uit de foto's die er al zijn (portfolio + `assets/shoots/`); loveshoot en portret krijgen dan weinig +- B) Andrea levert per shoot een nieuwe selectie (bijv. 4–6 foto's); tot die tijd de bestaande foto's +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A, Andrea levert later meer foto's aan + +## Vraag 11 — Navigatie + +Hoe vind je de shootpagina's via het menu? + +- A) Geen menuwijziging; alleen links vanaf /soorten-fotoshoots, de homepage en de footer +- B) Een submenu onder "Soorten fotoshoots" in de navigatiebalk (meer werk: dropdown op desktop, uitklapbaar op mobiel) +- C) Alleen extra links in de footer (plus de links vanaf /soorten-fotoshoots) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B + +## Vraag 12 — Breadcrumb + +- A) Ja, een zichtbare breadcrumb (Home › Soorten fotoshoots › Newborn) plus `BreadcrumbList` JSON-LD +- B) Alleen de `BreadcrumbList` JSON-LD, niet zichtbaar +- C) Nee +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag: Beveiligingsextensies + +Moeten de beveiligingsregels als harde vereisten worden afgedwongen voor dit project? (Bij de vorige features: Ja.) + +- A) Ja — dwing alle BEVEILIGINGSREGELS af als blokkerende vereisten (aanbevolen voor productietoepassingen) +- B) Nee — sla alle BEVEILIGINGSREGELS over (geschikt voor PoC's, prototypes en experimentele projecten) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag: Property-Based Testing Extensie + +Moeten de property-based testing (PBT) regels worden afgedwongen voor dit project? (Bij de vorige features: Ja, volledig.) + +- A) Ja — dwing alle PBT-regels af als blokkerende vereisten (aanbevolen voor projecten met bedrijfslogica, datatransformaties, serialisatie of stateful componenten) +- B) Gedeeltelijk — dwing PBT-regels alleen af voor pure functies en serialisatie round-trips (geschikt voor projecten met beperkte algoritmische complexiteit) +- C) Nee — sla alle PBT-regels over (geschikt voor eenvoudige CRUD-applicaties, UI-only projecten of dunne integratielagen zonder significante bedrijfslogica) +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: A + +## Vraag: Operations-fase + +Moet deze feature na Construction door de Operations-fase (deployment en monitoring opzetten)? (Bij de vorige features: Nee; de bestaande CI/CD-pipeline deployt.) + +- A) Ja — voer de Operations-fase uit na Construction (deployment + monitoring) +- B) Nee — stop na Build and Test (deployment/monitoring vallen buiten deze feature) +- C) Weet ik nog niet — vraag het opnieuw na de Construction-fase +- X) Anders (beschrijf hieronder na de [Answer]:-tag) + +[Answer]: B diff --git a/aidlc-docs/features/shoot-type-pages/inception/requirements/requirements.md b/aidlc-docs/features/shoot-type-pages/inception/requirements/requirements.md new file mode 100644 index 0000000..80ac583 --- /dev/null +++ b/aidlc-docs/features/shoot-type-pages/inception/requirements/requirements.md @@ -0,0 +1,307 @@ +# Requirements — Shoot Type Pages + +## Intent Analysis +- **User Request**: one page per shoot type, to improve SEO and to go deeper into what each shoot involves, with a few highlighted photos as an impression and generic information shown on every page, such as a timeline of the steps (request, choose date and location, deposit, shoot, editing time per shoot, delivery). Design suggestions first; built with AI-DLC. +- **Request Type**: New Feature (five new routes under `/soorten-fotoshoots/`) with backwards-compatible extensions of the overview page, the navigation, the content model and the SEO helpers +- **Scope Estimate**: Multiple components within one package (`web/`), plus [LAYOUT.md](../../../../../LAYOUT.md) +- **Complexity Estimate**: Moderate. One page template filled from data for five shoot types, a new timeline and FAQ block, a navigation submenu (desktop dropdown + mobile expandable), three new kinds of structured data (BreadcrumbList, FAQPage, per-page Service), route restructuring of `/soorten-fotoshoots`, and a large amount of new Dutch copy awaiting Andrea's approval +- **Requirements Depth**: Standard + +## Source of Truth +- **Layout and styling**: design **E · Definitief** on the Design canvas (https://claude.ai/artifact/BdXmEgsTPK2567g9AFQCXa, board `E-Definitief.dc.html`, worked out for Newborn): direction D (A · Verhaal + the package block of B + the horizontal icon timeline) plus the FAQ of C. There is no shoot page in `design/andreaslop-static/`; design E takes its place for this page type. The house style (theme tokens, text styles, angular shapes, `paper`/`paper.alt` bands) applies as everywhere. *Source: Q1 = D + FAQ from C* +- **Decisions**: [requirement-verification-questions.md](requirement-verification-questions.md), [requirement-clarification-questions.md](requirement-clarification-questions.md) (including the stated readings at the top, accepted by the user) +- **Codebase facts**: shoot content in `web/src/content/shootTypes.ts`, `packages.ts`, `types.ts`; registry `web/src/sitePages.ts`; SEO helpers `web/src/seo.ts`; menus `web/src/navigation.ts` and `web/src/components/NavigationBar/` + +## Page Structure (per shoot) +Shell header → **Intro** (breadcrumb, eyebrow, h1, intro text) → **Story 1–4** (four text/photo blocks on alternating bands) → **Process timeline** ("Zo werkt het", six steps) → **Photo mosaic** ("Impressie") → **FAQ** ("Veelgestelde vragen") → **Package** (or "Prijs op aanvraag") → **Book** (CTA band) → shell footer. + +```mermaid +graph TD + Intro["Intro: breadcrumb + h1"] --> S1["Story 1: wat kun je verwachten"] + S1 --> S2["Story 2: beste periode"] + S2 --> S3["Story 3: locatie"] + S3 --> S4["Story 4: duur"] + S4 --> TL["Process timeline (6 steps)"] + TL --> Mosaic["Photo mosaic"] + Mosaic --> Faq["FAQ (3-5 questions)"] + Faq --> Pkg["Package or Prijs op aanvraag"] + Pkg --> Cta["Book (CTA band)"] + classDef head fill:#e76f51,stroke:#ad533d,color:#000; + classDef story fill:#f4a261,stroke:#b77a49,color:#000; + classDef generic fill:#2a9d8f,stroke:#20766b,color:#000; + classDef perShoot fill:#e9c46a,stroke:#af9350,color:#000; + classDef cta fill:#b56576,stroke:#884c59,color:#000; + class Intro head; + class S1,S2,S3,S4 story; + class TL generic; + class Mosaic,Faq,Pkg perShoot; + class Cta cta; +``` + +Text alternative: each shoot page runs from the intro with breadcrumb through four story blocks, the process timeline (same steps on every page), the photo mosaic, the FAQ and the package (or "Prijs op aanvraag") block to the closing call to action. + +--- + +## Functional Requirements + +### FR-ST-01 Routes and slugs +- Five pages: `/soorten-fotoshoots/newborn`, `/zwangerschap`, `/gezin`, `/loveshoot`, `/portret`. The slug equals the stable `ShootTypeId`. *Source: Q2 = A* +- All five go live and indexed with this feature. *Source: Q3 = A* +- `/soorten-fotoshoots` keeps rendering the overview page; it must not turn into a layout that renders a child page inside it. (Today `routes/soorten-fotoshoots.tsx` is a flat leaf route; adding children requires restructuring it, e.g. to an index route. Mechanism decided in design.) +- Each of the five paths is a concrete `RoutePath` with its own `sitePages` entry (FR-ST-12). If design chooses one parameterised route (`$slug`), it must still yield five concrete registry entries, sitemap lines and Lighthouse URLs; `Record<RoutePath, PageMeta>` cannot key on a `$slug` template as it is. +- A single pure function derives the page path from a shoot id, and a single pure function maps a slug back to a shoot id (or `undefined`). Links, navigation, breadcrumb, structured data and the registry use these, never hand-written paths. +- An unknown slug (e.g. `/soorten-fotoshoots/onzin`) shows the existing not-found page, never a broken or empty shoot page. + +### FR-ST-02 Intro with breadcrumb +- Visible breadcrumb above the h1: **Home › Soorten fotoshoots › <shoot name>** (e.g. "Newborn", "Portretten"), as `nav` named "Kruimelpad" with an ordered list; the first two items are links, the last is the current page (`aria-current="page"`, not a link). Separators are decorative. *Source: Q12 = A* +- Eyebrow, the page's only h1 and an intro paragraph per shoot (design E Newborn: eyebrow "Newbornfotograaf in Huizen", h1 "Newbornshoot bij jou thuis"). Uses or extends the existing `PageIntro`; the extension is optional and existing callers render unchanged. + +### FR-ST-03 Story blocks +- Four blocks per shoot, each a `section` named by its h2, with eyebrow, h2, one or more paragraphs and an optional photo. Bands alternate `paper` / `paper.alt` and the photo side alternates, as in design E; on phones the photo sits above the text. Built on `MediaText` (with its existing `reverse`, `aspectRatio`, `frameColor` options) and the shoot's frame colour. +- Design E's four themes for Newborn: wat kun je verwachten · de beste periode · locatie · duur. Other shoots use four blocks with headings that fit the shoot (drafts, CON-ST-02). +- A block without a photo renders as a text block without an empty frame or layout gap. + +### FR-ST-04 Process timeline +- Section "Zo werkt het", h2 "Van aanvraag tot online galerij", with the **same six steps on every page**, in this order: **Aanvragen → Datum & locatie kiezen → Aanbetaling → De shoot → Bewerking → Oplevering**. Each step has a decorative icon (no numbers), an h3 and a short text. *Source: Q7 = A* +- Per-shoot values filled in from data: the location text in step 2 (e.g. Newborn "Een newbornshoot is bij jou thuis."), the shoot duration in step 4, and the **opleverduur** in step 5. Opleverduur is a per-shoot field, currently **2–3 weken** for all five. *Source: Q5 = X, Q7 = A* +- Generic values come from one shared place: the reply time (existing `siteContent.contactForm.replyTime`, "1-2 werkdagen") in step 1 and the deposit in step 3: "Met een aanbetaling van € 50 staat je datum vast." *Source: Q6 = A* +- Layout: on wide screens a horizontal line with the six icons and the step texts alternating above and below the line; below ~900 px (design E; the exact breakpoint is chosen in design, a theme breakpoint or token, not a hard-coded pixel value in components) it collapses into a vertical line with the texts beside the icons. The DOM order (an `ol`) equals the reading order in both layouts. +- **No** cancellation or rescheduling terms anywhere on the site. *Source: Clarification 2 = B* + +### FR-ST-05 Photo mosaic +- Section "Impressie" with a heading per shoot (design E: "Uit eerdere newbornshoots") and a mosaic of the shoot's highlight photos that adapts to the number of photos (design E: one large, one wide, two small on desktop; two columns on phones). +- Photos are chosen from existing assets (`assets/portfolio/`, `assets/shoots/`). Loveshoot and Portret have only their 2 photos (main + detail) for now. *Source: Q10 = A, Q3 = A* +- A minimum photo count below which the mosaic is left out is set in design; the page then still has a valid heading outline. +- A photo appears at most once per page (design E repeats `f41a8700` in Story 2 and the mosaic; resolve in design). +- "Bekijk meer …foto's" (`shootPortfolioLink`) follows the existing rule: only when the portfolio page is live and the type has portfolio photos (today Loveshoot and Portret have none, so no link). + +### FR-ST-06 FAQ +- Section "Veelgestelde vragen" (h2 per shoot, e.g. "Vragen over de newbornshoot"), a lead with a link to contact ("Staat je vraag er niet tussen? Stuur gerust een berichtje."), and **3–5 questions per shoot**, mixing shoot-specific and general questions. *Source: Q9 = A* +- Each question is an expandable item (native `details`/`summary` or an accessible disclosure/accordion); the answer text is in the DOM also when collapsed. Which items start open is a design detail (design E opens the first two). +- Answers may contain inline links (existing `RichText` with typed internal targets), no raw HTML. + +### FR-ST-07 Package block +- For a shoot whose `packageId` points to a **visible** package (`visiblePackages`; today Newborn € 185, Zwangerschap € 175, Gezin € 175): the package block in the style of direction B: detail photo, eyebrow ("Pakket newborn"), h2 ("Wat zit er in een newbornshoot"), the price (`formatPrice`), the package features, button **"Boek dit pakket"** → `/contact?pakket=<id>` (existing `shootContactLink`), secondary link **"Eerst een vraag stellen"** → `/contact`, and the note **"Aanbetaling € 50, restbedrag na de shoot."** All figures come from `packages.ts` and the shared deposit value, not from free text. *Source: Q1, Q6 = A, Clarification 1 = A* +- For a shoot without a visible package (today Loveshoot and Portret): the same block with **"Prijs op aanvraag"** in place of the price and features, and a link to `/contact`. *Source: Q3 = A, accepted reading* +- The variant is decided by the data (visible package or not), not by the shoot id, so an invalid or removed package falls back to "Prijs op aanvraag" instead of breaking the page. + +### FR-ST-08 Closing call to action +- The existing `CallToAction` band with a per-shoot h2 and lead (design E: "Op zoek naar een newbornfotograaf in Huizen?" / "Stuur gerust een berichtje voor de mogelijkheden. …") and an accent `LinkButton` ("Boek je newbornshoot") → `shootContactLink(shoot, packages)`. + +### FR-ST-09 Overview page links +- `/soorten-fotoshoots` stays as it is, plus per shoot block a link **"Lees meer over de <shoot>"** (e.g. "Lees meer over de newbornshoot") to the shoot's page. Each link's accessible name is unique per shoot. *Source: Q4 = A* +- The existing anchors (`/soorten-fotoshoots#newborn`, …) keep working (the `article` ids stay). + +### FR-ST-10 Navigation submenu +- In the main navigation, "Soorten fotoshoots" gets a submenu with the five shoot pages (labels = shoot `name`), derived from `shootTypes` and the path function of FR-ST-01, so a new shoot type cannot be forgotten in the menu. *Source: Q11 = B* +- **Desktop** (from `lg`): a dropdown. "Soorten fotoshoots" itself stays a link to the overview; a separate toggle (or an equivalent accessible pattern chosen in design) opens the submenu. Opens by click/tap and keyboard (Enter/Space), closes on Escape (focus back to the toggle), on a click outside, on choosing a link and on route change. Hover opening is optional and never the only way. The panel stays readable when the header is transparent over the home hero. +- **Mobile** (below `lg`): inside the existing full-screen `MobileNav`, an expandable sub-list under "Soorten fotoshoots" with a toggle (`aria-expanded`). Choosing a link closes the whole menu. The menu scrolls when its content is taller than the screen (today it is vertically centred with `overflow` locked on the body, so five extra items can be cut off on short phones). +- The parent item shows as current (existing underline/accent styling) when the overview or one of the shoot pages is open; the active shoot link has `aria-current="page"`. +- The footer menu is unchanged. + +### FR-ST-11 Content model (flat, CMS-ready) +- The shoot page content is flat, API-shaped data in `web/src/content/` (strings, string arrays, `RichText`, `ContentImage`, ids, numbers), extending `ShootType` or in a separate per-shoot page content list keyed by `ShootTypeId` (decided in design). Per shoot: intro (eyebrow, title, text), four story blocks (eyebrow, title, paragraphs, optional image), timeline location text, shoot duration text, opleverduur, highlight photos (ordered list of `ContentImage`), FAQ items (question, answer as `RichText`), mosaic heading, CTA texts. +- Shared, generic content in one place: the six step titles and texts, the deposit amount (whole euros, € 50) and its settlement note, the FAQ lead, the "Prijs op aanvraag" texts. +- **Adding photos later (Andrea delivers more, Q10) is a data-only change**: adding a `ContentImage` to the shoot's list (plus the asset file, until the CMS serves images) changes the page without touching components or routes. +- Link targets are derived in code (`shootContactLink`, `shootPortfolioLink`, the path function), not stored as URLs in content. +- Existing content (`shootTypes.ts` fields, the overview page texts) and its consumers (overview page, portfolio filters, contact options) keep working unchanged. + +### FR-ST-12 Registry, sitemap and Lighthouse entries +- Each shoot page gets a `sitePages.ts` entry: `indexed: true`, a title (≤ ~60 characters including " | Andrea Slop Fotografie"), a description (≤ ~155 characters) naming the shoot and the region, and an `ogImage` (see SEO-ST-05). Sitemap lines follow automatically from the registry. +- The five paths are added to `indexedPaths` in `web/lighthouserc.cjs` (the existing sync test with `sitePages` must pass) and, as photo pages, to `photoPagePaths` (FR-ST-13, NFR-ST-04). + +### FR-ST-13 LAYOUT.md +- New section **"Shoot page"** (one generic diagram for all five shoots) following [.ai/layout-conventions.md](../../../../../.ai/layout-conventions.md): A Intro (with breadcrumb), B–E Story 1–4, F Process timeline, G Photos, H FAQ, I Package, J Book. Letters H, I and J need new template colours (stroke = fill × 0.75), added to the template in `.ai/layout-conventions.md` as well. +- "Types of shoots" keeps its blocks (the new links do not add a section). The Shell diagram does not show menu items, so it stays unchanged. + +### FR-ST-14 404 inside the shoot section +- An unknown URL under `/soorten-fotoshoots/` (e.g. `/soorten-fotoshoots/niet-bestaande-shoot`; prefix match case-insensitive, like the router) shows the normal 404 page with two actions: **"Terug naar Soorten fotoshoots"** (link to `/soorten-fotoshoots`, `accent` variant, first) and **"Terug naar home"** (link to `/`, `outline`). Every other unknown URL keeps the single "Terug naar home" button. Title, text and `noindex` stay unchanged. +- Implemented in `NotFound` by reading the current pathname; no layout route is added (the route tree, the menu matching of unit 3 and the bundle stay unchanged). *Source: user request 2026-10-30, added during Code Generation* + +--- + +## SEO Requirements + +### SEO-ST-01 Indexing and canonical +- All five pages indexed (no `robots noindex`), in `sitemap.xml`, each with its own canonical via `pageHead`. *Source: Q3 = A* + +### SEO-ST-02 Titles and descriptions +- One title and description per page, drafted with the shoot keyword and the region (e.g. "Newbornshoot in Huizen …"), unique across the site. Drafts for Andrea's approval (CON-ST-02). + +### SEO-ST-03 Structured data per shoot page +- `WebPage` via the shared `webPage()` helper whose `mainEntity` is the shoot's `Service` (`name`, `serviceType`, `description`, `image`, `provider: { '@id': businessId }`, `areaServed` from `siteContent.serviceArea`). The Service has **one stable `@id`** shared with the overview page's `ItemList`, so search engines see one entity; its `url` is the shoot page. The overview's `shootServices` is updated accordingly. +- Only where the page shows a price: an `offers` `Offer` with that price in EUR. No offer for "Prijs op aanvraag". +- `BreadcrumbList` matching the visible breadcrumb (positions 1..3, absolute URLs; Home, Soorten fotoshoots, the shoot). *Source: Q12 = A* +- `FAQPage` with one `Question`/`acceptedAnswer` per visible FAQ item, in page order, answer text equal to the visible text (inline links flattened to their text). *Source: Q9 = A* +- No e-mail address. All structured data goes through `jsonLdScript` (escapes `<`, `>`, `&`) and, as on the overview page, is rendered by the route component so the content stays in the page's chunk. The new helpers are pure functions in `seo.ts` (100 % coverage threshold applies). + +### SEO-ST-04 Semantic structure +- One h1; h2 per section (story blocks, timeline, mosaic, FAQ, package, CTA); h3 per timeline step; questions as the disclosure labels (no skipped levels); descriptive link texts; images with width and height. + +### SEO-ST-05 Preview image +- Per page an `ogImage` 1200×630 from the shoot's main photo, in `web/public/` with its own alt text, as on the other pages. If a crop does not work, the default `/og-image.jpg` is used. *(Assumption, not asked; see A-ST-04.)* + +--- + +## Non-Functional Requirements + +### NFR-ST-01 Accessibility (WCAG 2.1 AA as guideline) +- Heading outline as in SEO-ST-04; every section named by its heading (`aria-labelledby`). +- Breadcrumb as FR-ST-02. Timeline as an ordered list with decorative icons (`aria-hidden`), the line decorative. +- Navigation submenu: **disclosure navigation pattern** (button with `aria-expanded`/`aria-controls`, a plain list of links), **not** the ARIA `menu`/`menuitem` pattern (so not Chakra's `Menu` as is); full keyboard operation and focus handling per FR-ST-10; visible focus ring (theme). +- FAQ disclosures operable by keyboard with a visible state. +- Text contrast ≥ 4.5:1; touch targets ≥ 44×44 px (links, buttons, toggles, FAQ summaries); `prefers-reduced-motion` respected (reveal, submenu and FAQ animations). +- Axe checks in the component and route tests; Lighthouse accessibility 1.0 on all five pages (mobile and desktop) and unchanged on the existing pages. + +### NFR-ST-02 Styling and reuse +- Reuse before building: `PageIntro`, `PageSection`, `MediaText`/`FramedImage`/`DeferredImage`, `Reveal`, `CallToAction`, `LinkButton`, `Link` (`underline`), `RouterLink`, `RichParagraph`, `formatPrice`, `visiblePackages`, `shootContactLink`, `shootPortfolioLink`, and theme tokens/text styles. +- New building blocks (breadcrumb, timeline, mosaic, FAQ, package block, nav submenu) are shared components in their own folders under `components/`, usable for future pages; no hard-coded colours, CSS files or Tailwind; icons as inline SVG components, no icon library. +- Responsive from 320 px to ultrawide, mobile-first, no horizontal scroll, usable at 200 % zoom. +- Prettier style; code comments in English; visitor-facing texts in Dutch. + +### NFR-ST-03 Performance +- The shoot page content and components are code-split from the main bundle (as the overview page does). +- The largest contentful paint image (decided in design; in design E the first story photo) is not deferred; all other photos use `DeferredImage` with intrinsic width/height (no layout shift). +- Lighthouse performance: desktop ≥ 0.9; mobile ≥ 0.85 via `photoPagePaths` (same known limit as `/over-mij` and `/soorten-fotoshoots`), with 0.9 as the goal. Performance stays warn-only in CI. +- No new network requests other than bundled images. Five extra pages × two Lighthouse runs lengthen the CI Lighthouse step on the Raspberry Pi runner; accepted. + +### NFR-ST-04 Maintainability +- One source per fact: shoot ids/slugs (FR-ST-01), prices and features (`packages.ts`), deposit and step texts (shared content), reply time (`siteContent`), opleverduur per shoot. No figure is repeated as free text where data exists. +- A new shoot type needs only content plus a route entry (if static routes are chosen) and registry/Lighthouse entries, all guarded by tests (NFR-ST-06). + +### NFR-ST-05 Security (Security Baseline enabled, blocking) +- **SECURITY-04**: header set and CSP in `web/config/securityHeaders.ts` unchanged; no inline event handlers; the only inline script is the existing JSON-LD pattern. +- **SECURITY-05**: any route or search parameter (a `$slug` if chosen; existing `?pakket=`) is validated against the known id lists; outgoing `?pakket=` values come only from visible package ids. +- **SECURITY-09**: no debug output, no sample or placeholder content in production; draft markers are removed before merge (CON-ST-03). +- **SECURITY-10**: no new dependencies (Chakra's built-in primitives only); lockfile unchanged except if unavoidable and justified in design. +- **SECURITY-11**: content is rendered as text/typed links only; `dangerouslySetInnerHTML` only with `jsonLdScript` output; no e-mail address in markup, bundle, content or structured data. +- **SECURITY-13**: all assets self-hosted; no CDN or third-party embeds. +- **SECURITY-15**: unknown slugs and missing/invalid content fail safe (not-found page, "Prijs op aanvraag", omitted mosaic), never a crash; existing global error handling unchanged. +- SECURITY-01, -02, -03, -06, -07, -08, -12, -14: N/A (see compliance table). + +### NFR-ST-06 Testing (Property-Based Testing enabled, full) +- **Example-based**: page structure and heading outline per shoot; timeline order and per-shoot values; package vs "Prijs op aanvraag" variant; FAQ disclosures; breadcrumb; mosaic with 2 and with many photos; overview "Lees meer" links and kept anchors; nav submenu (desktop and mobile: open, close by Escape/outside/route change, focus return, current state); not-found for unknown slugs; head tags (title, description, canonical, `og:image`, no `noindex`); axe checks. +- **Registry consistency** (finite sets, example-based): every shoot type has a route, an indexed `sitePages` entry, a sitemap line, an entry in `indexedPaths` and `photoPagePaths`, a nav child and a "Lees meer" link, and nothing extra exists. +- **Property-based** (fast-check, `src/test/arbitraries.ts`, existing seed logging): see PBT targets in the compliance table. +- `pnpm check` (lint, format, tests incl. coverage thresholds, build, audits, Lighthouse) passes. + +### NFR-ST-07 Coordination +- Hot files (`sitePages.ts`, `lighthouserc.cjs`, `navigation.ts`, `NavigationBar/`, `seo.ts`, `content/types.ts`, `shootTypes.ts`, `LAYOUT.md`, `_shared/reverse-engineering/`): only this feature's entries are changed, and changes to shared components are backwards compatible. No other feature is active at the time of writing (`active-features.md`). + +--- + +## Content Requirements + +### CON-ST-01 Fixed facts (from the user's answers) +| Fact | Value | Source | +|---|---|---| +| Deposit | € 50, settled against the total; remainder paid after the shoot | Q6 = A, Clarification 1 = A | +| Opleverduur | 2–3 weken, all five shoots (per-shoot field) | Q5 = X | +| Steps | Aanvragen → Datum & locatie kiezen → Aanbetaling → De shoot → Bewerking → Oplevering | Q7 = A | +| Cancellation / rescheduling | Not mentioned on the site | Clarification 2 = B | +| Newborn date (exception) | Newborn depends on the birth date, so the Newborn page keeps "We zetten een voorlopige datum … en schuiven mee als jullie baby eerder of later komt". This is a Newborn-specific planning fact, not general rescheduling terms; other shoots do not get such a line | User, 2026-10-29 | +| Prices | From `packages.ts` (Newborn € 185, Zwangerschap € 175, Gezin € 175); Loveshoot and Portret "Prijs op aanvraag" | code, Q3 = A | +| Reply time | 1-2 werkdagen (`siteContent`) | code | + +### CON-ST-02 Drafts by Claude in Andrea's tone (Andrea approves before merge) +*Source: Q8 = A, Q9 = A.* Per shoot, based on the existing texts in `shootTypes.ts` and `packages.ts`: intro (eyebrow, h1, text); four story blocks; timeline location text and shoot-duration text; mosaic heading; 3–5 FAQ items; CTA texts; package/"Prijs op aanvraag" texts; page title and description; alt texts for photos used in a new context; the photo selection per slot. Design E's Newborn texts are the starting draft for Newborn. The Gezin overview text from the previous feature is still a draft as well. + +### CON-ST-03 Approval gate +- Every drafted text is marked as a draft in the content file until Andrea approves it; the list of drafts is presented to her in one review. The feature is not merged with unapproved drafts. + +### CON-ST-04 Unknown facts — not to be invented (ask Andrea) +| Item | Why open | +|---|---| +| Shoot duration for Loveshoot and Portret | No package, so no "N uur fotografie"; needed for Story 4 and timeline step 4 | +| Number of photos delivered and online gallery for Loveshoot and Portret | Package features exist only for the three packages; timeline step 6 assumes an online gallery for all | +| Best period for Loveshoot and Portret, locations for Portret (natuur / zakelijk) | Not in the current texts | +| "Na de aanvraag stuur ik je een korte checklist" (design E FAQ) | Placeholder in the design; unknown whether such a checklist exists | +| "Ik neem zelf dekens en doeken mee" / "Ik neem alles mee wat ik nodig heb" (design E) | Plausible but not confirmed | +| When and how the remainder is paid "na de shoot" (before delivery?) | Only "after the shoot" is known | +| Whether the € 50 deposit also applies to Loveshoot and Portret | Assumed yes (identical timeline, Q7 = A) | + +### CON-ST-05 Photos +- From existing assets only (Q10 = A). Available pools: Newborn 6 portfolio + 2 shoot photos; Zwangerschap 2 + 2; Gezin 2 + 2 (the `shoots/gezin*` photos show newborn families); Loveshoot 2; Portret 2. Andrea delivers more later; adding them is data-only (FR-ST-11). + +--- + +## Out of Scope +- New photos (Andrea delivers later), a responsive image pipeline, prerendering. +- Cancellation, rescheduling and general terms (Clarification 2 = B). +- Footer and homepage links to the shoot pages (Q11 = B covers the main navigation only). +- Changes to the contact page or form (it already handles `?pakket=`). +- `HowTo` structured data for the timeline. +- Google Business Profile. +- Operations phase. *Source: Operations = B* +- Process note, not a requirement: the work is orchestrated with sub-agents (aidlc-state.md § Orchestration). + +## Assumptions and Open Items +- **A-ST-01** Slug = `ShootTypeId`; Portret's page is `/soorten-fotoshoots/portret` while its display name is "Portretten". +- **A-ST-02** The timeline step texts are identical on every page except the per-shoot fields (location, duration, opleverduur). +- **A-ST-03** The deposit note appears in both package variants; confirm with Andrea (CON-ST-04). +- **A-ST-04** Per-page OG images are wanted (not asked; follows earlier pages). +- **A-ST-05** FAQPage markup is valid schema.org, but Google shows FAQ rich results only for a limited set of authoritative sites since 2023, so the SEO value is mainly the on-page content; the markup is kept because it is cheap and matches the page. +- **O-ST-01** Route mechanism (five static files vs one `$slug` route) and how the overview route is restructured: Application Design. +- **O-ST-02** Exact horizontal/vertical timeline breakpoint, mosaic minimum and layouts for 2 photos, FAQ items open by default: Functional/UI design. +- **O-ST-03** Content facts in CON-ST-04: Andrea. + +--- + +## Extension Compliance — Requirements Level + +### Security Baseline +| Rule | Status | Rationale | +|---|---|---| +| SECURITY-01 Encryption | N/A | No data stores | +| SECURITY-02 Access logging | N/A | No intermediaries added; hosting unchanged | +| SECURITY-03 Application logging | N/A | No server-side component; client errors already go to Sentry | +| SECURITY-04 HTTP security headers | Compliant | Header set and CSP unchanged (NFR-ST-05) | +| SECURITY-05 Input validation | Compliant | Slug and `?pakket=` validated against known ids (NFR-ST-05) | +| SECURITY-06 Least privilege | N/A | No IAM | +| SECURITY-07 Network configuration | N/A | No network infrastructure | +| SECURITY-08 Access control | N/A | Public content | +| SECURITY-09 Hardening | Compliant | No debug output; draft markers removed before merge | +| SECURITY-10 Supply chain | Compliant | No new dependencies | +| SECURITY-11 Secure design | Compliant | Text-only rendering, escaped JSON-LD, no e-mail | +| SECURITY-12 Authentication | N/A | No authentication | +| SECURITY-13 Integrity | Compliant | All assets self-hosted | +| SECURITY-14 Alerting | N/A | No server-side component; monitoring unchanged | +| SECURITY-15 Exception handling | Compliant | Fail-safe fallbacks (NFR-ST-05) | + +### Property-Based Testing (PBT targets) +| Rule | Status | Target | +|---|---|---| +| PBT-01 Property identification | Planned | Properties listed per unit in Functional Design | +| PBT-02 Round-trip | Planned | `slugToId(pathOf(id))` = id for every shoot id; `jsonLdScript` output of BreadcrumbList/FAQPage/Service built from arbitrary strings (incl. `</script>`, `<`, `>`, `&`, U+2028) parses back to the same data | +| PBT-03 Invariants | Planned | Slug parsing of any string returns a known id or `undefined`, never throws; breadcrumb positions are 1..n consecutive with absolute URLs under `siteUrl`, last item the page; FAQPage has one Question per item in order with answer = flattened visible text; structured data never contains an e-mail address; `offers` present iff a visible package exists; the package variant and `?pakket=` follow `visiblePackages` only; the timeline always has the six steps in fixed order for any shoot content; nav children are known routes, one per shoot | +| PBT-04 Idempotency | N/A / candidate | None identified yet; if a nav state reducer is introduced, `close(close(s))` = `close(s)` | +| PBT-05 Oracle | N/A | No reference implementation | +| PBT-06 Stateful | Planned if applicable | If the submenu/mobile-menu state is a reducer: model-based sequences (open, close, Escape, route change, breakpoint change) with invariants (submenu never open while the mobile menu is closed). Otherwise N/A with rationale in design | +| PBT-07 Generators | Planned | Extend `src/test/arbitraries.ts` with the new shoot page content (story blocks, FAQ with `RichText`, photo lists of 0..n, optional package) | +| PBT-08 Shrinking/reproducibility | Compliant | Existing seed logging (`config/testSeed.ts`) | +| PBT-09 Framework | Compliant | fast-check already configured | +| PBT-10 Complementary testing | Planned | Example-based and registry-consistency tests alongside PBT (NFR-ST-06) | + +--- + +## Traceability +| Answer | Decision | Requirements | +|---|---|---| +| Q1 = D + FAQ of C | Design E | Page Structure, FR-ST-02..08, FR-ST-13 | +| Q2 = A | `/soorten-fotoshoots/<slug>` | FR-ST-01, FR-ST-02, SEO-ST-03 | +| Q3 = A | All five live; Loveshoot/Portret 2 photos, no price | FR-ST-01, FR-ST-05, FR-ST-07, FR-ST-12, SEO-ST-01 | +| Q4 = A | Overview unchanged + "Lees meer" links, anchors kept | FR-ST-09 | +| Q5 = X | Opleverduur 2–3 weken for all, per-shoot field | FR-ST-04, FR-ST-11, CON-ST-01 | +| Q6 = A | Deposit € 50 | FR-ST-04, FR-ST-07, CON-ST-01 | +| Q7 = A | Same steps; location and opleverduur per shoot | FR-ST-04, A-ST-02 | +| Q8 = A | Claude drafts, Andrea approves | CON-ST-02, CON-ST-03 | +| Q9 = A | 3–5 FAQ per shoot, mixed | FR-ST-06, SEO-ST-03, CON-ST-02 | +| Q10 = A | Existing photos; more later | FR-ST-05, FR-ST-11, CON-ST-05 | +| Q11 = B | Nav submenu (dropdown / expandable) | FR-ST-10, NFR-ST-01 | +| Q12 = A | Visible breadcrumb + BreadcrumbList | FR-ST-02, SEO-ST-03 | +| Clarification 1 = A | Deposit settled; remainder after the shoot | FR-ST-07, CON-ST-01 | +| Clarification 2 = B | No cancellation/rescheduling text | FR-ST-04, CON-ST-04, Out of Scope | +| Accepted readings | "Prijs op aanvraag" + 2 photos; anchors kept | FR-ST-07, FR-ST-05, FR-ST-09 | +| Security = A | Baseline enforced | NFR-ST-05 | +| PBT = A | Full enforcement | NFR-ST-06, PBT table | +| Operations = B | No Operations phase | Out of Scope | diff --git a/web/lighthouserc.cjs b/web/lighthouserc.cjs index 6703071..bba7cfb 100644 --- a/web/lighthouserc.cjs +++ b/web/lighthouserc.cjs @@ -11,6 +11,11 @@ const indexedPaths = [ '/over-mij', '/portfolio', '/soorten-fotoshoots', + '/soorten-fotoshoots/newborn', + '/soorten-fotoshoots/zwangerschap', + '/soorten-fotoshoots/gezin', + '/soorten-fotoshoots/loveshoot', + '/soorten-fotoshoots/portret', '/contact', ]; const noindexPaths = ['/privacyverklaring']; @@ -25,9 +30,18 @@ const homeMobilePerformance = 0.8; // Lighthouse simulates a slow connection: the photo is only requested once // the main bundle and the page's own chunk have run, so these pages land on // LCP ~3.2s and a score of ~0.895, right on 0.9 (measured on /over-mij and -// /soorten-fotoshoots; fewer image bytes do not move it). Back to 0.9 with -// prerendering or a smaller main bundle (NFR-P-01). -const photoPagePaths = ['/over-mij', '/soorten-fotoshoots']; +// /soorten-fotoshoots; fewer image bytes do not move it). The shoot pages +// (largest paint: the first story photo) are in the same position. Back to +// 0.9 with prerendering or a smaller main bundle (NFR-P-01). +const photoPagePaths = [ + '/over-mij', + '/soorten-fotoshoots', + '/soorten-fotoshoots/newborn', + '/soorten-fotoshoots/zwangerschap', + '/soorten-fotoshoots/gezin', + '/soorten-fotoshoots/loveshoot', + '/soorten-fotoshoots/portret', +]; const photoPageMobilePerformance = 0.85; // Performance hangt af van de snelheid van de meetmachine: Lighthouse vertraagt diff --git a/web/lighthouserc.d.cts b/web/lighthouserc.d.cts index 226b62b..bd537e4 100644 --- a/web/lighthouserc.d.cts +++ b/web/lighthouserc.d.cts @@ -4,6 +4,7 @@ declare const config: { indexedPaths: string[]; noindexPaths: string[]; notFoundPath: string; + photoPagePaths: string[]; ci: unknown; }; diff --git a/web/public/og-gezin.jpg b/web/public/og-gezin.jpg new file mode 100644 index 0000000..c30148c Binary files /dev/null and b/web/public/og-gezin.jpg differ diff --git a/web/public/og-loveshoot.jpg b/web/public/og-loveshoot.jpg new file mode 100644 index 0000000..c738555 Binary files /dev/null and b/web/public/og-loveshoot.jpg differ diff --git a/web/public/og-newborn.jpg b/web/public/og-newborn.jpg new file mode 100644 index 0000000..4852b30 Binary files /dev/null and b/web/public/og-newborn.jpg differ diff --git a/web/public/og-portret.jpg b/web/public/og-portret.jpg new file mode 100644 index 0000000..3f64f9b Binary files /dev/null and b/web/public/og-portret.jpg differ diff --git a/web/public/og-zwangerschap.jpg b/web/public/og-zwangerschap.jpg new file mode 100644 index 0000000..30bb0c9 Binary files /dev/null and b/web/public/og-zwangerschap.jpg differ diff --git a/web/src/app.test.tsx b/web/src/app.test.tsx index a5a2780..b2d5f7a 100644 --- a/web/src/app.test.tsx +++ b/web/src/app.test.tsx @@ -1,20 +1,16 @@ -import { ChakraProvider } from '@chakra-ui/react'; -import { - createMemoryHistory, - createRouter, - RouterProvider, -} from '@tanstack/react-router'; -import { render, screen, waitFor, within } from '@testing-library/react'; +import { screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import lighthouseConfig from '../lighthouserc.cjs'; -import ErrorPage from './components/StatusPage/ErrorPage'; +import shootTypes from './content/shootTypes'; +import { shootPagePath } from './lib/shootPages'; +import { siteUrl } from './seo'; +import { sitemapXml } from './sitemap'; import { FakeIntersectionObserver } from './test/fakeIntersectionObserver'; -import { routeTree } from './routeTree.gen'; import sitePages from './sitePages'; import { axeResults } from './test/axe'; +import { expectShell, renderApp } from './test/renderApp'; import type { SocialLink } from './content/types'; -import system from './theme'; // Laat PageIntro op verzoek crashen, om de foutpagina binnen de shell te testen const crash = vi.hoisted(() => ({ enabled: false })); @@ -65,28 +61,6 @@ afterEach(() => { delete Element.prototype.scrollTo; }); -// De echte app: route tree, router-opties en thema zoals in main.tsx -async function renderApp(path: string) { - const router = createRouter({ - routeTree, - history: createMemoryHistory({ initialEntries: [path] }), - scrollRestoration: true, - defaultErrorComponent: ErrorPage, - }); - await router.load(); - const result = render( - <ChakraProvider value={system}> - <RouterProvider router={router} /> - </ChakraProvider>, - ); - return { ...result, router }; -} - -const expectShell = () => { - expect(screen.getByRole('banner')).toBeInTheDocument(); - expect(screen.getByRole('contentinfo')).toBeInTheDocument(); -}; - describe('app', () => { it.each(Object.keys(sitePages))( '%s rendert binnen de shell met een h1 en zonder axe-fouten', @@ -520,7 +494,136 @@ describe('homepage ?pakket=', () => { ); }); +// The JSON-LD objects in the page, in document order +const structuredData = () => + [...document.querySelectorAll('script[type="application/ld+json"]')].map( + (script) => JSON.parse(script.textContent!), + ); + +const shootIds = shootTypes.map((shoot) => shoot.id); + +describe('shoot pages', () => { + it.each(shootIds)('%s has its own head and structured data', async (id) => { + const path = shootPagePath(id); + await renderApp(path); + await screen.findByRole('heading', { level: 1 }); + expect(document.title).toBe( + `${sitePages[path].title} | Andrea Slop Fotografie`, + ); + expect( + document.head.querySelector('meta[name="description"]'), + ).toHaveAttribute('content', sitePages[path].description); + expect( + document.head.querySelector('link[rel="canonical"]'), + ).toHaveAttribute('href', `${siteUrl}${path}`); + // Each shoot page has its own preview image from the registry + expect( + document.head.querySelector('meta[property="og:image"]'), + ).toHaveAttribute( + 'content', + `${siteUrl}${sitePages[path].ogImage!.path}`, + ); + expect(document.head.querySelector('meta[name="robots"]')).toBeNull(); + + const data = structuredData(); + expect(data.map((item) => item['@type']).sort()).toEqual([ + 'FAQPage', + 'ProfessionalService', + 'WebPage', + ]); + const page = data.find((item) => item['@type'] === 'WebPage'); + expect(page.mainEntity['@id']).toBe(`${siteUrl}${path}#service`); + expect('offers' in page.mainEntity).toBe( + ['newborn', 'zwangerschap', 'gezin'].includes(id), + ); + }); + + it('gives the overview the Service ids of the shoot pages and renders no shoot page', async () => { + await renderApp('/soorten-fotoshoots'); + await screen.findByRole('heading', { + level: 1, + name: 'Soorten fotoshoots', + }); + const page = structuredData().find( + (item) => item['@type'] === 'WebPage', + ); + expect( + page.mainEntity.itemListElement.map( + (entry: { item: { '@id': string } }) => entry.item['@id'], + ), + ).toEqual( + shootIds.map((id) => `${siteUrl}${shootPagePath(id)}#service`), + ); + // No layout route: nothing of a shoot page on the overview + expect( + document.querySelector('script[type="application/ld+json"]'), + ).not.toBeNull(); + expect( + structuredData().some((item) => item['@type'] === 'FAQPage'), + ).toBe(false); + }); + + it.each(['/soorten-fotoshoots/onzin', '/soorten-fotoshoots/newborn/extra'])( + 'shows the 404 within the shell for %s', + async (path) => { + await renderApp(path); + expect( + await screen.findByRole('heading', { + level: 1, + name: 'Pagina niet gevonden', + }), + ).toBeInTheDocument(); + expectShell(); + }, + ); + + // The router matches paths case-insensitively (default), so this is not + // a 404; the canonical URL stays the lowercase one + it('serves /soorten-fotoshoots/Newborn as the newborn page with the lowercase canonical', async () => { + await renderApp('/soorten-fotoshoots/Newborn'); + await screen.findByRole('heading', { level: 1 }); + expect( + document.head.querySelector('link[rel="canonical"]'), + ).toHaveAttribute('href', `${siteUrl}/soorten-fotoshoots/newborn`); + }); +}); + describe('pagina-register', () => { + // Finite sets, so example-based: every shoot page is registered + // everywhere, and nothing else lives under /soorten-fotoshoots/ + it('has every shoot page in the router, registry, sitemap and Lighthouse lists', async () => { + const { router } = await renderApp('/'); + const sitemap = sitemapXml( + Object.entries(sitePages).map(([path, page]) => ({ + path, + indexed: page.indexed, + })) as Parameters<typeof sitemapXml>[0], + siteUrl, + ); + const prefix = '/soorten-fotoshoots/'; + const expected = shootIds.map(shootPagePath).sort(); + const underPrefix = (paths: string[]) => + paths.filter((path) => path.startsWith(prefix)).sort(); + + for (const path of expected) { + expect(router.routesByPath).toHaveProperty([path]); + expect(sitePages[path as keyof typeof sitePages].indexed).toBe( + true, + ); + expect(sitemap).toContain(`<loc>${siteUrl}${path}</loc>`); + expect(lighthouseConfig.indexedPaths).toContain(path); + expect(lighthouseConfig.photoPagePaths).toContain(path); + } + expect(underPrefix(Object.keys(router.routesByPath))).toEqual(expected); + expect(underPrefix(Object.keys(sitePages))).toEqual(expected); + expect(underPrefix(lighthouseConfig.indexedPaths)).toEqual(expected); + expect(underPrefix(lighthouseConfig.photoPagePaths)).toEqual(expected); + const sitemapPaths = [...sitemap.matchAll(/<loc>([^<]*)<\/loc>/g)].map( + (match) => match[1].replace(siteUrl, ''), + ); + expect(underPrefix(sitemapPaths)).toEqual(expected); + }); + it('bevat precies de routes van de route tree', async () => { const { router } = await renderApp('/'); const routePaths = Object.keys(router.routesByPath).sort(); diff --git a/web/src/components/Breadcrumb/Breadcrumb.test.tsx b/web/src/components/Breadcrumb/Breadcrumb.test.tsx new file mode 100644 index 0000000..a678237 --- /dev/null +++ b/web/src/components/Breadcrumb/Breadcrumb.test.tsx @@ -0,0 +1,97 @@ +import { screen, within } from '@testing-library/react'; +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { cleanup } from '@testing-library/react'; +import type { BreadcrumbItem } from '@/lib/shootPageView'; +import { axeResults } from '@/test/axe'; +import { knownRoutePath } from '@/test/arbitraries'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import Breadcrumb from './Breadcrumb'; + +const three: BreadcrumbItem[] = [ + { label: 'Home', to: '/' }, + { label: 'Soorten fotoshoots', to: '/soorten-fotoshoots' }, + { label: 'Newborn', to: '/soorten-fotoshoots/newborn' }, +]; + +describe('Breadcrumb', () => { + it('shows links for all but the last item, which is the current page', async () => { + const { container } = await renderWithProviders( + <Breadcrumb label="Kruimelpad" items={three} data-testid="crumb" />, + { path: '/soorten-fotoshoots/newborn' }, + ); + const nav = screen.getByRole('navigation', { name: 'Kruimelpad' }); + expect(nav).toBe(screen.getByTestId('crumb')); + expect(within(nav).getAllByRole('link')).toHaveLength(2); + expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute( + 'href', + '/', + ); + expect( + screen.getByRole('link', { name: 'Soorten fotoshoots' }), + ).toHaveAttribute('href', '/soorten-fotoshoots'); + const current = screen.getByText('Newborn'); + expect(current.tagName).toBe('SPAN'); + expect(current).toHaveAttribute('aria-current', 'page'); + expect(nav.querySelectorAll('[aria-current]')).toHaveLength(1); + expect(nav.querySelectorAll('li[aria-hidden="true"]')).toHaveLength(2); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('shows only the current page for one item', async () => { + await renderWithProviders( + <Breadcrumb label="Kruimelpad" items={three.slice(2)} />, + ); + expect(screen.queryByRole('link')).toBeNull(); + expect(screen.getByText('Newborn')).toHaveAttribute( + 'aria-current', + 'page', + ); + expect( + document.querySelectorAll('li[aria-hidden="true"]'), + ).toHaveLength(0); + }); + + it('renders nothing without items', async () => { + const { container } = await renderWithProviders( + <Breadcrumb label="Kruimelpad" items={[]} />, + ); + expect(screen.queryByRole('navigation')).toBeNull(); + expect(container.querySelector('ol')).toBeNull(); + }); + + it('marks only the last item as current, and the links are not current on their own page (invariant)', async () => { + const items = fc.uniqueArray( + fc.record({ + label: fc + .string({ minLength: 1, maxLength: 12 }) + .filter((text) => text.trim() !== ''), + to: knownRoutePath, + }), + { selector: (item) => item.to, minLength: 1, maxLength: 5 }, + ); + const samples = fc.sample(items, { numRuns: 8 }); + for (const sample of samples) { + const { container } = await renderWithProviders( + <Breadcrumb label="Kruimelpad" items={sample} />, + { path: sample[sample.length - 1].to }, + ); + const entries = [...container.querySelectorAll('ol > li')].filter( + (li) => li.getAttribute('aria-hidden') !== 'true', + ); + expect(entries).toHaveLength(sample.length); + entries.forEach((li, index) => { + const last = index === sample.length - 1; + expect(li.querySelectorAll('a')).toHaveLength(last ? 0 : 1); + expect( + li.querySelectorAll('[aria-current="page"]').length, + ).toBe(last ? 1 : 0); + expect(li.textContent).toBe(sample[index].label); + }); + expect( + container.querySelectorAll('li[aria-hidden="true"]'), + ).toHaveLength(sample.length - 1); + cleanup(); + } + }); +}); diff --git a/web/src/components/Breadcrumb/Breadcrumb.tsx b/web/src/components/Breadcrumb/Breadcrumb.tsx new file mode 100644 index 0000000..5f4e2a5 --- /dev/null +++ b/web/src/components/Breadcrumb/Breadcrumb.tsx @@ -0,0 +1,80 @@ +import { Fragment } from 'react'; +import { Box, Flex, Text } from '@chakra-ui/react'; +import RouterLink from '@/components/RouterLink'; +import type { BreadcrumbItem } from '@/lib/shootPageView'; + +type BreadcrumbProps = { + // The name of the navigation landmark, e.g. "Kruimelpad" + label: string; + // The last item is the page itself + items: readonly BreadcrumbItem[]; + 'data-testid'?: string; +}; + +// The path to the current page (BR-SP-01..04): links for every item but the +// last, which is plain text marked as the current page. The links match +// exactly, so only the page itself can ever be "current". +export default function Breadcrumb({ + label, + items, + 'data-testid': testId, +}: BreadcrumbProps) { + if (items.length === 0) return null; + + return ( + <Box as="nav" aria-label={label} data-testid={testId}> + <Flex + as="ol" + wrap="wrap" + justify="center" + align="center" + gap={2} + fontSize="0.875rem" + color="ink.soft" + listStyle="none" + m={0} + p={0} + > + {items.map((item, index) => { + const last = index === items.length - 1; + // The list is static, so the index is a stable key + return ( + <Fragment key={index}> + <Box as="li"> + {last ? ( + <Text + as="span" + aria-current="page" + color="ink" + minH="2.75rem" + display="inline-flex" + alignItems="center" + > + {item.label} + </Text> + ) : ( + <RouterLink + to={item.to} + activeOptions={{ exact: true }} + color="accent.deep" + textDecoration="underline" + minH="2.75rem" + display="inline-flex" + alignItems="center" + > + {item.label} + </RouterLink> + )} + </Box> + {!last && ( + <Box as="li" aria-hidden="true"> + / + </Box> + )} + </Fragment> + ); + })} + </Flex> + </Box> + ); +} diff --git a/web/src/components/CallToAction/CallToAction.test.tsx b/web/src/components/CallToAction/CallToAction.test.tsx index d3d6263..0c31ca6 100644 --- a/web/src/components/CallToAction/CallToAction.test.tsx +++ b/web/src/components/CallToAction/CallToAction.test.tsx @@ -3,6 +3,7 @@ import { describe, expect, it } from 'vitest'; import LinkButton from '@/components/LinkButton'; import RichParagraph from '@/components/RichParagraph/RichParagraph'; import { axeResults } from '@/test/axe'; +import { cssRulesFor } from '@/test/cssRules'; import { renderWithProviders } from '@/test/renderWithProviders'; import CallToAction from './CallToAction'; @@ -66,4 +67,28 @@ describe('CallToAction', () => { ); expect(screen.queryByRole('paragraph')).toBeNull(); }); + + it('takes the alt tone by default and the given tone otherwise', async () => { + const { unmount } = await renderWithProviders( + <CallToAction title="Vragen?" titleId="q" data-testid="cta"> + <LinkButton to="/">Contact</LinkButton> + </CallToAction>, + ); + const rules = (testId: string) => + cssRulesFor(screen.getByTestId(testId)).join(); + expect(rules('cta')).toContain('var(--slp-colors-paper-alt)'); + unmount(); + + await renderWithProviders( + <CallToAction + title="Vragen?" + titleId="q" + tone="paper" + data-testid="cta" + > + <LinkButton to="/">Contact</LinkButton> + </CallToAction>, + ); + expect(rules('cta')).not.toContain('var(--slp-colors-paper-alt)'); + }); }); diff --git a/web/src/components/CallToAction/CallToAction.tsx b/web/src/components/CallToAction/CallToAction.tsx index 7469b47..6302a45 100644 --- a/web/src/components/CallToAction/CallToAction.tsx +++ b/web/src/components/CallToAction/CallToAction.tsx @@ -9,6 +9,8 @@ type CallToActionProps = { titleId: string; // Plain text, or a paragraph with links in it (e.g. RichParagraph) lead?: ReactNode; + // Band colour; alt unless the page needs it to differ from the band above + tone?: 'paper' | 'alt'; 'data-testid'?: string; // The action below the text, e.g. a LinkButton children: ReactNode; @@ -16,18 +18,19 @@ type CallToActionProps = { // Closing block of a page (design .section--alt.section--tight with a narrow, // centred column): a heading, a short lead and one action. The page chooses -// the action and any link in the lead. +// the action, any link in the lead and, when needed, the band colour. export default function CallToAction({ title, titleId, lead, + tone = 'alt', 'data-testid': testId, children, }: CallToActionProps) { return ( <PageSection labelledBy={titleId} - tone="alt" + tone={tone} width="narrow" spacing="tight" data-testid={testId} diff --git a/web/src/components/FaqList/FaqList.test.tsx b/web/src/components/FaqList/FaqList.test.tsx new file mode 100644 index 0000000..e978680 --- /dev/null +++ b/web/src/components/FaqList/FaqList.test.tsx @@ -0,0 +1,101 @@ +import { cleanup, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import type { FaqItem } from '@/content/types'; +import { faqItems } from '@/test/arbitraries'; +import { axeResults } from '@/test/axe'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import FaqList from './FaqList'; + +const items: FaqItem[] = [ + { + id: 'een', + question: 'Wanneer boek ik?', + answer: [ + 'Zo vroeg mogelijk, zie ', + { text: 'de prijzen', to: '/', hash: 'prijzen' }, + '.', + ], + }, + { id: 'twee', question: 'Waar?', answer: ['Bij jullie thuis.'] }, + { id: 'drie', question: 'Hoe lang?', answer: ['Twee uur.'] }, +]; + +describe('FaqList', () => { + it('shows every question closed, with the answers in the page', async () => { + const { container } = await renderWithProviders( + <FaqList items={items} data-testid="faq" />, + ); + const details = container.querySelectorAll('details'); + expect(details).toHaveLength(3); + for (const item of details) expect(item).not.toHaveAttribute('open'); + for (const item of items) { + expect(screen.getByText(item.question).tagName).toBe('SUMMARY'); + } + expect( + screen.getByText('Bij jullie thuis.', { exact: false }), + ).toBeInTheDocument(); + expect( + screen.getByRole('link', { name: 'de prijzen' }), + ).toHaveAttribute('href', '/#prijzen'); + // The questions are labels, not headings + expect(screen.queryByRole('heading')).toBeNull(); + expect( + container.querySelectorAll('summary svg[aria-hidden="true"]'), + ).toHaveLength(3); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + // jsdom does not turn Enter or Space on a summary into the click that + // opens the details (browsers do, for any summary that is the first + // child of its details), and user-event only does so for buttons and + // links. So the test checks what the page controls: the summary is + // focusable and is the first child of its details, and activating it + // (the click a browser sends) toggles the item. + it('has a focusable summary as first child, which toggles the item when activated', async () => { + const user = userEvent.setup(); + const { container } = await renderWithProviders( + <FaqList items={items} />, + ); + const first = container.querySelector('details')!; + const summary = first.firstElementChild as HTMLElement; + expect(summary.tagName).toBe('SUMMARY'); + expect(summary).toHaveTextContent('Wanneer boek ik?'); + expect(summary.getAttribute('tabindex')).not.toBe('-1'); + await user.tab(); + expect(summary).toHaveFocus(); + await user.click(summary); + expect(first).toHaveAttribute('open'); + await user.click(summary); + expect(first).not.toHaveAttribute('open'); + }); + + it('renders nothing without questions', async () => { + const { container } = await renderWithProviders(<FaqList items={[]} />); + expect(container.querySelector('details')).toBeNull(); + }); + + it('has one closed details per item, with every answer in the page (invariant)', async () => { + for (const sample of fc.sample(faqItems, { numRuns: 6 })) { + const { container } = await renderWithProviders( + <FaqList items={sample} />, + ); + const details = container.querySelectorAll('details'); + expect(details).toHaveLength(sample.length); + details.forEach((item, index) => { + expect(item.hasAttribute('open')).toBe(false); + expect(item.querySelector('summary')!.textContent).toBe( + sample[index].question, + ); + const answer = sample[index].answer + .map((piece) => + typeof piece === 'string' ? piece : piece.text, + ) + .join(''); + expect(item.querySelector('p')!.textContent).toBe(answer); + }); + cleanup(); + } + }); +}); diff --git a/web/src/components/FaqList/FaqList.tsx b/web/src/components/FaqList/FaqList.tsx new file mode 100644 index 0000000..128705b --- /dev/null +++ b/web/src/components/FaqList/FaqList.tsx @@ -0,0 +1,82 @@ +import { Box, chakra } from '@chakra-ui/react'; +import RichParagraph from '@/components/RichParagraph/RichParagraph'; +import type { FaqItem } from '@/content/types'; + +type FaqListProps = { + items: readonly FaqItem[]; + 'data-testid'?: string; +}; + +// The plus that turns into a minus while its item is open: the vertical +// stroke is hidden by CSS under details[open]. Decoration only. +function ToggleIcon() { + return ( + <chakra.svg + aria-hidden="true" + focusable="false" + viewBox="0 0 24 24" + w="1.25rem" + h="1.25rem" + flexShrink={0} + fill="none" + stroke="currentColor" + strokeWidth="1.5" + strokeLinecap="round" + > + <path d="M5 12h14" /> + <path data-faq-vertical d="M12 5v14" /> + </chakra.svg> + ); +} + +// The questions of a shoot page (FR-ST-06, BR-SP-50..52): one native +// details element per question, so it works without JavaScript and by +// keyboard. All items start closed; the answers are in the page either way. +// The browser keeps track of what is open, there is no state here. +export default function FaqList({ + items, + 'data-testid': testId, +}: FaqListProps) { + if (items.length === 0) return null; + + return ( + <Box borderTopWidth="1px" borderColor="sand" data-testid={testId}> + {items.map((item) => ( + <Box + as="details" + key={item.id} + borderBottomWidth="1px" + borderColor="sand" + css={{ + '&[open] [data-faq-vertical]': { display: 'none' }, + }} + > + <Box + as="summary" + display="flex" + alignItems="center" + justifyContent="space-between" + gap={4} + minH="2.75rem" + py={5} + fontFamily="heading" + fontSize="1.25rem" + color="ink" + cursor="pointer" + listStyle="none" + css={{ + '&::-webkit-details-marker': { display: 'none' }, + }} + _focusVisible={{ outlineOffset: '2px' }} + > + {item.question} + <ToggleIcon /> + </Box> + <Box mb={6} maxW="680px" color="ink.soft"> + <RichParagraph paragraph={item.answer} /> + </Box> + </Box> + ))} + </Box> + ); +} diff --git a/web/src/components/Footer/Footer.test.tsx b/web/src/components/Footer/Footer.test.tsx index c44cb88..3220347 100644 --- a/web/src/components/Footer/Footer.test.tsx +++ b/web/src/components/Footer/Footer.test.tsx @@ -77,6 +77,44 @@ describe('Footer', () => { expect(links[1]).not.toHaveAttribute('aria-current'); }); + it('markeert op een shootpagina geen footerlink (exact)', async () => { + await renderFooter(siteContent, '/soorten-fotoshoots/newborn'); + const nav = screen.getByRole('navigation', { name: 'Footermenu' }); + for (const link of within(nav).getAllByRole('link')) { + expect(link).not.toHaveAttribute('aria-current'); + } + }); + + it.each(['/soorten-fotoshoots', '/soorten-fotoshoots/'])( + 'markeert Soorten fotoshoots op %s', + async (path) => { + await renderFooter(siteContent, path); + const nav = screen.getByRole('navigation', { name: 'Footermenu' }); + expect( + within(nav).getByRole('link', { name: 'Soorten fotoshoots' }), + ).toHaveAttribute('aria-current', 'page'); + expect( + within(nav).getByRole('link', { name: 'Portfolio' }), + ).not.toHaveAttribute('aria-current'); + }, + ); + + it('markeert Portfolio ook met een query in de URL', async () => { + await renderFooter(siteContent, '/portfolio?shoot=newborn'); + const nav = screen.getByRole('navigation', { name: 'Footermenu' }); + expect( + within(nav).getByRole('link', { name: 'Portfolio' }), + ).toHaveAttribute('aria-current', 'page'); + }); + + it('blijft zonder axe-fouten op een shootpagina', async () => { + const { container } = await renderFooter( + siteContent, + '/soorten-fotoshoots/newborn', + ); + expect(await axeResults(container)).toHaveNoViolations(); + }); + it('laat lege kolommen weg', async () => { await renderFooter({ ...siteContent, diff --git a/web/src/components/Footer/Footer.tsx b/web/src/components/Footer/Footer.tsx index c70c4dc..41eed28 100644 --- a/web/src/components/Footer/Footer.tsx +++ b/web/src/components/Footer/Footer.tsx @@ -138,6 +138,12 @@ export default function Footer({ content }: FooterProps) { <FooterLink asChild> <RouterLink to={item.to} + // Exact, also with a query: on a shoot page the + // overview link is not the current page + activeOptions={{ + exact: true, + includeSearch: false, + }} data-testid={`footer-nav-${item.to.slice(1)}`} > {item.label} diff --git a/web/src/components/MediaText/MediaText.test.tsx b/web/src/components/MediaText/MediaText.test.tsx index edbf2c3..3237ebc 100644 --- a/web/src/components/MediaText/MediaText.test.tsx +++ b/web/src/components/MediaText/MediaText.test.tsx @@ -167,4 +167,23 @@ describe('MediaText', () => { ); expect(await axeResults(container)).toHaveNoViolations(); }); + + it('keeps a medium photo at most 30rem wide and lays out like small', async () => { + await renderWithProviders( + <MediaText image={image} aspectRatio="4 / 5" mediaSize="medium"> + <h2>Newborn</h2> + </MediaText>, + ); + expect(gridRules()).toMatch( + /grid-template-columns: minmax\(0, ?30rem\) minmax\(0, ?1fr\)/, + ); + expect(cssRulesFor(photoColumnElement()).join()).toContain( + 'max-width: 30rem', + ); + const textRules = cssRulesFor( + screen.getByRole('heading').closest('[data-reveal]')!, + ).join(); + expect(textRules).toContain('max-width: 36rem'); + expect(textRules).toMatch(/min-width: 64rem.*margin-inline: auto/s); + }); }); diff --git a/web/src/components/MediaText/MediaText.tsx b/web/src/components/MediaText/MediaText.tsx index 51d7b0e..a9886a3 100644 --- a/web/src/components/MediaText/MediaText.tsx +++ b/web/src/components/MediaText/MediaText.tsx @@ -9,6 +9,8 @@ import type { ContentImage, FrameColor } from '@/content/types'; // alone, or the photo with a detail photo overlapping it const SMALL_MEDIA = '20rem'; const SMALL_MEDIA_WITH_DETAIL = '28rem'; +// Widest a medium photo column gets (a portrait photo on a shoot page) +const MEDIUM_MEDIA = '30rem'; // Widest the text next to a small photo gets: about 70 characters a line const SMALL_TEXT = '36rem'; @@ -23,8 +25,9 @@ type MediaTextProps = { reverse?: boolean; // half: photo and text share the width equally (design .about); // small: the photo column stays narrow (20rem, 28rem with a detail - // photo); the text, at most 36rem, is centred in the rest - mediaSize?: 'half' | 'small'; + // photo); the text, at most 36rem, is centred in the rest; + // medium: laid out like small, with a photo column up to 30rem + mediaSize?: 'half' | 'small' | 'medium'; // A smaller square photo overlapping the main one's lower right corner detailImage?: ContentImage; // Colour of the block behind the photo (FramedImage) @@ -48,8 +51,14 @@ export default function MediaText({ 'data-testid': testId, children, }: MediaTextProps) { - const small = mediaSize === 'small'; - const mediaWidth = detailImage ? SMALL_MEDIA_WITH_DETAIL : SMALL_MEDIA; + // medium shares the layout of small, with a wider photo column + const small = mediaSize !== 'half'; + const mediaWidth = + mediaSize === 'medium' + ? MEDIUM_MEDIA + : detailImage + ? SMALL_MEDIA_WITH_DETAIL + : SMALL_MEDIA; const media = `minmax(0, ${mediaWidth})`; const columns = small ? reverse diff --git a/web/src/components/NavigationBar/ChevronIcon.tsx b/web/src/components/NavigationBar/ChevronIcon.tsx new file mode 100644 index 0000000..abe7fd9 --- /dev/null +++ b/web/src/components/NavigationBar/ChevronIcon.tsx @@ -0,0 +1,28 @@ +import { chakra } from '@chakra-ui/react'; + +// A small chevron for the submenu toggles. Decorative: the button carries the +// name and aria-expanded. It turns upside down while its button has +// `data-open`; with reduced motion it jumps instead of turning (BR-NAV-42). +export default function ChevronIcon() { + return ( + <chakra.svg + viewBox="0 0 12 12" + width="12px" + height="12px" + aria-hidden="true" + focusable="false" + fill="none" + stroke="currentColor" + strokeWidth="1.5" + strokeLinecap="round" + strokeLinejoin="round" + transitionProperty="transform" + transitionDuration="swap" + transitionTimingFunction="smooth" + _motionReduce={{ transition: 'none' }} + css={{ '[data-open] > &': { transform: 'rotate(180deg)' } }} + > + <path d="M2 4.25 6 8l4-3.75" /> + </chakra.svg> + ); +} diff --git a/web/src/components/NavigationBar/MobileNav.test.tsx b/web/src/components/NavigationBar/MobileNav.test.tsx new file mode 100644 index 0000000..638ad2f --- /dev/null +++ b/web/src/components/NavigationBar/MobileNav.test.tsx @@ -0,0 +1,177 @@ +import { screen, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { describe, expect, it } from 'vitest'; +import { axeResults } from '@/test/axe'; +import { cssRulesFor } from '@/test/cssRules'; +import { mockViewport } from '@/test/navViewport'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import NavigationBar from './NavigationBar'; + +const GROUP = 'Submenu Soorten fotoshoots'; + +// The mobile layout (below lg) through the whole navigation bar +async function renderMobile(path = '/contact') { + mockViewport(375); + const result = await renderWithProviders(<NavigationBar />, { path }); + return { ...result, user: userEvent.setup() }; +} + +const hamburger = () => screen.getByTestId('nav-menu-toggle'); +const menu = () => document.getElementById('mobile-nav')!; +const inMenu = () => within(menu()); +const groupToggle = () => inMenu().getByRole('button', { name: GROUP }); +const subLinks = () => ['Newborn', 'Zwangerschap', 'Gezin']; + +async function openMenu(path?: string) { + const rendered = await renderMobile(path); + await rendered.user.click(hamburger()); + return rendered; +} + +describe('MobileNav', () => { + it('opens with the hamburger and shows the main items', async () => { + await openMenu(); + expect(hamburger()).toHaveAttribute('aria-expanded', 'true'); + expect(hamburger()).toHaveAccessibleName('Menu sluiten'); + for (const name of ['Home', 'Over mij', 'Portfolio', 'Contact']) { + expect(inMenu().getByRole('link', { name })).toBeVisible(); + } + }); + + it('keeps the menu out of reach while closed', async () => { + await renderMobile(); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + expect( + within(menu()).queryByRole('link', { name: 'Contact' }), + ).toBeNull(); + }); + + it('starts with the group collapsed outside the section (BR-NAV-31)', async () => { + await openMenu('/contact'); + expect(groupToggle()).toHaveAttribute('aria-expanded', 'false'); + }); + + it.each(['/soorten-fotoshoots', '/soorten-fotoshoots/gezin'])( + 'starts with the group expanded on %s (BR-NAV-31)', + async (path) => { + await openMenu(path); + expect(groupToggle()).toHaveAttribute('aria-expanded', 'true'); + for (const name of subLinks()) { + expect(inMenu().getByRole('link', { name })).toBeVisible(); + } + }, + ); + + it('flips the group with the chevron and hides collapsed links (BR-NAV-36)', async () => { + const { user } = await openMenu('/contact'); + expect(groupToggle()).toHaveAttribute( + 'aria-controls', + 'mobile-group-soorten-fotoshoots', + ); + for (const name of subLinks()) { + expect(inMenu().queryByRole('link', { name })).toBeNull(); + } + + await user.click(groupToggle()); + expect(groupToggle()).toHaveAttribute('aria-expanded', 'true'); + for (const name of subLinks()) { + expect(inMenu().getByRole('link', { name })).toBeVisible(); + } + + await user.click(groupToggle()); + expect(groupToggle()).toHaveAttribute('aria-expanded', 'false'); + expect(inMenu().queryByRole('link', { name: 'Gezin' })).toBeNull(); + }); + + it('is not reached by Tab while the group is collapsed', async () => { + const { user } = await openMenu('/contact'); + const reached: string[] = []; + for (let i = 0; i < 10; i += 1) { + await user.tab(); + reached.push(document.activeElement?.textContent ?? ''); + } + for (const name of subLinks()) expect(reached).not.toContain(name); + }); + + it.each(['Contact', 'Soorten fotoshoots'])( + 'closes the whole menu when %s is chosen (BR-NAV-32)', + async (name) => { + const { user } = await openMenu('/contact'); + await user.click(inMenu().getByRole('link', { name })); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + expect(hamburger()).toHaveAccessibleName('Menu openen'); + }, + ); + + it('closes the whole menu when a sub-link is chosen', async () => { + const { user } = await openMenu('/soorten-fotoshoots'); + await user.click(inMenu().getByRole('link', { name: 'Gezin' })); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('closes with the hamburger itself', async () => { + const { user } = await openMenu(); + await user.click(hamburger()); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('closes with Escape and puts the focus on the hamburger (BR-NAV-33)', async () => { + const { user } = await openMenu(); + inMenu().getByRole('link', { name: 'Portfolio' }).focus(); + await user.keyboard('{Escape}'); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + expect(hamburger()).toHaveFocus(); + }); + + it('also returns the focus to the hamburger when Escape is pressed on it', async () => { + const { user } = await openMenu(); + expect(hamburger()).toHaveFocus(); + await user.keyboard('{Escape}'); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + expect(hamburger()).toHaveFocus(); + }); + + it('does not move the focus on Escape when it was elsewhere', async () => { + const { user } = await openMenu(); + (document.activeElement as HTMLElement).blur(); + await user.keyboard('{Escape}'); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + expect(hamburger()).not.toHaveFocus(); + }); + + it('scrolls inside the screen and centres short content (BR-NAV-34)', async () => { + await openMenu(); + expect(getComputedStyle(menu()).overflowY).toBe('auto'); + const rules = cssRulesFor(menu()).join('\n'); + expect(rules).toContain('overscroll-behavior'); + const centring = menu().firstElementChild!; + expect(cssRulesFor(centring).join('\n')).toContain('margin-block'); + expect(centring.querySelector('nav')).not.toBeNull(); + }); + + it('locks the page behind it while open and restores it after', async () => { + const { user } = await openMenu(); + expect(document.body.style.overflow).toBe('hidden'); + await user.click(hamburger()); + expect(document.body.style.overflow).toBe(''); + }); + + it('has no axe violations open, collapsed and expanded', async () => { + const { container, user } = await openMenu('/contact'); + expect(await axeResults(container)).toHaveNoViolations(); + await user.click(groupToggle()); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('removes the transitions with reduced motion (BR-NAV-42)', async () => { + await openMenu('/soorten-fotoshoots'); + const group = document.getElementById( + 'mobile-group-soorten-fotoshoots', + )!; + for (const element of [menu(), group]) { + const rules = cssRulesFor(element).join('\n'); + expect(rules).toContain('prefers-reduced-motion: reduce'); + expect(rules).toContain('transition: none'); + } + }); +}); diff --git a/web/src/components/NavigationBar/MobileNav.tsx b/web/src/components/NavigationBar/MobileNav.tsx index d44f84b..12336d9 100644 --- a/web/src/components/NavigationBar/MobileNav.tsx +++ b/web/src/components/NavigationBar/MobileNav.tsx @@ -1,22 +1,43 @@ -import { useEffect } from 'react'; +import { useEffect, useRef } from 'react'; import { Box, Stack } from '@chakra-ui/react'; -import { mainNav } from '@/navigation'; +import type { NavMenuEvent } from '@/lib/navMenuState'; +import { hasChildren, mainNav } from '@/navigation'; import RouterLink from '../RouterLink'; +import MobileNavGroup from './MobileNavGroup'; type MobileNavProps = { id: string; open: boolean; - onClose: () => void; + // The sub-list of the item with children is expanded + groupOpen: boolean; + pathname: string; + dispatch: (event: NavMenuEvent) => void; }; // Menu onder de navigatiebalk op mobiel, vult de rest van het scherm -export default function MobileNav({ id, open, onClose }: MobileNavProps) { - // Pagina eronder niet laten scrollen, en sluiten met Escape +export default function MobileNav({ + id, + open, + groupOpen, + pathname, + dispatch, +}: MobileNavProps) { + const box = useRef<HTMLDivElement>(null); + + // Pagina eronder niet laten scrollen, en sluiten met Escape. De focus gaat + // terug naar de hamburger als die in het menu of op de hamburger stond + // (de hamburger herken je aan aria-controls naar dit menu). useEffect(() => { if (!open) return; const onKeyDown = (event: KeyboardEvent) => { - if (event.key === 'Escape') onClose(); + if (event.key !== 'Escape') return; + const active = document.activeElement; + const focusInside = + !!active && + (!!box.current?.contains(active) || + active.getAttribute('aria-controls') === id); + dispatch({ type: 'escape', focusInside }); }; document.body.style.overflow = 'hidden'; document.addEventListener('keydown', onKeyDown); @@ -25,10 +46,11 @@ export default function MobileNav({ id, open, onClose }: MobileNavProps) { document.body.style.overflow = ''; document.removeEventListener('keydown', onKeyDown); }; - }, [open, onClose]); + }, [open, id, dispatch]); return ( <Box + ref={box} id={id} position="fixed" top="header" @@ -38,7 +60,9 @@ export default function MobileNav({ id, open, onClose }: MobileNavProps) { zIndex="mobileNav" display={{ base: 'flex', lg: 'none' }} flexDirection="column" - justifyContent="center" + // Een hoog menu scrolt binnen het scherm (BR-NAV-34) + overflowY="auto" + overscrollBehavior="contain" pt={8} pb={16} px="gutter" @@ -49,26 +73,43 @@ export default function MobileNav({ id, open, onClose }: MobileNavProps) { transitionProperty="clip-path, visibility" transitionDuration="interaction" transitionTimingFunction="smooth" + _motionReduce={{ transition: 'none' }} > - <nav aria-label="Mobiel menu"> - <Stack as="ul" gap={5} listStyleType="none"> - {mainNav.map((item) => ( - <li key={item.to}> - <RouterLink - to={item.to} - onClick={onClose} - display="block" - fontFamily="heading" - fontSize="1.9rem" - color="ink" - _currentPage={{ color: 'accent' }} - > - {item.label} - </RouterLink> - </li> - ))} - </Stack> - </nav> + {/* Automatische marges centreren een kort menu en laten een hoog + menu bovenaan beginnen (centreren zou de bovenkant afknippen) */} + <Box marginBlock="auto"> + <nav aria-label="Mobiel menu"> + <Stack as="ul" gap={5} listStyleType="none"> + {mainNav.map((item) => ( + <li key={item.to}> + {hasChildren(item) ? ( + <MobileNavGroup + item={item} + id={`mobile-group-${item.to.slice(1)}`} + open={groupOpen} + pathname={pathname} + dispatch={dispatch} + /> + ) : ( + <RouterLink + to={item.to} + onClick={() => + dispatch({ type: 'linkChosen' }) + } + display="block" + fontFamily="heading" + fontSize="1.9rem" + color="ink" + _currentPage={{ color: 'accent' }} + > + {item.label} + </RouterLink> + )} + </li> + ))} + </Stack> + </nav> + </Box> </Box> ); } diff --git a/web/src/components/NavigationBar/MobileNavGroup.tsx b/web/src/components/NavigationBar/MobileNavGroup.tsx new file mode 100644 index 0000000..e3500b9 --- /dev/null +++ b/web/src/components/NavigationBar/MobileNavGroup.tsx @@ -0,0 +1,113 @@ +import { Box, chakra, Flex } from '@chakra-ui/react'; +import { isSectionCurrent } from '@/lib/navCurrent'; +import type { NavMenuEvent } from '@/lib/navMenuState'; +import type { NavItem } from '@/navigation'; +import RouterLink from '../RouterLink'; +import ChevronIcon from './ChevronIcon'; + +type MobileNavGroupProps = { + item: NavItem & { children: readonly NavItem[] }; + // Id of the sub-list, for aria-controls + id: string; + open: boolean; + pathname: string; + dispatch: (event: NavMenuEvent) => void; +}; + +// Exact: only the page itself is current (BR-NAV-01), also with a query +const exactActive = { exact: true, includeSearch: false } as const; + +const duration = '0.3s'; +const easing = 'cubic-bezier(.22, .61, .36, 1)'; + +// The parent row of the mobile menu: the link to the overview, a chevron +// button and an expandable list of sub-pages (BR-NAV-30..36) +export default function MobileNavGroup({ + item, + id, + open, + pathname, + dispatch, +}: MobileNavGroupProps) { + return ( + <> + <Flex alignItems="center" gap={1}> + <RouterLink + to={item.to} + activeOptions={exactActive} + onClick={() => dispatch({ type: 'linkChosen' })} + display="block" + fontFamily="heading" + fontSize="1.9rem" + color={isSectionCurrent(item, pathname) ? 'accent' : 'ink'} + _currentPage={{ color: 'accent' }} + > + {item.label} + </RouterLink> + <chakra.button + type="button" + aria-expanded={open} + aria-controls={id} + aria-label={`Submenu ${item.label}`} + data-open={open || undefined} + display="flex" + alignItems="center" + justifyContent="center" + // 44px: minimaal klikdoel op touch (BR-NAV-40) + w="44px" + h="44px" + flexShrink={0} + cursor="pointer" + color="ink" + onClick={() => dispatch({ type: 'toggleGroup' })} + > + <ChevronIcon /> + </chakra.button> + </Flex> + {/* Grid rows 0fr to 1fr animate the height without measuring. On + close the visibility switches only after the collapse, so the + collapse is seen; collapsed links are neither focusable nor + read (BR-NAV-36). */} + <Box + id={id} + display="grid" + gridTemplateRows={open ? '1fr' : '0fr'} + visibility={open ? 'visible' : 'hidden'} + transition={`grid-template-rows ${duration} ${easing}, visibility 0s linear ${open ? '0s' : duration}`} + _motionReduce={{ transition: 'none' }} + > + <Box overflow="hidden" minH={0}> + <chakra.ul + listStyleType="none" + pl="1.25rem" + pt={2} + display="flex" + flexDirection="column" + > + {item.children.map((child) => ( + <li key={child.to}> + <RouterLink + to={child.to} + activeOptions={exactActive} + onClick={() => + dispatch({ type: 'linkChosen' }) + } + display="flex" + alignItems="center" + minH="44px" + fontFamily="heading" + fontSize="1.4rem" + color="ink" + // accent.deep: 1.4rem is not large text + _currentPage={{ color: 'accent.deep' }} + > + {child.label} + </RouterLink> + </li> + ))} + </chakra.ul> + </Box> + </Box> + </> + ); +} diff --git a/web/src/components/NavigationBar/NavLink.test.tsx b/web/src/components/NavigationBar/NavLink.test.tsx new file mode 100644 index 0000000..d527635 --- /dev/null +++ b/web/src/components/NavigationBar/NavLink.test.tsx @@ -0,0 +1,63 @@ +import { screen } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import { cssRulesFor } from '@/test/cssRules'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import NavLink from './NavLink'; + +describe('NavLink', () => { + it('marks the section without aria-current', async () => { + await renderWithProviders( + <NavLink + to="/soorten-fotoshoots" + activeOptions={{ exact: true, includeSearch: false }} + sectionCurrent + > + Soorten + </NavLink>, + { path: '/soorten-fotoshoots/newborn' }, + ); + const link = screen.getByRole('link', { name: 'Soorten' }); + expect(link).toHaveAttribute('data-section-current'); + expect(link).not.toHaveAttribute('aria-current'); + }); + + it('sets no section mark by default or when false', async () => { + await renderWithProviders( + <> + <NavLink to="/portfolio">Plain</NavLink> + <NavLink to="/contact" sectionCurrent={false}> + Off + </NavLink> + </>, + ); + for (const name of ['Plain', 'Off']) { + expect(screen.getByRole('link', { name })).not.toHaveAttribute( + 'data-section-current', + ); + } + }); + + it('still lets the router set aria-current on the current page', async () => { + await renderWithProviders( + <NavLink to="/portfolio">Portfolio</NavLink>, + { + path: '/portfolio', + }, + ); + expect(screen.getByRole('link')).toHaveAttribute( + 'aria-current', + 'page', + ); + }); + + it('draws the underline for the section mark too', async () => { + await renderWithProviders( + <NavLink to="/soorten-fotoshoots" sectionCurrent> + Soorten + </NavLink>, + ); + const rules = cssRulesFor(screen.getByRole('link')).join('\n'); + expect(rules).toContain('[data-section-current]::after'); + expect(rules).toContain('[aria-current="page"]::after'); + }); +}); diff --git a/web/src/components/NavigationBar/NavLink.tsx b/web/src/components/NavigationBar/NavLink.tsx index c816b6a..3cf6059 100644 --- a/web/src/components/NavigationBar/NavLink.tsx +++ b/web/src/components/NavigationBar/NavLink.tsx @@ -1,8 +1,16 @@ import RouterLink from '../RouterLink'; -type NavLinkProps = React.ComponentProps<typeof RouterLink>; +type NavLinkProps = React.ComponentProps<typeof RouterLink> & { + // The page is below this link (a shoot page below the overview): shows + // the same underline as the current page, without aria-current + sectionCurrent?: boolean; +}; -export default function NavLink({ children, ...props }: NavLinkProps) { +export default function NavLink({ + children, + sectionCurrent, + ...props +}: NavLinkProps) { return ( <RouterLink textStyle="eyebrow" @@ -11,6 +19,7 @@ export default function NavLink({ children, ...props }: NavLinkProps) { display="inline-block" py="2" mx="4" + data-section-current={sectionCurrent ? '' : undefined} css={{ '&::after': { content: '""', @@ -26,7 +35,7 @@ export default function NavLink({ children, ...props }: NavLinkProps) { transitionDuration: 'interaction', transitionTimingFunction: 'smooth', }, - '&:hover::after, &:focus-visible::after, &[aria-current="page"]::after': + '&:hover::after, &:focus-visible::after, &[aria-current="page"]::after, &[data-section-current]::after': { transform: 'scaleX(1)', transformOrigin: 'left', diff --git a/web/src/components/NavigationBar/NavSubmenu.test.tsx b/web/src/components/NavigationBar/NavSubmenu.test.tsx new file mode 100644 index 0000000..505e275 --- /dev/null +++ b/web/src/components/NavigationBar/NavSubmenu.test.tsx @@ -0,0 +1,158 @@ +import { createRef } from 'react'; +import { fireEvent, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { describe, expect, it, vi } from 'vitest'; +import { hasChildren, mainNav } from '@/navigation'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import NavSubmenu from './NavSubmenu'; + +const item = mainNav.find(hasChildren)!; +const TOGGLE = 'Submenu Soorten fotoshoots'; + +// The component alone with a fake dispatch: what it reports, not what the +// reducer does with it +async function renderSubmenu({ + open = false, + path = '/', + transparent = false, +} = {}) { + const dispatch = vi.fn(); + const toggleRef = createRef<HTMLButtonElement>(); + await renderWithProviders( + <> + <NavSubmenu + item={item} + id="submenu-soorten-fotoshoots" + open={open} + pathname={path} + transparent={transparent} + toggleRef={toggleRef} + dispatch={dispatch} + /> + <button>elsewhere</button> + </>, + { path }, + ); + return { dispatch, toggleRef, user: userEvent.setup() }; +} + +const toggle = () => screen.getByRole('button', { name: TOGGLE }); + +describe('NavSubmenu', () => { + it('renders without errors with the real main menu item', async () => { + await renderSubmenu(); + expect( + screen.getByRole('link', { name: 'Soorten fotoshoots' }), + ).toHaveAttribute('href', '/soorten-fotoshoots'); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('passes the toggle element to toggleRef', async () => { + const { toggleRef } = await renderSubmenu(); + expect(toggleRef.current).toBe(toggle()); + }); + + it('reflects open in aria-expanded and data-open', async () => { + await renderSubmenu({ open: true }); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + expect(toggle()).toHaveAttribute('data-open'); + }); + + it('reports toggleSubmenu for a click on the toggle', async () => { + const { dispatch, user } = await renderSubmenu(); + await user.click(toggle()); + expect(dispatch).toHaveBeenCalledExactlyOnceWith({ + type: 'toggleSubmenu', + }); + }); + + it('reports linkChosen for a click on a panel link', async () => { + const { dispatch, user } = await renderSubmenu({ open: true }); + await user.click(screen.getByRole('link', { name: 'Gezin' })); + expect(dispatch).toHaveBeenCalledExactlyOnceWith({ + type: 'linkChosen', + }); + }); + + it('reports escape with focusInside true when focus is in the submenu', async () => { + const { dispatch, user } = await renderSubmenu({ open: true }); + toggle().focus(); + await user.keyboard('{Escape}'); + expect(dispatch).toHaveBeenCalledExactlyOnceWith({ + type: 'escape', + focusInside: true, + }); + }); + + it('reports escape with focusInside false when focus is elsewhere', async () => { + const { dispatch, user } = await renderSubmenu({ open: true }); + screen.getByRole('button', { name: 'elsewhere' }).focus(); + await user.keyboard('{Escape}'); + expect(dispatch).toHaveBeenCalledExactlyOnceWith({ + type: 'escape', + focusInside: false, + }); + }); + + it('reports outside for a pointer down outside, not inside', async () => { + const { dispatch } = await renderSubmenu({ open: true }); + fireEvent.pointerDown(toggle()); + expect(dispatch).not.toHaveBeenCalled(); + fireEvent.pointerDown( + screen.getByRole('button', { name: 'elsewhere' }), + ); + expect(dispatch).toHaveBeenCalledExactlyOnceWith({ type: 'outside' }); + }); + + it('listens for Escape and outside only while open', async () => { + const { dispatch, user } = await renderSubmenu({ open: false }); + await user.keyboard('{Escape}'); + fireEvent.pointerDown( + screen.getByRole('button', { name: 'elsewhere' }), + ); + expect(dispatch).not.toHaveBeenCalled(); + }); + + it('reports focusLeave when focus moves to an element outside', async () => { + const { dispatch } = await renderSubmenu({ open: true }); + fireEvent.focusOut(toggle(), { + relatedTarget: screen.getByRole('button', { name: 'elsewhere' }), + }); + expect(dispatch).toHaveBeenCalledExactlyOnceWith({ + type: 'focusLeave', + }); + }); + + it('ignores focus that stays inside or has no target', async () => { + const { dispatch } = await renderSubmenu({ open: true }); + fireEvent.focusOut(toggle(), { + relatedTarget: screen.getByRole('link', { name: 'Newborn' }), + }); + fireEvent.focusOut(toggle(), { relatedTarget: null }); + expect(dispatch).not.toHaveBeenCalled(); + }); + + it('reports nothing for hover or arrow keys (BR-NAV-21, BR-NAV-27)', async () => { + const { dispatch, user } = await renderSubmenu({ open: true }); + await user.hover(toggle()); + await user.hover(screen.getByRole('link', { name: 'Gezin' })); + screen.getByRole('link', { name: 'Gezin' }).focus(); + await user.keyboard( + '{ArrowDown}{ArrowUp}{ArrowLeft}{ArrowRight}{Home}{End}', + ); + expect(dispatch).not.toHaveBeenCalled(); + }); + + it('marks the shoot page in the panel and the section on the parent', async () => { + await renderSubmenu({ open: true, path: '/soorten-fotoshoots/gezin' }); + expect(screen.getByRole('link', { name: 'Gezin' })).toHaveAttribute( + 'aria-current', + 'page', + ); + const parent = screen.getByRole('link', { + name: 'Soorten fotoshoots', + }); + expect(parent).not.toHaveAttribute('aria-current'); + expect(parent).toHaveAttribute('data-section-current'); + }); +}); diff --git a/web/src/components/NavigationBar/NavSubmenu.tsx b/web/src/components/NavigationBar/NavSubmenu.tsx new file mode 100644 index 0000000..54a596c --- /dev/null +++ b/web/src/components/NavigationBar/NavSubmenu.tsx @@ -0,0 +1,162 @@ +import { useRef, type RefObject } from 'react'; +import { Box, chakra } from '@chakra-ui/react'; +import useDismiss from '@/hooks/useDismiss'; +import { isSectionCurrent } from '@/lib/navCurrent'; +import type { NavMenuEvent } from '@/lib/navMenuState'; +import type { NavItem } from '@/navigation'; +import RouterLink from '../RouterLink'; +import ChevronIcon from './ChevronIcon'; +import NavLink from './NavLink'; + +type NavSubmenuProps = { + item: NavItem & { children: readonly NavItem[] }; + // Id of the panel, for aria-controls + id: string; + open: boolean; + pathname: string; + // The header is see-through over the home hero (white text) + transparent: boolean; + toggleRef: RefObject<HTMLButtonElement | null>; + dispatch: (event: NavMenuEvent) => void; +}; + +// Exact: only the page itself is current, not the pages below it (BR-NAV-01); +// without the query, so a filter in the URL does not switch it off +const exactActive = { exact: true, includeSearch: false } as const; + +// Desktop submenu: the parent stays a link, a separate toggle opens a panel +// with the sub-pages. Disclosure navigation: no role="menu", no arrow keys, +// no hover opening (BR-NAV-21, BR-NAV-27). +export default function NavSubmenu({ + item, + id, + open, + pathname, + transparent, + toggleRef, + dispatch, +}: NavSubmenuProps) { + const wrapper = useRef<HTMLDivElement>(null); + + useDismiss(wrapper, open, (reason) => + dispatch( + reason === 'escape' + ? { + type: 'escape', + focusInside: + wrapper.current?.contains(document.activeElement) ?? + false, + } + : { type: 'outside' }, + ), + ); + + return ( + <Box + ref={wrapper} + position="relative" + display="flex" + alignItems="center" + // Focus moving to something outside closes the panel; a blur + // without a target (window blur) is ignored (BR-NAV-25) + onBlur={(event) => { + const next = event.relatedTarget; + if ( + next instanceof Node && + !event.currentTarget.contains(next) + ) { + dispatch({ type: 'focusLeave' }); + } + }} + > + <NavLink + to={item.to} + activeOptions={exactActive} + sectionCurrent={isSectionCurrent(item, pathname)} + mr={0} + > + {item.label} + </NavLink> + <chakra.button + ref={toggleRef} + type="button" + aria-expanded={open} + aria-controls={id} + aria-label={`Submenu ${item.label}`} + data-open={open || undefined} + display="flex" + alignItems="center" + justifyContent="center" + // 44px: minimaal klikdoel op touch (BR-NAV-40) + w="44px" + h="44px" + cursor="pointer" + color="currentColor" + // Over the hero the header is dark: a white ring (BR-NAV-43) + css={ + transparent ? { '--focus-ring-color': 'white' } : undefined + } + onClick={() => dispatch({ type: 'toggleSubmenu' })} + > + <ChevronIcon /> + </chakra.button> + <Box + id={id} + position="absolute" + top="calc(100% + 0.75rem)" + left="4" + minW="15rem" + // Own colours, so the panel is solid also over the hero (BR-NAV-29) + bg="bg" + color="fg" + borderWidth="1px" + borderColor="line" + shadow="panel" + // Hidden from sight and from Tab and screen readers while + // closed, but kept in the DOM so aria-controls stays valid + visibility={open ? 'visible' : 'hidden'} + opacity={open ? 1 : 0} + transform={open ? 'none' : 'translateY(-6px)'} + pointerEvents={open ? 'auto' : 'none'} + transitionProperty="opacity, transform, visibility" + transitionDuration="swap" + transitionTimingFunction="smooth" + _motionReduce={{ transition: 'none' }} + > + <chakra.ul listStyleType="none" py="2"> + {item.children.map((child) => ( + <li key={child.to}> + <RouterLink + to={child.to} + activeOptions={exactActive} + onClick={() => dispatch({ type: 'linkChosen' })} + textStyle="eyebrow" + color="fg" + display="flex" + alignItems="center" + minH="44px" + px="5" + position="relative" + _hover={{ bg: 'paper.alt' }} + _currentPage={{ + color: 'accent.deep', + _before: { + content: '""', + position: 'absolute', + left: 0, + top: 0, + bottom: 0, + width: '2px', + bg: 'accent', + }, + }} + > + {child.label} + </RouterLink> + </li> + ))} + </chakra.ul> + </Box> + </Box> + ); +} diff --git a/web/src/components/NavigationBar/NavigationBar.test.tsx b/web/src/components/NavigationBar/NavigationBar.test.tsx index 7a3fab0..664efa8 100644 --- a/web/src/components/NavigationBar/NavigationBar.test.tsx +++ b/web/src/components/NavigationBar/NavigationBar.test.tsx @@ -1,9 +1,30 @@ -import { screen, within } from '@testing-library/react'; +import { fireEvent, screen, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import { describe, expect, it } from 'vitest'; import { axeResults } from '@/test/axe'; +import { cssRulesFor } from '@/test/cssRules'; +import { mockViewport } from '@/test/navViewport'; import { renderWithProviders } from '@/test/renderWithProviders'; import NavigationBar from './NavigationBar'; +const TOGGLE = 'Submenu Soorten fotoshoots'; +const SHOOTS = ['Newborn', 'Zwangerschap', 'Gezin', 'Loveshoot', 'Portretten']; + +// The desktop layout (lg and up) unless a width is given +async function renderBar(path = '/', width = 1280) { + mockViewport(width); + const result = await renderWithProviders(<NavigationBar />, { path }); + return { ...result, user: userEvent.setup() }; +} + +const toggle = () => screen.getByRole('button', { name: TOGGLE }); +const panel = () => document.getElementById('submenu-soorten-fotoshoots')!; +// By text: the name of a link in a closed (hidden) panel is empty +const panelLink = (text: string) => + within(panel()) + .getAllByRole('link', { hidden: true }) + .find((link) => link.textContent === text)!; + describe('NavigationBar', () => { it('heeft het logo als link naar home', async () => { await renderWithProviders(<NavigationBar />, { path: '/portfolio' }); @@ -15,12 +36,11 @@ describe('NavigationBar', () => { }); it('toont het hoofdmenu in de vaste volgorde', async () => { - const { container } = await renderWithProviders(<NavigationBar />); + const { container } = await renderBar(); const nav = screen.getByRole('navigation', { name: 'Hoofdmenu' }); + const topLevel = [...nav.querySelectorAll(':scope > ul > li')]; expect( - within(nav) - .getAllByRole('link', { hidden: true }) - .map((link) => link.textContent), + topLevel.map((li) => li.querySelector('a')?.textContent), ).toEqual([ 'Home', 'Over mij', @@ -28,6 +48,11 @@ describe('NavigationBar', () => { 'Soorten fotoshoots', 'Contact', ]); + expect( + within(panel()) + .getAllByRole('link', { hidden: true }) + .map((link) => link.textContent), + ).toEqual(SHOOTS); expect(await axeResults(container)).toHaveNoViolations(); }); @@ -38,3 +63,222 @@ describe('NavigationBar', () => { ); }); }); + +describe('NavigationBar submenu', () => { + it('heeft een knop met vaste naam, aria-expanded en een bestaand paneel', async () => { + await renderBar(); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + expect(toggle()).toHaveAttribute( + 'aria-controls', + 'submenu-soorten-fotoshoots', + ); + expect(panel()).toBeInTheDocument(); + }); + + it('opent met een klik en meldt dat in aria-expanded', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + expect(toggle()).toHaveAccessibleName(TOGGLE); + for (const name of SHOOTS) { + expect(screen.getByRole('link', { name })).toBeVisible(); + } + }); + + it.each(['{Enter}', ' '])('opent met toets %j', async (key) => { + const { user } = await renderBar(); + toggle().focus(); + await user.keyboard(key); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + }); + + it('opent niet bij hoveren (BR-NAV-21)', async () => { + const { user } = await renderBar(); + await user.hover(toggle()); + await user.hover( + screen.getByRole('link', { name: 'Soorten fotoshoots' }), + ); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('sluit met Escape en zet de focus op de knop als die binnen stond (BR-NAV-23)', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + await user.tab(); + expect(document.activeElement).toBe(panelLink('Newborn')); + await user.keyboard('{Escape}'); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + expect(document.activeElement).toBe(toggle()); + }); + + it('laat de focus staan bij Escape als die buiten het submenu stond', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + toggle().blur(); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + await user.keyboard('{Escape}'); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + expect(document.activeElement).not.toBe(toggle()); + }); + + it('sluit bij een pointer-down buiten zonder de focus te verplaatsen (BR-NAV-24)', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + fireEvent.pointerDown(document.body); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + expect(document.activeElement).toBe(toggle()); + }); + + it('blijft open bij een pointer-down binnen het paneel', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + fireEvent.pointerDown(panelLink('Gezin')); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + }); + + it('sluit als Tab de focus uit het laatste paneellink haalt (BR-NAV-25)', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + panelLink('Portretten').focus(); + await user.tab(); + expect(screen.getByRole('link', { name: 'Contact' })).toHaveFocus(); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('blijft open bij een focusout zonder doel, zoals een venster-blur', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + fireEvent.focusOut(toggle(), { relatedTarget: null }); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + }); + + it('blijft open als de focus binnen het submenu verschuift', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + await user.tab(); + await user.tab(); + expect(panelLink('Zwangerschap')).toHaveFocus(); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + }); + + it('houdt de links van een gesloten paneel buiten bereik van rolzoeker en Tab (BR-NAV-28)', async () => { + const { user } = await renderBar(); + for (const name of SHOOTS) { + expect(screen.queryByRole('link', { name })).toBeNull(); + } + const reached: string[] = []; + for (let i = 0; i < 8; i += 1) { + await user.tab(); + reached.push(document.activeElement?.textContent ?? ''); + } + for (const name of SHOOTS) expect(reached).not.toContain(name); + + await user.click(toggle()); + for (const name of SHOOTS) { + expect(screen.getByRole('link', { name })).toBeVisible(); + } + }); + + it('sluit na het kiezen van een link', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + await user.click(screen.getByRole('link', { name: 'Gezin' })); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('sluit weer met een tweede klik en laat de focus op de knop', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + await user.click(toggle()); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + expect(toggle()).toHaveFocus(); + }); + + it('gebruikt geen menu-rollen (disclosure, geen menu)', async () => { + const { user } = await renderBar(); + await user.click(toggle()); + expect( + document.querySelector('[role="menu"], [role="menuitem"]'), + ).toBeNull(); + }); + + it('heeft geen axe-fouten met het paneel dicht en open', async () => { + const { container, user } = await renderBar(); + expect(await axeResults(container)).toHaveNoViolations(); + await user.click(toggle()); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('zet de eigen kleuren op het paneel en currentColor op de knop (BR-NAV-29)', async () => { + await renderBar('/'); + const panelRules = cssRulesFor(panel()).join('\n'); + expect(panelRules).toMatch(/background(-color)?:/); + const toggleRules = cssRulesFor(toggle()).join('\n'); + expect(toggleRules.toLowerCase()).toContain('color: currentcolor'); + // Over de hero is de header doorzichtig: witte focusring (BR-NAV-43) + expect(toggleRules).toContain('--focus-ring-color: white'); + }); + + it('zet de witte focusring niet op een effen header', async () => { + await renderBar('/portfolio'); + expect(cssRulesFor(toggle()).join('\n')).not.toContain( + '--focus-ring-color: white', + ); + }); + + it('zet bij voorkeur voor minder beweging geen overgang (BR-NAV-42)', async () => { + await renderBar(); + const panelRules = cssRulesFor(panel()).join('\n'); + expect(panelRules).toContain('prefers-reduced-motion: reduce'); + expect(panelRules).toContain('transition: none'); + const chevron = toggle().querySelector('svg')!; + const chevronRules = cssRulesFor(chevron).join('\n'); + expect(chevronRules).toContain('prefers-reduced-motion: reduce'); + expect(chevronRules).toContain('transition: none'); + }); + + it('draait de pijl open via data-open (rotatie 180 graden)', async () => { + const { user } = await renderBar(); + const chevron = toggle().querySelector('svg')!; + expect(cssRulesFor(chevron).join('\n')).toContain('rotate(180deg)'); + expect(toggle()).not.toHaveAttribute('data-open'); + await user.click(toggle()); + expect(toggle()).toHaveAttribute('data-open'); + }); +}); + +describe('NavigationBar current page', () => { + it('markeert op een shootpagina het paneellink en alleen de sectie bij het hoofditem', async () => { + await renderBar('/soorten-fotoshoots/newborn'); + expect(panelLink('Newborn')).toHaveAttribute('aria-current', 'page'); + for (const name of SHOOTS.slice(1)) { + expect(panelLink(name)).not.toHaveAttribute('aria-current'); + } + const parent = screen.getByRole('link', { + name: 'Soorten fotoshoots', + }); + expect(parent).not.toHaveAttribute('aria-current'); + expect(parent).toHaveAttribute('data-section-current'); + }); + + it('markeert op het overzicht het hoofditem met beide', async () => { + await renderBar('/soorten-fotoshoots'); + const parent = screen.getByRole('link', { + name: 'Soorten fotoshoots', + }); + expect(parent).toHaveAttribute('aria-current', 'page'); + expect(parent).toHaveAttribute('data-section-current'); + for (const name of SHOOTS) { + expect(panelLink(name)).not.toHaveAttribute('aria-current'); + } + }); + + it('markeert op een andere pagina het hoofditem niet', async () => { + await renderBar('/portfolio'); + const parent = screen.getByRole('link', { + name: 'Soorten fotoshoots', + }); + expect(parent).not.toHaveAttribute('data-section-current'); + expect(parent).not.toHaveAttribute('aria-current'); + }); +}); diff --git a/web/src/components/NavigationBar/NavigationBar.tsx b/web/src/components/NavigationBar/NavigationBar.tsx index 6aa0e7b..b66778c 100644 --- a/web/src/components/NavigationBar/NavigationBar.tsx +++ b/web/src/components/NavigationBar/NavigationBar.tsx @@ -8,32 +8,65 @@ import { } from '@chakra-ui/react'; import NavLink from './NavLink'; import MobileNav from './MobileNav'; -import { mainNav } from '@/navigation'; +import NavSubmenu from './NavSubmenu'; +import { hasChildren, mainNav } from '@/navigation'; import RouterLink from '../RouterLink'; import useScrolledPast from '@/hooks/useScrolledPast'; -import { useCallback, useState } from 'react'; +import { isSectionCurrent } from '@/lib/navCurrent'; +import { initialNavMenuState, navMenuReducer } from '@/lib/navMenuState'; +import { useEffect, useReducer, useRef } from 'react'; import { useRouterState } from '@tanstack/react-router'; // Images import logoLight from '../../assets/logo-light.png'; import logoDark from '../../assets/logo-dark.png'; +// Het item met een submenu: bepaalt of het mobiele menu open start in een sectie +const parentItem = mainNav.find(hasChildren); + export default function NavigationBar() { - const [open, setOpen] = useState(false); - const closeMenu = useCallback(() => setOpen(false), []); + // Eén reducer voor het mobiele menu, de groep en het desktop-submenu, zodat + // ze elkaar niet tegenspreken + const [state, dispatch] = useReducer(navMenuReducer, initialNavMenuState); + const hamburgerRef = useRef<HTMLButtonElement>(null); + const submenuToggleRef = useRef<HTMLButtonElement>(null); // Het mobiele menu bestaat alleen onder lg; wordt het scherm breder, dan - // telt het als dicht. + // sluit de reducer het. Eerste render kan undefined geven: telt als mobiel. const isDesktop = useBreakpointValue( { base: false, lg: true }, { ssr: false }, ); - const menuOpen = open && !isDesktop; + useEffect(() => { + dispatch({ type: 'viewport', isDesktop: !!isDesktop }); + }, [isDesktop]); + + const pathname = useRouterState({ + select: (routerState) => routerState.location.pathname, + }); + const isHome = pathname === '/'; + + // Elke wissel van pagina sluit de menu's (ook de terugknop), maar niet + // bij de eerste render + const previousPathname = useRef(pathname); + useEffect(() => { + if (previousPathname.current === pathname) return; + previousPathname.current = pathname; + dispatch({ type: 'routeChanged' }); + }, [pathname]); + + // De reducer vraagt om focus (na Escape); hier wordt die verplaatst + useEffect(() => { + if (!state.focusRequest) return; + const target = + state.focusRequest === 'menuToggle' + ? hamburgerRef.current + : submenuToggleRef.current; + target?.focus(); + dispatch({ type: 'focusHandled' }); + }, [state.focusRequest]); const pastHero = useScrolledPast(() => 150); - const isHome = useRouterState({ - select: (state) => state.location.pathname === '/', - }); const isSolid = pastHero || !isHome; // Doorzichtig over de hero, maar alleen op desktop. Op mobiel staat de @@ -119,9 +152,21 @@ export default function NavigationBar() { > {mainNav.map((item) => ( <chakra.li key={item.to}> - <NavLink to={item.to}> - {item.label} - </NavLink> + {hasChildren(item) ? ( + <NavSubmenu + item={item} + id={`submenu-${item.to.slice(1)}`} + open={state.submenuOpen} + pathname={pathname} + transparent={!isSolid} + toggleRef={submenuToggleRef} + dispatch={dispatch} + /> + ) : ( + <NavLink to={item.to}> + {item.label} + </NavLink> + )} </chakra.li> ))} </HStack> @@ -134,13 +179,26 @@ export default function NavigationBar() { justifyContent="flex-end" > <chakra.button - onClick={() => setOpen(!menuOpen)} - aria-label={ - menuOpen ? 'Menu sluiten' : 'Menu openen' + ref={hamburgerRef} + onClick={() => + dispatch({ + type: 'toggleMenu', + inSection: parentItem + ? isSectionCurrent( + parentItem, + pathname, + ) + : false, + }) } - aria-expanded={menuOpen} + aria-label={ + state.menuOpen + ? 'Menu sluiten' + : 'Menu openen' + } + aria-expanded={state.menuOpen} aria-controls="mobile-nav" - data-open={menuOpen || undefined} + data-open={state.menuOpen || undefined} // Op desktop opent deze knop straks het info-menu (side area) display={{ base: 'block', lg: 'none' }} data-testid="nav-menu-toggle" @@ -189,7 +247,13 @@ export default function NavigationBar() { </Flex> </Container> </chakra.header> - <MobileNav id="mobile-nav" open={menuOpen} onClose={closeMenu} /> + <MobileNav + id="mobile-nav" + open={state.menuOpen} + groupOpen={state.groupOpen} + pathname={pathname} + dispatch={dispatch} + /> </> ); } diff --git a/web/src/components/NavigationBar/activeOptions.test.tsx b/web/src/components/NavigationBar/activeOptions.test.tsx new file mode 100644 index 0000000..818559c --- /dev/null +++ b/web/src/components/NavigationBar/activeOptions.test.tsx @@ -0,0 +1,108 @@ +import { cleanup, screen } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import { renderApp } from '@/test/renderApp'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import RouterLink from '../RouterLink'; + +// Regression probe of the router's `activeOptions` (BR-NAV-01, BR-NAV-04). +// The facts pinned here decide why every nav and footer link gets +// `{ exact: true, includeSearch: false }`: a plain `exact` ignores a trailing +// slash but not letter case, and loses `aria-current` on any query string. + +const bothVariants = [ + ['exact', { exact: true }], + ['exact + includeSearch false', { exact: true, includeSearch: false }], +] as const; + +async function currentOf( + variant: (typeof bothVariants)[number][1], + path: string, +) { + cleanup(); + await renderWithProviders( + <> + <RouterLink to="/soorten-fotoshoots" activeOptions={variant}> + parent + </RouterLink> + <RouterLink + to="/soorten-fotoshoots/newborn" + activeOptions={variant} + > + child + </RouterLink> + </>, + { path }, + ); + const isCurrent = (name: string) => + screen.getByRole('link', { name }).getAttribute('aria-current') === + 'page'; + return { parent: isCurrent('parent'), child: isCurrent('child') }; +} + +describe.each(bothVariants)('activeOptions %s', (_name, variant) => { + it('marks the exact path only', async () => { + expect(await currentOf(variant, '/soorten-fotoshoots')).toEqual({ + parent: true, + child: false, + }); + }); + + it('marks the child, not the parent, on the child path', async () => { + expect(await currentOf(variant, '/soorten-fotoshoots/newborn')).toEqual( + { parent: false, child: true }, + ); + }); + + it('ignores a trailing slash', async () => { + expect(await currentOf(variant, '/soorten-fotoshoots/')).toEqual({ + parent: true, + child: false, + }); + expect( + await currentOf(variant, '/soorten-fotoshoots/newborn/'), + ).toEqual({ parent: false, child: true }); + }); + + it('does not ignore letter case', async () => { + expect(await currentOf(variant, '/Soorten-Fotoshoots/Newborn')).toEqual( + { parent: false, child: false }, + ); + }); +}); + +describe('activeOptions and the query string', () => { + it('plain exact loses aria-current when the URL has a query', async () => { + expect( + await currentOf({ exact: true }, '/soorten-fotoshoots?x=1'), + ).toEqual({ parent: false, child: false }); + }); + + it('includeSearch false keeps aria-current with a query', async () => { + expect( + await currentOf( + { exact: true, includeSearch: false }, + '/soorten-fotoshoots?x=1', + ), + ).toEqual({ parent: true, child: false }); + }); + + it('includeSearch false keeps a non-matching page unmarked', async () => { + expect( + await currentOf( + { exact: true, includeSearch: false }, + '/portfolio?shoot=newborn', + ), + ).toEqual({ parent: false, child: false }); + }); +}); + +describe('activeOptions in the real route tree', () => { + it('renders the Newborn page on a case variant', async () => { + // The router matches case-insensitively, so the page shows; which + // links are current there is pinned in navSubmenu.test.tsx + await renderApp('/soorten-fotoshoots/Newborn'); + expect( + await screen.findByRole('heading', { level: 1 }), + ).toBeInTheDocument(); + }); +}); diff --git a/web/src/components/PackageBlock/PackageBlock.test.tsx b/web/src/components/PackageBlock/PackageBlock.test.tsx new file mode 100644 index 0000000..be86d29 --- /dev/null +++ b/web/src/components/PackageBlock/PackageBlock.test.tsx @@ -0,0 +1,95 @@ +import { screen, within } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import LinkButton from '@/components/LinkButton'; +import packages from '@/content/packages'; +import shootTypes from '@/content/shootTypes'; +import type { PricingPackage } from '@/content/types'; +import { formatPrice } from '@/lib/formatPrice'; +import { axeResults } from '@/test/axe'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import PackageBlock from './PackageBlock'; + +const newborn = shootTypes.find((shoot) => shoot.id === 'newborn')!; +const pkg: PricingPackage = packages.find( + (item) => item.id === newborn.packageId, +)!; +const onRequest = { price: 'Prijs op aanvraag', text: 'Neem contact op.' }; + +describe('PackageBlock', () => { + it('shows the price, the features, the actions and the note for a package', async () => { + const { container } = await renderWithProviders( + <PackageBlock + titleId="offer-title" + eyebrow="Het pakket" + title="Newbornshoot" + image={newborn.image} + pkg={pkg} + onRequest={onRequest} + note="Aanbetaling € 50." + data-testid="package" + > + <LinkButton variant="accent" to="/contact"> + Boek dit pakket + </LinkButton> + <a href="/contact">Eerst een vraag stellen</a> + </PackageBlock>, + ); + expect(screen.getByRole('heading', { level: 2 })).toHaveAttribute( + 'id', + 'offer-title', + ); + // The price keeps its non-breaking space + const price = screen.getByText(/185/); + expect(price.textContent).toBe(formatPrice(pkg.price)); + expect(price.textContent).toBe('€ 185'); + const list = screen.getByRole('list'); + const rows = within(list).getAllByRole('listitem'); + expect(rows.map((row) => row.textContent)).toEqual(pkg.features); + expect(screen.queryByText(onRequest.text)).toBeNull(); + expect( + screen.getByRole('link', { name: 'Boek dit pakket' }), + ).toBeInTheDocument(); + expect( + screen.getByRole('link', { name: 'Eerst een vraag stellen' }), + ).toBeInTheDocument(); + expect(screen.getByText('Aanbetaling € 50.')).toBeInTheDocument(); + expect(screen.getByTestId('package')).toBeInTheDocument(); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('shows the on-request price and text, without a list, when there is no package', async () => { + const { container } = await renderWithProviders( + <PackageBlock + titleId="offer-title" + eyebrow="Het aanbod" + title="Loveshoot" + image={newborn.image} + onRequest={onRequest} + > + <LinkButton variant="accent" to="/contact"> + Vraag naar de mogelijkheden + </LinkButton> + </PackageBlock>, + ); + expect(screen.getByText('Prijs op aanvraag')).toBeInTheDocument(); + expect(screen.getByText('Neem contact op.')).toBeInTheDocument(); + expect(screen.queryByRole('list')).toBeNull(); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('leaves out the note when there is none', async () => { + await renderWithProviders( + <PackageBlock + titleId="t" + eyebrow="e" + title="Titel" + image={newborn.image} + pkg={pkg} + onRequest={onRequest} + > + <a href="/contact">Actie</a> + </PackageBlock>, + ); + expect(screen.queryByText(/Aanbetaling/)).toBeNull(); + }); +}); diff --git a/web/src/components/PackageBlock/PackageBlock.tsx b/web/src/components/PackageBlock/PackageBlock.tsx new file mode 100644 index 0000000..397af93 --- /dev/null +++ b/web/src/components/PackageBlock/PackageBlock.tsx @@ -0,0 +1,94 @@ +import type { ReactNode } from 'react'; +import { Box, Flex, Heading, Text } from '@chakra-ui/react'; +import Eyebrow from '@/components/Eyebrow/Eyebrow'; +import MediaText from '@/components/MediaText/MediaText'; +import type { ContentImage, FrameColor, PricingPackage } from '@/content/types'; +import { formatPrice } from '@/lib/formatPrice'; + +type PackageBlockProps = { + // Id of the h2, which names the section around the block + titleId: string; + eyebrow: string; + title: string; + image: ContentImage; + frameColor?: FrameColor; + // Present: the price and the features. Absent: the on-request text. + pkg?: PricingPackage; + onRequest: { price: string; text: string }; + // Small print below the actions, e.g. the deposit + note?: string; + 'data-testid'?: string; + // The actions below the text, e.g. link buttons + children: ReactNode; +}; + +// The offer of a shoot page (FR-ST-07, BR-SP-60..62): a small square photo +// next to the price and either the features of the package or the text for +// a shoot without a fixed price. The variant follows from `pkg` alone. +export default function PackageBlock({ + titleId, + eyebrow, + title, + image, + frameColor, + pkg, + onRequest, + note, + 'data-testid': testId, + children, +}: PackageBlockProps) { + return ( + <MediaText + image={image} + aspectRatio="1 / 1" + mediaSize="small" + frameColor={frameColor} + data-testid={testId} + > + <Eyebrow>{eyebrow}</Eyebrow> + <Heading as="h2" id={titleId} textStyle="sectionTitle"> + {title} + </Heading> + <Text + fontFamily="heading" + fontSize="2.25rem" + lineHeight="1.2" + color="accent.deep" + mt={4} + > + {pkg ? formatPrice(pkg.price) : onRequest.price} + </Text> + {pkg ? ( + <Box as="ul" role="list" listStyle="none" m={0} p={0} mt={5}> + {pkg.features.map((feature, index) => ( + <Box + as="li" + key={`${index}-${feature}`} + py={3} + color="ink.soft" + borderTopWidth="1px" + borderColor="sand" + borderBottomWidth={ + index === pkg.features.length - 1 ? '1px' : 0 + } + > + {feature} + </Box> + ))} + </Box> + ) : ( + <Text color="ink.soft" mt={4}> + {onRequest.text} + </Text> + )} + <Flex wrap="wrap" align="center" columnGap={7} rowGap={3} mt={7}> + {children} + </Flex> + {note && ( + <Text fontSize="0.875rem" color="ink.soft" mt={5}> + {note} + </Text> + )} + </MediaText> + ); +} diff --git a/web/src/components/PageIntro/PageIntro.test.tsx b/web/src/components/PageIntro/PageIntro.test.tsx index 7db443c..429485c 100644 --- a/web/src/components/PageIntro/PageIntro.test.tsx +++ b/web/src/components/PageIntro/PageIntro.test.tsx @@ -28,4 +28,46 @@ describe('PageIntro', () => { 'Contact', ); }); + + it('renders exactly the old markup when the new props are left out', async () => { + const { container } = await renderWithProviders( + <PageIntro eyebrow="Werk" title="Portfolio"> + Intro + </PageIntro>, + ); + const section = container.querySelector('section')!; + expect(section.hasAttribute('aria-labelledby')).toBe(false); + expect([...section.children].map((child) => child.tagName)).toEqual([ + 'P', + 'H1', + 'P', + ]); + expect(section.querySelector('h1')!.hasAttribute('id')).toBe(false); + }); + + it('names the section by the h1 and shows the breadcrumb above the label', async () => { + const { container } = await renderWithProviders( + <PageIntro + eyebrow="Newborn" + title="Newbornshoot" + titleId="intro-title" + breadcrumb={<nav aria-label="Kruimelpad">Pad</nav>} + > + Intro + </PageIntro>, + ); + expect( + screen.getByRole('region', { name: 'Newbornshoot' }), + ).toBeInTheDocument(); + expect(screen.getByRole('heading', { level: 1 })).toHaveAttribute( + 'id', + 'intro-title', + ); + const nav = screen.getByRole('navigation', { name: 'Kruimelpad' }); + expect( + nav.compareDocumentPosition(screen.getByText('Newborn')) & + Node.DOCUMENT_POSITION_FOLLOWING, + ).toBeTruthy(); + expect(await axeResults(container)).toHaveNoViolations(); + }); }); diff --git a/web/src/components/PageIntro/PageIntro.tsx b/web/src/components/PageIntro/PageIntro.tsx index c43da7c..76006a5 100644 --- a/web/src/components/PageIntro/PageIntro.tsx +++ b/web/src/components/PageIntro/PageIntro.tsx @@ -1,29 +1,38 @@ import type { ReactNode } from 'react'; -import { Container, Heading, Text } from '@chakra-ui/react'; +import { Box, Container, Heading, Text } from '@chakra-ui/react'; import Eyebrow from '@/components/Eyebrow/Eyebrow'; type PageIntroProps = { title: string; eyebrow?: string; + // Id of the h1; the section is then named by it + titleId?: string; + // E.g. a Breadcrumb, shown above the eyebrow + breadcrumb?: ReactNode; children?: ReactNode; }; // Bovenste blok van een gewone pagina (.page-head in het design): label, -// de enige h1 van de pagina en een korte intro +// de enige h1 van de pagina en een korte intro. Optioneel een kruimelpad +// erboven en een id voor de h1 (de sectie krijgt daar zijn naam van). export default function PageIntro({ title, eyebrow, + titleId, + breadcrumb, children, }: PageIntroProps) { return ( <Container as="section" + aria-labelledby={titleId} pt="pageTop" pb={{ base: 8, md: 12, lg: 16 }} textAlign="center" > + {breadcrumb && <Box mb={{ base: 6, md: 7 }}>{breadcrumb}</Box>} {eyebrow && <Eyebrow>{eyebrow}</Eyebrow>} - <Heading as="h1" textStyle="pageTitle" mb={4}> + <Heading as="h1" id={titleId} textStyle="pageTitle" mb={4}> {title} </Heading> {children && ( diff --git a/web/src/components/PhotoMosaic/PhotoMosaic.test.tsx b/web/src/components/PhotoMosaic/PhotoMosaic.test.tsx new file mode 100644 index 0000000..3515502 --- /dev/null +++ b/web/src/components/PhotoMosaic/PhotoMosaic.test.tsx @@ -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(); + } + }); +}); diff --git a/web/src/components/PhotoMosaic/PhotoMosaic.tsx b/web/src/components/PhotoMosaic/PhotoMosaic.tsx new file mode 100644 index 0000000..388fc34 --- /dev/null +++ b/web/src/components/PhotoMosaic/PhotoMosaic.tsx @@ -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> + ); +} diff --git a/web/src/components/ProcessTimeline/ProcessTimeline.test.tsx b/web/src/components/ProcessTimeline/ProcessTimeline.test.tsx new file mode 100644 index 0000000..689f793 --- /dev/null +++ b/web/src/components/ProcessTimeline/ProcessTimeline.test.tsx @@ -0,0 +1,144 @@ +import { cleanup, screen, within } from '@testing-library/react'; +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { processIcons } from '@/components/shoots/ProcessIcons/ProcessIcons'; +import shootPageShared from '@/content/shootPageShared'; +import { PROCESS_STEP_ORDER } from '@/lib/shootPageView'; +import { timelineSteps } from '@/test/arbitraries'; +import { axeResults } from '@/test/axe'; +import { cssRulesFor } from '@/test/cssRules'; +import { renderWithProviders } from '@/test/renderWithProviders'; +import ProcessTimeline from './ProcessTimeline'; + +const six = PROCESS_STEP_ORDER.map((id) => { + const Icon = processIcons[id]; + return { + id, + title: shootPageShared.process.steps[id].title, + text: shootPageShared.process.steps[id].text, + icon: <Icon />, + }; +}); + +describe('ProcessTimeline', () => { + it('lists six steps in order, each with an h3 and a text', async () => { + const { container } = await renderWithProviders( + <ProcessTimeline steps={six} data-testid="timeline" />, + ); + const list = screen.getByRole('list'); + expect(list.tagName).toBe('OL'); + const items = within(list).getAllByRole('listitem'); + expect(items).toHaveLength(6); + items.forEach((item, index) => { + expect( + within(item).getByRole('heading', { level: 3 }), + ).toHaveTextContent(six[index].title); + expect(within(item).getByText(six[index].text)).toBeInTheDocument(); + }); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('puts the text above the line for even indexes and below for odd ones', async () => { + await renderWithProviders(<ProcessTimeline steps={six} />); + const positions = screen + .getAllByRole('listitem') + .map((item) => + item + .querySelector('[data-text-position]')! + .getAttribute('data-text-position'), + ); + expect(positions).toEqual([ + 'above', + 'below', + 'above', + 'below', + 'above', + 'below', + ]); + }); + + it('fills only the last marker and hides every marker and line from assistive technology', async () => { + const { container } = await renderWithProviders( + <ProcessTimeline steps={six} data-testid="timeline" />, + ); + const markers = screen.getAllByTestId('timeline-marker'); + expect(markers.map((m) => m.getAttribute('data-filled'))).toEqual([ + 'false', + 'false', + 'false', + 'false', + 'false', + 'true', + ]); + for (const marker of markers) { + expect(marker).toHaveAttribute('aria-hidden', 'true'); + } + const lines = container.querySelectorAll('li > span'); + // One horizontal line per step, one vertical line per step but the + // last + expect(lines).toHaveLength(6 + 5); + for (const line of lines) { + expect(line).toHaveAttribute('aria-hidden', 'true'); + } + }); + + it('is one column up to lg and a grid of one column per step from lg', async () => { + await renderWithProviders(<ProcessTimeline steps={six} />); + const rules = cssRulesFor(screen.getByRole('list')).join('\n'); + expect(rules).toMatch( + /min-width: 64rem[^}]*repeat\(6, minmax\(0, 1fr\)\)/, + ); + expect(rules).toContain('max-width: 34rem'); + }); + + it('lines the markers up with subgrid rows from lg', async () => { + await renderWithProviders(<ProcessTimeline steps={six} />); + const rules = cssRulesFor(screen.getAllByRole('listitem')[0]).join(); + expect(rules).toContain('subgrid'); + }); + + it('lays out one step and works without icons, in the alt tone', async () => { + const { container } = await renderWithProviders( + <ProcessTimeline + tone="alt" + steps={[{ id: 'a', title: 'Eén', text: 'Alleen' }]} + />, + ); + expect(screen.getAllByRole('listitem')).toHaveLength(1); + expect(container.querySelectorAll('svg')).toHaveLength(0); + expect( + container.querySelector('li > span[aria-hidden]'), + ).not.toBeNull(); + }); + + it('renders nothing without steps', async () => { + const { container } = await renderWithProviders( + <ProcessTimeline steps={[]} />, + ); + expect(container.querySelector('ol')).toBeNull(); + }); + + it('keeps the order and adds no numbers for any steps (invariant)', async () => { + for (const steps of fc.sample(timelineSteps, { numRuns: 6 })) { + const { container } = await renderWithProviders( + <ProcessTimeline steps={steps} />, + ); + const items = container.querySelectorAll('ol > li'); + expect(items).toHaveLength(steps.length); + items.forEach((item, index) => { + expect(item.querySelectorAll('h3')).toHaveLength(1); + expect(item.querySelector('h3')!.textContent).toBe( + steps[index].title, + ); + // Nothing but the title and the text is visible text + expect(item.textContent).toBe( + steps[index].title + steps[index].text, + ); + for (const hidden of item.querySelectorAll('[aria-hidden]')) { + expect(hidden.textContent).toBe(''); + } + }); + cleanup(); + } + }); +}); diff --git a/web/src/components/ProcessTimeline/ProcessTimeline.tsx b/web/src/components/ProcessTimeline/ProcessTimeline.tsx new file mode 100644 index 0000000..876ecc8 --- /dev/null +++ b/web/src/components/ProcessTimeline/ProcessTimeline.tsx @@ -0,0 +1,164 @@ +import type { ReactNode } from 'react'; +import { Box, Flex, Heading, Text } from '@chakra-ui/react'; +import Reveal from '@/components/Reveal/Reveal'; + +// Height and width of a marker, and so the height of the middle row +const MARKER = '3.5rem'; + +type TimelineStep = { + id: string; + title: string; + text: string; + // A decorative icon, e.g. from ProcessIcons + icon?: ReactNode; +}; + +type ProcessTimelineProps = { + steps: readonly TimelineStep[]; + // The band colour: the markers use it to hide the line behind them + tone?: 'paper' | 'alt'; + 'data-testid'?: string; +}; + +// The steps of a process as a timeline (FR-ST-04, BR-SP-20..26): vertical +// with the text beside each marker below `lg`, horizontal from `lg` with +// the texts alternating above and below the line. One ordered list in both +// layouts, so the reading order is the order of the steps. The line, the +// markers and the icons are decoration only. +export default function ProcessTimeline({ + steps, + tone = 'paper', + 'data-testid': testId, +}: ProcessTimelineProps) { + if (steps.length === 0) return null; + const background = tone === 'alt' ? 'paper.alt' : 'paper'; + + return ( + <Reveal data-testid={testId}> + <Box + as="ol" + role="list" + listStyle="none" + m={0} + p={0} + maxW={{ base: '34rem', lg: 'none' }} + mx="auto" + display={{ lg: 'grid' }} + gridTemplateColumns={{ + lg: `repeat(${steps.length}, minmax(0, 1fr))`, + }} + gridTemplateRows={{ lg: `auto ${MARKER} auto` }} + > + {steps.map((step, index) => { + const first = index === 0; + const last = index === steps.length - 1; + const above = index % 2 === 0; + return ( + <Box + as="li" + key={step.id} + position="relative" + display="grid" + gridTemplateColumns={{ + base: `${MARKER} 1fr`, + lg: 'minmax(0, 1fr)', + }} + columnGap={{ base: 5, lg: 0 }} + pb={{ base: last ? 0 : 8, lg: 0 }} + gridRow={{ lg: '1 / 4' }} + // The rows of the list itself, so the markers line + // up whatever the text heights are. Subgrid is + // supported by every current browser; a style prop + // cannot hold a fallback for older ones. + gridTemplateRows={{ lg: 'subgrid' }} + > + {/* The line down to the next marker (vertical + layout); the next marker hides its end */} + {!last && ( + <Box + as="span" + aria-hidden="true" + display={{ base: 'block', lg: 'none' }} + position="absolute" + left={`calc(${MARKER} / 2 - 1px)`} + top={`calc(${MARKER} / 2)`} + bottom={`calc(${MARKER} / -2)`} + w="2px" + bg="sand" + /> + )} + {/* The line through the marker (horizontal + layout), from the first to the last centre */} + <Box + as="span" + aria-hidden="true" + display={{ base: 'none', lg: 'block' }} + gridRow={{ lg: 2 }} + gridColumn={{ lg: 1 }} + alignSelf="center" + h="2px" + bg="sand" + ml={first ? '50%' : 0} + mr={last ? '50%' : 0} + /> + <Flex + aria-hidden="true" + data-testid={ + testId ? `${testId}-marker` : undefined + } + data-filled={last ? 'true' : 'false'} + position="relative" + zIndex={1} + align="center" + justify="center" + w={MARKER} + h={MARKER} + borderRadius="full" + borderWidth="1.5px" + borderColor="accent.deep" + bg={last ? 'accent.deep' : background} + color={last ? 'white' : 'accent.deep'} + gridRow={{ base: 1, lg: 2 }} + gridColumn={1} + justifySelf={{ lg: 'center' }} + > + {step.icon} + </Flex> + <Box + data-text-position={above ? 'above' : 'below'} + gridColumn={{ base: 2, lg: 1 }} + gridRow={{ base: 1, lg: above ? 1 : 3 }} + alignSelf={{ + base: 'start', + lg: above ? 'end' : 'start', + }} + pt={{ base: 3, lg: above ? 0 : 6 }} + pb={{ lg: above ? 6 : 0 }} + px={{ lg: 3 }} + textAlign={{ lg: 'center' }} + > + <Heading + as="h3" + fontFamily="heading" + fontWeight="normal" + fontSize="xl" + lineHeight="1.2" + > + {step.title} + </Heading> + <Text + mt={2} + fontSize="0.9375rem" + lineHeight="1.6" + color="ink.soft" + > + {step.text} + </Text> + </Box> + </Box> + ); + })} + </Box> + </Reveal> + ); +} diff --git a/web/src/components/StatusPage/NotFound.tsx b/web/src/components/StatusPage/NotFound.tsx index dd69fd7..add323c 100644 --- a/web/src/components/StatusPage/NotFound.tsx +++ b/web/src/components/StatusPage/NotFound.tsx @@ -1,14 +1,45 @@ +import { useRouterState } from '@tanstack/react-router'; +import { isShootSectionPath } from '@/lib/isShootSectionPath'; +import LinkButton from '../LinkButton'; import StatusPage from './StatusPage'; // Pagina voor een onbekende URL, binnen de shell (FR-09). Een globale // not-found heeft geen eigen route-head; React 19 zet <title> en <meta> // daarom zelf in <head> en haalt ze weer weg bij het verlaten (BR-404-02). +// Onder /soorten-fotoshoots/ komt er een knop naar het overzicht bij +// (FR-ST-14). export default function NotFound() { + const pathname = useRouterState({ + select: (routerState) => routerState.location.pathname, + }); + return ( <> <title>Pagina niet gevonden | Andrea Slop Fotografie - + + + Terug naar Soorten fotoshoots + + + Terug naar home + + + ) : undefined + } + > Deze pagina bestaat niet (meer). Misschien is de link verouderd of zit er een typfout in het adres. diff --git a/web/src/components/StatusPage/StatusPage.test.tsx b/web/src/components/StatusPage/StatusPage.test.tsx index 5e70da2..cb2e2f9 100644 --- a/web/src/components/StatusPage/StatusPage.test.tsx +++ b/web/src/components/StatusPage/StatusPage.test.tsx @@ -29,6 +29,35 @@ describe('NotFound', () => { document.head.querySelector('meta[name="robots"]'), ).toHaveAttribute('content', 'noindex'); }); + + it('toont onder /soorten-fotoshoots/ twee knoppen in vaste volgorde', async () => { + const { container } = await renderWithProviders(, { + path: '/soorten-fotoshoots/niet-bestaande-shoot', + }); + const links = screen.getAllByRole('link'); + expect(links.map((link) => link.textContent)).toEqual([ + 'Terug naar Soorten fotoshoots', + 'Terug naar home', + ]); + expect(links[0]).toHaveAttribute('href', '/soorten-fotoshoots'); + expect(links[1]).toHaveAttribute('href', '/'); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('herkent het prefix hoofdletterongevoelig', async () => { + await renderWithProviders(, { + path: '/Soorten-Fotoshoots/x', + }); + expect(screen.getAllByRole('link')).toHaveLength(2); + expect( + screen.getByRole('link', { name: 'Terug naar Soorten fotoshoots' }), + ).toHaveAttribute('href', '/soorten-fotoshoots'); + }); + + it('houdt buiten de sectie één knop', async () => { + await renderWithProviders(, { path: '/bestaat-niet' }); + expect(screen.getAllByRole('link')).toHaveLength(1); + }); }); describe('ErrorPage', () => { diff --git a/web/src/components/StructuredData/StructuredData.test.tsx b/web/src/components/StructuredData/StructuredData.test.tsx new file mode 100644 index 0000000..91f53ce --- /dev/null +++ b/web/src/components/StructuredData/StructuredData.test.tsx @@ -0,0 +1,40 @@ +import { render } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import StructuredData from './StructuredData'; + +const scripts = (container: HTMLElement) => + container.querySelectorAll('script[type="application/ld+json"]'); + +describe('StructuredData', () => { + it('renders the data as one ld+json script that parses back to it', () => { + const data = { + '@type': 'FAQPage', + name: 'Vragen & antwoorden', + items: [1, 'twee'], + }; + const { container } = render(); + expect(scripts(container)).toHaveLength(1); + expect(JSON.parse(scripts(container)[0].textContent ?? '')).toEqual( + data, + ); + }); + + it('does not let in the data end the element', () => { + const data = { + name: '', + text: '', + }; + const { container } = render(); + const text = scripts(container)[0].textContent ?? ''; + expect(text).not.toMatch(/[<>&]/); + expect(JSON.parse(text)).toEqual(data); + // The serialised page parsed again as HTML: still one script, and + // nothing from the data became an element + const page = new DOMParser().parseFromString( + container.innerHTML, + 'text/html', + ); + expect(page.querySelectorAll('script')).toHaveLength(1); + expect(page.querySelector('img')).toBeNull(); + }); +}); diff --git a/web/src/components/StructuredData/StructuredData.tsx b/web/src/components/StructuredData/StructuredData.tsx new file mode 100644 index 0000000..b2890ee --- /dev/null +++ b/web/src/components/StructuredData/StructuredData.tsx @@ -0,0 +1,18 @@ +import { jsonLdScript } from '@/seo'; + +type StructuredDataProps = { + data: unknown; +}; + +// One object of structured data as an ld+json script in the page. This is +// the only place the shoot pages use dangerouslySetInnerHTML, and only with +// jsonLdScript's output: it escapes <, > and &, so content can never close +// the script element (SECURITY-04, SECURITY-11). +export default function StructuredData({ data }: StructuredDataProps) { + return ( + ', + eyebrow: 'b', + title: 'Twee', + paragraphs: [['y']], + }, + ]; + const { container } = await renderWithProviders( + , + ); + 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( + , + ); + expect(container.querySelector('section')).toBeNull(); + }); +}); diff --git a/web/src/components/shoots/StoryBlocks/StoryBlocks.tsx b/web/src/components/shoots/StoryBlocks/StoryBlocks.tsx new file mode 100644 index 0000000..6578d9e --- /dev/null +++ b/web/src/components/shoots/StoryBlocks/StoryBlocks.tsx @@ -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 = ( + <> + {story.eyebrow} + + {story.title} + + + {story.paragraphs.map((paragraph, number) => ( + // Static content: the order never changes + + ))} + + + ); + + return ( + + {story.image !== undefined && layout.media ? ( + + {text} + + ) : ( + + + {text} + + + )} + + ); + })} + + ); +} diff --git a/web/src/content/shootPageShared.ts b/web/src/content/shootPageShared.ts new file mode 100644 index 0000000..a9e31b8 --- /dev/null +++ b/web/src/content/shootPageShared.ts @@ -0,0 +1,123 @@ +import type { FaqItem, ShootPageShared } from './types'; + +// The general questions every shoot page may include in its own FAQ list +// (D7). The placeholders are filled in per shoot, see ShootPageShared. + +// "Wanneer krijg ik de foto's?" +// DRAFT(CON-ST-03): awaiting Andrea's approval +export const deliveryFaq: FaqItem = { + id: 'fotos-ontvangen', + question: "Wanneer krijg ik de foto's?", + answer: [ + "Reken op {opleverduur} na de shoot. In die tijd selecteer en bewerk ik de mooiste foto's.", + ], +}; + +// "Hoe leg ik de datum vast?" +// DRAFT(CON-ST-03): awaiting Andrea's approval +// OPEN(CON-ST-04): does the deposit also apply to Loveshoot and Portret, and when exactly is the remainder paid after the shoot (before delivery)? +export const bookingFaq: FaqItem = { + id: 'datum-vastleggen', + question: 'Hoe leg ik de datum vast?', + answer: [ + { text: 'Stuur een berichtje', to: '/contact' }, + ', dan kiezen we samen een moment. Met een aanbetaling van {aanbetaling} staat je datum vast. De aanbetaling wordt verrekend met het totaalbedrag; het restbedrag betaal je na de shoot.', + ], +}; + +// "Hoe snel hoor ik iets van je?" +// DRAFT(CON-ST-03): awaiting Andrea's approval +export const replyFaq: FaqItem = { + id: 'reactie', + question: 'Hoe snel hoor ik iets van je?', + answer: ['Ik reageer binnen {reactietermijn} op je berichtje.'], +}; + +// The texts that are the same on every shoot page, until the CMS API exists. +// Step titles, the deposit amount and the breadcrumb labels are fixed by the +// requirements (FR-ST-02, FR-ST-04, CON-ST-01); the other texts are drafts. +const shootPageShared: ShootPageShared = { + breadcrumb: { + label: 'Kruimelpad', + home: 'Home', + overview: 'Soorten fotoshoots', + }, + process: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + eyebrow: 'Zo werkt het', + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Van aanvraag tot online galerij', + // DRAFT(CON-ST-03): awaiting Andrea's approval + lead: 'Elke shoot volgt dezelfde zes stappen, zodat je precies weet waar je aan toe bent.', + steps: { + aanvragen: { + title: 'Aanvragen', + // DRAFT(CON-ST-03): awaiting Andrea's approval + text: 'Stuur een berichtje. Ik reageer binnen {reactietermijn}.', + }, + datum: { + title: 'Datum & locatie kiezen', + // DRAFT(CON-ST-03): awaiting Andrea's approval + text: 'We kiezen samen een moment. {locatie}', + }, + aanbetaling: { + title: 'Aanbetaling', + // DRAFT(CON-ST-03): awaiting Andrea's approval + text: 'Met een aanbetaling van {aanbetaling} staat je datum vast.', + }, + shoot: { + title: 'De shoot', + // DRAFT(CON-ST-03): awaiting Andrea's approval + text: '{duur}', + }, + bewerking: { + title: 'Bewerking', + // DRAFT(CON-ST-03): awaiting Andrea's approval + text: "Ik selecteer en bewerk de mooiste foto's. Opleverduur: {opleverduur}.", + }, + oplevering: { + title: 'Oplevering', + // DRAFT(CON-ST-03): awaiting Andrea's approval + // OPEN(CON-ST-04): is there an online gallery for Loveshoot and Portret too (confirmed only for the three packages)? + text: "Je foto's staan klaar in je persoonlijke online fotogalerij.", + }, + }, + }, + deposit: { + // Whole euros, settled against the total (CON-ST-01) + amount: 50, + // DRAFT(CON-ST-03): awaiting Andrea's approval + // OPEN(CON-ST-04): does the deposit also apply to Loveshoot and Portret, and when exactly is the remainder paid after the shoot (before delivery)? + note: 'Aanbetaling {aanbetaling}, restbedrag na de shoot.', + }, + photos: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + eyebrow: 'Impressie', + }, + faq: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + eyebrow: 'Veelgestelde vragen', + // DRAFT(CON-ST-03): awaiting Andrea's approval + lead: [ + 'Staat je vraag er niet tussen? ', + { text: 'Stuur gerust een berichtje', to: '/contact' }, + '.', + ], + }, + offer: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + bookLabel: 'Boek dit pakket', + // DRAFT(CON-ST-03): awaiting Andrea's approval + askLabel: 'Eerst een vraag stellen', + // Shown for a shoot without a visible package; no figures, the + // variant is decided by the data (FR-ST-07) + // DRAFT(CON-ST-03): awaiting Andrea's approval + onRequest: { + price: 'Prijs op aanvraag', + text: 'Stuur me een berichtje met wat je in gedachten hebt, dan vertel ik je graag meer over de mogelijkheden en de prijs.', + linkLabel: 'Vraag naar de mogelijkheden', + }, + }, +}; + +export default shootPageShared; diff --git a/web/src/content/shootPages/gezin.ts b/web/src/content/shootPages/gezin.ts new file mode 100644 index 0000000..3b6a694 --- /dev/null +++ b/web/src/content/shootPages/gezin.ts @@ -0,0 +1,147 @@ +import type { ShootPageContent } from '../types'; +import { bookingFaq, deliveryFaq } from '../shootPageShared'; + +// Images: the shoot's main photo and the family photos from the portfolio, +// with the descriptions they have there. Provisional selection per slot; +// unit 2 finalises it in its functional design. Note: the shoots/gezin* +// photos show newborn families (CON-ST-05). The detail photo is shown by +// the package block, so it is not used here. +import gezin from '../../assets/shoots/gezin.jpg'; +import f41a1579 from '../../assets/portfolio/f41a1579.jpg'; +import f41a7138 from '../../assets/portfolio/f41a7138.jpg'; + +const bigBrother = { + src: f41a1579, + alt: 'Grote broer kust zijn pasgeboren broertje of zusje op een wit bed', + width: 800, + height: 534, +}; +const parents = { + src: f41a7138, + alt: 'Jonge ouders kijken samen naar hun slapende pasgeboren baby', + width: 800, + height: 1200, +}; + +// The family page (/soorten-fotoshoots/gezin) until the CMS API exists. +// Drafted from the texts in shootTypes.ts and packages.ts; no facts beyond +// them (CON-ST-04). +const gezinPage: ShootPageContent = { + id: 'gezin', + // DRAFT(CON-ST-03): awaiting Andrea's approval + intro: { + eyebrow: 'Gezinsfotograaf in Huizen', + title: 'Gezinsshoot vol echte momenten', + text: 'Met een gezinsshoot leggen we vast hoe jullie nu samen zijn. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving, bij jullie thuis of buiten in de natuur.', + }, + stories: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'verwachten', + eyebrow: 'Wat kun je verwachten', + title: 'Spelen, knuffelen en lachen', + paragraphs: [ + [ + 'Met een gezinsshoot leggen we vast hoe jullie nu samen zijn: spelen, knuffelen en lachen. Geen stijve poses, maar echte momenten die je later met plezier terugkijkt.', + ], + ], + image: { + src: gezin, + alt: 'Vader en moeder kijken samen naar hun pasgeboren baby in de armen van de vader', + width: 848, + height: 1060, + }, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'samen', + eyebrow: 'Het hele gezin', + title: 'Iedereen hoort erbij', + paragraphs: [ + [ + 'Papa, mama, broertjes en zusjes: op een gezinsshoot hoort iedereen erbij. Ook als jullie gezin net een kleintje rijker is.', + ], + ], + image: bigBrother, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'locatie', + eyebrow: 'Thuis of buiten', + title: 'Een plek die bij jullie past', + paragraphs: [ + [ + 'We kiezen samen een plek die bij jullie past, bij jullie thuis of buiten in de natuur.', + ], + ], + image: parents, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'duur', + eyebrow: 'Hoe lang duurt het', + title: 'Rustig de tijd', + paragraphs: [ + [ + 'We nemen de tijd, zodat iedereen zich op zijn gemak voelt. Ook de kleinsten: is er even een pauze nodig, dan is daar gewoon ruimte voor.', + ], + ], + }, + ], + process: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + location: + 'En een plek die bij jullie past: bij jullie thuis of buiten in de natuur.', + // DRAFT(CON-ST-03): awaiting Andrea's approval + duration: '1 uur fotografie, zonder haast.', + // The same for every shoot (CON-ST-01) + deliveryTime: '2–3 weken', + }, + photos: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Uit eerdere gezinsshoots', + // Both photos are used by the story blocks, so the page view leaves + // the mosaic out (D14, D15) until Andrea delivers more photos; adding + // them here is then a data-only change + images: [bigBrother, parents], + }, + faq: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Vragen over de gezinsshoot', + items: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'wie', + question: 'Wie mogen er op de foto?', + answer: [ + 'Het hele gezin: papa, mama, broertjes en zusjes. Geen stijve poses, maar echte momenten met elkaar.', + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'locatie', + question: 'Fotograferen we bij ons thuis of buiten?', + answer: [ + 'Allebei kan. We kiezen samen een plek die bij jullie past, bij jullie thuis of buiten in de natuur.', + ], + }, + bookingFaq, + deliveryFaq, + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + offer: { + eyebrow: 'Pakket gezin', + title: 'Wat zit er in een gezinsshoot', + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + closing: { + title: 'Op zoek naar een gezinsfotograaf in Huizen?', + lead: [ + 'Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een plek die bij jullie past.', + ], + buttonLabel: 'Boek je gezinsshoot', + }, +}; + +export default gezinPage; diff --git a/web/src/content/shootPages/loveshoot.ts b/web/src/content/shootPages/loveshoot.ts new file mode 100644 index 0000000..a16ff5b --- /dev/null +++ b/web/src/content/shootPages/loveshoot.ts @@ -0,0 +1,140 @@ +import type { ShootPageContent } from '../types'; +import { bookingFaq, deliveryFaq } from '../shootPageShared'; + +// Images: for now only the shoot's main photo and detail photo exist, with +// the descriptions they have in shootTypes.ts (CON-ST-05) +import loveshoot from '../../assets/shoots/loveshoot.jpg'; +import loveshootDetail from '../../assets/shoots/loveshoot-detail.jpg'; + +const mainPhoto = { + src: loveshoot, + alt: 'Een stel ligt in de zon op een plaid in het gras, met de hoofden tegen elkaar', + width: 848, + height: 1060, +}; + +// The loveshoot page (/soorten-fotoshoots/loveshoot) until the CMS API +// exists. Drafted from the text in shootTypes.ts. Duration, number of +// photos, best period and locations are not known, so the texts do not +// name them (CON-ST-04). No package, so no price: the page shows "Prijs op +// aanvraag", decided by the data (FR-ST-07). +const loveshootPage: ShootPageContent = { + id: 'loveshoot', + // DRAFT(CON-ST-03): awaiting Andrea's approval + intro: { + eyebrow: 'Loveshoot in Huizen', + title: 'Loveshoot voor jullie twee', + text: 'Een loveshoot is een prachtige manier om jullie liefde vast te leggen. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving.', + }, + stories: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'verwachten', + eyebrow: 'Wat kun je verwachten', + title: 'Jullie liefde, vastgelegd', + paragraphs: [ + [ + 'Een loveshoot is een prachtige manier om jullie liefde vast te leggen. Mijn stijl is natuurlijk en ongedwongen: geen ongemakkelijke poses, maar spontane momenten van jullie samen.', + ], + ], + image: mainPhoto, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'trouwkaart', + eyebrow: 'Verloofd?', + title: 'Voor jullie trouwkaart', + paragraphs: [ + [ + "Zijn jullie verloofd? Dan kan je de foto's gebruiken voor de trouwkaart. Vertel het me gerust bij je aanvraag, dan houden we daar rekening mee.", + ], + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'locatie', + eyebrow: 'De locatie', + title: 'Samen een plek kiezen', + paragraphs: [ + [ + 'We kiezen samen een plek die bij jullie past. Vertel me gerust wat jullie mooi vinden of waar jullie graag samen komen.', + ], + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'ontspannen', + eyebrow: 'Gewoon jullie zelf', + title: 'Ontspannen voor de camera', + paragraphs: [ + [ + 'Spannend om samen voor de camera te staan? Dat hoeft niet. We nemen de tijd, zodat jullie je op je gemak voelen en ik jullie kan vastleggen zoals jullie zijn.', + ], + ], + }, + ], + process: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + location: 'En een plek die bij jullie past.', + // DRAFT(CON-ST-03): awaiting Andrea's approval + // OPEN(CON-ST-04): shoot duration for the loveshoot + duration: 'We stemmen de duur samen af.', + // The same for every shoot (CON-ST-01) + deliveryTime: '2–3 weken', + }, + photos: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Uit eerdere loveshoots', + // Only the main and the detail photo for now. Story 1 and the package + // block use them, so the page view leaves the mosaic out (D14, D15); + // they are listed so that adding photos later is a data-only change. + images: [ + mainPhoto, + { + src: loveshootDetail, + alt: 'Een man schuift een ring om de vinger van zijn partner, met paarse heide op de achtergrond', + width: 480, + height: 480, + }, + ], + }, + faq: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Vragen over de loveshoot', + items: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'trouwkaart', + question: "Kunnen we de foto's gebruiken voor onze trouwkaart?", + answer: [ + "Ja, zeker. Zijn jullie verloofd? Dan kan je de foto's van jullie loveshoot gebruiken voor de trouwkaart.", + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'ontspannen', + question: 'We staan niet graag op de foto. Is dat erg?', + answer: [ + 'Helemaal niet. We nemen de tijd, zodat jullie je op je gemak voelen. Geen ongemakkelijke poses, maar spontane momenten van jullie samen.', + ], + }, + bookingFaq, + deliveryFaq, + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + offer: { + eyebrow: 'Loveshoot boeken', + title: 'Benieuwd naar de mogelijkheden?', + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + closing: { + title: 'Op zoek naar een fotograaf voor jullie loveshoot?', + lead: [ + 'Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een plek die bij jullie past.', + ], + buttonLabel: 'Boek je loveshoot', + }, +}; + +export default loveshootPage; diff --git a/web/src/content/shootPages/newborn.ts b/web/src/content/shootPages/newborn.ts new file mode 100644 index 0000000..134a7ea --- /dev/null +++ b/web/src/content/shootPages/newborn.ts @@ -0,0 +1,195 @@ +import type { ShootPageContent } from '../types'; +import { deliveryFaq } from '../shootPageShared'; + +// Images: the shoot's main photo and newborn photos from the portfolio, with +// the descriptions they have there. Provisional selection per slot; unit 2 +// finalises it in its functional design (CON-ST-05). +import newborn from '../../assets/shoots/newborn.jpg'; +import f41a1916 from '../../assets/portfolio/f41a1916.jpg'; +import f41a1922 from '../../assets/portfolio/f41a1922.jpg'; +import f41a4650 from '../../assets/portfolio/f41a4650.jpg'; +import f41a7176 from '../../assets/portfolio/f41a7176.jpg'; +import f41a7284 from '../../assets/portfolio/f41a7284.jpg'; +import f41a8700 from '../../assets/portfolio/f41a8700.jpg'; + +const sleepingBaby = { + src: f41a8700, + alt: 'Slapende pasgeboren baby in een bruin-wit gestreept pakje', + width: 800, + height: 534, +}; + +// The newborn page (/soorten-fotoshoots/newborn) until the CMS API exists. +// Texts from design E, without its bracketed placeholders and without facts +// that are not confirmed (CON-ST-04). +const newbornPage: ShootPageContent = { + id: 'newborn', + // DRAFT(CON-ST-03): awaiting Andrea's approval + intro: { + eyebrow: 'Newbornfotograaf in Huizen', + title: 'Newbornshoot bij jou thuis', + text: "Ben je in verwachting? Boek een newbornshoot om de 'kleinste' momenten voor altijd te bewaren. Ik fotografeer bij jou thuis in Huizen, Bussum, Hilversum en omgeving, in het rustige ritme van jullie baby.", + }, + stories: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'verwachten', + eyebrow: 'Wat kun je verwachten', + title: 'De kleinste momenten, voor altijd bewaard', + paragraphs: [ + [ + 'Een newbornshoot is rustig en ontspannen. Ik fotografeer jullie baby in de eerste weken, slapend en wakker, alleen en in jullie armen. Geen haast en geen ingewikkelde opstellingen: de kleine details en de warmte van jullie eerste weken staan centraal.', + ], + ], + image: { + src: newborn, + alt: 'Een pasgeboren baby in een gestreept pakje slaapt met het hoofdje opzij', + width: 848, + height: 1060, + }, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'periode', + eyebrow: 'De beste periode', + title: 'Tot 12 weken na de geboorte', + paragraphs: [ + [ + "De ideale periode voor een newbornshoot is tot 12 weken na de geboorte van je baby. In die eerste weken slapen baby's veel en zijn ze nog heerlijk klein.", + ], + // Newborn only: the date depends on the birth (CON-ST-01) + [ + 'Boek je shoot het liefst al tijdens je zwangerschap. Dan zetten we een voorlopige datum rond je uitgerekende datum en schuiven we mee als jullie baby eerder of later komt.', + ], + ], + image: sleepingBaby, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'locatie', + eyebrow: 'Bij jou thuis', + title: 'In jullie eigen vertrouwde omgeving', + paragraphs: [ + [ + "De fotoshoot vindt bij jou thuis plaats. Je hoeft nergens heen met een baby van een paar weken oud, en jullie huis maakt de foto's persoonlijk.", + ], + [ + 'Je kunt tussendoor gewoon je baby voeden en verschonen als dat nodig is.', + ], + ], + image: { + src: f41a7176, + alt: 'Moeder drukt haar gezicht tegen het hoofdje van haar pasgeboren baby', + width: 800, + height: 1200, + }, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'duur', + eyebrow: 'Hoe lang duurt het', + title: '1 tot 2 uur, op het ritme van je baby', + paragraphs: [ + [ + 'We nemen alle tijd en volgen het ritme van jullie baby. Reken op 1 tot 2 uur fotografie, inclusief pauzes om te voeden, te troosten of even te knuffelen.', + ], + [ + 'Wil je broertjes, zusjes of jezelf ook op de foto? Dat plannen we gewoon in.', + ], + ], + image: { + src: f41a1916, + alt: 'Pasgeboren baby in een wit pakje ligt op de onderarm van een ouder en kijkt in de camera', + width: 800, + height: 1200, + }, + }, + ], + process: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + location: 'Een newbornshoot is bij jou thuis.', + // DRAFT(CON-ST-03): awaiting Andrea's approval + duration: '1-2 uur fotografie, in het tempo van jullie baby.', + // The same for every shoot (CON-ST-01) + deliveryTime: '2–3 weken', + }, + photos: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Uit eerdere newbornshoots', + // The sleeping baby is also in story 2, as in design E; the page view + // leaves it out of the mosaic (D14) + images: [ + { + src: f41a1922, + alt: 'Vader kust zijn pasgeboren baby op het hoofd', + width: 800, + height: 1200, + }, + { + src: f41a4650, + alt: 'Babyvuistje tussen een gebreide deken en een geruite doek', + width: 800, + height: 533, + }, + { + src: f41a7284, + alt: 'Blote babyvoetjes in een gestreept gebreid broekje', + width: 800, + height: 1200, + }, + sleepingBaby, + ], + }, + faq: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Vragen over de newbornshoot', + items: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'boeken', + question: 'Wanneer boek ik de newbornshoot het beste?', + answer: [ + 'Het liefst al tijdens je zwangerschap. We zetten een voorlopige datum rond je uitgerekende datum en schuiven mee als jullie baby eerder of later komt. De shoot vindt plaats binnen 12 weken na de geboorte.', + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'slapen', + question: 'Wat als mijn baby niet wil slapen?', + answer: [ + "Geen probleem. We volgen het ritme van jullie baby en nemen pauzes om te voeden, te verschonen of te troosten. Wakkere momenten leveren ook prachtige foto's op.", + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'familie', + question: 'Mogen wij en broertjes of zusjes ook op de foto?', + answer: [ + "Ja, heel graag. Foto's met papa, mama en broertjes of zusjes horen er wat mij betreft gewoon bij.", + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'voorbereiden', + question: 'Wat moet ik thuis voorbereiden?', + answer: ['Weinig. Een warme kamer met wat daglicht is fijn.'], + }, + deliveryFaq, + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + offer: { + eyebrow: 'Pakket newborn', + title: 'Wat zit er in een newbornshoot', + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + closing: { + title: 'Op zoek naar een newbornfotograaf in Huizen?', + lead: [ + 'Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een datum rond je uitgerekende datum.', + ], + buttonLabel: 'Boek je newbornshoot', + }, +}; + +export default newbornPage; diff --git a/web/src/content/shootPages/portret.ts b/web/src/content/shootPages/portret.ts new file mode 100644 index 0000000..34216e1 --- /dev/null +++ b/web/src/content/shootPages/portret.ts @@ -0,0 +1,142 @@ +import type { ShootPageContent } from '../types'; +import { bookingFaq, deliveryFaq } from '../shootPageShared'; + +// Images: for now only the shoot's main photo and detail photo exist, with +// the descriptions they have in shootTypes.ts (CON-ST-05) +import portret from '../../assets/shoots/portret.jpg'; +import portretDetail from '../../assets/shoots/portret-detail.jpg'; + +const mainPhoto = { + src: portret, + alt: 'Een vrouw met lang bruin haar in een witte blouse kijkt glimlachend omlaag, met bomen op de achtergrond', + width: 848, + height: 1060, +}; + +// The portrait page (/soorten-fotoshoots/portret) until the CMS API exists. +// Drafted from the text in shootTypes.ts. Duration, number of photos, best +// period and locations are not known, so the texts do not name them +// (CON-ST-04). No package, so no price: the page shows "Prijs op aanvraag", +// decided by the data (FR-ST-07). +const portretPage: ShootPageContent = { + id: 'portret', + // DRAFT(CON-ST-03): awaiting Andrea's approval + intro: { + eyebrow: 'Portretfotograaf in Huizen', + title: 'Portretshoot in de natuur of zakelijk', + text: 'Van portretshoots in de natuur tot zakelijke shoots voor de branding van je bedrijf. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving.', + }, + stories: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'verwachten', + eyebrow: 'Wat kun je verwachten', + title: 'Jij, zoals je bent', + paragraphs: [ + [ + "Mijn stijl is natuurlijk en ongedwongen. Geen ongemakkelijke poses, maar foto's waarop je jezelf herkent.", + ], + ], + image: mainPhoto, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'natuur-zakelijk', + eyebrow: 'Natuur of zakelijk', + title: 'Persoonlijk of voor je bedrijf', + paragraphs: [ + [ + "Van portretshoots in de natuur tot zakelijke shoots voor de branding van je bedrijf. Vertel me waarvoor je de foto's wilt gebruiken, dan stemmen we de shoot daarop af.", + ], + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + // OPEN(CON-ST-04): locations for the portrait shoot (natuur / zakelijk) + { + id: 'locatie', + eyebrow: 'De locatie', + title: 'Samen een plek kiezen', + paragraphs: [ + [ + 'We kiezen samen een plek die past bij jou of bij je bedrijf.', + ], + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'ontspannen', + eyebrow: 'Gewoon jezelf', + title: 'Op je gemak voor de camera', + paragraphs: [ + [ + 'Niet gewend om op de foto te gaan? Geen zorgen. We nemen de tijd, zodat je je op je gemak voelt.', + ], + ], + }, + ], + process: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + // OPEN(CON-ST-04): locations for the portrait shoot (natuur / zakelijk) + location: 'En een plek die bij jou past.', + // DRAFT(CON-ST-03): awaiting Andrea's approval + // OPEN(CON-ST-04): shoot duration for the portrait shoot + duration: 'We stemmen de duur samen af.', + // The same for every shoot (CON-ST-01) + deliveryTime: '2–3 weken', + }, + photos: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Uit eerdere portretshoots', + // Only the main and the detail photo for now. Story 1 and the package + // block use them, so the page view leaves the mosaic out (D14, D15); + // they are listed so that adding photos later is a data-only change. + images: [ + mainPhoto, + { + src: portretDetail, + alt: 'Een vrouw met lang blond haar in een jurk met bloemenprint houdt een takje heide vast op de heide', + width: 480, + height: 480, + }, + ], + }, + faq: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Vragen over de portretshoot', + items: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'zakelijk', + question: "Kan ik ook zakelijke foto's laten maken?", + answer: [ + 'Ja. Naast portretshoots in de natuur doe ik ook zakelijke shoots voor de branding van je bedrijf.', + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'ontspannen', + question: 'Ik sta niet graag op de foto. Is dat erg?', + answer: [ + "Helemaal niet. We nemen de tijd, zodat je je op je gemak voelt. Geen ongemakkelijke poses, maar foto's waarop je jezelf herkent.", + ], + }, + bookingFaq, + deliveryFaq, + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + offer: { + eyebrow: 'Portretshoot boeken', + title: 'Benieuwd naar de mogelijkheden?', + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + closing: { + title: 'Op zoek naar een portretfotograaf in Huizen?', + lead: [ + "Stuur gerust een berichtje voor de mogelijkheden. Vertel me waarvoor je de foto's wilt gebruiken.", + ], + buttonLabel: 'Boek je portretshoot', + }, +}; + +export default portretPage; diff --git a/web/src/content/shootPages/shootPages.test.ts b/web/src/content/shootPages/shootPages.test.ts new file mode 100644 index 0000000..c744713 --- /dev/null +++ b/web/src/content/shootPages/shootPages.test.ts @@ -0,0 +1,206 @@ +import { describe, expect, it } from 'vitest'; +import { shootPackage } from '../../lib/shootPackage'; +import { shootPageView, type ShootPageSources } from '../../lib/shootPageView'; +import packages from '../packages'; +import portfolioContent from '../portfolioContent'; +import siteContent from '../siteContent'; +import shootPageShared from '../shootPageShared'; +import shootTypes from '../shootTypes'; +import type { ContentImage, ShootPageContent, ShootTypeId } from '../types'; +import gezinPage from './gezin'; +import loveshootPage from './loveshoot'; +import newbornPage from './newborn'; +import portretPage from './portret'; +import zwangerschapPage from './zwangerschap'; + +// One entry per shoot type, so a missing page file is a type error +const pages: Record = { + newborn: newbornPage, + zwangerschap: zwangerschapPage, + gezin: gezinPage, + loveshoot: loveshootPage, + portret: portretPage, +}; +const entries = Object.entries(pages) as [ShootTypeId, ShootPageContent][]; + +// The real sources, as the routes pass them +const sources: ShootPageSources = { + shootTypes, + packages, + shared: shootPageShared, + site: siteContent, + portfolioShoots: [], +}; + +// The placeholders the page view fills in (see ShootPageShared) +const knownPlaceholders = [ + 'reactietermijn', + 'aanbetaling', + 'locatie', + 'duur', + 'opleverduur', +]; + +// Every visitor-facing string in a content object: all strings except +// image file paths +function texts(value: unknown): string[] { + if (typeof value === 'string') return [value]; + if (Array.isArray(value)) return value.flatMap(texts); + if (typeof value === 'object' && value !== null) { + return Object.entries(value).flatMap(([key, item]) => + key === 'src' ? [] : texts(item), + ); + } + return []; +} + +function images(page: ShootPageContent): ContentImage[] { + return [ + ...page.stories.flatMap((story) => + story.image === undefined ? [] : [story.image], + ), + ...page.photos.images, + ]; +} + +// The photos as they are described elsewhere on the site, by file +const knownImages = new Map( + [ + ...shootTypes.flatMap((shoot) => + shoot.detailImage === undefined + ? [shoot.image] + : [shoot.image, shoot.detailImage], + ), + ...portfolioContent.photos.map((photo) => photo.thumb), + ].map((image) => [image.src, image]), +); + +describe('shoot page content', () => { + it('has a page for every shoot type, with its own id', () => { + expect(Object.keys(pages).sort()).toEqual( + shootTypes.map((shoot) => shoot.id).sort(), + ); + for (const [id, page] of entries) { + expect(page.id).toBe(id); + } + }); + + it.each(entries)( + '%s has exactly four stories with unique ids', + (_, page) => { + expect(page.stories).toHaveLength(4); + const ids = page.stories.map((story) => story.id); + expect(new Set(ids).size).toBe(ids.length); + for (const story of page.stories) { + expect(story.paragraphs.length).toBeGreaterThan(0); + } + }, + ); + + it.each(entries)('%s has 3 to 5 FAQ items with unique ids', (_, page) => { + const ids = page.faq.items.map((item) => item.id); + expect(ids.length).toBeGreaterThanOrEqual(3); + expect(ids.length).toBeLessThanOrEqual(5); + expect(new Set(ids).size).toBe(ids.length); + }); + + it.each(entries)( + '%s describes every photo and gives it a size', + (_, page) => { + for (const image of images(page)) { + expect(image.alt.trim()).not.toBe(''); + expect(image.width).toBeGreaterThan(0); + expect(image.height).toBeGreaterThan(0); + } + }, + ); + + it.each(entries)( + '%s reuses the description and size a photo has elsewhere', + (_, page) => { + const reused = images(page).filter((image) => + knownImages.has(image.src), + ); + // At least the shoot's main photo + expect(reused.length).toBeGreaterThan(0); + for (const image of reused) { + expect(image).toEqual(knownImages.get(image.src)); + } + }, + ); + + it.each(entries)('%s has a page view', (id, page) => { + expect(shootPageView(id, page, sources)).toBeDefined(); + }); + + // D14: every photo once on the rendered page + it.each(entries)('%s shows no photo twice on the page', (id, page) => { + const view = shootPageView(id, page, sources); + expect(view).toBeDefined(); + const shown = [ + ...(view?.stories.flatMap((story) => + story.image === undefined ? [] : [story.image], + ) ?? []), + ...(view === undefined ? [] : [view.offer.image]), + ...(view?.photos?.images ?? []), + ]; + const shownSources = shown.map((image) => image.src); + expect(new Set(shownSources).size).toBe(shownSources.length); + }); + + // D6: one duration, the same as in the package + it.each(entries)( + '%s names the duration of its package, if it has one', + (_, page) => { + const shoot = shootTypes.find((item) => item.id === page.id); + expect(shoot).toBeDefined(); + const pkg = shoot && shootPackage(shoot, packages); + if (pkg === undefined) return; + const duration = pkg.features.find((feature) => + feature.endsWith('uur fotografie'), + ); + expect(duration).toBeDefined(); + expect(page.process.duration.startsWith(duration ?? '')).toBe(true); + }, + ); + + it.each(entries)('%s is delivered in 2–3 weken (CON-ST-01)', (_, page) => { + expect(page.process.deliveryTime).toBe('2–3 weken'); + }); + + describe.each([...entries, ['shared', shootPageShared] as const])( + 'the texts of %s', + (_, content) => { + const all = texts(content); + + it('contain no design placeholders in brackets', () => { + for (const text of all) { + expect(text).not.toMatch(/[[\]]/); + } + }); + + it('only use known placeholders', () => { + for (const text of all) { + for (const [, name] of text.matchAll(/\{([^}]*)\}/g)) { + expect(knownPlaceholders).toContain(name); + } + // No stray brace outside a placeholder + expect(text.replace(/\{[^{}]*\}/g, '')).not.toMatch(/[{}]/); + } + }); + + it('contain no e-mail address', () => { + for (const text of all) { + expect(text).not.toContain('@'); + } + }); + + // Clarification 2 = B: no cancellation or rescheduling terms + it('say nothing about cancelling or rescheduling', () => { + for (const text of all) { + expect(text.toLowerCase()).not.toMatch(/annuler|verzet/); + } + }); + }, + ); +}); diff --git a/web/src/content/shootPages/zwangerschap.ts b/web/src/content/shootPages/zwangerschap.ts new file mode 100644 index 0000000..cd802e8 --- /dev/null +++ b/web/src/content/shootPages/zwangerschap.ts @@ -0,0 +1,154 @@ +import type { ShootPageContent } from '../types'; +import { bookingFaq, deliveryFaq } from '../shootPageShared'; + +// Images: the shoot's main photo and the maternity photos from the +// portfolio, with the descriptions they have there. Provisional selection +// per slot; unit 2 finalises it in its functional design (CON-ST-05). The +// detail photo is shown by the package block, so it is not used here. +import zwangerschap from '../../assets/shoots/zwangerschap.jpg'; +import f41a7883 from '../../assets/portfolio/f41a7883.jpg'; +import f41a8206 from '../../assets/portfolio/f41a8206.jpg'; + +const belly = { + src: f41a8206, + alt: 'Zwangere buik in een zwarte jurk, omarmd door twee handen', + width: 800, + height: 534, +}; +const dunes = { + src: f41a7883, + alt: 'Aanstaande vader omarmt zijn zwangere partner op een zandvlakte in de avondzon', + width: 800, + height: 1200, +}; + +// The maternity page (/soorten-fotoshoots/zwangerschap) until the CMS API +// exists. Drafted from the texts in shootTypes.ts and packages.ts; no facts +// beyond them (CON-ST-04). +const zwangerschapPage: ShootPageContent = { + id: 'zwangerschap', + // DRAFT(CON-ST-03): awaiting Andrea's approval + intro: { + eyebrow: 'Zwangerschapsfotograaf in Huizen', + title: 'Je zwangerschap, voor altijd vastgelegd', + text: 'Met een zwangerschapsshoot leg je deze bijzondere periode vast voor altijd. Ik fotografeer in Huizen, Bussum, Hilversum en omgeving, op een plek die bij jullie past.', + }, + stories: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'verwachten', + eyebrow: 'Wat kun je verwachten', + title: 'Deze bijzondere periode, voor altijd bewaard', + paragraphs: [ + [ + 'Een zwangerschapsshoot is ontspannen en ongedwongen. Ik leg jullie vast zoals jullie zijn: geen ongemakkelijke poses, maar spontane momenten van jou, je buik en, als je wilt, je partner.', + ], + ], + image: { + src: zwangerschap, + alt: 'Een zwangere vrouw en haar partner kijken elkaar lachend aan op een zandvlakte, zijn hand op haar buik', + width: 848, + height: 1060, + }, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'periode', + eyebrow: 'De beste periode', + title: 'Tussen 30 en 34 weken', + paragraphs: [ + [ + 'De mooiste periode voor een zwangerschapsshoot is tussen de 30 en 34 weken. Stuur gerust op tijd een berichtje, dan plannen we de shoot samen in die weken.', + ], + ], + image: belly, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'locatie', + eyebrow: 'De locatie', + title: 'Op een plek die bij jullie past', + paragraphs: [ + [ + 'We kiezen samen een locatie uit die bij jullie past, denk aan de Soesterduinen of de heide.', + ], + ], + image: dunes, + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'duur', + eyebrow: 'Hoe lang duurt het', + title: 'Rustig de tijd', + paragraphs: [ + [ + 'We nemen de tijd, zodat jullie je op je gemak voelen. Zo ontstaan de mooiste, spontane momenten.', + ], + ], + }, + ], + process: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + location: + 'En een plek die bij jullie past, zoals de Soesterduinen of de heide.', + // DRAFT(CON-ST-03): awaiting Andrea's approval + duration: '1 uur fotografie, zonder haast.', + // The same for every shoot (CON-ST-01) + deliveryTime: '2–3 weken', + }, + photos: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Uit eerdere zwangerschapsshoots', + // Both photos are used by the story blocks, so the page view leaves + // the mosaic out (D14, D15) until Andrea delivers more photos; adding + // them here is then a data-only change + images: [dunes, belly], + }, + faq: { + // DRAFT(CON-ST-03): awaiting Andrea's approval + title: 'Vragen over de zwangerschapsshoot', + items: [ + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'periode', + question: 'Wanneer plan ik de zwangerschapsshoot?', + answer: [ + 'De mooiste periode is tussen de 30 en 34 weken. Stuur gerust al eerder een berichtje, dan zoeken we samen een moment in die weken.', + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'partner', + question: 'Mag mijn partner ook op de foto?', + answer: [ + 'Ja, heel graag. Samen op de foto of alleen jij: we doen wat bij jullie past.', + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + { + id: 'locatie', + question: 'Waar vindt de zwangerschapsshoot plaats?', + answer: [ + 'We kiezen samen een locatie uit die bij jullie past, denk aan de Soesterduinen of de heide.', + ], + }, + bookingFaq, + deliveryFaq, + ], + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + offer: { + eyebrow: 'Pakket zwangerschap', + title: 'Wat zit er in een zwangerschapsshoot', + }, + // DRAFT(CON-ST-03): awaiting Andrea's approval + closing: { + title: 'Op zoek naar een zwangerschapsfotograaf in Huizen?', + lead: [ + 'Stuur gerust een berichtje voor de mogelijkheden. Ik denk graag mee over een plek die bij jullie past.', + ], + buttonLabel: 'Boek je zwangerschapsshoot', + }, +}; + +export default zwangerschapPage; diff --git a/web/src/content/shootTypes.ts b/web/src/content/shootTypes.ts index f0b1191..74a2f0d 100644 --- a/web/src/content/shootTypes.ts +++ b/web/src/content/shootTypes.ts @@ -67,7 +67,7 @@ const shootTypes: ShootType[] = [ name: 'Gezin', shootLabel: 'Gezinsshoot', photosLabel: "gezinsfoto's", - // Draft text, still to be approved by Andrea (FR-SF-02) + // DRAFT(CON-ST-03): awaiting Andrea's approval paragraphs: [ 'Met een gezinsshoot leggen we vast hoe jullie nu samen zijn: spelen, knuffelen en lachen. Geen stijve poses, maar echte momenten die je later met plezier terugkijkt. We kiezen samen een plek die bij jullie past, bij jullie thuis of buiten in de natuur.', ], diff --git a/web/src/content/types.ts b/web/src/content/types.ts index eaa9df8..1c836f3 100644 --- a/web/src/content/types.ts +++ b/web/src/content/types.ts @@ -232,6 +232,109 @@ export interface ShootTypesPageContent { }; } +// One block of the story on a shoot page (FR-ST-03) +export interface StoryBlock { + // Stable slug, e.g. 'verwachten'; used in the heading id + id: string; + eyebrow: string; + title: string; + // One or more; RichText so a block can link inline + paragraphs: RichText[]; + // Without one the block is text only + image?: ContentImage; +} + +// One question of the FAQ on a shoot page (FR-ST-06). The answer may contain +// placeholders, see ShootPageShared. +export interface FaqItem { + // Stable slug, unique per page + id: string; + question: string; + answer: RichText; +} + +// The six fixed steps of the process timeline, in this order (FR-ST-04) +export type ProcessStepId = + | 'aanvragen' + | 'datum' + | 'aanbetaling' + | 'shoot' + | 'bewerking' + | 'oplevering'; + +// Title and text of one process step (FR-ST-04) +export interface ProcessStepContent { + title: string; + // May contain placeholders, see ShootPageShared + text: string; +} + +// The deposit that fixes the date (FR-ST-04, FR-ST-07) +export interface DepositInfo { + // Whole euros + amount: number; + // E.g. 'Aanbetaling {aanbetaling}, restbedrag na de shoot.' + note: string; +} + +// The text that is the same on every shoot page (FR-ST-11, shared part). +// Some texts contain placeholders, filled in per shoot when the page view is +// built. There are five, and they may appear in the step texts, the deposit +// note and the FAQ answers: +// {reactietermijn} siteContent.contactForm.replyTime +// {aanbetaling} the deposit amount as a price +// {locatie} ShootPageContent.process.location +// {duur} ShootPageContent.process.duration +// {opleverduur} ShootPageContent.process.deliveryTime +export interface ShootPageShared { + // E.g. 'Kruimelpad', 'Home', 'Soorten fotoshoots' + breadcrumb: { label: string; home: string; overview: string }; + process: { + // E.g. 'Zo werkt het' + eyebrow: string; + // E.g. 'Van aanvraag tot online galerij' + title: string; + lead: string; + steps: Record; + }; + deposit: DepositInfo; + // E.g. 'Impressie' + photos: { eyebrow: string }; + faq: { eyebrow: string; lead: RichText }; + offer: { + // E.g. 'Boek dit pakket' + bookLabel: string; + // E.g. 'Eerst een vraag stellen' + askLabel: string; + // Shown when the shoot has no visible package, e.g. 'Prijs op aanvraag' + onRequest: { price: string; text: string; linkLabel: string }; + }; +} + +// The content of one shoot page (FR-ST-11, per-shoot part); one file per shoot +export interface ShootPageContent { + // Must match the route that imports it (checked by a test) + id: ShootTypeId; + intro: { eyebrow: string; title: string; text: string }; + // Four per shoot (checked by a test) + stories: StoryBlock[]; + process: { + // Step 2, e.g. 'Een newbornshoot is bij jou thuis.' + location: string; + // Step 4, e.g. '1-2 uur fotografie, in het tempo van jullie baby.' + duration: string; + // Step 5 and the shared FAQ, e.g. '2–3 weken' + deliveryTime: string; + }; + // Ordered; adding a photo is a data-only change + photos: { title: string; images: ContentImage[] }; + // 3-5 items, shared ones mixed in + faq: { title: string; items: FaqItem[] }; + // E.g. 'Pakket newborn', 'Wat zit er in een newbornshoot' + offer: { eyebrow: string; title: string }; + closing: { title: string; lead: RichText; buttonLabel: string }; +} + export interface HeroSlide { id: string; src: string; diff --git a/web/src/hooks/useDismiss.test.tsx b/web/src/hooks/useDismiss.test.tsx new file mode 100644 index 0000000..c07b870 --- /dev/null +++ b/web/src/hooks/useDismiss.test.tsx @@ -0,0 +1,114 @@ +import { fireEvent, render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { useRef } from 'react'; +import { describe, expect, it, vi } from 'vitest'; +import useDismiss, { type DismissReason } from './useDismiss'; + +function Harness({ + active, + onDismiss, +}: { + active: boolean; + onDismiss: (reason: DismissReason) => void; +}) { + const ref = useRef(null); + useDismiss(ref, active, onDismiss); + return ( + <> +
+ +
+ + + ); +} + +describe('useDismiss', () => { + it('reports Escape while active', async () => { + const onDismiss = vi.fn(); + render(); + await userEvent.keyboard('{Escape}'); + expect(onDismiss).toHaveBeenCalledExactlyOnceWith('escape'); + }); + + it('ignores other keys', async () => { + const onDismiss = vi.fn(); + render(); + await userEvent.keyboard('a{Enter}{Tab}'); + expect(onDismiss).not.toHaveBeenCalled(); + }); + + it('reports a pointer down outside, not inside', async () => { + const onDismiss = vi.fn(); + render(); + await userEvent.click(screen.getByRole('button', { name: 'inside' })); + expect(onDismiss).not.toHaveBeenCalled(); + await userEvent.click(screen.getByRole('button', { name: 'outside' })); + expect(onDismiss).toHaveBeenCalledExactlyOnceWith('outside'); + }); + + it('reports nothing while inactive', async () => { + const onDismiss = vi.fn(); + render(); + await userEvent.keyboard('{Escape}'); + await userEvent.click(screen.getByRole('button', { name: 'outside' })); + expect(onDismiss).not.toHaveBeenCalled(); + }); + + it('starts and stops listening when active changes', async () => { + const onDismiss = vi.fn(); + const { rerender } = render( + , + ); + rerender(); + await userEvent.keyboard('{Escape}'); + expect(onDismiss).toHaveBeenCalledTimes(1); + rerender(); + await userEvent.keyboard('{Escape}'); + expect(onDismiss).toHaveBeenCalledTimes(1); + }); + + it('removes its listeners on unmount', async () => { + const onDismiss = vi.fn(); + const { unmount } = render(); + const remove = vi.spyOn(document, 'removeEventListener'); + unmount(); + expect(remove.mock.calls.map(([type]) => type).sort()).toEqual([ + 'keydown', + 'pointerdown', + ]); + await userEvent.keyboard('{Escape}'); + fireEvent.pointerDown(document.body); + expect(onDismiss).not.toHaveBeenCalled(); + }); + + it('calls the latest callback once without re-subscribing', async () => { + const first = vi.fn(); + const second = vi.fn(); + const { rerender } = render(); + const add = vi.spyOn(document, 'addEventListener'); + rerender(); + expect(add).not.toHaveBeenCalled(); + await userEvent.keyboard('{Escape}'); + expect(first).not.toHaveBeenCalled(); + expect(second).toHaveBeenCalledTimes(1); + }); + + it('ignores a pointer down whose target is not a Node', () => { + const onDismiss = vi.fn(); + render(); + fireEvent.pointerDown(window); + expect(onDismiss).not.toHaveBeenCalled(); + }); + + it('ignores a pointer down when the ref is empty', () => { + const onDismiss = vi.fn(); + function Detached() { + useDismiss({ current: null }, true, onDismiss); + return null; + } + render(); + fireEvent.pointerDown(document.body); + expect(onDismiss).not.toHaveBeenCalled(); + }); +}); diff --git a/web/src/hooks/useDismiss.ts b/web/src/hooks/useDismiss.ts new file mode 100644 index 0000000..816895a --- /dev/null +++ b/web/src/hooks/useDismiss.ts @@ -0,0 +1,39 @@ +import { useEffect, useRef, type RefObject } from 'react'; + +export type DismissReason = 'escape' | 'outside'; + +// Reports Escape and a pointer down outside `ref` while `active` is true. +// It only listens: what a dismissal means is up to the caller (FR-ST-10). +// The listeners exist only while active and are removed on deactivation and +// unmount. A missing element or a target that is no Node is ignored. +export default function useDismiss( + ref: RefObject, + active: boolean, + onDismiss: (reason: DismissReason) => void, +) { + // The latest callback, so a new function identity does not re-subscribe + const callback = useRef(onDismiss); + useEffect(() => { + callback.current = onDismiss; + }, [onDismiss]); + + useEffect(() => { + if (!active) return; + + const onKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') callback.current('escape'); + }; + const onPointerDown = (event: PointerEvent) => { + const element = ref.current; + if (!element || !(event.target instanceof Node)) return; + if (!element.contains(event.target)) callback.current('outside'); + }; + + document.addEventListener('keydown', onKeyDown); + document.addEventListener('pointerdown', onPointerDown); + return () => { + document.removeEventListener('keydown', onKeyDown); + document.removeEventListener('pointerdown', onPointerDown); + }; + }, [active, ref]); +} diff --git a/web/src/lib/fillPlaceholders.test.ts b/web/src/lib/fillPlaceholders.test.ts new file mode 100644 index 0000000..9f3f48d --- /dev/null +++ b/web/src/lib/fillPlaceholders.test.ts @@ -0,0 +1,187 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { + knownPlaceholders, + placeholderName, + plainText, + richText, + textWithPlaceholders, +} from '../test/arbitraries'; +import { fillPlaceholders, fillRichText } from './fillPlaceholders'; + +const values = { + reactietermijn: '1-2 werkdagen', + aanbetaling: '€ 50', + locatie: 'Een newbornshoot is bij jou thuis.', + duur: '1-2 uur fotografie', + opleverduur: '2–3 weken', +}; + +// A value for every known placeholder; values never contain braces, as in +// the content +const allValues = fc + .tuple(...knownPlaceholders.map(() => plainText)) + .map((texts) => + Object.fromEntries( + knownPlaceholders.map((name, index) => [name, texts[index]]), + ), + ); + +// Values for some names, known or not +const someValues = fc.dictionary(placeholderName, plainText, { maxKeys: 6 }); + +// Text in which no {name} appears, stray braces included +const withoutPlaceholder = fc + .string() + .filter((text) => !/\{[^{}]*\}/.test(text)); + +const hasKnownPlaceholder = (text: string) => + knownPlaceholders.some((name) => text.includes(`{${name}}`)); + +describe('fillPlaceholders', () => { + it('fills in each placeholder', () => { + expect( + fillPlaceholders('Ik reageer binnen {reactietermijn}.', values), + ).toBe('Ik reageer binnen 1-2 werkdagen.'); + expect(fillPlaceholders('Aanbetaling {aanbetaling}.', values)).toBe( + 'Aanbetaling € 50.', + ); + expect(fillPlaceholders('{locatie}', values)).toBe(values.locatie); + expect(fillPlaceholders('{duur}', values)).toBe(values.duur); + expect(fillPlaceholders('Binnen {opleverduur}.', values)).toBe( + 'Binnen 2–3 weken.', + ); + }); + + it('fills in a repeated placeholder every time', () => { + expect(fillPlaceholders('{duur} en nog eens {duur}', values)).toBe( + '1-2 uur fotografie en nog eens 1-2 uur fotografie', + ); + }); + + it('keeps unknown placeholders, stray braces and inherited names', () => { + expect(fillPlaceholders('{onbekend}', values)).toBe('{onbekend}'); + expect(fillPlaceholders('{Duur} { duur}', values)).toBe( + '{Duur} { duur}', + ); + expect(fillPlaceholders('{ en }', values)).toBe('{ en }'); + expect(fillPlaceholders('}{', values)).toBe('}{'); + expect(fillPlaceholders('{}', values)).toBe('{}'); + expect(fillPlaceholders('{constructor} {toString}', values)).toBe( + '{constructor} {toString}', + ); + expect(fillPlaceholders('{{duur}}', values)).toBe( + '{1-2 uur fotografie}', + ); + }); + + it('inserts a value literally', () => { + expect(fillPlaceholders('{duur}', { duur: '$& $1 $$' })).toBe( + '$& $1 $$', + ); + }); + + it('returns text without placeholders as it is (invariant)', () => { + fc.assert( + fc.property( + withoutPlaceholder, + fc.dictionary(fc.string(), fc.string()), + (text, given) => { + expect(fillPlaceholders(text, given)).toBe(text); + }, + ), + ); + }); + + it('changes nothing when filled in a second time (idempotency)', () => { + fc.assert( + fc.property(textWithPlaceholders, someValues, (text, given) => { + const once = fillPlaceholders(text, given); + expect(fillPlaceholders(once, given)).toBe(once); + }), + ); + }); + + it('leaves no known placeholder behind (invariant)', () => { + fc.assert( + fc.property(textWithPlaceholders, allValues, (text, given) => { + expect(hasKnownPlaceholder(fillPlaceholders(text, given))).toBe( + false, + ); + }), + ); + }); +}); + +describe('fillRichText', () => { + it('fills in text pieces and link texts, and keeps the link target', () => { + expect( + fillRichText( + [ + 'Binnen {opleverduur}. ', + { + text: 'Vraag het binnen {reactietermijn}', + to: '/contact', + }, + { + text: '{duur}', + to: '/soorten-fotoshoots', + hash: 'newborn', + }, + ], + values, + ), + ).toEqual([ + 'Binnen 2–3 weken. ', + { text: 'Vraag het binnen 1-2 werkdagen', to: '/contact' }, + { + text: '1-2 uur fotografie', + to: '/soorten-fotoshoots', + hash: 'newborn', + }, + ]); + }); + + it('fills every piece in its place and keeps links as links with their target (invariant)', () => { + fc.assert( + fc.property(richText, someValues, (text, given) => { + const filled = fillRichText(text, given); + expect(filled).toHaveLength(text.length); + filled.forEach((piece, index) => { + const before = text[index]; + if (typeof before === 'string') { + expect(piece).toBe(fillPlaceholders(before, given)); + } else { + expect(piece).toEqual({ + ...before, + text: fillPlaceholders(before.text, given), + }); + } + }); + }), + ); + }); + + it('changes nothing when filled in a second time (idempotency)', () => { + fc.assert( + fc.property(richText, someValues, (text, given) => { + const once = fillRichText(text, given); + expect(fillRichText(once, given)).toEqual(once); + }), + ); + }); + + it('leaves no known placeholder behind (invariant)', () => { + fc.assert( + fc.property(richText, allValues, (text, given) => { + fillRichText(text, given).forEach((piece) => { + expect( + hasKnownPlaceholder( + typeof piece === 'string' ? piece : piece.text, + ), + ).toBe(false); + }); + }), + ); + }); +}); diff --git a/web/src/lib/fillPlaceholders.ts b/web/src/lib/fillPlaceholders.ts new file mode 100644 index 0000000..236669d --- /dev/null +++ b/web/src/lib/fillPlaceholders.ts @@ -0,0 +1,31 @@ +import type { RichText } from '../content/types.ts'; + +// A placeholder: a name between braces, with no brace inside +const PLACEHOLDER = /\{([^{}]*)\}/g; + +// Fills in every {name} whose name is one of the values, so a figure that +// is data (reply time, deposit, duration, ...) is written in one place only +// (D8, NFR-ST-04). Unknown placeholders and other text stay as they are; +// only own properties count, so {constructor} is no placeholder. The values +// are inserted literally ($& and the like mean nothing here). +export function fillPlaceholders( + text: string, + values: Readonly>, +): string { + return text.replace(PLACEHOLDER, (match, name: string) => + Object.hasOwn(values, name) ? values[name] : match, + ); +} + +// The same for running text: the text pieces and the link texts are filled +// in, link targets stay as they are +export function fillRichText( + text: RichText, + values: Readonly>, +): RichText { + return text.map((piece) => + typeof piece === 'string' + ? fillPlaceholders(piece, values) + : { ...piece, text: fillPlaceholders(piece.text, values) }, + ); +} diff --git a/web/src/lib/headingId.test.ts b/web/src/lib/headingId.test.ts new file mode 100644 index 0000000..3096f68 --- /dev/null +++ b/web/src/lib/headingId.test.ts @@ -0,0 +1,52 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { shootTypeId } from '@/test/arbitraries'; +import { headingId } from './headingId'; + +describe('headingId', () => { + it.each([ + ['story', 'verwachten', 'story-verwachten'], + ['story', 'Met Spatie', 'story-met-spatie'], + ['story', 'UPPER', 'story-upper'], + ['story', '', 'story---script-'], + ['story', '', 'story-'], + ['story', 'één', 'story---n'], + ['Story', 'a_b-c', 'story-a_b-c'], + ])('maps (%s, %s) to %s', (prefix, id, expected) => { + expect(headingId(prefix, id)).toBe(expected); + }); + + it('keeps the five real shoot ids readable', () => { + for (const id of [ + 'newborn', + 'zwangerschap', + 'gezin', + 'loveshoot', + 'portret', + ]) { + expect(headingId('shoot', id)).toBe(`shoot-${id}`); + } + }); + + it('only produces a-z, 0-9, - and _, and is deterministic (invariant)', () => { + fc.assert( + fc.property( + fc.oneof( + fc.string(), + fc.string({ unit: 'binary' }), + shootTypeId, + ), + fc.oneof( + fc.string(), + fc.string({ unit: 'binary' }), + fc.constantFrom('', ' ', '"', "'", '\u0130'), + ), + (prefix, id) => { + const result = headingId(prefix, id); + expect(result).toMatch(/^[a-z0-9\-_]*$/); + expect(headingId(prefix, id)).toBe(result); + }, + ), + ); + }); +}); diff --git a/web/src/lib/headingId.ts b/web/src/lib/headingId.ts new file mode 100644 index 0000000..1893f65 --- /dev/null +++ b/web/src/lib/headingId.ts @@ -0,0 +1,7 @@ +// An id for a heading that aria-labelledby can always point at: lower-case +// letters, digits, '-' and '_' only. Anything else, such as a space in a +// story id from the content, becomes '-' (BR-SP-72). The caller adds +// '-title' where the id belongs to a heading. +export function headingId(prefix: string, id: string): string { + return `${prefix}-${id}`.toLowerCase().replace(/[^a-z0-9\-_]/g, '-'); +} diff --git a/web/src/lib/isShootSectionPath.test.ts b/web/src/lib/isShootSectionPath.test.ts new file mode 100644 index 0000000..ced7b0c --- /dev/null +++ b/web/src/lib/isShootSectionPath.test.ts @@ -0,0 +1,52 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { isShootSectionPath } from './isShootSectionPath'; + +// Het prefix in willekeurige hoofd- en kleine letters +const prefixInRandomCase = fc + .array(fc.boolean(), { minLength: 20, maxLength: 20 }) + .map((flags) => + [...'/soorten-fotoshoots/'] + .map((ch, i) => (flags[i] ? ch.toUpperCase() : ch)) + .join(''), + ); + +describe('isShootSectionPath', () => { + it.each([ + ['/soorten-fotoshoots/niet-bestaande-shoot', true], + ['/Soorten-Fotoshoots/x', true], + ['/soorten-fotoshoots/', true], + ['/soorten-fotoshoots', false], + ['/soorten-fotoshootsx/abc', false], + ['/bestaat-niet', false], + ['/', false], + ])('%s geeft %s', (path, expected) => { + expect(isShootSectionPath(path)).toBe(expected); + }); + + it('is true voor elk pad met het prefix, in elke schrijfwijze (property)', () => { + fc.assert( + fc.property(prefixInRandomCase, fc.string(), (prefix, rest) => { + expect(isShootSectionPath(prefix + rest)).toBe(true); + }), + ); + }); + + it('is false voor paden zonder het prefix (property)', () => { + fc.assert( + fc.property( + fc + .string() + .filter( + (path) => + !path + .toLowerCase() + .startsWith('/soorten-fotoshoots/'), + ), + (path) => { + expect(isShootSectionPath(path)).toBe(false); + }, + ), + ); + }); +}); diff --git a/web/src/lib/isShootSectionPath.ts b/web/src/lib/isShootSectionPath.ts new file mode 100644 index 0000000..9b59401 --- /dev/null +++ b/web/src/lib/isShootSectionPath.ts @@ -0,0 +1,7 @@ +const SHOOT_SECTION_PREFIX = '/soorten-fotoshoots/'; + +// Staat het pad onder /soorten-fotoshoots/ (FR-ST-14)? Hoofdletterongevoelig, +// net als de router. Het overzicht zelf (zonder slash) hoort er niet bij. +export function isShootSectionPath(pathname: string): boolean { + return pathname.toLowerCase().startsWith(SHOOT_SECTION_PREFIX); +} diff --git a/web/src/lib/mosaicLayout.test.ts b/web/src/lib/mosaicLayout.test.ts new file mode 100644 index 0000000..a580a3a --- /dev/null +++ b/web/src/lib/mosaicLayout.test.ts @@ -0,0 +1,96 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { mosaicCount } from '@/test/arbitraries'; +import { + MOSAIC_MAX_PHOTOS, + mosaicLayout, + type MosaicTile, +} from './mosaicLayout'; + +// The grid cells ("column,row") a tile covers, from its 'start / end' strings +function cells(tile: MosaicTile): string[] { + const [c0, c1] = tile.column.split(' / ').map(Number); + const [r0, r1] = tile.row.split(' / ').map(Number); + const result: string[] = []; + for (let c = c0; c < c1; c++) { + for (let r = r0; r < r1; r++) result.push(`${c},${r}`); + } + return result; +} + +describe('mosaicLayout', () => { + it('gives nothing for 0, a negative or a fractional count', () => { + expect(mosaicLayout(0)).toEqual([]); + expect(mosaicLayout(-1)).toEqual([]); + expect(mosaicLayout(1.5)).toEqual([]); + expect(mosaicLayout(Number.NaN)).toEqual([]); + }); + + it('gives one wide tile for 1', () => { + expect(mosaicLayout(1)).toEqual([ + { column: '1 / 5', row: '1 / 3', wide: true, phoneRatio: '4 / 3' }, + ]); + }); + + it('gives two equal tiles for 2', () => { + expect(mosaicLayout(2)).toEqual([ + { column: '1 / 3', row: '1 / 3', wide: true, phoneRatio: '4 / 3' }, + { column: '3 / 5', row: '1 / 3', wide: true, phoneRatio: '4 / 3' }, + ]); + }); + + it('gives a large and two wide tiles for 3', () => { + expect(mosaicLayout(3).map((tile) => tile.phoneRatio)).toEqual([ + '4 / 3', + '3 / 2', + '3 / 2', + ]); + expect(mosaicLayout(3)[2]).toMatchObject({ + column: '3 / 5', + row: '2 / 3', + }); + }); + + it('gives design E for 4, and the same for 5 or more', () => { + expect(mosaicLayout(4)).toEqual([ + { column: '1 / 3', row: '1 / 3', wide: true, phoneRatio: '4 / 3' }, + { column: '3 / 5', row: '1 / 2', wide: true, phoneRatio: '3 / 2' }, + { column: '3 / 4', row: '2 / 3', wide: false, phoneRatio: '1 / 1' }, + { column: '4 / 5', row: '2 / 3', wide: false, phoneRatio: '1 / 1' }, + ]); + expect(mosaicLayout(5)).toEqual(mosaicLayout(4)); + expect(mosaicLayout(12)).toEqual(mosaicLayout(4)); + }); + + it('returns fresh objects, so a caller cannot change the layout', () => { + mosaicLayout(4)[0].column = 'x'; + expect(mosaicLayout(4)[0].column).toBe('1 / 3'); + }); + + it('fills the 4 x 2 grid without overlap and stays well formed (invariant)', () => { + fc.assert( + fc.property(mosaicCount, (count) => { + const tiles = mosaicLayout(count); + expect(mosaicLayout(count)).toEqual(tiles); + if (count <= 0) { + expect(tiles).toEqual([]); + return; + } + expect(tiles).toHaveLength(Math.min(count, MOSAIC_MAX_PHOTOS)); + const covered = tiles.flatMap(cells); + expect(new Set(covered).size).toBe(covered.length); + if (count >= 2) expect(covered).toHaveLength(8); + if (count >= 2) { + // (A single photo, never shown, spans the whole grid) + expect(tiles[0]).toMatchObject({ + column: '1 / 3', + row: '1 / 3', + }); + expect(tiles.filter((tile) => !tile.wide).length % 2).toBe( + 0, + ); + } + }), + ); + }); +}); diff --git a/web/src/lib/mosaicLayout.ts b/web/src/lib/mosaicLayout.ts new file mode 100644 index 0000000..2f2447e --- /dev/null +++ b/web/src/lib/mosaicLayout.ts @@ -0,0 +1,50 @@ +// The photo mosaic of a shoot page: a 4 x 2 grid from `md`, two columns on +// phones (FR-ST-05). Each tile says where it sits; the component only +// draws them. + +// The most photos the mosaic shows; more stay in the content +export const MOSAIC_MAX_PHOTOS = 4; + +export interface MosaicTile { + // CSS grid-column from `md`, e.g. '1 / 3' + column: string; + // CSS grid-row from `md` + row: string; + // Spans both columns below `md` + wide: boolean; + // Aspect ratio of the tile below `md` + phoneRatio: '4 / 3' | '3 / 2' | '1 / 1'; +} + +const large: MosaicTile = { + column: '1 / 3', + row: '1 / 3', + wide: true, + phoneRatio: '4 / 3', +}; + +const layouts: Record<1 | 2 | 3 | 4, readonly MosaicTile[]> = { + // Never shown (the view needs at least two photos), kept so that the + // function is total + 1: [{ column: '1 / 5', row: '1 / 3', wide: true, phoneRatio: '4 / 3' }], + 2: [large, { ...large, column: '3 / 5' }], + 3: [ + large, + { column: '3 / 5', row: '1 / 2', wide: true, phoneRatio: '3 / 2' }, + { column: '3 / 5', row: '2 / 3', wide: true, phoneRatio: '3 / 2' }, + ], + 4: [ + large, + { column: '3 / 5', row: '1 / 2', wide: true, phoneRatio: '3 / 2' }, + { column: '3 / 4', row: '2 / 3', wide: false, phoneRatio: '1 / 1' }, + { column: '4 / 5', row: '2 / 3', wide: false, phoneRatio: '1 / 1' }, + ], +}; + +// The tiles for `count` photos. Nothing for a count below 1 or one that is +// not a whole number (fail safe); five or more get the layout for four. +export function mosaicLayout(count: number): MosaicTile[] { + if (!Number.isInteger(count) || count < 1) return []; + const key = Math.min(count, MOSAIC_MAX_PHOTOS) as 1 | 2 | 3 | 4; + return layouts[key].map((tile) => ({ ...tile })); +} diff --git a/web/src/lib/navCurrent.test.ts b/web/src/lib/navCurrent.test.ts new file mode 100644 index 0000000..41500e7 --- /dev/null +++ b/web/src/lib/navCurrent.test.ts @@ -0,0 +1,200 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import type { NavItem } from '../navigation'; +import { knownRoutePath, uniqueShootTypes } from '../test/arbitraries'; +import { pathname } from '../test/navArbitraries'; +import { isItemCurrent, isSectionCurrent } from './navCurrent'; +import { shootNavItems } from './shootNavItems'; + +// The comparison rule written out once more: lower case, one trailing slash +const normalise = (path: string) => { + const lower = path.toLowerCase(); + return lower.length > 1 && lower.endsWith('/') ? lower.slice(0, -1) : lower; +}; + +const item = fc.record({ to: knownRoutePath, label: fc.string() }); + +// The overview with a random set of shoot pages as children +const parent = uniqueShootTypes.map((shoots): NavItem => ({ + to: '/soorten-fotoshoots', + label: 'Soorten fotoshoots', + children: shootNavItems(shoots), +})); + +describe('isItemCurrent', () => { + it('is true exactly when the normalised paths are equal (invariant)', () => { + fc.assert( + fc.property(item, pathname, (nav, path) => { + expect(isItemCurrent(nav, path)).toBe( + normalise(nav.to) === normalise(path), + ); + }), + ); + }); + + it('is true for its own path in every spelling (invariant)', () => { + fc.assert( + fc.property(item, (nav) => { + for (const spelling of [ + nav.to, + `${nav.to}/`, + nav.to.toUpperCase(), + `${nav.to.toUpperCase()}/`, + ]) { + expect(isItemCurrent(nav, spelling)).toBe(true); + } + }), + ); + }); + + it('is not changed by letter case or one added trailing slash (idempotency)', () => { + fc.assert( + fc.property(item, pathname, (nav, path) => { + // '' and '/' have no "added slash" twin that means the same + fc.pre(path.length > 0 && path !== '/'); + const result = isItemCurrent(nav, path); + expect(isItemCurrent(nav, path.toUpperCase())).toBe( + isItemCurrent(nav, path.toLowerCase()), + ); + // Adding a slash to a path without one gives the same answer + fc.pre(!path.endsWith('/')); + expect(isItemCurrent(nav, `${path}/`)).toBe(result); + }), + ); + }); + + it('is false for a path that normalises differently (invariant)', () => { + fc.assert( + fc.property(item, pathname, (nav, path) => { + fc.pre(normalise(nav.to) !== normalise(path)); + expect(isItemCurrent(nav, path)).toBe(false); + }), + ); + }); + + it('accepts the item path with a trailing slash and other case', () => { + const nav: NavItem = { to: '/portfolio', label: 'Portfolio' }; + expect(isItemCurrent(nav, '/portfolio')).toBe(true); + expect(isItemCurrent(nav, '/portfolio/')).toBe(true); + expect(isItemCurrent(nav, '/Portfolio')).toBe(true); + expect(isItemCurrent(nav, '/')).toBe(false); + }); + + it('keeps the home page apart from every other path', () => { + const home: NavItem = { to: '/', label: 'Home' }; + expect(isItemCurrent(home, '/')).toBe(true); + expect(isItemCurrent(home, '')).toBe(false); + expect(isItemCurrent(home, '/portfolio')).toBe(false); + }); +}); + +describe('isSectionCurrent', () => { + it('is implied by isItemCurrent (invariant)', () => { + fc.assert( + fc.property(parent, pathname, (nav, path) => { + fc.pre(isItemCurrent(nav, path)); + expect(isSectionCurrent(nav, path)).toBe(true); + }), + ); + }); + + it('is implied by any child being current (invariant)', () => { + fc.assert( + fc.property(parent, fc.nat(), (nav, index) => { + const children = nav.children ?? []; + fc.pre(children.length > 0); + const child = children[index % children.length]; + expect(isSectionCurrent(nav, child.to)).toBe(true); + expect(isSectionCurrent(nav, `${child.to}/`)).toBe(true); + expect(isSectionCurrent(nav, child.to.toUpperCase())).toBe( + true, + ); + }), + ); + }); + + it('is true only for the item or a child (invariant)', () => { + fc.assert( + fc.property(parent, pathname, (nav, path) => { + const expected = + isItemCurrent(nav, path) || + (nav.children ?? []).some((child) => + isItemCurrent(child, path), + ); + expect(isSectionCurrent(nav, path)).toBe(expected); + }), + ); + }); + + it('is false for unrelated paths and prefix look-alikes (invariant)', () => { + fc.assert( + fc.property( + parent, + fc.constantFrom( + '/', + '/portfolio', + '/contact', + '/soorten-fotoshoots-extra', + '/soorten-fotoshootsX', + '/soorten-fotoshoots/newborn/extra', + '/soorten-fotoshoots/onbekend', + ), + (nav, path) => { + expect(isSectionCurrent(nav, path)).toBe(false); + }, + ), + ); + }); + + it('is false on the home page for the overview', () => { + const nav: NavItem = { + to: '/soorten-fotoshoots', + label: 'Soorten fotoshoots', + children: shootNavItems([]), + }; + expect(isSectionCurrent(nav, '/')).toBe(false); + }); + + it('marks the parent as section and the child as item on a shoot page', () => { + const child: NavItem = { + to: '/soorten-fotoshoots/newborn', + label: 'Newborn', + }; + const nav: NavItem = { + to: '/soorten-fotoshoots', + label: 'Soorten fotoshoots', + children: [child], + }; + expect(isSectionCurrent(nav, '/soorten-fotoshoots/newborn/')).toBe( + true, + ); + expect(isItemCurrent(child, '/soorten-fotoshoots/newborn/')).toBe(true); + expect(isItemCurrent(nav, '/soorten-fotoshoots/newborn/')).toBe(false); + }); + + it('works for an item without children', () => { + const nav: NavItem = { to: '/contact', label: 'Contact' }; + expect(isSectionCurrent(nav, '/contact')).toBe(true); + expect(isSectionCurrent(nav, '/portfolio')).toBe(false); + }); +}); + +describe('hostile pathnames', () => { + it('always gives a boolean and does not throw (invariant)', () => { + fc.assert( + fc.property(parent, fc.string(), (nav, path) => { + expect(typeof isItemCurrent(nav, path)).toBe('boolean'); + expect(typeof isSectionCurrent(nav, path)).toBe('boolean'); + }), + ); + }); + + it.each(['', '//', ' ', '%2F', '/%2F', 'a'.repeat(100_000)])( + 'handles %j without throwing', + (path) => { + const nav: NavItem = { to: '/', label: 'Home' }; + expect(() => isItemCurrent(nav, path)).not.toThrow(); + expect(() => isSectionCurrent(nav, path)).not.toThrow(); + }, + ); +}); diff --git a/web/src/lib/navCurrent.ts b/web/src/lib/navCurrent.ts new file mode 100644 index 0000000..bc42caf --- /dev/null +++ b/web/src/lib/navCurrent.ts @@ -0,0 +1,24 @@ +import type { NavItem } from '../navigation.ts'; + +// Lower case and without one trailing slash (not for "/"), the way the +// router matches a path (BR-NAV-04) +function normalise(path: string): string { + const lower = path.toLowerCase(); + return lower.length > 1 && lower.endsWith('/') ? lower.slice(0, -1) : lower; +} + +// Whether the item is the page at `pathname`. Pure string comparison: never +// throws and never renders the pathname (SECURITY-05, SECURITY-15). +export function isItemCurrent(item: NavItem, pathname: string): boolean { + return normalise(item.to) === normalise(pathname); +} + +// Whether the item or one of its children is the page at `pathname`; marks +// the parent while a page below it is open (D4) +export function isSectionCurrent(item: NavItem, pathname: string): boolean { + return ( + isItemCurrent(item, pathname) || + (item.children?.some((child) => isItemCurrent(child, pathname)) ?? + false) + ); +} diff --git a/web/src/lib/navMenuState.test.ts b/web/src/lib/navMenuState.test.ts new file mode 100644 index 0000000..64abc78 --- /dev/null +++ b/web/src/lib/navMenuState.test.ts @@ -0,0 +1,398 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { + navMenuEvent, + navMenuEvents, + navMenuState, + navMenuStateOn, +} from '../test/navArbitraries'; +import { + initialNavMenuState, + navMenuReducer, + type NavMenuEvent, + type NavMenuState, +} from './navMenuState'; + +const reduce = (events: readonly NavMenuEvent[], start = initialNavMenuState) => + events.reduce(navMenuReducer, start); + +const closed: NavMenuState = { ...initialNavMenuState }; +const mobile: NavMenuState = { ...closed, isDesktop: false }; +const desktop: NavMenuState = { ...closed, isDesktop: true }; +const mobileOpen: NavMenuState = { ...mobile, menuOpen: true }; +const mobileGroup: NavMenuState = { ...mobileOpen, groupOpen: true }; +const desktopOpen: NavMenuState = { ...desktop, submenuOpen: true }; + +// The invariants I1-I4 of the domain model +function expectInvariants(state: NavMenuState) { + if (state.submenuOpen) expect(state.isDesktop).toBe(true); + if (state.menuOpen) expect(state.isDesktop).toBe(false); + if (state.groupOpen) expect(state.menuOpen).toBe(true); + if (state.focusRequest === 'menuToggle') { + expect(state.isDesktop).toBe(false); + } + if (state.focusRequest === 'submenuToggle') { + expect(state.isDesktop).toBe(true); + } +} + +// An independent, deliberately plain model of the transition table, written +// per field instead of per event as the reducer does +function model(state: NavMenuState, event: NavMenuEvent) { + const next = { ...state }; + const everythingClosed = () => { + next.menuOpen = false; + next.groupOpen = false; + next.submenuOpen = false; + }; + if (event.type === 'viewport') { + next.isDesktop = event.isDesktop; + if (event.isDesktop) { + next.menuOpen = false; + next.groupOpen = false; + } else { + next.submenuOpen = false; + } + if (event.isDesktop && next.focusRequest === 'menuToggle') { + next.focusRequest = null; + } + if (!event.isDesktop && next.focusRequest === 'submenuToggle') { + next.focusRequest = null; + } + } else if (event.type === 'toggleMenu' && !state.isDesktop) { + next.menuOpen = !state.menuOpen; + next.groupOpen = next.menuOpen ? event.inSection : false; + } else if (event.type === 'toggleGroup' && state.menuOpen) { + next.groupOpen = !state.groupOpen; + } else if (event.type === 'toggleSubmenu' && state.isDesktop) { + next.submenuOpen = !state.submenuOpen; + } else if (event.type === 'escape' && state.menuOpen) { + next.menuOpen = false; + next.groupOpen = false; + next.focusRequest = event.focusInside ? 'menuToggle' : null; + } else if (event.type === 'escape' && state.submenuOpen) { + next.submenuOpen = false; + next.focusRequest = event.focusInside ? 'submenuToggle' : null; + } else if ( + (event.type === 'outside' || event.type === 'focusLeave') && + state.submenuOpen + ) { + next.submenuOpen = false; + } else if (event.type === 'linkChosen' || event.type === 'routeChanged') { + everythingClosed(); + next.focusRequest = null; + } else if (event.type === 'focusHandled') { + next.focusRequest = null; + } + return next; +} + +describe('navMenuReducer (stateful)', () => { + it('keeps I1-I4 and follows the model after every event (stateful)', () => { + fc.assert( + fc.property(navMenuEvents, (events) => { + let state = initialNavMenuState; + for (const event of events) { + const expected = model(state, event); + state = navMenuReducer(state, event); + expect(state).toEqual(expected); + expectInvariants(state); + } + }), + ); + }); + + it('starts all closed and keeps the invariants for any reached state', () => { + expectInvariants(initialNavMenuState); + fc.assert( + fc.property(navMenuState, (state) => { + expectInvariants(state); + }), + ); + }); + + it('returns the same object when an event does not apply (invariant)', () => { + fc.assert( + fc.property(navMenuState, navMenuEvent, (state, event) => { + const next = navMenuReducer(state, event); + if (JSON.stringify(next) === JSON.stringify(state)) { + expect(next).toBe(state); + } + }), + ); + }); +}); + +describe('navMenuReducer (idempotency)', () => { + it('ends all closed after routeChanged or linkChosen, twice as once (idempotency)', () => { + fc.assert( + fc.property( + navMenuState, + fc.constantFrom('routeChanged', 'linkChosen'), + (state, type) => { + const once = navMenuReducer(state, { type }); + expect(once.menuOpen).toBe(false); + expect(once.groupOpen).toBe(false); + expect(once.submenuOpen).toBe(false); + expect(once.focusRequest).toBeNull(); + expect(once.isDesktop).toBe(state.isDesktop); + expect(navMenuReducer(once, { type })).toEqual(once); + }, + ), + ); + }); + + it('closes the same on escape twice as once, apart from the focus request (idempotency)', () => { + fc.assert( + fc.property(navMenuState, fc.boolean(), (state, focusInside) => { + const event = { type: 'escape', focusInside } as const; + const once = navMenuReducer(state, event); + const twice = navMenuReducer(once, event); + expect({ ...twice, focusRequest: null }).toEqual({ + ...once, + focusRequest: null, + }); + }), + ); + }); + + it('closes the submenu on outside or focusLeave without touching the rest (invariant)', () => { + fc.assert( + fc.property( + navMenuState, + fc.constantFrom('outside', 'focusLeave'), + (state, type) => { + const once = navMenuReducer(state, { type }); + expect(once.menuOpen).toBe(state.menuOpen); + expect(once.groupOpen).toBe(state.groupOpen); + expect(once.focusRequest).toBe(state.focusRequest); + expect(once.submenuOpen).toBe(false); + expect(navMenuReducer(once, { type })).toBe(once); + }, + ), + ); + }); +}); + +describe('navMenuReducer (invariant)', () => { + it('gives back the original state after two submenu toggles on desktop (invariant)', () => { + fc.assert( + fc.property(navMenuStateOn(true), (state) => { + const twice = reduce( + [{ type: 'toggleSubmenu' }, { type: 'toggleSubmenu' }], + state, + ); + expect(twice).toEqual(state); + }), + ); + }); + + it('leaves no mobile state open after viewport(true) (invariant)', () => { + fc.assert( + fc.property(navMenuState, (state) => { + const next = navMenuReducer(state, { + type: 'viewport', + isDesktop: true, + }); + expect(next.isDesktop).toBe(true); + expect(next.menuOpen).toBe(false); + expect(next.groupOpen).toBe(false); + }), + ); + }); + + it('leaves no submenu open after viewport(false) (invariant)', () => { + fc.assert( + fc.property(navMenuState, (state) => { + const next = navMenuReducer(state, { + type: 'viewport', + isDesktop: false, + }); + expect(next.isDesktop).toBe(false); + expect(next.submenuOpen).toBe(false); + }), + ); + }); + + it('opens the menu with the group set to inSection and closes both (invariant)', () => { + fc.assert( + fc.property(fc.boolean(), (inSection) => { + const open = navMenuReducer(mobile, { + type: 'toggleMenu', + inSection, + }); + expect(open.menuOpen).toBe(true); + expect(open.groupOpen).toBe(inSection); + const shut = navMenuReducer(open, { + type: 'toggleMenu', + inSection, + }); + expect(shut.menuOpen).toBe(false); + expect(shut.groupOpen).toBe(false); + }), + ); + }); +}); + +describe('navMenuReducer (examples)', () => { + it('viewport sets the width and closes what no longer exists', () => { + expect( + navMenuReducer(initialNavMenuState, { + type: 'viewport', + isDesktop: true, + }), + ).toEqual(desktop); + expect( + navMenuReducer(mobileGroup, { type: 'viewport', isDesktop: true }), + ).toEqual(desktop); + expect( + navMenuReducer(desktopOpen, { type: 'viewport', isDesktop: false }), + ).toEqual(mobile); + }); + + it('viewport drops a focus request that no longer fits', () => { + expect( + navMenuReducer( + { ...desktop, focusRequest: 'submenuToggle' }, + { type: 'viewport', isDesktop: false }, + ).focusRequest, + ).toBeNull(); + expect( + navMenuReducer( + { ...mobile, focusRequest: 'menuToggle' }, + { type: 'viewport', isDesktop: true }, + ).focusRequest, + ).toBeNull(); + expect( + navMenuReducer( + { ...mobile, focusRequest: 'menuToggle' }, + { type: 'viewport', isDesktop: false }, + ).focusRequest, + ).toBe('menuToggle'); + }); + + it('viewport to the same width changes nothing and returns the same object', () => { + expect( + navMenuReducer(mobile, { type: 'viewport', isDesktop: false }), + ).toBe(mobile); + expect( + navMenuReducer(desktopOpen, { type: 'viewport', isDesktop: true }), + ).toBe(desktopOpen); + }); + + it('toggleMenu opens with the group expanded in the section, collapsed outside it', () => { + expect( + navMenuReducer(mobile, { type: 'toggleMenu', inSection: true }), + ).toEqual(mobileGroup); + expect( + navMenuReducer(mobile, { type: 'toggleMenu', inSection: false }), + ).toEqual(mobileOpen); + expect( + navMenuReducer(mobileGroup, { + type: 'toggleMenu', + inSection: true, + }), + ).toEqual(mobile); + }); + + it('toggleMenu on desktop is ignored', () => { + expect( + navMenuReducer(desktop, { type: 'toggleMenu', inSection: true }), + ).toBe(desktop); + }); + + it('toggleGroup flips the group while the menu is open', () => { + expect(navMenuReducer(mobileOpen, { type: 'toggleGroup' })).toEqual( + mobileGroup, + ); + expect(navMenuReducer(mobileGroup, { type: 'toggleGroup' })).toEqual( + mobileOpen, + ); + }); + + it('toggleGroup while the menu is closed is ignored', () => { + expect(navMenuReducer(mobile, { type: 'toggleGroup' })).toBe(mobile); + }); + + it('toggleSubmenu flips the submenu on desktop', () => { + expect(navMenuReducer(desktop, { type: 'toggleSubmenu' })).toEqual( + desktopOpen, + ); + expect(navMenuReducer(desktopOpen, { type: 'toggleSubmenu' })).toEqual( + desktop, + ); + }); + + it('toggleSubmenu on mobile is ignored', () => { + expect(navMenuReducer(mobile, { type: 'toggleSubmenu' })).toBe(mobile); + }); + + it('escape closes the mobile menu and asks for focus on the hamburger when focus is inside', () => { + expect( + navMenuReducer(mobileGroup, { type: 'escape', focusInside: true }), + ).toEqual({ ...mobile, focusRequest: 'menuToggle' }); + expect( + navMenuReducer(mobileGroup, { type: 'escape', focusInside: false }), + ).toEqual(mobile); + }); + + it('escape closes the submenu and asks for focus on its toggle when focus is inside', () => { + expect( + navMenuReducer(desktopOpen, { type: 'escape', focusInside: true }), + ).toEqual({ ...desktop, focusRequest: 'submenuToggle' }); + expect( + navMenuReducer(desktopOpen, { type: 'escape', focusInside: false }), + ).toEqual(desktop); + }); + + it('escape with nothing open is ignored', () => { + expect( + navMenuReducer(desktop, { type: 'escape', focusInside: true }), + ).toBe(desktop); + expect( + navMenuReducer(mobile, { type: 'escape', focusInside: true }), + ).toBe(mobile); + }); + + it('outside and focusLeave close the submenu without a focus request', () => { + expect(navMenuReducer(desktopOpen, { type: 'outside' })).toEqual( + desktop, + ); + expect(navMenuReducer(desktopOpen, { type: 'focusLeave' })).toEqual( + desktop, + ); + }); + + it('outside and focusLeave with the submenu closed are ignored', () => { + expect(navMenuReducer(desktop, { type: 'outside' })).toBe(desktop); + expect(navMenuReducer(desktop, { type: 'focusLeave' })).toBe(desktop); + expect(navMenuReducer(mobileGroup, { type: 'outside' })).toBe( + mobileGroup, + ); + }); + + it('linkChosen and routeChanged close everything', () => { + for (const type of ['linkChosen', 'routeChanged'] as const) { + expect(navMenuReducer(mobileGroup, { type })).toEqual(mobile); + expect(navMenuReducer(desktopOpen, { type })).toEqual(desktop); + expect(navMenuReducer(desktop, { type })).toBe(desktop); + } + }); + + it('focusHandled clears the request, or is ignored when there is none', () => { + const asked: NavMenuState = { + ...desktop, + focusRequest: 'submenuToggle', + }; + expect(navMenuReducer(asked, { type: 'focusHandled' })).toEqual( + desktop, + ); + expect(navMenuReducer(desktop, { type: 'focusHandled' })).toBe(desktop); + }); + + it('ignores an unknown event instead of opening anything', () => { + const unknown = { type: 'explode' } as unknown as NavMenuEvent; + expect(navMenuReducer(desktop, unknown)).toBe(desktop); + expect(navMenuReducer(mobileOpen, unknown)).toBe(mobileOpen); + }); +}); diff --git a/web/src/lib/navMenuState.ts b/web/src/lib/navMenuState.ts new file mode 100644 index 0000000..f7c5fc0 --- /dev/null +++ b/web/src/lib/navMenuState.ts @@ -0,0 +1,140 @@ +// The open/closed state of the navigation menus (FR-ST-10): the desktop +// submenu below "Soorten fotoshoots" and, below lg, the full-screen menu +// with its expandable group. One reducer, so the hamburger, the submenu, +// the group and the route listener cannot disagree. + +// Where the focus must go after a state change; cleared by `focusHandled` +export type FocusRequest = 'menuToggle' | 'submenuToggle' | null; + +// Invariants (checked by the property tests): +// I1 submenuOpen implies isDesktop +// I2 menuOpen implies !isDesktop +// I3 groupOpen implies menuOpen +// I4 focusRequest 'menuToggle' implies !isDesktop, 'submenuToggle' implies +// isDesktop +export interface NavMenuState { + // Viewport is at or above lg + isDesktop: boolean; + // The full-screen mobile menu + menuOpen: boolean; + // The "Soorten fotoshoots" sub-list inside the mobile menu + groupOpen: boolean; + // The desktop dropdown panel + submenuOpen: boolean; + focusRequest: FocusRequest; +} + +export type NavMenuEvent = + | { type: 'viewport'; isDesktop: boolean } + | { type: 'toggleMenu'; inSection: boolean } + | { type: 'toggleGroup' } + | { type: 'toggleSubmenu' } + | { type: 'escape'; focusInside: boolean } + | { type: 'outside' } + | { type: 'focusLeave' } + | { type: 'linkChosen' } + | { type: 'routeChanged' } + | { type: 'focusHandled' }; + +// Everything closed; the width is unknown until the first `viewport` event +export const initialNavMenuState: NavMenuState = { + isDesktop: false, + menuOpen: false, + groupOpen: false, + submenuOpen: false, + focusRequest: null, +}; + +// A focus request that cannot be met at this width is dropped (I4) +function fittingRequest(request: FocusRequest, isDesktop: boolean) { + if (request === 'menuToggle' && isDesktop) return null; + if (request === 'submenuToggle' && !isDesktop) return null; + return request; +} + +// The transition table of the navigation menus. An event that does not apply +// returns the same state object, so useReducer skips the re-render. Nothing +// is ever opened by a fallback (SECURITY-15). +export function navMenuReducer( + state: NavMenuState, + event: NavMenuEvent, +): NavMenuState { + switch (event.type) { + case 'viewport': { + const { isDesktop } = event; + const next: NavMenuState = { + isDesktop, + menuOpen: isDesktop ? false : state.menuOpen, + groupOpen: isDesktop ? false : state.groupOpen, + submenuOpen: isDesktop ? state.submenuOpen : false, + focusRequest: fittingRequest(state.focusRequest, isDesktop), + }; + return sameState(state, next) ? state : next; + } + case 'toggleMenu': + if (state.isDesktop) return state; + return state.menuOpen + ? { ...state, menuOpen: false, groupOpen: false } + : { ...state, menuOpen: true, groupOpen: event.inSection }; + case 'toggleGroup': + if (!state.menuOpen) return state; + return { ...state, groupOpen: !state.groupOpen }; + case 'toggleSubmenu': + if (!state.isDesktop) return state; + return { ...state, submenuOpen: !state.submenuOpen }; + case 'escape': + if (state.menuOpen) { + return { + ...state, + menuOpen: false, + groupOpen: false, + focusRequest: event.focusInside ? 'menuToggle' : null, + }; + } + if (state.submenuOpen) { + return { + ...state, + submenuOpen: false, + focusRequest: event.focusInside ? 'submenuToggle' : null, + }; + } + return state; + case 'outside': + case 'focusLeave': + if (!state.submenuOpen) return state; + return { ...state, submenuOpen: false }; + case 'linkChosen': + case 'routeChanged': { + const closed: NavMenuState = { + ...state, + menuOpen: false, + groupOpen: false, + submenuOpen: false, + focusRequest: null, + }; + return sameState(state, closed) ? state : closed; + } + case 'focusHandled': + if (state.focusRequest === null) return state; + return { ...state, focusRequest: null }; + default: + // A new event type without a case is a type error here (never); + // at run time an unknown event changes nothing + return ignore(state, event); + } +} + +function sameState(a: NavMenuState, b: NavMenuState) { + return ( + a.isDesktop === b.isDesktop && + a.menuOpen === b.menuOpen && + a.groupOpen === b.groupOpen && + a.submenuOpen === b.submenuOpen && + a.focusRequest === b.focusRequest + ); +} + +function ignore(state: NavMenuState, event: never): NavMenuState { + void event; + return state; +} diff --git a/web/src/lib/readMoreLabel.test.ts b/web/src/lib/readMoreLabel.test.ts new file mode 100644 index 0000000..1ac38f2 --- /dev/null +++ b/web/src/lib/readMoreLabel.test.ts @@ -0,0 +1,38 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import shootTypes from '@/content/shootTypes'; +import { uniqueShootTypes } from '@/test/arbitraries'; +import { readMoreLabel } from './readMoreLabel'; + +describe('readMoreLabel', () => { + it('names each of the five real shoots', () => { + expect(shootTypes.map(readMoreLabel)).toEqual([ + 'Lees meer over de newbornshoot', + 'Lees meer over de zwangerschapsshoot', + 'Lees meer over de gezinsshoot', + 'Lees meer over de loveshoot', + 'Lees meer over de portretshoot', + ]); + expect(new Set(shootTypes.map(readMoreLabel)).size).toBe(5); + }); + + it('starts with the fixed words and is unique for unique shoot labels (invariant)', () => { + fc.assert( + fc.property(uniqueShootTypes, (shoots) => { + const unique = shoots.filter( + (shoot, index) => + shoots.findIndex( + (other) => + other.shootLabel.toLowerCase() === + shoot.shootLabel.toLowerCase(), + ) === index, + ); + const labels = unique.map(readMoreLabel); + for (const label of labels) { + expect(label.startsWith('Lees meer over de ')).toBe(true); + } + expect(new Set(labels).size).toBe(labels.length); + }), + ); + }); +}); diff --git a/web/src/lib/readMoreLabel.ts b/web/src/lib/readMoreLabel.ts new file mode 100644 index 0000000..6202f49 --- /dev/null +++ b/web/src/lib/readMoreLabel.ts @@ -0,0 +1,7 @@ +import type { ShootType } from '../content/types.ts'; + +// The text of the link from the overview to a shoot page (FR-ST-09). It +// differs per shoot, so no aria-label is needed to tell the links apart. +export function readMoreLabel(shoot: ShootType): string { + return `Lees meer over de ${shoot.shootLabel.toLowerCase()}`; +} diff --git a/web/src/lib/richTextToPlain.test.ts b/web/src/lib/richTextToPlain.test.ts new file mode 100644 index 0000000..d4d6afc --- /dev/null +++ b/web/src/lib/richTextToPlain.test.ts @@ -0,0 +1,33 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { richText } from '../test/arbitraries'; +import { richTextToPlain } from './richTextToPlain'; + +describe('richTextToPlain', () => { + it('reads links by their text, without adding spaces', () => { + expect( + richTextToPlain([ + 'Staat je vraag er niet tussen? ', + { text: 'Stuur gerust een berichtje', to: '/contact' }, + '.', + ]), + ).toBe('Staat je vraag er niet tussen? Stuur gerust een berichtje.'); + expect(richTextToPlain([])).toBe(''); + expect(richTextToPlain(['Alleen tekst'])).toBe('Alleen tekst'); + }); + + it('is the text pieces and link texts joined, as long as they are together (invariant)', () => { + fc.assert( + fc.property(richText, (text) => { + const pieces = text.map((piece) => + typeof piece === 'string' ? piece : piece.text, + ); + const plain = richTextToPlain(text); + expect(plain).toBe(pieces.join('')); + expect(plain.length).toBe( + pieces.reduce((sum, piece) => sum + piece.length, 0), + ); + }), + ); + }); +}); diff --git a/web/src/lib/richTextToPlain.ts b/web/src/lib/richTextToPlain.ts new file mode 100644 index 0000000..2437b0d --- /dev/null +++ b/web/src/lib/richTextToPlain.ts @@ -0,0 +1,10 @@ +import type { RichText } from '../content/types.ts'; + +// The text a visitor reads: text pieces as they are, links by their text, +// joined without anything in between (spaces belong to the text). For +// places that take plain text only, such as the FAQ in structured data. +export function richTextToPlain(text: RichText): string { + return text + .map((piece) => (typeof piece === 'string' ? piece : piece.text)) + .join(''); +} diff --git a/web/src/lib/shootLinks.test.ts b/web/src/lib/shootLinks.test.ts index 9f965f3..d7670bb 100644 --- a/web/src/lib/shootLinks.test.ts +++ b/web/src/lib/shootLinks.test.ts @@ -9,6 +9,7 @@ import { shootContactLink, shootPortfolioLink, } from './shootLinks'; +import { shootPackage } from './shootPackage'; import { visiblePackages } from './visiblePackages'; const shoot = (id: string) => shootTypes.find((item) => item.id === id)!; @@ -58,6 +59,15 @@ describe('shootContactLink', () => { }), ); }); + + it('agrees with shootPackage (invariant)', () => { + fc.assert( + fc.property(shootType, fc.array(anyPackage), (item, list) => { + const link = shootContactLink(item, list); + expect(link.search?.pakket).toBe(shootPackage(item, list)?.id); + }), + ); + }); }); describe('shootPortfolioLink', () => { diff --git a/web/src/lib/shootLinks.ts b/web/src/lib/shootLinks.ts index 9611997..ae54ee4 100644 --- a/web/src/lib/shootLinks.ts +++ b/web/src/lib/shootLinks.ts @@ -1,7 +1,7 @@ import type { PricingPackage, ShootType } from '../content/types.ts'; import type { RoutePath } from '../navigation.ts'; import type { PageMeta } from '../sitePages.ts'; -import { visiblePackages } from './visiblePackages.ts'; +import { shootPackage } from './shootPackage.ts'; // Where "Stuur een berichtje" goes: the contact page, with the shoot's // package preselected when that package is shown (BR-SF-01..03, FR-CP-09) @@ -9,11 +9,9 @@ export function shootContactLink( shoot: ShootType, packages: readonly PricingPackage[], ) { - const shown = visiblePackages(packages).some( - (pkg) => pkg.id === shoot.packageId, - ); - return shown && shoot.packageId !== undefined - ? { to: '/contact' as const, search: { pakket: shoot.packageId } } + const pkg = shootPackage(shoot, packages); + return pkg !== undefined + ? { to: '/contact' as const, search: { pakket: pkg.id } } : { to: '/contact' as const }; } diff --git a/web/src/lib/shootNavItems.test.ts b/web/src/lib/shootNavItems.test.ts new file mode 100644 index 0000000..c47da53 --- /dev/null +++ b/web/src/lib/shootNavItems.test.ts @@ -0,0 +1,75 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import shootTypes from '../content/shootTypes'; +import { uniqueShootTypes } from '../test/arbitraries'; +import { shootNavItems } from './shootNavItems'; +import { SHOOT_TYPES_PATH, shootIdFromPath, shootPagePath } from './shootPages'; + +describe('shootNavItems', () => { + it('gives one item per shoot (invariant)', () => { + fc.assert( + fc.property(uniqueShootTypes, (shoots) => { + expect(shootNavItems(shoots)).toHaveLength(shoots.length); + }), + ); + }); + + it('keeps the order and uses the name as label (invariant)', () => { + fc.assert( + fc.property(uniqueShootTypes, (shoots) => { + const items = shootNavItems(shoots); + expect(items.map((item) => item.label)).toEqual( + shoots.map((shoot) => shoot.name), + ); + }), + ); + }); + + it('links to the page of the same shoot (round trip)', () => { + fc.assert( + fc.property(uniqueShootTypes, (shoots) => { + const items = shootNavItems(shoots); + items.forEach((item, index) => { + expect(shootIdFromPath(item.to)).toBe(shoots[index].id); + }); + }), + ); + }); + + it('links to a page below the overview (invariant)', () => { + fc.assert( + fc.property(uniqueShootTypes, (shoots) => { + shootNavItems(shoots).forEach((item, index) => { + expect(item.to).toBe(shootPagePath(shoots[index].id)); + expect(item.to.startsWith(`${SHOOT_TYPES_PATH}/`)).toBe( + true, + ); + }); + }), + ); + }); + + it('has no other fields than to and label (invariant)', () => { + fc.assert( + fc.property(uniqueShootTypes, (shoots) => { + for (const item of shootNavItems(shoots)) { + expect(Object.keys(item).sort()).toEqual(['label', 'to']); + } + }), + ); + }); + + it('gives the five names of the real shoot types in order', () => { + expect(shootNavItems(shootTypes).map((item) => item.label)).toEqual([ + 'Newborn', + 'Zwangerschap', + 'Gezin', + 'Loveshoot', + 'Portretten', + ]); + }); + + it('gives an empty list for no shoots', () => { + expect(shootNavItems([])).toEqual([]); + }); +}); diff --git a/web/src/lib/shootNavItems.ts b/web/src/lib/shootNavItems.ts new file mode 100644 index 0000000..4dade32 --- /dev/null +++ b/web/src/lib/shootNavItems.ts @@ -0,0 +1,12 @@ +import type { ShootType } from '../content/types.ts'; +import type { NavItem } from '../navigation.ts'; +import { shootPagePath } from './shootPages.ts'; + +// The submenu items of the shoot types, one per shoot in the given order: +// the label is the shoot name, the target its page (FR-ST-10, BR-NAV-10) +export function shootNavItems(shoots: readonly ShootType[]): NavItem[] { + return shoots.map((shoot) => ({ + to: shootPagePath(shoot.id), + label: shoot.name, + })); +} diff --git a/web/src/lib/shootPackage.test.ts b/web/src/lib/shootPackage.test.ts new file mode 100644 index 0000000..e03039b --- /dev/null +++ b/web/src/lib/shootPackage.test.ts @@ -0,0 +1,63 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import packages from '../content/packages'; +import shootTypes from '../content/shootTypes'; +import { anyPackage, shootType } from '../test/arbitraries'; +import { shootPackage } from './shootPackage'; +import { visiblePackages } from './visiblePackages'; + +const shoot = (id: string) => shootTypes.find((item) => item.id === id)!; + +describe('shootPackage', () => { + it('finds the package of the three shoots that have one', () => { + expect(shootPackage(shoot('newborn'), packages)).toMatchObject({ + id: 'newborn', + price: 185, + }); + expect(shootPackage(shoot('zwangerschap'), packages)).toMatchObject({ + id: 'zwangerschap', + price: 175, + }); + expect(shootPackage(shoot('gezin'), packages)).toMatchObject({ + id: 'gezin', + price: 175, + }); + }); + + it('finds none for Loveshoot and Portret', () => { + expect(shootPackage(shoot('loveshoot'), packages)).toBeUndefined(); + expect(shootPackage(shoot('portret'), packages)).toBeUndefined(); + }); + + it('finds none when the package is removed or invalid', () => { + expect( + shootPackage( + shoot('gezin'), + packages.filter((pkg) => pkg.id !== 'gezin'), + ), + ).toBeUndefined(); + expect( + shootPackage( + shoot('newborn'), + packages.map((pkg) => + pkg.id === 'newborn' ? { ...pkg, price: 0 } : pkg, + ), + ), + ).toBeUndefined(); + }); + + it('is undefined or a shown package with the id of the shoot (invariant)', () => { + fc.assert( + fc.property(shootType, fc.array(anyPackage), (item, list) => { + const result = shootPackage(item, list); + const shown = visiblePackages(list); + const expected = shown.some((pkg) => pkg.id === item.packageId); + expect(result !== undefined).toBe(expected); + if (result !== undefined) { + expect(result.id).toBe(item.packageId); + expect(shown).toContain(result); + } + }), + ); + }); +}); diff --git a/web/src/lib/shootPackage.ts b/web/src/lib/shootPackage.ts new file mode 100644 index 0000000..0aa55ea --- /dev/null +++ b/web/src/lib/shootPackage.ts @@ -0,0 +1,12 @@ +import type { PricingPackage, ShootType } from '../content/types.ts'; +import { visiblePackages } from './visiblePackages.ts'; + +// The package a shoot points to, if that package is shown; a removed or +// invalid package, or none, gives undefined, and the page then shows +// "Prijs op aanvraag" (FR-ST-07, SECURITY-15) +export function shootPackage( + shoot: ShootType, + packages: readonly PricingPackage[], +): PricingPackage | undefined { + return visiblePackages(packages).find((pkg) => pkg.id === shoot.packageId); +} diff --git a/web/src/lib/shootPageBands.test.ts b/web/src/lib/shootPageBands.test.ts new file mode 100644 index 0000000..ac7e53f --- /dev/null +++ b/web/src/lib/shootPageBands.test.ts @@ -0,0 +1,95 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import shootPageShared from '@/content/shootPageShared'; +import newbornPage from '@/content/shootPages/newborn'; +import loveshootPage from '@/content/shootPages/loveshoot'; +import packages from '@/content/packages'; +import shootTypes from '@/content/shootTypes'; +import siteContent from '@/content/siteContent'; +import { shootPageViewArb } from '@/test/arbitraries'; +import { shootPageBands } from './shootPageBands'; +import { shootPageView } from './shootPageView'; +import { storyLayout } from './storyLayout'; + +const sources = { + shootTypes, + packages, + shared: shootPageShared, + site: siteContent, + portfolioShoots: [], +}; + +describe('shootPageBands', () => { + it('gives the newborn page nine bands', () => { + const view = shootPageView('newborn', newbornPage, sources)!; + const bands = shootPageBands(view); + expect(bands).toHaveLength(9); + expect(bands.map((band) => band.id)).toEqual([ + ...view.stories.map((story) => `story-${story.id}`), + 'process', + 'photos', + 'faq', + 'offer', + 'closing', + ]); + expect(bands.map((band) => band.position)).toEqual([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, + ]); + expect(bands[0].tone).toBe('paper'); + expect(bands[1].tone).toBe('alt'); + }); + + it('leaves out the photos for loveshoot', () => { + const view = shootPageView('loveshoot', loveshootPage, sources)!; + const bands = shootPageBands(view); + expect(bands).toHaveLength(8); + expect(bands.map((band) => band.id)).not.toContain('photos'); + }); + + it('leaves out the FAQ of a view without questions', () => { + const view = shootPageView( + 'newborn', + { ...newbornPage, faq: { ...newbornPage.faq, items: [] } }, + sources, + )!; + const ids = shootPageBands(view).map((band) => band.id); + expect(ids).not.toContain('faq'); + expect(ids).toContain('photos'); + }); + + it('keeps the order, the alternation and the story tones for any view (invariant)', () => { + fc.assert( + fc.property(shootPageViewArb, (view) => { + const bands = shootPageBands(view); + expect(bands).toHaveLength( + view.stories.length + + 1 + + (view.photos ? 1 : 0) + + (view.faq ? 1 : 0) + + 2, + ); + bands.forEach((band, index) => { + expect(band.position).toBe(index); + expect(band.tone).toBe(index % 2 === 0 ? 'paper' : 'alt'); + }); + const tail = bands.slice(view.stories.length).map((b) => b.id); + expect(tail).toEqual([ + 'process', + ...(view.photos ? ['photos'] : []), + ...(view.faq ? ['faq'] : []), + 'offer', + 'closing', + ]); + expect( + bands.slice(0, view.stories.length).map((b) => b.id), + ).toEqual(view.stories.map((story) => `story-${story.id}`)); + const layout = storyLayout(view.stories); + layout.forEach((item, index) => { + expect(bands[index].tone).toBe(item.tone); + }); + // Story ids are unique in the generated content + expect(new Set(bands.map((b) => b.id)).size).toBe(bands.length); + }), + ); + }); +}); diff --git a/web/src/lib/shootPageBands.ts b/web/src/lib/shootPageBands.ts new file mode 100644 index 0000000..8452ee4 --- /dev/null +++ b/web/src/lib/shootPageBands.ts @@ -0,0 +1,29 @@ +import type { ShootPageView } from './shootPageView.ts'; + +export interface SectionBand { + id: `story-${string}` | 'process' | 'photos' | 'faq' | 'offer' | 'closing'; + // The band colour: paper at even positions, alt at odd ones + tone: 'paper' | 'alt'; + // 0 for the first story; the intro above it is not a band + position: number; +} + +// The bands of a shoot page in page order (BR-SP-70): the stories, the +// timeline, the photos and the FAQ when the view has them, the offer and +// the closing block. Tones alternate, so two bands never touch in the same +// colour; the intro above is always paper. +export function shootPageBands(view: ShootPageView): SectionBand[] { + const ids: SectionBand['id'][] = [ + ...view.stories.map((story) => `story-${story.id}` as const), + 'process', + ...(view.photos ? (['photos'] as const) : []), + ...(view.faq ? (['faq'] as const) : []), + 'offer', + 'closing', + ]; + return ids.map((id, position) => ({ + id, + tone: position % 2 === 0 ? 'paper' : 'alt', + position, + })); +} diff --git a/web/src/lib/shootPageView.test.ts b/web/src/lib/shootPageView.test.ts new file mode 100644 index 0000000..ad6a974 --- /dev/null +++ b/web/src/lib/shootPageView.test.ts @@ -0,0 +1,369 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import sleepingBaby from '../assets/portfolio/f41a8700.jpg'; +import packages from '../content/packages'; +import shootPageShared from '../content/shootPageShared'; +import loveshootPage from '../content/shootPages/loveshoot'; +import newbornPage from '../content/shootPages/newborn'; +import shootTypes from '../content/shootTypes'; +import siteContent from '../content/siteContent'; +import type { ContentImage, RichText } from '../content/types'; +import { + anyPackage, + anySiteContent, + contentImage, + knownPlaceholders, + plainText, + shootPageContent, + shootPageShared as anyShared, + shootType, + shootTypeId, +} from '../test/arbitraries'; +import { shootPackage } from './shootPackage'; +import { SHOOT_TYPE_IDS, shootPagePath } from './shootPages'; +import { + MOSAIC_MIN_PHOTOS, + PROCESS_STEP_ORDER, + shootPageView, + type ShootPageSources, + type ShootPageView, +} from './shootPageView'; +import { visiblePackages } from './visiblePackages'; + +const NBSP = ' '; + +const sources: ShootPageSources = { + shootTypes, + packages, + shared: shootPageShared, + site: siteContent, + portfolioShoots: ['newborn'], +}; + +// Shoot types with unique ids, some with a detail photo +const shoots = fc.uniqueArray( + fc + .tuple(shootType, fc.option(contentImage, { nil: undefined })) + .map(([shoot, detailImage]) => + detailImage === undefined ? shoot : { ...shoot, detailImage }, + ), + { selector: (shoot) => shoot.id, maxLength: 5 }, +); + +// The sources as the CMS could deliver them. The reply time has no braces, +// as in the content: it is filled in as a value. +const anySources: fc.Arbitrary = fc.record({ + shootTypes: shoots, + packages: fc.array(anyPackage, { maxLength: 6 }), + shared: anyShared, + site: fc.tuple(anySiteContent, plainText).map(([site, replyTime]) => ({ + ...site, + contactForm: { ...site.contactForm, replyTime }, + })), + portfolioShoots: fc.subarray([...SHOOT_TYPE_IDS]), +}); + +// A shoot id (mostly one of the sources), the sources, and page content +// that mostly belongs to that shoot, its photos repeating the shoot's own +const viewCase = anySources.chain((given) => { + const ids = given.shootTypes.map((shoot) => shoot.id); + const id = + ids.length > 0 + ? fc.oneof( + { arbitrary: fc.constantFrom(...ids), weight: 4 }, + shootTypeId, + ) + : shootTypeId; + return id.chain((shootId) => { + const shoot = given.shootTypes.find((item) => item.id === shootId); + const reuse = + shoot === undefined + ? [] + : [ + shoot.image, + ...(shoot.detailImage ? [shoot.detailImage] : []), + ]; + return fc.record({ + id: fc.constant(shootId), + sources: fc.constant(given), + page: fc.oneof( + { arbitrary: shootPageContent(shootId, reuse), weight: 4 }, + shootPageContent(undefined, reuse), + ), + }); + }); +}); + +// A case for which the view exists +const resolvedCase = viewCase.filter( + ({ id, page, sources: given }) => + page.id === id && given.shootTypes.some((shoot) => shoot.id === id), +); + +const build = (c: { + id: Parameters[0]; + page: Parameters[1]; + sources: ShootPageSources; +}) => shootPageView(c.id, c.page, c.sources) as ShootPageView; + +const plain = (text: RichText) => + text.map((piece) => (typeof piece === 'string' ? piece : piece.text)); + +// Every text in which placeholders are filled in +const filledTexts = (view: ShootPageView) => [ + ...view.stories.flatMap((story) => [ + story.eyebrow, + story.title, + ...story.paragraphs.flatMap(plain), + ]), + ...view.process.steps.map((step) => step.text), + ...(view.faq?.items ?? []).flatMap((item) => [ + item.question, + ...plain(item.answer), + ]), + view.offer.depositNote, +]; + +// The photos the story blocks and the package block show +const usedElsewhere = (view: ShootPageView): ContentImage[] => [ + ...view.stories.flatMap((story) => + story.image === undefined ? [] : [story.image], + ), + view.offer.image, +]; + +describe('shootPageView with the real content', () => { + it('builds the newborn page with its package, filled texts and mosaic', () => { + const view = shootPageView('newborn', newbornPage, sources)!; + expect(view.path).toBe('/soorten-fotoshoots/newborn'); + expect(view.breadcrumb).toEqual({ + label: 'Kruimelpad', + items: [ + { label: 'Home', to: '/' }, + { label: 'Soorten fotoshoots', to: '/soorten-fotoshoots' }, + { label: 'Newborn', to: '/soorten-fotoshoots/newborn' }, + ], + }); + expect(view.offer.pkg?.price).toBe(185); + expect(view.offer.bookLink).toEqual({ + to: '/contact', + search: { pakket: 'newborn' }, + }); + expect(view.closing.link).toEqual(view.offer.bookLink); + expect(view.offer.askLink).toEqual({ to: '/contact' }); + expect(view.offer.depositNote).toBe( + `Aanbetaling €${NBSP}50, restbedrag na de shoot.`, + ); + expect(view.offer.image).toBe(shootTypes[0].detailImage); + expect(view.process.steps.map((step) => step.id)).toEqual( + PROCESS_STEP_ORDER, + ); + expect(view.process.steps[0].text).toBe( + 'Stuur een berichtje. Ik reageer binnen 1-2 werkdagen.', + ); + expect(view.process.steps[2].text).toBe( + `Met een aanbetaling van €${NBSP}50 staat je datum vast.`, + ); + expect(view.process.steps[3].text).toBe(newbornPage.process.duration); + // The sleeping baby is in a story block already (D14) + expect(view.photos?.images).toEqual( + newbornPage.photos.images.filter( + (image) => image.src !== sleepingBaby, + ), + ); + expect(view.photos?.images).toHaveLength(3); + expect(view.photos?.portfolioLink).toEqual({ + to: '/portfolio', + search: { shoot: 'newborn' }, + }); + expect(view.faq?.items.length).toBe(newbornPage.faq.items.length); + }); + + it('builds the loveshoot page without package and without mosaic', () => { + const view = shootPageView('loveshoot', loveshootPage, sources)!; + expect(view.offer.pkg).toBeUndefined(); + expect(view).not.toHaveProperty('offer.pkg'); + expect(view.offer.bookLink).toEqual({ to: '/contact' }); + expect(view.closing.link).toEqual({ to: '/contact' }); + expect(view.offer.onRequest.price).toBe('Prijs op aanvraag'); + expect(view.photos).toBeUndefined(); + expect(view.breadcrumb.items.at(-1)).toEqual({ + label: 'Loveshoot', + to: '/soorten-fotoshoots/loveshoot', + }); + }); + + it('gives undefined for a missing shoot type or content of another shoot', () => { + expect( + shootPageView('newborn', newbornPage, { + ...sources, + shootTypes: shootTypes.filter( + (shoot) => shoot.id !== 'newborn', + ), + }), + ).toBeUndefined(); + expect( + shootPageView('loveshoot', newbornPage, sources), + ).toBeUndefined(); + }); + + it('leaves out the FAQ without questions and the portfolio link when the portfolio does not show the shoot', () => { + const view = shootPageView( + 'newborn', + { ...newbornPage, faq: { ...newbornPage.faq, items: [] } }, + { ...sources, portfolioShoots: [] }, + )!; + expect(view.faq).toBeUndefined(); + expect(view.photos).toBeDefined(); + expect(view.photos).not.toHaveProperty('portfolioLink'); + }); +}); + +describe('shootPageView', () => { + it('is undefined exactly when the shoot type is missing or the content is of another shoot (invariant)', () => { + fc.assert( + fc.property(viewCase, ({ id, page, sources: given }) => { + const view = shootPageView(id, page, given); + const exists = + page.id === id && + given.shootTypes.some((shoot) => shoot.id === id); + expect(view !== undefined).toBe(exists); + if (view !== undefined) { + expect(view.id).toBe(id); + expect(view.shoot.id).toBe(id); + expect(view.path).toBe(shootPagePath(id)); + } + }), + ); + }); + + it('always has the six steps in their fixed order, whatever the content order (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + expect(view.process.steps.map((step) => step.id)).toEqual( + PROCESS_STEP_ORDER, + ); + view.process.steps.forEach((step) => { + expect(step.title).toBe( + c.sources.shared.process.steps[step.id].title, + ); + }); + }), + ); + }); + + it('leaves no known placeholder in any text (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + for (const text of filledTexts(build(c))) { + for (const name of knownPlaceholders) { + expect(text).not.toContain(`{${name}}`); + } + } + }), + ); + }); + + it('shows each remaining page photo once, in order, never one used elsewhere, or no photos below the minimum (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + const used = new Set(usedElsewhere(view).map((i) => i.src)); + const remaining = new Set( + c.page.photos.images + .map((image) => image.src) + .filter((src) => !used.has(src)), + ); + if (remaining.size < MOSAIC_MIN_PHOTOS) { + expect(view.photos).toBeUndefined(); + return; + } + const images = view.photos!.images; + const srcs = images.map((image) => image.src); + expect(new Set(srcs).size).toBe(srcs.length); + expect(new Set(srcs)).toEqual(remaining); + expect(srcs.some((src) => used.has(src))).toBe(false); + // An ordered subset: each photo is a page photo, found + // after the one before it + let from = 0; + for (const image of images) { + const at = c.page.photos.images.indexOf(image, from); + expect(at).toBeGreaterThanOrEqual(from); + from = at + 1; + } + }), + ); + }); + + it('shows the package exactly when shootPackage finds one (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + expect(view.offer.pkg).toBe( + shootPackage(view.shoot, c.sources.packages), + ); + }), + ); + }); + + it('only ever preselects a shown package (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + const shown = visiblePackages(c.sources.packages).map( + (pkg) => pkg.id, + ); + for (const link of [view.offer.bookLink, view.closing.link]) { + expect(link.to).toBe('/contact'); + if (link.search !== undefined) { + expect(shown).toContain(link.search.pakket); + expect(link.search.pakket).toBe(view.offer.pkg?.id); + } + } + }), + ); + }); + + it('ends the breadcrumb with this page, after Home and the overview (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + expect(view.breadcrumb.items.map((item) => item.to)).toEqual([ + '/', + '/soorten-fotoshoots', + view.path, + ]); + expect(view.breadcrumb.items.at(-1)?.label).toBe( + view.shoot.name, + ); + }), + ); + }); + + it('links the photos to the portfolio exactly when the portfolio shows the shoot (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + if (view.photos === undefined) return; + expect(view.photos.portfolioLink !== undefined).toBe( + c.sources.portfolioShoots.includes(c.id), + ); + }), + ); + }); + + it('has a FAQ exactly when there are questions, all of them in order (invariant)', () => { + fc.assert( + fc.property(resolvedCase, (c) => { + const view = build(c); + expect(view.faq !== undefined).toBe( + c.page.faq.items.length > 0, + ); + expect((view.faq?.items ?? []).map((item) => item.id)).toEqual( + c.page.faq.items.map((item) => item.id), + ); + }), + ); + }); +}); diff --git a/web/src/lib/shootPageView.ts b/web/src/lib/shootPageView.ts new file mode 100644 index 0000000..439d707 --- /dev/null +++ b/web/src/lib/shootPageView.ts @@ -0,0 +1,232 @@ +import type { + ContentImage, + FaqItem, + PricingPackage, + ProcessStepId, + RichText, + ShootPageContent, + ShootPageShared, + ShootType, + ShootTypeId, + SiteContent, + StoryBlock, +} from '../content/types.ts'; +import type { RoutePath } from '../navigation.ts'; +import { fillPlaceholders, fillRichText } from './fillPlaceholders.ts'; +import { formatPrice } from './formatPrice.ts'; +import { shootContactLink, shootPortfolioLink } from './shootLinks.ts'; +import { shootPackage } from './shootPackage.ts'; +import { + SHOOT_TYPES_PATH, + shootPagePath, + type ShootPagePath, +} from './shootPages.ts'; + +// The six steps of the process timeline, always in this order (FR-ST-04) +export const PROCESS_STEP_ORDER: readonly ProcessStepId[] = [ + 'aanvragen', + 'datum', + 'aanbetaling', + 'shoot', + 'bewerking', + 'oplevering', +]; + +// The fewest photos the photo section needs; with fewer left it is not +// shown (D15). Proposed 2, confirmed in Functional Design of unit 2. +export const MOSAIC_MIN_PHOTOS = 2; + +export interface BreadcrumbItem { + label: string; + to: RoutePath; +} + +export interface ProcessStep { + id: ProcessStepId; + title: string; + text: string; +} + +// Everything a shoot page is built from besides its own content +export interface ShootPageSources { + shootTypes: readonly ShootType[]; + packages: readonly PricingPackage[]; + shared: ShootPageShared; + site: SiteContent; + // The shoot types that link to the portfolio (live and with photos) + portfolioShoots: readonly ShootTypeId[]; +} + +// A shoot page with everything decided: placeholders filled, steps in +// order, photos chosen, package and links resolved. The sections and the +// structured data are both built from it, so they cannot disagree (D9). +export interface ShootPageView { + id: ShootTypeId; + path: ShootPagePath; + shoot: ShootType; + // The last item is this page + breadcrumb: { label: string; items: BreadcrumbItem[] }; + intro: ShootPageContent['intro']; + stories: StoryBlock[]; + // Always six, in PROCESS_STEP_ORDER + process: { + eyebrow: string; + title: string; + lead: string; + steps: ProcessStep[]; + }; + // Left out below MOSAIC_MIN_PHOTOS; no photo that is used elsewhere on + // the page + photos?: { + eyebrow: string; + title: string; + images: ContentImage[]; + portfolioLink?: ReturnType; + }; + // Left out when there are no questions + faq?: { eyebrow: string; title: string; lead: RichText; items: FaqItem[] }; + offer: { + eyebrow: string; + title: string; + // The shoot's detail photo, else its main photo + image: ContentImage; + // Present exactly when the shoot's package is shown + pkg?: PricingPackage; + onRequest: ShootPageShared['offer']['onRequest']; + bookLabel: string; + askLabel: string; + bookLink: ReturnType; + askLink: { to: '/contact' }; + depositNote: string; + }; + closing: { + title: string; + lead: RichText; + buttonLabel: string; + link: ReturnType; + }; +} + +// The page photos left for the photo section: without the photos the story +// blocks and the package block already show, each photo once, in their own +// order (D14) +function remainingPhotos( + photos: readonly ContentImage[], + usedElsewhere: readonly ContentImage[], +): ContentImage[] { + const taken = new Set(usedElsewhere.map((image) => image.src)); + return photos.filter((image) => { + if (taken.has(image.src)) return false; + taken.add(image.src); + return true; + }); +} + +// The view of one shoot page, or undefined when the shoot type is missing +// or the content belongs to another shoot; the route then shows the +// not-found page (SECURITY-15) +export function shootPageView( + id: ShootTypeId, + page: ShootPageContent, + sources: ShootPageSources, +): ShootPageView | undefined { + const shoot = sources.shootTypes.find((item) => item.id === id); + if (shoot === undefined || page.id !== id) return undefined; + + const { shared, site, packages } = sources; + const path = shootPagePath(id); + + // Every figure that is data comes from its own source (D8, NFR-ST-04) + const values = { + reactietermijn: site.contactForm.replyTime, + aanbetaling: formatPrice(shared.deposit.amount), + locatie: page.process.location, + duur: page.process.duration, + opleverduur: page.process.deliveryTime, + }; + const fill = (text: string) => fillPlaceholders(text, values); + + const stories = page.stories.map((story) => ({ + ...story, + eyebrow: fill(story.eyebrow), + title: fill(story.title), + paragraphs: story.paragraphs.map((text) => fillRichText(text, values)), + })); + const faqItems = page.faq.items.map((item) => ({ + ...item, + question: fill(item.question), + answer: fillRichText(item.answer, values), + })); + + const offerImage = shoot.detailImage ?? shoot.image; + const photos = remainingPhotos(page.photos.images, [ + ...stories.flatMap((story) => + story.image === undefined ? [] : [story.image], + ), + offerImage, + ]); + + const pkg = shootPackage(shoot, packages); + const contactLink = shootContactLink(shoot, packages); + + return { + id, + path, + shoot, + breadcrumb: { + label: shared.breadcrumb.label, + items: [ + { label: shared.breadcrumb.home, to: '/' }, + { label: shared.breadcrumb.overview, to: SHOOT_TYPES_PATH }, + { label: shoot.name, to: path }, + ], + }, + intro: page.intro, + stories, + process: { + eyebrow: shared.process.eyebrow, + title: shared.process.title, + lead: shared.process.lead, + steps: PROCESS_STEP_ORDER.map((stepId) => ({ + id: stepId, + title: shared.process.steps[stepId].title, + text: fill(shared.process.steps[stepId].text), + })), + }, + ...(photos.length >= MOSAIC_MIN_PHOTOS + ? { + photos: { + eyebrow: shared.photos.eyebrow, + title: page.photos.title, + images: photos, + ...(sources.portfolioShoots.includes(id) + ? { portfolioLink: shootPortfolioLink(shoot) } + : {}), + }, + } + : {}), + ...(faqItems.length > 0 + ? { + faq: { + eyebrow: shared.faq.eyebrow, + title: page.faq.title, + lead: shared.faq.lead, + items: faqItems, + }, + } + : {}), + offer: { + eyebrow: page.offer.eyebrow, + title: page.offer.title, + image: offerImage, + ...(pkg !== undefined ? { pkg } : {}), + onRequest: shared.offer.onRequest, + bookLabel: shared.offer.bookLabel, + askLabel: shared.offer.askLabel, + bookLink: contactLink, + askLink: { to: '/contact' }, + depositNote: fill(shared.deposit.note), + }, + closing: { ...page.closing, link: contactLink }, + }; +} diff --git a/web/src/lib/shootPages.test.ts b/web/src/lib/shootPages.test.ts new file mode 100644 index 0000000..cfba395 --- /dev/null +++ b/web/src/lib/shootPages.test.ts @@ -0,0 +1,131 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import { shootTypeId, slugInput } from '../test/arbitraries'; +import { + SHOOT_TYPE_IDS, + SHOOT_TYPES_PATH, + shootIdFromPath, + shootIdFromSlug, + shootPagePath, +} from './shootPages'; + +// Paths as they could reach the app: a slug below the overview, with or +// without slashes after it, the overview itself, or anything else +const pathInput = fc.oneof( + fc + .tuple( + slugInput.filter((slug) => typeof slug === 'string'), + fc.constantFrom('', '/', '//'), + ) + .map(([slug, end]) => `${SHOOT_TYPES_PATH}/${slug as string}${end}`), + fc.constantFrom(SHOOT_TYPES_PATH, `${SHOOT_TYPES_PATH}/`, '/', ''), + fc.string(), +); + +describe('shootPagePath and SHOOT_TYPE_IDS', () => { + it('lists the five shoot types, each with a page below the overview', () => { + expect(SHOOT_TYPE_IDS).toEqual([ + 'newborn', + 'zwangerschap', + 'gezin', + 'loveshoot', + 'portret', + ]); + expect(SHOOT_TYPE_IDS.map(shootPagePath)).toEqual([ + '/soorten-fotoshoots/newborn', + '/soorten-fotoshoots/zwangerschap', + '/soorten-fotoshoots/gezin', + '/soorten-fotoshoots/loveshoot', + '/soorten-fotoshoots/portret', + ]); + }); +}); + +describe('shootIdFromSlug', () => { + it('knows every shoot type by its exact id', () => { + for (const id of SHOOT_TYPE_IDS) { + expect(shootIdFromSlug(id)).toBe(id); + } + }); + + it('ignores other cases, padding, slashes and non-text values', () => { + expect(shootIdFromSlug('Newborn')).toBeUndefined(); + expect(shootIdFromSlug(' newborn')).toBeUndefined(); + expect(shootIdFromSlug('newborn/')).toBeUndefined(); + expect(shootIdFromSlug('onzin')).toBeUndefined(); + expect(shootIdFromSlug('constructor')).toBeUndefined(); + expect(shootIdFromSlug(['newborn'])).toBeUndefined(); + expect(shootIdFromSlug(undefined)).toBeUndefined(); + }); + + it('gives back the id it was given (round trip)', () => { + fc.assert( + fc.property(shootTypeId, (id) => { + expect(shootIdFromSlug(id)).toBe(id); + }), + ); + }); + + it('gives a known id for exactly that slug, or undefined, and never throws (invariant)', () => { + fc.assert( + fc.property(slugInput, (slug) => { + const result = shootIdFromSlug(slug); + if (result !== undefined) { + expect(SHOOT_TYPE_IDS).toContain(result); + expect(result).toBe(slug); + } + }), + ); + }); +}); + +describe('shootIdFromPath', () => { + it('finds the shoot type of its page, with one trailing slash tolerated', () => { + expect(shootIdFromPath('/soorten-fotoshoots/newborn')).toBe('newborn'); + expect(shootIdFromPath('/soorten-fotoshoots/portret')).toBe('portret'); + expect(shootIdFromPath('/soorten-fotoshoots/newborn/')).toBe('newborn'); + }); + + it('gives undefined for any other path', () => { + expect(shootIdFromPath('/soorten-fotoshoots/onzin')).toBeUndefined(); + expect(shootIdFromPath('/soorten-fotoshoots')).toBeUndefined(); + expect(shootIdFromPath('/soorten-fotoshoots/')).toBeUndefined(); + expect(shootIdFromPath('/soorten-fotoshoots/Newborn')).toBeUndefined(); + expect( + shootIdFromPath('/soorten-fotoshoots/newborn/extra'), + ).toBeUndefined(); + expect( + shootIdFromPath('/soorten-fotoshoots/newborn//'), + ).toBeUndefined(); + expect( + shootIdFromPath('/soorten-fotoshoots%2Fnewborn'), + ).toBeUndefined(); + expect( + shootIdFromPath('/soorten-fotoshoots/newborn%2Fextra'), + ).toBeUndefined(); + expect(shootIdFromPath('/newborn')).toBeUndefined(); + expect(shootIdFromPath('')).toBeUndefined(); + }); + + it('gives back the id of every shoot page path (round trip)', () => { + fc.assert( + fc.property(shootTypeId, (id) => { + expect(shootIdFromPath(shootPagePath(id))).toBe(id); + }), + ); + }); + + it('gives a known id only for its exact page path, or undefined, and never throws (invariant)', () => { + fc.assert( + fc.property(pathInput, (path) => { + const result = shootIdFromPath(path); + if (result !== undefined) { + expect(SHOOT_TYPE_IDS).toContain(result); + expect(shootPagePath(result)).toBe( + path.endsWith('/') ? path.slice(0, -1) : path, + ); + } + }), + ); + }); +}); diff --git a/web/src/lib/shootPages.ts b/web/src/lib/shootPages.ts new file mode 100644 index 0000000..9821106 --- /dev/null +++ b/web/src/lib/shootPages.ts @@ -0,0 +1,51 @@ +import type { ShootTypeId } from '../content/types.ts'; +import type { RoutePath } from '../navigation.ts'; +import { isShootTypeId } from './portfolioFilters.ts'; + +// The overview of all shoot types; each shoot page is one level below it +export const SHOOT_TYPES_PATH = '/soorten-fotoshoots'; + +// Every shoot type id once. As a record, a new id in ShootTypeId is a type +// error until it is listed here. +const everyShootTypeId: Record = { + newborn: true, + zwangerschap: true, + gezin: true, + loveshoot: true, + portret: true, +}; + +export const SHOOT_TYPE_IDS: readonly ShootTypeId[] = Object.keys( + everyShootTypeId, +) as ShootTypeId[]; + +export type ShootPagePath = `${typeof SHOOT_TYPES_PATH}/${ShootTypeId}`; + +// The page of one shoot type, e.g. '/soorten-fotoshoots/newborn' (FR-ST-01) +export function shootPagePath(id: ShootTypeId): ShootPagePath { + return `${SHOOT_TYPES_PATH}/${id}`; +} + +// The inverse: a known id for exactly a known slug (letter case, spaces and +// slashes count), anything else gives undefined; never throws (SECURITY-05) +export function shootIdFromSlug(slug: unknown): ShootTypeId | undefined { + return isShootTypeId(slug, SHOOT_TYPE_IDS) ? slug : undefined; +} + +// The shoot type of a shoot page path: exactly '/soorten-fotoshoots/', +// with one trailing slash tolerated; any other path gives undefined +export function shootIdFromPath(pathname: string): ShootTypeId | undefined { + const prefix = `${SHOOT_TYPES_PATH}/`; + if (!pathname.startsWith(prefix)) return undefined; + const rest = pathname.slice(prefix.length); + return shootIdFromSlug(rest.endsWith('/') ? rest.slice(0, -1) : rest); +} + +type Assert = T; + +// Compile-time guard: every shoot page path is a route. A new shoot type +// without a route file is a type error here. Exported only because +// noUnusedLocals rejects an unused local type. +export type EveryShootHasARoute = Assert< + ShootPagePath extends RoutePath ? true : false +>; diff --git a/web/src/lib/storyLayout.test.ts b/web/src/lib/storyLayout.test.ts new file mode 100644 index 0000000..6141afb --- /dev/null +++ b/web/src/lib/storyLayout.test.ts @@ -0,0 +1,119 @@ +import fc from 'fast-check'; +import { describe, expect, it } from 'vitest'; +import newbornPage from '@/content/shootPages/newborn'; +import loveshootPage from '@/content/shootPages/loveshoot'; +import type { StoryBlock } from '@/content/types'; +import { imageWithOrientation, storyBlock } from '@/test/arbitraries'; +import { LANDSCAPE_RATIO, storyLayout } from './storyLayout'; + +const story = (width?: number, height?: number): StoryBlock => ({ + id: 's', + eyebrow: 'e', + title: 't', + paragraphs: [['p']], + ...(width === undefined || height === undefined + ? {} + : { image: { src: '/a.jpg', alt: 'a', width, height } }), +}); + +describe('storyLayout', () => { + it('lays out the four real newborn stories', () => { + const layout = storyLayout(newbornPage.stories); + expect(layout.map((item) => item.media)).toEqual([ + { aspectRatio: '4 / 5', mediaSize: 'medium' }, + { aspectRatio: '3 / 2', mediaSize: 'half' }, + { aspectRatio: '4 / 5', mediaSize: 'medium' }, + { aspectRatio: '4 / 5', mediaSize: 'medium' }, + ]); + expect(layout.map((item) => item.tone)).toEqual([ + 'paper', + 'alt', + 'paper', + 'alt', + ]); + expect(layout.map((item) => item.reverse)).toEqual([ + false, + true, + false, + true, + ]); + expect(layout.map((item) => item.priority)).toEqual([ + true, + false, + false, + false, + ]); + expect(layout[0].spacing).toBe('flushTop'); + expect(layout[1].spacing).toBe('default'); + }); + + it('gives text-only stories no media and no priority', () => { + const layout = storyLayout(loveshootPage.stories); + expect(layout[0].media).toBeDefined(); + for (const item of layout.slice(1)) { + expect(item).not.toHaveProperty('media'); + expect(item.priority).toBe(false); + } + expect(storyLayout([story()])[0].priority).toBe(false); + }); + + it('switches to landscape at exactly 1.2', () => { + expect(LANDSCAPE_RATIO).toBe(1.2); + expect(storyLayout([story(120, 100)])[0].media?.aspectRatio).toBe( + '3 / 2', + ); + expect(storyLayout([story(119, 100)])[0].media?.aspectRatio).toBe( + '4 / 5', + ); + }); + + it('gives nothing for no stories', () => { + expect(storyLayout([])).toEqual([]); + }); + + it('alternates, and decides ratio and width by the photo (invariant)', () => { + fc.assert( + fc.property( + fc.array( + fc.tuple( + storyBlock, + fc.option(imageWithOrientation, { nil: undefined }), + ), + { maxLength: 8 }, + ), + (pairs) => { + const stories = pairs.map(([block, image]) => ({ + ...block, + image, + })); + const layout = storyLayout(stories); + expect(layout).toHaveLength(stories.length); + layout.forEach((item, index) => { + const { image } = stories[index]; + expect(item.tone).toBe( + index % 2 === 0 ? 'paper' : 'alt', + ); + expect(item.reverse).toBe(index % 2 === 1); + expect(item.priority).toBe( + index === 0 && image !== undefined, + ); + if (image === undefined) { + expect(item.media).toBeUndefined(); + return; + } + const landscape = + image.width >= LANDSCAPE_RATIO * image.height; + expect(item.media).toEqual( + landscape + ? { aspectRatio: '3 / 2', mediaSize: 'half' } + : { + aspectRatio: '4 / 5', + mediaSize: 'medium', + }, + ); + }); + }, + ), + ); + }); +}); diff --git a/web/src/lib/storyLayout.ts b/web/src/lib/storyLayout.ts new file mode 100644 index 0000000..1546828 --- /dev/null +++ b/web/src/lib/storyLayout.ts @@ -0,0 +1,44 @@ +import type { StoryBlock } from '../content/types.ts'; + +// A photo is landscape when it is at least this much wider than it is high +export const LANDSCAPE_RATIO = 1.2; + +export interface StoryLayout { + // Band colour; the same rule as shootPageBands gives the story bands + tone: 'paper' | 'alt'; + // flushTop: no space above the first block, below the page head + spacing: 'flushTop' | 'default'; + // Photo in the right-hand column from `lg` + reverse: boolean; + // Only the first story's photo may load with priority + priority: boolean; + // Absent for a story without a photo + media?: { + aspectRatio: '3 / 2' | '4 / 5'; + mediaSize: 'half' | 'medium'; + }; +} + +// How each story block is laid out (FR-ST-03): tone and side from the +// index, the photo's shape and column width from its proportions. +export function storyLayout(stories: readonly StoryBlock[]): StoryLayout[] { + return stories.map((story, index) => { + const { image } = story; + const landscape = + image !== undefined && + image.width >= LANDSCAPE_RATIO * image.height; + return { + tone: index % 2 === 0 ? 'paper' : 'alt', + spacing: index === 0 ? 'flushTop' : 'default', + reverse: index % 2 === 1, + priority: index === 0 && image !== undefined, + ...(image === undefined + ? {} + : { + media: landscape + ? { aspectRatio: '3 / 2', mediaSize: 'half' } + : { aspectRatio: '4 / 5', mediaSize: 'medium' }, + }), + }; + }); +} diff --git a/web/src/navSubmenu.test.tsx b/web/src/navSubmenu.test.tsx new file mode 100644 index 0000000..3fe9cdf --- /dev/null +++ b/web/src/navSubmenu.test.tsx @@ -0,0 +1,226 @@ +import { act, screen, waitFor, within } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import shootTypes from '@/content/shootTypes'; +import { shootPagePath } from '@/lib/shootPages'; +import { FakeIntersectionObserver } from '@/test/fakeIntersectionObserver'; +import { mockViewport } from '@/test/navViewport'; +import { renderApp } from '@/test/renderApp'; + +// The real route tree with the real navigation: current state (D4), closing +// on a route change and the mobile menu (FR-ST-10) + +// The homepage's review carousel (Zag) needs an IntersectionObserver and +// Element.scrollTo, which jsdom lacks (as in app.test.tsx) +beforeEach(() => { + vi.stubGlobal('IntersectionObserver', FakeIntersectionObserver); + Element.prototype.scrollTo = () => {}; +}); + +afterEach(() => { + vi.unstubAllGlobals(); + FakeIntersectionObserver.reset(); + // @ts-expect-error -- jsdom has no Element.scrollTo of its own + delete Element.prototype.scrollTo; +}); + +const PARENT = 'Soorten fotoshoots'; +const TOGGLE = 'Submenu Soorten fotoshoots'; + +const header = () => screen.getByRole('banner'); +const panel = () => document.getElementById('submenu-soorten-fotoshoots')!; +const footerNav = () => screen.getByRole('navigation', { name: 'Footermenu' }); +const toggle = () => screen.getByRole('button', { name: TOGGLE }); +const hamburger = () => screen.getByTestId('nav-menu-toggle'); + +// By text: the name of a link in a closed (hidden) panel is empty +const panelLinks = () => within(panel()).getAllByRole('link', { hidden: true }); +const panelLink = (text: string) => + panelLinks().find((link) => link.textContent === text)!; +const parentLink = () => within(header()).getByRole('link', { name: PARENT }); +const footerLink = () => + within(footerNav()).getByRole('link', { name: PARENT }); + +async function renderDesktop(path: string) { + mockViewport(1280); + const rendered = await renderApp(path); + // The shell is there once the lazy route has loaded + await screen.findByRole('main'); + return { ...rendered, user: userEvent.setup() }; +} + +async function renderMobile(path: string) { + const viewport = mockViewport(375); + const rendered = await renderApp(path); + await screen.findByRole('main'); + return { ...rendered, viewport, user: userEvent.setup() }; +} + +describe('current page in the navigation (D4)', () => { + it.each(shootTypes)( + 'marks $name in the panel, the section on the parent and nothing in the footer', + async (shoot) => { + await renderDesktop(shootPagePath(shoot.id)); + for (const link of panelLinks()) { + if (link.textContent === shoot.name) { + expect(link).toHaveAttribute('aria-current', 'page'); + } else { + expect(link).not.toHaveAttribute('aria-current'); + } + } + expect(parentLink()).not.toHaveAttribute('aria-current'); + expect(parentLink()).toHaveAttribute('data-section-current'); + expect(footerLink()).not.toHaveAttribute('aria-current'); + }, + ); + + it('marks the parent and the footer on the overview, and no panel link', async () => { + await renderDesktop('/soorten-fotoshoots'); + expect(parentLink()).toHaveAttribute('aria-current', 'page'); + expect(parentLink()).toHaveAttribute('data-section-current'); + expect(footerLink()).toHaveAttribute('aria-current', 'page'); + for (const link of panelLinks()) { + expect(link).not.toHaveAttribute('aria-current'); + } + }); + + it('marks no panel link and no section on another page', async () => { + await renderDesktop('/portfolio'); + for (const link of panelLinks()) { + expect(link).not.toHaveAttribute('aria-current'); + } + expect(parentLink()).not.toHaveAttribute('data-section-current'); + expect(parentLink()).not.toHaveAttribute('aria-current'); + }); + + it('treats a trailing slash like the plain path (BR-NAV-04)', async () => { + await renderDesktop('/soorten-fotoshoots/newborn/'); + expect(panelLink('Newborn')).toHaveAttribute('aria-current', 'page'); + expect(parentLink()).toHaveAttribute('data-section-current'); + expect(parentLink()).not.toHaveAttribute('aria-current'); + expect(footerLink()).not.toHaveAttribute('aria-current'); + }); + + it('shows the page on a case variant, underlines the section but marks no link (router case rule)', async () => { + await renderDesktop('/soorten-fotoshoots/Newborn'); + // The router matches case-insensitively and renders the page, but + // its exact aria-current compares case-sensitively (Step 2). The + // only mark left is the breadcrumb's own current item (BR-SP-01). + const current = document.querySelectorAll('[aria-current="page"]'); + expect(current).toHaveLength(1); + expect(current[0]).not.toHaveAttribute('href'); + expect(current[0].closest('nav')).toHaveAccessibleName('Kruimelpad'); + expect(parentLink()).toHaveAttribute('data-section-current'); + }); + + it('keeps the panel in step with the shoot types (single source)', async () => { + await renderDesktop('/'); + expect(panelLinks().map((link) => link.textContent)).toEqual( + shootTypes.map((shoot) => shoot.name), + ); + expect(panelLinks().map((link) => link.getAttribute('href'))).toEqual( + shootTypes.map((shoot) => shootPagePath(shoot.id)), + ); + }); +}); + +describe('desktop submenu and the router', () => { + it('closes when the route changes', async () => { + const { router, user } = await renderDesktop('/'); + await user.click(toggle()); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + await act(() => router.navigate({ to: '/portfolio' })); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('closes on a link choice, opens the page and focuses main (BR-NAV-26)', async () => { + const { user } = await renderDesktop('/'); + await user.click(toggle()); + await user.click( + within(panel()).getByRole('link', { name: 'Zwangerschap' }), + ); + await waitFor(() => + expect( + screen.getByRole('heading', { level: 1 }), + ).toBeInTheDocument(), + ); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + await waitFor(() => + expect(document.getElementById('main')).toHaveFocus(), + ); + expect(panelLink('Zwangerschap')).toHaveAttribute( + 'aria-current', + 'page', + ); + }); + + it('does not close on the first render', async () => { + const { user } = await renderDesktop('/'); + await user.click(toggle()); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + }); +}); + +describe('mobile menu and the router', () => { + it('closes when the route changes without a menu click', async () => { + const { router, user } = await renderMobile('/contact'); + await user.click(hamburger()); + expect(hamburger()).toHaveAttribute('aria-expanded', 'true'); + await act(() => router.navigate({ to: '/portfolio' })); + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'); + }); + + it('closes on the browser back button (BR-NAV-32)', async () => { + const { router, user } = await renderMobile('/contact'); + await act(() => router.navigate({ to: '/portfolio' })); + await user.click(hamburger()); + expect(hamburger()).toHaveAttribute('aria-expanded', 'true'); + await act(async () => router.history.back()); + await waitFor(() => + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'), + ); + expect(router.state.location.pathname).toBe('/contact'); + }); + + it('expands the group when it opens on a shoot page', async () => { + const { user } = await renderMobile('/soorten-fotoshoots/loveshoot'); + await user.click(hamburger()); + const group = within(document.getElementById('mobile-nav')!).getByRole( + 'button', + { name: TOGGLE }, + ); + expect(group).toHaveAttribute('aria-expanded', 'true'); + expect( + within(document.getElementById('mobile-nav')!).getByRole('link', { + name: 'Loveshoot', + }), + ).toHaveAttribute('aria-current', 'page'); + }); +}); + +describe('crossing the lg breakpoint', () => { + it('closes the mobile menu that no longer exists', async () => { + const { viewport, user } = await renderMobile('/contact'); + await user.click(hamburger()); + expect(hamburger()).toHaveAttribute('aria-expanded', 'true'); + viewport.resize(1280); + viewport.resize(375); + await waitFor(() => + expect(hamburger()).toHaveAttribute('aria-expanded', 'false'), + ); + expect(document.body.style.overflow).toBe(''); + }); + + it('closes the desktop submenu that no longer exists', async () => { + const rendered = await renderMobile('/contact'); + rendered.viewport.resize(1280); + await waitFor(() => expect(toggle()).toBeInTheDocument()); + await rendered.user.click(toggle()); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + rendered.viewport.resize(375); + rendered.viewport.resize(1280); + await waitFor(() => + expect(toggle()).toHaveAttribute('aria-expanded', 'false'), + ); + }); +}); diff --git a/web/src/navigation.test.ts b/web/src/navigation.test.ts index 316c00b..14da7a7 100644 --- a/web/src/navigation.test.ts +++ b/web/src/navigation.test.ts @@ -1,5 +1,13 @@ import { describe, expect, it } from 'vitest'; -import { footerNav, mainNav } from './navigation'; +import shootTypes from './content/shootTypes'; +import { + SHOOT_TYPE_IDS, + SHOOT_TYPES_PATH, + shootIdFromPath, + shootPagePath, +} from './lib/shootPages'; +import { footerNav, hasChildren, mainNav } from './navigation'; +import sitePages from './sitePages'; describe('menu', () => { it('hoofdmenu heeft de vaste volgorde', () => { @@ -35,3 +43,66 @@ describe('menu', () => { } }); }); + +describe('submenu Soorten fotoshoots', () => { + const parent = mainNav.find((item) => item.to === SHOOT_TYPES_PATH); + + it('heeft de vijf shoots als kinderen, in de volgorde van de shoottypes', () => { + expect(parent?.children).toEqual( + shootTypes.map((shoot) => ({ + to: shootPagePath(shoot.id), + label: shoot.name, + })), + ); + expect(parent?.children?.map((child) => child.label)).toEqual([ + 'Newborn', + 'Zwangerschap', + 'Gezin', + 'Loveshoot', + 'Portretten', + ]); + }); + + it('heeft een menu-item voor elk shoottype en niets extra', () => { + expect( + parent?.children + ?.map((child) => shootIdFromPath(child.to)) + .toSorted(), + ).toEqual([...SHOOT_TYPE_IDS].toSorted()); + }); + + it('geeft alleen het hoofditem kinderen, op één niveau', () => { + const others = [ + ...mainNav.filter((item) => item !== parent), + ...footerNav, + ]; + for (const item of others) { + expect(item.children).toBeUndefined(); + } + for (const child of parent?.children ?? []) { + expect(child.children).toBeUndefined(); + } + }); + + it('hasChildren is alleen waar voor het hoofditem', () => { + expect(mainNav.filter(hasChildren)).toEqual([parent]); + expect(hasChildren({ to: '/', label: 'Home', children: [] })).toBe( + false, + ); + expect(hasChildren({ to: '/', label: 'Home' })).toBe(false); + }); + + it('heeft geen dubbele routes in het hoofditem en zijn kinderen', () => { + const paths = [ + parent?.to, + ...(parent?.children ?? []).map((c) => c.to), + ]; + expect(new Set(paths).size).toBe(paths.length); + }); + + it('linkt alleen naar geregistreerde, geïndexeerde pagina’s', () => { + for (const child of parent?.children ?? []) { + expect(sitePages[child.to]?.indexed).toBe(true); + } + }); +}); diff --git a/web/src/navigation.ts b/web/src/navigation.ts index d47e7b4..e019ba0 100644 --- a/web/src/navigation.ts +++ b/web/src/navigation.ts @@ -1,3 +1,5 @@ +import shootTypes from './content/shootTypes.ts'; +import { shootNavItems } from './lib/shootNavItems.ts'; import type { FileRoutesByTo } from './routeTree.gen.ts'; // Menu's verwijzen naar routes, en routes zijn code: het CMS kan geen @@ -7,6 +9,15 @@ export type RoutePath = keyof FileRoutesByTo; export interface NavItem { to: RoutePath; label: string; + // Sub-pages, one level only; an empty array counts as none + children?: readonly NavItem[]; +} + +// Whether the item has a submenu (a non-empty list of children) +export function hasChildren( + item: NavItem, +): item is NavItem & { children: readonly NavItem[] } { + return (item.children?.length ?? 0) > 0; } // Hoofdmenu: desktopnavigatie en mobiel menu @@ -14,7 +25,12 @@ export const mainNav: readonly NavItem[] = [ { to: '/', label: 'Home' }, { to: '/over-mij', label: 'Over mij' }, { to: '/portfolio', label: 'Portfolio' }, - { to: '/soorten-fotoshoots', label: 'Soorten fotoshoots' }, + { + to: '/soorten-fotoshoots', + label: 'Soorten fotoshoots', + // One source: a new shoot type shows up in the menu by itself (D5) + children: shootNavItems(shootTypes), + }, { to: '/contact', label: 'Contact' }, ]; diff --git a/web/src/routeTree.gen.ts b/web/src/routeTree.gen.ts index f336be9..55c6803 100644 --- a/web/src/routeTree.gen.ts +++ b/web/src/routeTree.gen.ts @@ -14,7 +14,12 @@ import { Route as ContactRouteImport } from './routes/contact' import { Route as OverMijRouteImport } from './routes/over-mij' import { Route as PortfolioRouteImport } from './routes/portfolio' import { Route as PrivacyverklaringRouteImport } from './routes/privacyverklaring' -import { Route as SoortenFotoshootsRouteImport } from './routes/soorten-fotoshoots' +import { Route as SoortenFotoshootsIndexRouteImport } from './routes/soorten-fotoshoots/index' +import { Route as SoortenFotoshootsGezinRouteImport } from './routes/soorten-fotoshoots/gezin' +import { Route as SoortenFotoshootsLoveshootRouteImport } from './routes/soorten-fotoshoots/loveshoot' +import { Route as SoortenFotoshootsNewbornRouteImport } from './routes/soorten-fotoshoots/newborn' +import { Route as SoortenFotoshootsPortretRouteImport } from './routes/soorten-fotoshoots/portret' +import { Route as SoortenFotoshootsZwangerschapRouteImport } from './routes/soorten-fotoshoots/zwangerschap' const IndexRoute = IndexRouteImport.update({ id: '/', @@ -41,11 +46,40 @@ const PrivacyverklaringRoute = PrivacyverklaringRouteImport.update({ path: '/privacyverklaring', getParentRoute: () => rootRouteImport, } as any) -const SoortenFotoshootsRoute = SoortenFotoshootsRouteImport.update({ - id: '/soorten-fotoshoots', - path: '/soorten-fotoshoots', +const SoortenFotoshootsIndexRoute = SoortenFotoshootsIndexRouteImport.update({ + id: '/soorten-fotoshoots/', + path: '/soorten-fotoshoots/', getParentRoute: () => rootRouteImport, } as any) +const SoortenFotoshootsGezinRoute = SoortenFotoshootsGezinRouteImport.update({ + id: '/soorten-fotoshoots/gezin', + path: '/soorten-fotoshoots/gezin', + getParentRoute: () => rootRouteImport, +} as any) +const SoortenFotoshootsLoveshootRoute = + SoortenFotoshootsLoveshootRouteImport.update({ + id: '/soorten-fotoshoots/loveshoot', + path: '/soorten-fotoshoots/loveshoot', + getParentRoute: () => rootRouteImport, + } as any) +const SoortenFotoshootsNewbornRoute = + SoortenFotoshootsNewbornRouteImport.update({ + id: '/soorten-fotoshoots/newborn', + path: '/soorten-fotoshoots/newborn', + getParentRoute: () => rootRouteImport, + } as any) +const SoortenFotoshootsPortretRoute = + SoortenFotoshootsPortretRouteImport.update({ + id: '/soorten-fotoshoots/portret', + path: '/soorten-fotoshoots/portret', + getParentRoute: () => rootRouteImport, + } as any) +const SoortenFotoshootsZwangerschapRoute = + SoortenFotoshootsZwangerschapRouteImport.update({ + id: '/soorten-fotoshoots/zwangerschap', + path: '/soorten-fotoshoots/zwangerschap', + getParentRoute: () => rootRouteImport, + } as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -53,7 +87,12 @@ export interface FileRoutesByFullPath { '/over-mij': typeof OverMijRoute '/portfolio': typeof PortfolioRoute '/privacyverklaring': typeof PrivacyverklaringRoute - '/soorten-fotoshoots': typeof SoortenFotoshootsRoute + '/soorten-fotoshoots/gezin': typeof SoortenFotoshootsGezinRoute + '/soorten-fotoshoots/loveshoot': typeof SoortenFotoshootsLoveshootRoute + '/soorten-fotoshoots/newborn': typeof SoortenFotoshootsNewbornRoute + '/soorten-fotoshoots/portret': typeof SoortenFotoshootsPortretRoute + '/soorten-fotoshoots/zwangerschap': typeof SoortenFotoshootsZwangerschapRoute + '/soorten-fotoshoots/': typeof SoortenFotoshootsIndexRoute } export interface FileRoutesByTo { '/': typeof IndexRoute @@ -61,7 +100,12 @@ export interface FileRoutesByTo { '/over-mij': typeof OverMijRoute '/portfolio': typeof PortfolioRoute '/privacyverklaring': typeof PrivacyverklaringRoute - '/soorten-fotoshoots': typeof SoortenFotoshootsRoute + '/soorten-fotoshoots/gezin': typeof SoortenFotoshootsGezinRoute + '/soorten-fotoshoots/loveshoot': typeof SoortenFotoshootsLoveshootRoute + '/soorten-fotoshoots/newborn': typeof SoortenFotoshootsNewbornRoute + '/soorten-fotoshoots/portret': typeof SoortenFotoshootsPortretRoute + '/soorten-fotoshoots/zwangerschap': typeof SoortenFotoshootsZwangerschapRoute + '/soorten-fotoshoots': typeof SoortenFotoshootsIndexRoute } export interface FileRoutesById { __root__: typeof rootRouteImport @@ -70,7 +114,12 @@ export interface FileRoutesById { '/over-mij': typeof OverMijRoute '/portfolio': typeof PortfolioRoute '/privacyverklaring': typeof PrivacyverklaringRoute - '/soorten-fotoshoots': typeof SoortenFotoshootsRoute + '/soorten-fotoshoots/gezin': typeof SoortenFotoshootsGezinRoute + '/soorten-fotoshoots/loveshoot': typeof SoortenFotoshootsLoveshootRoute + '/soorten-fotoshoots/newborn': typeof SoortenFotoshootsNewbornRoute + '/soorten-fotoshoots/portret': typeof SoortenFotoshootsPortretRoute + '/soorten-fotoshoots/zwangerschap': typeof SoortenFotoshootsZwangerschapRoute + '/soorten-fotoshoots/': typeof SoortenFotoshootsIndexRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath @@ -80,7 +129,12 @@ export interface FileRouteTypes { | '/over-mij' | '/portfolio' | '/privacyverklaring' - | '/soorten-fotoshoots' + | '/soorten-fotoshoots/gezin' + | '/soorten-fotoshoots/loveshoot' + | '/soorten-fotoshoots/newborn' + | '/soorten-fotoshoots/portret' + | '/soorten-fotoshoots/zwangerschap' + | '/soorten-fotoshoots/' fileRoutesByTo: FileRoutesByTo to: | '/' @@ -88,6 +142,11 @@ export interface FileRouteTypes { | '/over-mij' | '/portfolio' | '/privacyverklaring' + | '/soorten-fotoshoots/gezin' + | '/soorten-fotoshoots/loveshoot' + | '/soorten-fotoshoots/newborn' + | '/soorten-fotoshoots/portret' + | '/soorten-fotoshoots/zwangerschap' | '/soorten-fotoshoots' id: | '__root__' @@ -96,7 +155,12 @@ export interface FileRouteTypes { | '/over-mij' | '/portfolio' | '/privacyverklaring' - | '/soorten-fotoshoots' + | '/soorten-fotoshoots/gezin' + | '/soorten-fotoshoots/loveshoot' + | '/soorten-fotoshoots/newborn' + | '/soorten-fotoshoots/portret' + | '/soorten-fotoshoots/zwangerschap' + | '/soorten-fotoshoots/' fileRoutesById: FileRoutesById } export interface RootRouteChildren { @@ -105,7 +169,12 @@ export interface RootRouteChildren { OverMijRoute: typeof OverMijRoute PortfolioRoute: typeof PortfolioRoute PrivacyverklaringRoute: typeof PrivacyverklaringRoute - SoortenFotoshootsRoute: typeof SoortenFotoshootsRoute + SoortenFotoshootsGezinRoute: typeof SoortenFotoshootsGezinRoute + SoortenFotoshootsLoveshootRoute: typeof SoortenFotoshootsLoveshootRoute + SoortenFotoshootsNewbornRoute: typeof SoortenFotoshootsNewbornRoute + SoortenFotoshootsPortretRoute: typeof SoortenFotoshootsPortretRoute + SoortenFotoshootsZwangerschapRoute: typeof SoortenFotoshootsZwangerschapRoute + SoortenFotoshootsIndexRoute: typeof SoortenFotoshootsIndexRoute } declare module '@tanstack/react-router' { @@ -145,11 +214,46 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof PrivacyverklaringRouteImport parentRoute: typeof rootRouteImport } - '/soorten-fotoshoots': { - id: '/soorten-fotoshoots' + '/soorten-fotoshoots/': { + id: '/soorten-fotoshoots/' path: '/soorten-fotoshoots' - fullPath: '/soorten-fotoshoots' - preLoaderRoute: typeof SoortenFotoshootsRouteImport + fullPath: '/soorten-fotoshoots/' + preLoaderRoute: typeof SoortenFotoshootsIndexRouteImport + parentRoute: typeof rootRouteImport + } + '/soorten-fotoshoots/gezin': { + id: '/soorten-fotoshoots/gezin' + path: '/soorten-fotoshoots/gezin' + fullPath: '/soorten-fotoshoots/gezin' + preLoaderRoute: typeof SoortenFotoshootsGezinRouteImport + parentRoute: typeof rootRouteImport + } + '/soorten-fotoshoots/loveshoot': { + id: '/soorten-fotoshoots/loveshoot' + path: '/soorten-fotoshoots/loveshoot' + fullPath: '/soorten-fotoshoots/loveshoot' + preLoaderRoute: typeof SoortenFotoshootsLoveshootRouteImport + parentRoute: typeof rootRouteImport + } + '/soorten-fotoshoots/newborn': { + id: '/soorten-fotoshoots/newborn' + path: '/soorten-fotoshoots/newborn' + fullPath: '/soorten-fotoshoots/newborn' + preLoaderRoute: typeof SoortenFotoshootsNewbornRouteImport + parentRoute: typeof rootRouteImport + } + '/soorten-fotoshoots/portret': { + id: '/soorten-fotoshoots/portret' + path: '/soorten-fotoshoots/portret' + fullPath: '/soorten-fotoshoots/portret' + preLoaderRoute: typeof SoortenFotoshootsPortretRouteImport + parentRoute: typeof rootRouteImport + } + '/soorten-fotoshoots/zwangerschap': { + id: '/soorten-fotoshoots/zwangerschap' + path: '/soorten-fotoshoots/zwangerschap' + fullPath: '/soorten-fotoshoots/zwangerschap' + preLoaderRoute: typeof SoortenFotoshootsZwangerschapRouteImport parentRoute: typeof rootRouteImport } } @@ -161,7 +265,12 @@ const rootRouteChildren: RootRouteChildren = { OverMijRoute: OverMijRoute, PortfolioRoute: PortfolioRoute, PrivacyverklaringRoute: PrivacyverklaringRoute, - SoortenFotoshootsRoute: SoortenFotoshootsRoute, + SoortenFotoshootsGezinRoute: SoortenFotoshootsGezinRoute, + SoortenFotoshootsLoveshootRoute: SoortenFotoshootsLoveshootRoute, + SoortenFotoshootsNewbornRoute: SoortenFotoshootsNewbornRoute, + SoortenFotoshootsPortretRoute: SoortenFotoshootsPortretRoute, + SoortenFotoshootsZwangerschapRoute: SoortenFotoshootsZwangerschapRoute, + SoortenFotoshootsIndexRoute: SoortenFotoshootsIndexRoute, } export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) diff --git a/web/src/routes/soorten-fotoshoots/-shootPageSources.ts b/web/src/routes/soorten-fotoshoots/-shootPageSources.ts new file mode 100644 index 0000000..9a7b007 --- /dev/null +++ b/web/src/routes/soorten-fotoshoots/-shootPageSources.ts @@ -0,0 +1,24 @@ +import packages from '../../content/packages'; +import portfolioContent from '../../content/portfolioContent'; +import shootPageShared from '../../content/shootPageShared'; +import shootTypes from '../../content/shootTypes'; +import siteContent from '../../content/siteContent'; +import { shootTypesWithPhotos } from '../../lib/portfolioFilters'; +import type { ShootPageSources } from '../../lib/shootPageView'; +import { isPortfolioLive } from '../../lib/shootLinks'; +import sitePages from '../../sitePages'; + +// What every shoot page is built from besides its own content. The file +// name starts with '-' so the router does not take it for a route. +export const shootPageSources: ShootPageSources = { + shootTypes, + packages, + shared: shootPageShared, + site: siteContent, + // Same as on the overview: only shoots with photos in a live portfolio + portfolioShoots: isPortfolioLive(sitePages) + ? shootTypesWithPhotos(shootTypes, portfolioContent.photos).map( + (type) => type.id, + ) + : [], +}; diff --git a/web/src/routes/soorten-fotoshoots/gezin.tsx b/web/src/routes/soorten-fotoshoots/gezin.tsx new file mode 100644 index 0000000..9cc9251 --- /dev/null +++ b/web/src/routes/soorten-fotoshoots/gezin.tsx @@ -0,0 +1,30 @@ +import { createFileRoute } from '@tanstack/react-router'; +import NotFound from '../../components/StatusPage/NotFound'; +import ShootPage from '../../components/shoots/ShootPage/ShootPage'; +import StructuredData from '../../components/StructuredData/StructuredData'; +import gezinPage from '../../content/shootPages/gezin'; +import siteContent from '../../content/siteContent'; +import { shootPageView } from '../../lib/shootPageView'; +import { pageHead, shootPageGraph } from '../../seo'; +import { shootPageSources } from './-shootPageSources'; + +export const Route = createFileRoute('/soorten-fotoshoots/gezin')({ + head: () => pageHead('/soorten-fotoshoots/gezin'), + component: GezinPage, +}); + +// The gezin page. The structured data lives here, not in head(): head() is +// part of the main bundle, the component is split off, so the page texts +// only load with this page. +function GezinPage() { + const view = shootPageView('gezin', gezinPage, shootPageSources); + if (view === undefined) return ; + return ( + <> + {shootPageGraph(view, siteContent).map((data) => ( + + ))} + + + ); +} diff --git a/web/src/routes/soorten-fotoshoots.tsx b/web/src/routes/soorten-fotoshoots/index.tsx similarity index 57% rename from web/src/routes/soorten-fotoshoots.tsx rename to web/src/routes/soorten-fotoshoots/index.tsx index 83acbe2..2e00b29 100644 --- a/web/src/routes/soorten-fotoshoots.tsx +++ b/web/src/routes/soorten-fotoshoots/index.tsx @@ -1,20 +1,21 @@ import { createFileRoute } from '@tanstack/react-router'; -import CallToAction from '../components/CallToAction/CallToAction'; -import LinkButton from '../components/LinkButton'; -import PageIntro from '../components/PageIntro/PageIntro'; -import RichParagraph from '../components/RichParagraph/RichParagraph'; -import ShootList from '../components/shoots/ShootList/ShootList'; -import packages from '../content/packages'; -import portfolioContent from '../content/portfolioContent'; -import shootTypes from '../content/shootTypes'; -import shootTypesPageContent from '../content/shootTypesPageContent'; -import siteContent from '../content/siteContent'; -import { shootTypesWithPhotos } from '../lib/portfolioFilters'; -import { isPortfolioLive } from '../lib/shootLinks'; -import { jsonLdScript, pageHead, shootServices, webPage } from '../seo'; -import sitePages from '../sitePages'; +import CallToAction from '../../components/CallToAction/CallToAction'; +import LinkButton from '../../components/LinkButton'; +import PageIntro from '../../components/PageIntro/PageIntro'; +import RichParagraph from '../../components/RichParagraph/RichParagraph'; +import ShootList from '../../components/shoots/ShootList/ShootList'; +import StructuredData from '../../components/StructuredData/StructuredData'; +import packages from '../../content/packages'; +import portfolioContent from '../../content/portfolioContent'; +import shootTypes from '../../content/shootTypes'; +import shootTypesPageContent from '../../content/shootTypesPageContent'; +import siteContent from '../../content/siteContent'; +import { shootTypesWithPhotos } from '../../lib/portfolioFilters'; +import { isPortfolioLive } from '../../lib/shootLinks'; +import { pageHead, shootServices, webPage } from '../../seo'; +import sitePages from '../../sitePages'; -export const Route = createFileRoute('/soorten-fotoshoots')({ +export const Route = createFileRoute('/soorten-fotoshoots/')({ head: () => pageHead('/soorten-fotoshoots'), component: PhotoshootTypes, }); @@ -28,16 +29,11 @@ function PhotoshootTypes() { {/* The structured data lives here, not in head(): head() is part of the main bundle, the component is split off, so the shoot texts only load with this page. Google reads JSON-LD anywhere - in the page; jsonLdScript escapes <, > and &. */} - , <, >, &, quotes, backslashes and line separators +export const plainText = fc.oneof( + fc.string({ maxLength: 20 }).filter((text) => !/[{}]/.test(text)), + fc.constantFrom('', '<', '>', '&', '"', '\\', '
', ' '), +); + +// Text with placeholders in it, as an editor might write it. A stray brace +// is only ever an opening one: an opening and a closing brace around a +// filled placeholder could otherwise form a new one, which content never +// contains. +export const textWithPlaceholders = fc + .array( + fc.oneof( + plainText, + placeholderName.map((name) => `{${name}}`), + fc.constant('{'), + ), + { maxLength: 6 }, + ) + .map((pieces) => pieces.join('')); + +// Every route of the site +export const knownRoutePath = fc.constantFrom( + ...(Object.keys(sitePages) as RoutePath[]), +); + +// A link inside running text: a known route, optionally an anchor +export const inlineLink: fc.Arbitrary = fc.record( + { to: knownRoutePath, hash: pathSegment, text: textWithPlaceholders }, + { requiredKeys: ['to', 'text'] }, +); + +// Running text as text pieces and links, hostile characters included +export const richText: fc.Arbitrary = fc.array( + fc.oneof(textWithPlaceholders, inlineLink), + { maxLength: 5 }, +); + +const slug = fc.stringMatching(/^[a-z0-9-]{1,12}$/); + +// A story block, with or without an image +export const storyBlock: fc.Arbitrary = fc.record( + { + id: slug, + eyebrow: textWithPlaceholders, + title: textWithPlaceholders, + paragraphs: fc.array(richText, { minLength: 1, maxLength: 3 }), + image: contentImage, + }, + { requiredKeys: ['id', 'eyebrow', 'title', 'paragraphs'] }, +); + +export const faqItem: fc.Arbitrary = fc.record({ + id: slug, + question: textWithPlaceholders, + answer: richText, +}); + +// FAQ items with unique ids, as one page has them +export const faqItems = fc.uniqueArray(faqItem, { + selector: (item) => item.id, + maxLength: 6, +}); + +const processStepIds: ProcessStepId[] = [ + 'aanvragen', + 'datum', + 'aanbetaling', + 'shoot', + 'bewerking', + 'oplevering', +]; + +const processStepContent: fc.Arbitrary = fc.record({ + title: plainText, + text: textWithPlaceholders, +}); + +// All six steps, with the keys in a random order: the content's key order +// must not decide the order on the page +const processSteps: fc.Arbitrary> = fc + .tuple( + fc.shuffledSubarray(processStepIds, { + minLength: processStepIds.length, + maxLength: processStepIds.length, + }), + fc.array(processStepContent, { + minLength: processStepIds.length, + maxLength: processStepIds.length, + }), + ) + .map( + ([order, steps]) => + Object.fromEntries( + order.map((id, index) => [id, steps[index]]), + ) as Record, + ); + +// The shared shoot page texts as the CMS could deliver them +export const shootPageShared: fc.Arbitrary = fc.record({ + breadcrumb: fc.record({ + label: plainText, + home: plainText, + overview: plainText, + }), + process: fc.record({ + eyebrow: plainText, + title: plainText, + lead: plainText, + steps: processSteps, + }), + deposit: fc.record({ + amount: fc.integer({ min: 1, max: 999 }), + note: textWithPlaceholders, + }), + photos: fc.record({ eyebrow: plainText }), + faq: fc.record({ eyebrow: plainText, lead: richText }), + offer: fc.record({ + bookLabel: plainText, + askLabel: plainText, + onRequest: fc.record({ + price: plainText, + text: plainText, + linkLabel: plainText, + }), + }), +}); + +// One shoot page as the CMS could deliver it, for the given shoot or any. +// The photos deliberately repeat each other, the story images and the +// images in `reuse` (pass the shoot's main and detail photo), so the rule +// that a photo appears once per page is put to the test. +export function shootPageContent( + id?: ShootTypeId, + reuse: readonly ContentImage[] = [], +): fc.Arbitrary { + const stories = fc.uniqueArray(storyBlock, { + selector: (story) => story.id, + maxLength: 6, + }); + return stories.chain((storyList) => { + const used = [ + ...storyList.flatMap((story) => + story.image === undefined ? [] : [story.image], + ), + ...reuse, + ]; + const photo = + used.length > 0 + ? fc.oneof(contentImage, fc.constantFrom(...used)) + : contentImage; + const photos = fc + .tuple( + fc.array(photo, { maxLength: 6 }), + fc.array(fc.nat(), { maxLength: 2 }), + ) + .map(([list, repeats]) => + list.length === 0 + ? list + : [...list, ...repeats.map((n) => list[n % list.length])], + ); + return fc.record({ + id: id === undefined ? shootTypeId : fc.constant(id), + intro: fc.record({ + eyebrow: plainText, + title: plainText, + text: plainText, + }), + stories: fc.constant(storyList), + // The values of {locatie}, {duur} and {opleverduur} + process: fc.record({ + location: plainText, + duration: plainText, + deliveryTime: plainText, + }), + photos: fc.record({ title: plainText, images: photos }), + faq: fc.record({ title: plainText, items: faqItems }), + offer: fc.record({ eyebrow: plainText, title: plainText }), + closing: fc.record({ + title: plainText, + lead: richText, + buttonLabel: plainText, + }), + }); + }); +} + +// What could end up where a shoot slug is expected: the known ids, other +// letter cases, slashes, '..', an encoded slash, whitespace, markup, any +// string, and values that are no string at all +export const slugInput: fc.Arbitrary = fc.oneof( + shootTypeId, + shootTypeId.map((id) => id.toUpperCase()), + shootTypeId.map((id) => id[0].toUpperCase() + id.slice(1)), + fc + .tuple( + fc.constantFrom('', '/', '//', ' ', '\t', '..', '../', '%2F'), + shootTypeId, + fc.constantFrom( + '', + '/', + '//', + ' ', + '\n', + '/..', + '%2F', + '', + ), + ) + .map((parts) => parts.join('')), + fc.constantFrom( + '', + '..', + '%2F', + '', + 'newborn/extra', + 'newborn%2Fextra', + 'onzin', + 'constructor', + '__proto__', + ), + fc.string(), + fc.oneof( + fc.integer(), + fc.boolean(), + fc.constant(null), + fc.constant(undefined), + fc.array(shootTypeId, { maxLength: 2 }), + 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 = 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( + '', + '<', + '>', + '&', + 'x'.repeat(120), + ' ', + ' ', + 'ac&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 = 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; + }), + ); diff --git a/web/src/test/navArbitraries.ts b/web/src/test/navArbitraries.ts new file mode 100644 index 0000000..54ef470 --- /dev/null +++ b/web/src/test/navArbitraries.ts @@ -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 = 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 = 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 = 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 => + 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 = 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() }, +); diff --git a/web/src/test/navViewport.ts b/web/src/test/navViewport.ts new file mode 100644 index 0000000..f3e201f --- /dev/null +++ b/web/src/test/navViewport.ts @@ -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) }); + } + }); + }, + }; +} diff --git a/web/src/test/renderApp.tsx b/web/src/test/renderApp.tsx new file mode 100644 index 0000000..63eaef7 --- /dev/null +++ b/web/src/test/renderApp.tsx @@ -0,0 +1,33 @@ +import { ChakraProvider } from '@chakra-ui/react'; +import { + createMemoryHistory, + createRouter, + RouterProvider, +} from '@tanstack/react-router'; +import { render, screen } from '@testing-library/react'; +import { expect } from 'vitest'; +import ErrorPage from '../components/StatusPage/ErrorPage'; +import { routeTree } from '../routeTree.gen'; +import system from '../theme'; + +// De echte app: route tree, router-opties en thema zoals in main.tsx +export async function renderApp(path: string) { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [path] }), + scrollRestoration: true, + defaultErrorComponent: ErrorPage, + }); + await router.load(); + const result = render( + + + , + ); + return { ...result, router }; +} + +export const expectShell = () => { + expect(screen.getByRole('banner')).toBeInTheDocument(); + expect(screen.getByRole('contentinfo')).toBeInTheDocument(); +};