Adds the functional design of the second unit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 22:17:56 +01:00
co-authored by Claude Opus 5.5
parent df10832086
commit 5a0845ab57
7 changed files with 826 additions and 0 deletions
@@ -0,0 +1,211 @@
# Business Rules - Unit 2: Display fallbacks
Rule ids are scoped to this feature and this unit. "Source" points at a requirement (FR/NFR), a design decision (D1 to D13 in [application-design.md](../../../inception/application-design/application-design.md)) or a unit 1 rule ([business-rules.md](../../start-migration/functional-design/business-rules.md)). Flows and evidence: [business-logic-model.md](business-logic-model.md). Components: [frontend-components.md](frontend-components.md). Data: [domain-entities.md](domain-entities.md).
Groups: BR-RVL reveal, BR-IMG images, BR-NAV menu without JavaScript, BR-NJS other fallbacks, BR-PRE first-photo preload, BR-DMS measurement, BR-DTS tests.
**Provisional** marks a choice that belongs to the owner. The recommendation is written down; the alternatives are in section 5.
All statements marked "verified" were checked on 2026-10-31 against `web/src`, the built `web/dist/client` and a real Chrome (Playwright, local preview server) without changing any code.
## 1. Decision flowcharts
### 1.1 What `Reveal` does after hydration
```mermaid
graph TD
Start["Reveal mounted in the browser"] --> Support{"IntersectionObserver available and no reduced motion"}
Support -->|"no"| Settled["Settled: visible, nothing to animate"]
Support -->|"yes"| Measure["Layout effect: read top edge of the element"]
Measure --> Below{"Top edge at or below the viewport bottom"}
Below -->|"no"| Settled
Below -->|"yes"| Hidden["Hidden: opacity 0, no transition"]
Hidden --> Seen{"12 percent visible above the 60 px line"}
Seen -->|"yes, once"| Revealed["Revealed: fades in with the delay"]
classDef state fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
classDef step fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
classDef choice fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
class Settled,Hidden,Revealed state;
class Start,Measure step;
class Support,Below,Seen choice;
```
Text alternative: after hydration an element that is wholly below the viewport is hidden without a transition and fades in once on scroll; every other element stays visible.
### 1.2 Which markup a deferred photo gets
```mermaid
graph TD
Img["DeferredImage renders"] --> Pair["Image without src plus a noscript twin with src"]
Pair --> Js{"JavaScript on"}
Js -->|"yes"| Today["Twin is plain text to the parser: no request, no preload"]
Today --> Load["After load and in view the effect sets src"]
Js -->|"no"| Hide["CSS hides the empty image, the twin shows the photo"]
classDef step fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
classDef choice fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
classDef result fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
class Img,Pair step;
class Js choice;
class Today,Load,Hide result;
```
Text alternative: a deferred photo is rendered as an empty image plus a noscript twin; with JavaScript the twin is ignored, without it the CSS hides the empty image and shows the twin.
### 1.3 How a page gets its first-photo preload
```mermaid
graph TD
Photo["First photo of a page"] --> Plain{"A plain img with src and high priority"}
Plain -->|"yes"| React["React hoists a preload link into the head"]
Plain -->|"no, inside picture"| Explicit["Route head adds preloadImage with media"]
Photo --> Hidden{"Hidden at some breakpoint"}
Hidden -->|"yes"| Lazy["Image is lazy: no fetch, no preload there"]
Photo --> Deferred{"Deliberately deferred"}
Deferred -->|"yes"| None["No preload, see BR-PRE-08"]
classDef step fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
classDef choice fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
classDef result fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
class Photo step;
class Plain,Hidden,Deferred choice;
class React,Explicit,Lazy,None result;
```
Text alternative: a plain high-priority photo is preloaded by React itself, a photo in a picture element needs an explicit media-bound link, hidden photos are lazy and deferred photos get no preload.
## 2. Rules
### BR-RVL: Reveal and `useReveal`
| Id | Rule | Source |
|---|---|---|
| BR-RVL-01 | The first render of `Reveal`, on the server and in the browser, is visible: `data-reveal="visible"`, `opacity` 1, no transform, no transition. The prerendered HTML therefore shows all `Reveal` content, with and without JavaScript. | FR-PR-09, FR-PR-11; D7; BR-HYD-01 |
| BR-RVL-02 | After hydration each `Reveal` decides in a `useLayoutEffect` whether to hide itself. The effect reads `element.getBoundingClientRect().top` and `window.innerHeight` and hides the element only when `top >= innerHeight`. A layout effect runs after the DOM commit and before the next paint, so hiding a below-the-fold element is never painted as a flash. All `Reveal`s of a commit read before any of them writes (state is set after the effects), so the reads cost one layout. React 19 does not warn for `useLayoutEffect` during prerendering (no such message in `react-dom-server.*.development.js`). | FR-PR-09; D6, D7 |
| BR-RVL-03 | "In view at load" means: not wholly below the bottom edge of the viewport. This includes an element that is partly visible, one taller than the screen, and one above the viewport (scroll restoration, `#anchor` jump). The 60 px trigger margin is not part of this test: an element whose top sits in that band was painted from the HTML, and hiding it would make it disappear. | FR-PR-09 |
| BR-RVL-04 | The hidden state is `opacity` 0 and `translateY(24px)` with `transition: none`. The change from settled to hidden therefore never animates. | FR-PR-09 |
| BR-RVL-05 | The reveal trigger is unchanged: one `IntersectionObserver`, `threshold` 0.12, `rootMargin` `0px 0px -60px 0px`, disconnected after the first intersection. When it fires, the element becomes revealed: `opacity` 1, no transform, `transitionProperty` `opacity, transform`, duration token `reveal` (0.8 s), `smooth`, `transitionDelay` `${delay}s`. | FR-PR-09 ("as it does now") |
| BR-RVL-06 | `delay` only matters for an element that was hidden and is revealed. Elements in view at load show at once, so a staggered row (`Pricing` cards, `PhotoMosaic` tiles) that is in view at load appears together. Rows revealed on scroll keep their stagger. | FR-PR-09 |
| BR-RVL-07 | With `prefers-reduced-motion: reduce` nothing is hidden and no observer is created. The layout effect reads `window.matchMedia('(prefers-reduced-motion: reduce)').matches` itself: Chakra's `useMediaQuery` still holds its server-safe `false` while the layout effect runs (BR-HYD-07), and a late `true` would first hide and then animate. `useReveal` no longer calls `useMediaQuery`. In addition `Reveal` carries `_motionReduce` `{ opacity: 1, transform: 'none', transition: 'none' }`, so a preference that changes while elements are hidden shows them at once. | FR-PR-10 |
| BR-RVL-08 | Without `IntersectionObserver` (old browsers, jsdom) the element stays settled and visible. | FR-PR-09; BR-HYD-05 |
| BR-RVL-09 | The transitions are one-way: settled stays settled, hidden becomes revealed, revealed stays revealed. An element never goes back to hidden, also not when it scrolls out of view. The observer is disconnected on unmount. | FR-PR-09 |
| BR-RVL-10 | **Provisional.** A `Reveal` that mounts after hydration (client navigation, the lazy testimonial and contact content) follows the same rules; there is no `useHydrated` branch. Content in view when the new page mounts appears at once, content below the viewport fades in on scroll. Reason: FR-PR-09 asks that content in view never waits for an animation, and the same rule on both paths is simpler to test and cannot diverge from the first load. Consequence: the entrance fade of the first screen on client navigation, which exists today, is dropped. Edge: the router scrolls to the top after the new page mounts, so on a navigation from a scrolled page, elements that end up below the fold after that scroll may already be settled and not fade. | FR-PR-09 |
| BR-RVL-11 | `Reveal` keeps its props (`BoxProps` plus `delay`) and all 21 call sites stay as they are (list in [frontend-components.md § 4](frontend-components.md)). `useReveal<T>()` returns `{ ref, visible, animated }`: `visible` is `false` only while hidden; `animated` is `true` only once revealed. `data-reveal` keeps the values `visible` and `hidden` that tests select on. | FR-PR-09 |
| BR-RVL-12 | The decision is pure logic in `src/lib/revealPhase.ts`: `startsHidden(top, viewportHeight)` and `nextRevealPhase(phase, event)`. The hook only reads the DOM and calls them. `src/lib` has a 100 % coverage threshold. | NFR-PR-Q-01, Q-02 |
| BR-RVL-13 | The existing trigger cannot reveal an element taller than `(innerHeight - 60) / 0.12` (6358 px at 823 px, 4833 px at 640 px, 4233 px at 568 px): the 12 % threshold is then never reached. Observed 2026-10-31: on `/portfolio` at 412 x 823 the grid wrapper (4537 px high, top at 377 px) stayed `hidden` for good until scrolled, although it was in view; the grid showed as an empty area under the filters. BR-RVL-03 removes this for elements that start in view. For an element that starts below the fold the limit stays. Code generation checks the tallest `Reveal` on every page at 320, 360 and 412 px wide (V-D6). | FR-PR-09 |
| BR-RVL-14 | Anchors and scroll restoration are decided at hydration time, as today. `/?pakket=...#contact` and `/#prijzen` jump before hydration (the element exists in the HTML), so the target is in view and settled. Smooth scrolling to `#contact` after hydration passes hidden sections; they fade as they intersect, as now. A scroll position restored after hydration reveals content by scrolling, as now. | FR-PR-07, FR-PR-09 |
### BR-IMG: Images and `DeferredImage`
| Id | Rule | Source |
|---|---|---|
| BR-IMG-01 | `DeferredImage` renders two siblings: the deferred `<img>` exactly as today, and `<noscript>` with a twin `<img>`. The twin has `src` (`image.src`), `alt`, `width` and `height` from the image, `decoding="async"`, no `loading` attribute, and the same style props as the first image, so it has the same class and the same box. It leaves out `id`, `data-testid` and `ref`. The props of `DeferredImage` do not change. | FR-PR-11; D8 |
| BR-IMG-02 | The deferred `<img>` carries `data-deferred`. The no-JavaScript CSS hides `img[data-deferred]:not([src])` with `display: none !important`. Without it Chrome draws the empty image as a sized box with a broken-image icon and the alt text inside it (verified on `/soorten-fotoshoots` without JavaScript: `complete` is `true`, `naturalWidth` 0, the box keeps its size). Hidden with `display: none`, the empty image is not announced either, so a screen reader without JavaScript meets the photo once, in the twin. | FR-PR-11 |
| BR-IMG-03 | With JavaScript nothing changes. The HTML parser reads `noscript` content as text when scripting is on, so the twin is not fetched. React renders no `noscript` children in the browser (`shouldSetTextContent` is true for `noscript` in `react-dom-client`) and ignores them when hydrating, so there is no mismatch. Prerendering skips the preload for an `img` inside `noscript` (`tagScope & 1` in `react-dom-server`), so no `<link rel="preload">` is added. Code generation proves "no extra request" with a request log (V-D2). | FR-PR-11; D6, D8 |
| BR-IMG-04 | The no-JavaScript CSS gives `noscript` `display: contents`, so the wrapper element takes no part in flex, grid or positioning of the twin (absolute photos in `PhotoMosaic`, `MediaText` and the `Pricing` decorations keep their containing block either way). | FR-PR-11 |
| BR-IMG-05 | Without JavaScript browsers do not honour `loading="lazy"` (Chrome disables it when scripting is off), so every twin on a page loads at once; on `/portfolio` that is all photos of the grid. The twin carries no `loading` attribute for that reason. Accepted: the visitors are rare and the alternative (load nothing) leaves empty frames. | FR-PR-11 |
| BR-IMG-06 | Photos that are already in the HTML with a `src` need nothing: `Image` with `priority` in `FramedImage`, the hero's first slide, `ContactAside` (`<source srcSet>` in `<picture>` works without JavaScript), the `ContactDetails` portrait, the logos. Inventory of every image path: [business-logic-model.md § 2.3](business-logic-model.md). | FR-PR-11 |
| BR-IMG-07 | Hero slides other than the first need JavaScript to appear and stay out of the HTML (the first render loads only the active slide). Without JavaScript the visitor sees slide 1, its text and the call to action. | FR-PR-13 |
| BR-IMG-08 | The `Lightbox` needs JavaScript. Every tile of `PortfolioGrid` is a plain link to the large photo (`href` is `item.full.src`), so without JavaScript a tile opens the photo file itself. | FR-PR-13 |
| BR-IMG-09 | The testimonial placeholder's visually hidden review copies contain deferred photos too, so their twins also load without JavaScript although nobody sees them. Accepted (review photos only); see BR-NJS-05. | FR-PR-11 |
| BR-IMG-10 | The twin never changes what a page looks like with JavaScript, so hydration needs no new rule: the first render still has no `src` on either side (BR-HYD-01 and unit 1 section 3). | FR-PR-05 |
### BR-NAV: The menu without JavaScript
| Id | Rule | Source |
|---|---|---|
| BR-NAV-01 | The CSS for all no-JavaScript fallbacks (menu, deferred photos, hidden controls) lives in one `<noscript><style>` in the `<head>`, rendered by the root shell after `HeadContent`. That position is valid HTML: `style` is only allowed in `noscript` inside `head`, not in `body`. The two menu links are `<noscript>` elements in the body. This replaces the application design's single `NoScriptNav` that held the CSS as well. | FR-PR-12; D9 |
| BR-NAV-02 | The CSS is allowed by `style-src 'self' 'unsafe-inline'` (unchanged, `securityHeaders.ts`). The script step leaves it alone: `inlineScripts.ts` treats `noscript` as a raw-text element and only looks for `<script>`; the CSS contains none. The CSS has no `</`, no `url(` and no `@import` (a test checks this), so it cannot end the `noscript` early or fetch anything. It holds no e-mail address, so the address scan stays clean. | NFR-PR-SEC-01; BR-SCR-02, BR-MAIL-10 |
| BR-NAV-03 | Open link: `<a class="ns-menu-open" href="#mobile-nav" aria-label="Menu openen">` with three bars, inside the header's right-hand `div` before the hamburger. It is 44 x 44 px like the button. It is hidden from `64rem` up (`lg`), where the header shows the links. `aria-label` reuses the existing string. | FR-PR-12 |
| BR-NAV-04 | The hamburger `button` gets `data-requires-js` and is hidden without JavaScript (BR-NJS-01). | FR-PR-12, FR-PR-13 |
| BR-NAV-05 | `#mobile-nav:target { clip-path: inset(0); visibility: visible }`. No `!important`: an id selector outranks the single-class selectors Emotion generates, also those inside media queries (verified: with the rule the computed values were `inset(0px)` and `visible`). `display` is not touched, so the panel stays `none` from `lg` up even when the address ends in `#mobile-nav`. The existing `clip-path` and `visibility` transition animates the opening, and `_motionReduce` on the panel still switches it off. | FR-PR-12 |
| BR-NAV-06 | The shoot submenu is expanded without JavaScript: `#mobile-nav [id^="mobile-group-"] { grid-template-rows: 1fr; visibility: visible; transition: none }` always, not only on `:target` (selector weight 1,1,0 beats Emotion's single class). The chevron button of the group carries `data-requires-js` and is hidden. | FR-PR-12 |
| BR-NAV-07 | Close link: `<a class="ns-menu-close" href="#site-header">` with the existing text "Menu sluiten", as the first child of the panel's content, so it is the first Tab stop after opening. `#site-header` is the fixed `header`, which gets an `id` for this. A fragment navigation to a fixed element does not scroll: verified in Chrome with the page at `scrollY` 300, opening via `#mobile-nav` and closing via `#site-header` both left it at 300 (Firefox and Safari: V-D4). Rejected: `href="#"` (scrolls to the top of the page) and `href="#main"` (scrolls to the content). | FR-PR-12 |
| BR-NAV-08 | Focus order without JavaScript: skip link, logo, open link; closed, the panel is `visibility: hidden`, so none of its links is focusable. After activating the open link the browser's sequential focus starting point is `#mobile-nav`, so the next Tab goes to the close link, then Home, Over mij, Portfolio, Soorten fotoshoots, Newborn, Zwangerschap, Gezin, Loveshoot, Portretten, Contact (verified, in that order). Both links get a visible focus ring (`:focus-visible` outline in the CSS). | FR-PR-12; WCAG 2.4.3, 2.4.7 |
| BR-NAV-09 | Desktop (from `lg`): all top-level links are in the header and work. The panel with the five shoot links is `visibility: hidden`, so by keyboard those links are unreachable, and the chevron button does nothing. **Provisional:** `[data-submenu]:focus-within > [data-submenu-panel] { visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition: none }` opens it while focus is on the "Soorten fotoshoots" link or inside the panel, and the chevron is hidden (`data-requires-js`). `transition: none` is needed: the panel's `visibility` transition starts hidden, and a Tab pressed in the same frame skipped the panel (observed); with a 150 ms pause, Tab reached Newborn to Gezin in order. Mouse users click "Soorten fotoshoots", which opens the overview where each shoot has its "Lees meer" link; hover opening is not offered (the 0.75rem gap between link and panel would close it). | FR-PR-12; BR-NAV-21, 27 (earlier feature: no hover opening) |
| BR-NAV-10 | The JavaScript menu stays as it is. The additions are `id="site-header"`, `data-requires-js` on the hamburger and the two chevron buttons, `data-submenu` on the submenu wrapper and `data-submenu-panel` on its panel, and the close link. With JavaScript these attributes do nothing (`noscript` content is not rendered). `useReducer`, ARIA and focus handling are not touched. | FR-PR-12; D9 |
| BR-NAV-11 | Opening and closing add history entries (`#mobile-nav`, `#site-header`). Back from a page reached through the menu can return to the home page with the menu open. Accepted. | FR-PR-12 |
| BR-NAV-12 | A visitor with JavaScript switched on whose script fails to load gets no `noscript` content, so the hamburger stays inert. That case is not covered by FR-PR-12 ("without JavaScript") and not by this design; the desktop links still work. | FR-PR-12 |
### BR-NJS: Other fallbacks without JavaScript
| Id | Rule | Source |
|---|---|---|
| BR-NJS-01 | One marker, `data-requires-js`, means "no function without JavaScript". The no-JavaScript CSS hides it: `[data-requires-js] { display: none !important }`. `!important` is needed because style props set `display` on several of these elements, and Emotion's rules are unlayered single-class rules that come later in the document than the `head` CSS. Marked: the hamburger button, the two chevron buttons, `HeroArrows` buttons, `HeroPauseButton`, the hero progress bar, the `FilterBar` root, the testimonial controls spacer, the footer Contact column. | FR-PR-13 |
| BR-NJS-02 | `[data-email-pending] { display: none !important }`: the e-mail placeholders (footer, contact card, gate sentence and gate button) stay in the HTML for layout during hydration, and are removed from layout without JavaScript, where the address never comes (FR-PR-22). The footer Contact column gets `data-requires-js` as well, so its title "Contact" does not stand alone (BR-MAIL-09). `FooterColumn` takes an optional prop to put the marker on its root. | FR-PR-22; BR-MAIL-09 |
| BR-NJS-03 | Hero: slide 1 with its photo, h1, call to action and social links. The arrows, the pause button and the progress bar are hidden. The progress bar would otherwise run once and stop. The section keeps `aria-roledescription="carousel"`; a screen reader without JavaScript hears a carousel with one slide. Accepted. | FR-PR-13 |
| BR-NJS-04 | Testimonials: the placeholder shows the longest review (not necessarily the first) and keeps the other copies visually hidden, `aria-hidden` and `inert`, as unit 1 decided (BR-LZY-02) and as the browser test V9 asserts. The empty 48 px spacer for the carousel controls is hidden. **Provisional:** a visitor without JavaScript reads one review, not all. | FR-PR-13; BR-LZY-02 |
| BR-NJS-05 | Contact form: on `/contact` the form is a hidden streamed segment (`<div hidden id="S:0">`) that stays hidden without JavaScript, and the gate shows its notice over a blank, blurred area. On `/` the notice sits over the placeholder box. The notice text "Het contactformulier komt binnenkort." is readable; the address and the mail button do not exist without JavaScript (FR-PR-22). The form is disabled today (`contactForm.enabled` is `false`), so nothing usable is lost. When it is enabled, a visitor without JavaScript gets an empty area and no way to send a message; that must be designed then. | FR-PR-13, FR-PR-22; BR-LZY-01 |
| BR-NJS-06 | Portfolio: the filter buttons are hidden and all photos show, also for `/portfolio?shoot=...` (the search only applies after hydration, BR-HYD-10). Tiles are links to the large photos. | FR-PR-13 |
| BR-NJS-07 | The "Boek" links of the price cards go to `/?pakket=...`. Without JavaScript the page loads at the top and the package is not applied. Accepted. | FR-PR-06, FR-PR-13 |
| BR-NJS-08 | `BackToTop` is already `inert` and `visibility: hidden` until a scroll listener shows it, so it needs no marker. The 404 page already shows one button, "Terug naar home", a link. | FR-PR-13 |
| BR-NJS-09 | Specificity policy for the CSS: id selectors and attribute selectors with a pseudo-class beat Emotion's single-class rules by weight; a bare attribute selector has equal weight and loses to the later Emotion rule, so it needs `!important` (BR-NJS-01) or an id. | FR-PR-12, FR-PR-13 |
| BR-NJS-10 | No Dutch copy is written or changed. The only visible texts the unit uses are existing strings: "Menu openen", "Menu sluiten". | FR-PR-12 |
| BR-NJS-11 | What a visitor without JavaScript sees, per page, is in [business-logic-model.md § 4](business-logic-model.md). Remaining imperfections: BR-IMG-05, BR-NAV-11, BR-NAV-12, BR-NJS-03, BR-NJS-04, BR-NJS-05, BR-NJS-07, and the missing e-mail address (FR-PR-22). | FR-PR-11, FR-PR-13 |
### BR-PRE: First-photo preload
| Id | Rule | Source |
|---|---|---|
| BR-PRE-01 | Fact, verified in `dist/client`: React 19.3 already writes `<link rel="preload" as="image">` into the `<head>` for every `<img>` with a string `src` that is not `loading="lazy"`, not `fetchPriority="low"`, not a `data:` URL, and not inside `<picture>` or `<noscript>`. Photos with `fetchPriority="high"` get `fetchPriority="high"` on the link. So `/` (hero 8), `/over-mij`, `/soorten-fotoshoots` and the five shoot pages already preload their first photo, with the hashed URL, from the same `src` the `<img>` uses (so the browser can never fetch it twice). The declaration of "this is the first photo" is `priority` on `FramedImage` / `fetchPriority="high"` on the `<img>`, which unit 1 left in place. | FR-PR-21; D8 |
| BR-PRE-02 | Explicit links are only for images React cannot hoist. That is `/contact` from `lg`: the photo is a `<source media="(min-width: 64em)" srcSet>` in a `<picture>` and the `<img>` has a `data:` placeholder, so nothing is preloaded today and it is the largest paint at 1350 x 940. The contact route's `head()` adds `preloadImage(image, { media: ASIDE_MEDIA })`: `rel="preload"`, `as="image"`, `href` the hashed URL, `fetchPriority="high"`, `media="(min-width: 64em)"`. Below `lg` the media query keeps it from downloading. | FR-PR-21 |
| BR-PRE-03 | `preloadImage(image: ContentImage, options?: { media?: string }): HeadLink` is added to `seo.ts` (component-methods.md named it `preloadImage(src)`). It returns a plain object with `rel`, `as`, `href` (= `image.src`), `fetchPriority` and, only when given, `media`. `seo.ts` has a 100 % coverage threshold: examples and property P22 cover it. `pageHead` is not changed: passing every page's first photo to it would write the same preload twice (BR-PRE-04). The application design said pages pass their first photo to `pageHead`; the investigation shows React already does it. | FR-PR-21; D8 |
| BR-PRE-04 | A photo is declared once. A build test over all 12 HTML files asserts: every `preload as="image"` `href` occurs once; every page that has a `priority` photo has its preload; `/contact` has the `media` link and no other link for that file. This also catches a React upgrade that changes the hoisting. | FR-PR-21; NFR-PR-Q-01 |
| BR-PRE-05 | Nothing is preloaded that is not shown. Measured on `dist/client`: every page preloads both logos, `/contact` preloads the 72 px portrait (5 KB) that is `display: none` from `lg`. Fixes, both by `loading="lazy"` (a lazy image is neither fetched while `display: none` nor hoisted by React): the contact page's narrow portrait; the light logo on every page except `/` (on those pages the header is never transparent, so the light logo is never shown). `NavigationBar` knows `isHome` from the pathname in its first render, which is the same on the server and in the browser (the prerendered 404 has `/404`, never `/`). On `/` both logos stay eager, because both are shown in some state (dark below `lg` and after scrolling 150 px, light over the hero from `lg`). The light logo is 25 KB, about 140 ms of simulated LCP at the Lighthouse throttle on ten pages (estimate from the 5.4 ms per KB slope in the business logic model, to be measured). Verified in Chrome on the built `/over-mij`: with `loading="lazy"` on the light logo and its preload link removed, only the dark logo is requested. **Provisional.** | FR-PR-21; NFR-PR-P-01 |
| BR-PRE-06 | Largest paint per page and screen size, measured in Chrome 2026-10-31 at 412 x 823, 768 x 1024 and 1350 x 940 (unthrottled, Reveal forced visible to simulate this unit) and checked against the Lighthouse reports: `/`: the h1 text at every size (the hero photo is never reported, probably because it covers the whole viewport; not confirmed); `/over-mij`, `/soorten-fotoshoots` and the five shoot pages: their `priority` photo at every size; `/contact`: the intro text below `lg`, the aside photo from `lg`; `/portfolio`: a grid photo at every size once the grid is visible (a different tile per width); `/privacyverklaring` and the 404 page: text or the footer logo. Table with names: [domain-entities.md § 6](domain-entities.md). | FR-PR-21 |
| BR-PRE-07 | The hero photo on `/` keeps its React-written preload with `fetchPriority="high"` although the largest paint there is text: it is the first thing a visitor sees. No explicit link is added. | FR-PR-21 |
| BR-PRE-08 | **Provisional, and a deviation from FR-PR-21:** `/portfolio` gets no preload. Its largest paint after this unit is a grid photo (`DeferredImage`, loaded after the `load` event), a different tile at each width. `PortfolioGallery` keeps `eagerCount={0}` (decision 2026-10-27: eager photos measured 0.80 against 0.91 on mobile, because they slowed fonts and the intro text). A preload would repeat that and could not name one photo. The comment in `PortfolioGallery` ("the grid fades in, so its photos are never the largest paint") stops being true for a grid in view and is rewritten. Measuring "first row eager plus preload" is V-D5. | FR-PR-21; decision 2026-10-27 |
| BR-PRE-09 | A route never preloads an image that is lazy or deferred, and never more than one explicit link per page. No `imagesrcset` or `imagesizes` is used (responsive photos are out of scope). | FR-PR-21 |
### BR-DMS: Measurement and the largest-paint mechanism
| Id | Rule | Source |
|---|---|---|
| BR-DMS-01 | Explanation, with evidence in [business-logic-model.md § 6](business-logic-model.md): the mobile Lighthouse LCP is a throttled simulation whose result follows the bytes requested before the real (unthrottled) LCP moment, at about 5.4 ms per KB; and in the "after" run the shoot pages' LCP waits for hydration because `Reveal` hides the photo. This unit removes the second cause. It does not change the bytes. | NFR-PR-P-03 |
| BR-DMS-02 | After code generation the gate measurement is repeated with the unit 1 method (`lhci collect`, 3 runs per URL, mobile and desktop, median, same machine) against `measurement-gate.md`. At least one run per URL keeps its trace (Lighthouse gather mode) so the claim in BR-DMS-01 can be checked against the trace and not only inferred. | NFR-PR-P-03 |
| BR-DMS-03 | Expected result, from the "Reveal visible" run (B) and the changes above: score and LCP better than A on `/over-mij`, `/soorten-fotoshoots`, the five shoot pages (by 77 to 226 ms), `/contact`; `/portfolio` on mobile worse than A (3007 to about 3600 ms, score 0.94 to about 0.90) because a photo becomes the largest paint; `/` unchanged at about 4280 ms. B is only an indication (BR-MEA-05); the real figures come from the measurement. | NFR-PR-P-01 |
| BR-DMS-04 | Not solved by this unit and reported as such: `/` stays at about 0.85 (the 224 KB hero photo is requested before the text paint); zwangerschap, gezin, loveshoot and portret stay below 0.9 on mobile in B (0.88 to 0.89), and zwangerschap (+6), portret (+9), gezin (+80) and loveshoot (+139 ms) stay above master. The levers are bytes (photo size, 48 KB of 500 x 500 logos shown at 46 px, script size), which belong to the responsive-photos feature, unit 3 or the owner's per-page decision (NFR-PR-P-01). | NFR-PR-P-01 |
### BR-DTS: Tests
| Id | Rule | Source |
|---|---|---|
| BR-DTS-01 | `useReveal.test.tsx` changes where behaviour changed: jsdom has no layout (`getBoundingClientRect` returns zeros, so every element counts as in view), so tests that need a below-the-fold element stub `getBoundingClientRect` to return `top` larger than `innerHeight`. The cases "server render is visible", "in view at hydration stays visible, no observer", "below the fold is hidden and then visible after the observer fires", "reduced motion hides nothing and creates no observer", "no IntersectionObserver stays visible", "disconnects on unmount" replace the old ones. `Reveal.test.tsx` stays. No other test selects on hidden content (`grep` of `src`, 2026-10-31). | BR-TST-02 |
| BR-DTS-02 | New example tests: `DeferredImage` through `renderToString` (twin once, `data-deferred` on the first image, no `<link rel="preload">` for the twin) and through `hydrate()` (no hydration error); `NoScriptNav` and `NoScriptStyles` through `renderToString`; `preloadImage`; the CSS-content test of BR-NAV-02; a check that every id the CSS names exists in the components (`mobile-nav`, `site-header`, `mobile-group-`, `data-submenu`). | NFR-PR-Q-01 |
| BR-DTS-03 | Browser tests (`e2e/`, JavaScript off, 11 pages and the 404 page at 390 and 1280 px): no visible `button`; no visible `img` without a loaded photo (`complete` and `naturalWidth` > 0), none with `display` other than `none` among `img[data-deferred]`; every `img` has its alt text in the accessibility tree once; at 390 px the open link opens the menu, all links are focusable in the order of BR-NAV-08, the close link closes it, `scrollY` is unchanged; at 1280 px the submenu links are reached by Tab. With JavaScript, at 390 and 1280 px: the opacity of every `Reveal` that is in view at load is 1 on every animation frame from the first paint to hydration and after; below-the-fold ones are 0 and then fade in on scroll; no request for a deferred photo before it is near; every `preload as="image"` URL is used by a visible `img` at that width and requested exactly once; at 1280 px `/contact` requests the aside photo once and at 390 px not at all. | NFR-PR-Q-03; FR-PR-09, 11, 12, 21 |
| BR-DTS-04 | The unit-1 browser tests keep passing: V9 (one review, the rest 1 px, `aria-hidden`, `inert`), V15 (the h1 and `main` stay in place between JavaScript off and on), BR-HYD-20 (no console error on any page). The raw-HTML tests that count `img` or links parse with `DOMParser`, which treats `noscript` as markup, so they must not count the twins or the menu links twice (V-D8). | BR-TST-05, 06 |
## 3. What this unit leaves for unit 3
| Belongs to | Left as it is |
|---|---|
| Servers and upload | Nothing changes: the new CSS and links are inside the HTML files. |
| Lighthouse targets | `lighthouserc.cjs` exceptions are decided after BR-DMS-02; `/portfolio` may need an owner decision (section 5, O2). |
| Responsive photos | Out of scope. The logos and photos stay as they are. |
## 4. To verify in code generation
Neither the code nor the probes of this design settle these.
| # | Point | Where it matters |
|---|---|---|
| V-D1 | `useLayoutEffect` in `Reveal` during `renderToString`, `hydrateRoot` and StrictMode (double effect): no warning, no mismatch, the hide step runs once visibly. | BR-RVL-02 |
| V-D2 | With JavaScript on, the twin image is never requested (request log on `/soorten-fotoshoots` and `/portfolio` before any scroll), and the preload scanner does not read inside `noscript`. Also that Emotion writes the shared class once (one `<style>` for the two images). | BR-IMG-03 |
| V-D3 | `<noscript>` inside `<head>` and inside the header and the panel hydrate without a mismatch in `hydrateRoot(document)` (the shell hydrates `<html>`), and the head hoisting of `HeadContent` keeps the CSS in the head. | BR-NAV-01 |
| V-D4 | Fragment navigation to a fixed element does not scroll in Firefox and Safari, and Chrome on Android (only desktop Chrome was probed). If one scrolls, the fixed `header` target moves to a zero-size fixed element. | BR-NAV-07 |
| V-D5 | Measure `/portfolio` with the first row eager and preloaded against deferred (mobile and desktop) before any change to `eagerCount`. | BR-PRE-08 |
| V-D6 | Height of every `Reveal` at 320, 360, 412, 768, 1350 px wide against the limit of BR-RVL-13. | BR-RVL-13 |
| V-D7 | After the gate measurement: whether `loading="lazy"` on the light logo and the contact portrait changes score and LCP as estimated; that the logo does not flash on `/` or on a client navigation from `/` to another page and back. | BR-PRE-05 |
| V-D8 | The raw-HTML e2e tests that count `img` or links (`rawHtml.e2e.ts`) with `noscript` content present. | BR-DTS-04 |
| V-D9 | The visible focus ring of the two menu links in Chakra's reset (a bare `a` outside Chakra components). | BR-NAV-08 |
| V-D10 | Whether Chrome really excludes the viewport-filling hero photo from LCP (so text is the candidate on `/`), by a trace. Only explains `/`; changes no rule. | BR-PRE-06 |
| V-D11 | The first React 19 upgrade: the hoisting facts of BR-PRE-01 (tested by BR-PRE-04). | BR-PRE-01 |
| V-D12 | Visual check without JavaScript on every page at 390 and 1280 px (screenshots through `E2E_SCREENSHOT_DIR`, looked at, not compared): header, hero, nav, footer, empty areas left by hidden controls (`mb` of the filter bar, the gate's margin). | BR-NJS-01 to 06 |
## 5. Decisions for the owner (all provisional)
| # | Decision | Recommendation (written down) | Alternatives |
|---|---|---|---|
| O1 | First screen on client navigation (BR-RVL-10) | Same rule as the first load: in view appears at once, below the fold fades in on scroll | Keep today's entrance fade for the first screen on client navigation (needs a `useHydrated` branch and a second path to test) |
| O2 | `/portfolio`: grid in view is visible, no preload, deferred photos stay (BR-RVL-03, BR-PRE-08) | Follow FR-PR-09 literally; expect mobile 0.94 to about 0.90 in the lab, real visitors see the photos earlier | (a) Keep the grid hidden until 12 % visible, i.e. leave the mobile portfolio grid empty under the filters at load as today (keeps 3007 ms, contradicts "content in view stays visible"); (b) first row eager plus preload (FR-PR-21 literal, measure first, V-D5) |
| O3 | Desktop shoot submenu without JavaScript (BR-NAV-09) | Open on keyboard focus (`:focus-within`) | Leave unreachable (the overview page lists all five); or also open on hover with a bridge for the gap |
| O4 | `loading="lazy"` on the light logo (not on `/`) and the contact portrait (BR-PRE-05) | Do it, about 140 ms of lab LCP on ten pages | Leave as is and resize the two 500 x 500 PNG logos (48 KB shown at 46 px) in the responsive-photos feature, which saves more |
| O5 | Testimonials without JavaScript (BR-NJS-04) | One review (longest), as unit 1 | Show all reviews stacked: needs the hidden copies to lose `aria-hidden`, and V9 changes |