Records unit 3 of the Contact page as generated

Functional design, code generation plan and summary of the contact page,
the updated LAYOUT.md diagram and the extended link requirement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 19:27:18 +01:00
co-authored by Claude Opus 5.5
parent e92b652061
commit 9c2601d846
13 changed files with 451 additions and 11 deletions
@@ -0,0 +1,34 @@
# Code Summary — Unit 3: Contact page
## Created
- `web/src/routes/contact.tsx` — replaces the placeholder: page head, the narrow card, the form column (visually hidden h2 + `ContactPanel load="eager"`), `ContactAside` with the wide card; `?pakket=` validation and clean-up; head with `ContactPage` JSON-LD
- `web/src/components/contact/ContactAside/ContactAside.tsx` (+ test) — `picture` with a `(min-width: 64em)` source and a transparent `data:` fallback, priority, intrinsic size; card slot over the bottom of the photo
- `web/src/content/contactContent.ts` — head texts (intro with `{reactietermijn}`), headings, photo and portrait
- `web/src/lib/withReplyTime.ts` (+ test) — fills in the reply time
- `web/src/assets/contact/contact.jpg` (840×1050, 80 KB), `contact-portret.jpg` (144×144, 5 KB), `web/public/og-contact.jpg` (1200×630, 60 KB) — crops of the original live photo (1600×1067), approved by the owner (portrait zoomed out, variant B)
## Modified
- `web/src/content/types.ts` — `ContactPageContent`
- `web/src/seo.ts` (+ test) — `contactPage()`
- `web/src/sitePages.ts` — `/contact`: title, description, `indexed: true`, `ogImage`
- `web/lighthouserc.cjs` — `/contact` indexed (standard 0.9 mobile budget, owner's choice)
- `web/src/sitemap.test.ts` — expects `/contact`
- `web/src/content/aboutContent.ts`, `web/src/app.test.tsx`, `web/src/components/about/AboutIntro/AboutIntro.test.tsx` — Over mij links to `/contact`; contact route tests
- `web/src/components/ContactDetails/ContactDetails.tsx` — filled mail icon, matching the filled platform icons
- `web/src/theme.ts`, `web/src/recipes/linkButton.ts` — accent button on `accent.deep` (white ≈ 5.7:1), hover on new `accent.deeper` (#475042)
- `LAYOUT.md` — Contact: Intro; Contact form beside Photo + contact details
- `web/src/lib/shootLinks.ts` (+ test), `web/src/content/shootTypesPageContent.ts`, `web/src/components/shoots/ShootBlock/ShootBlock.test.tsx` — Soorten fotoshoots: "Stuur een berichtje" → `/contact?pakket=<id>` (or `/contact`), "Boek je shoot" → `/contact` (FR-CP-09 extension, owner's request)
## Findings fixed during verification
- `chakra.img` treated `width`/`height` as CSS props, so the intrinsic size was missing; now Chakra `Image` with `htmlWidth`/`htmlHeight`.
- A property test of `withReplyTime` passed by chance: half placeholders around a real one could form a new one; generator restricted to brace-free text.
- **Accent button contrast** (site-wide, pre-existing): white on `#7f8b76` = 3.58:1. Lighthouse only caught it here because the button is in the first screen; elsewhere `Reveal` keeps it at opacity 0 during the measurement, and jsdom computes no colours. Fixed in the recipe (owner's choice: darker green).
## Verification
- `pnpm test`: 71 files, 367 tests passed (seed 1926155072; after the Soorten link change again 367/367, seed 1607463937); lint, format, build clean. Lighthouse not re-run for the link change (href-only change, no effect on performance or accessibility).
- Production build in Chrome: no request for `contact.jpg` up to 1023 px (LCP = intro text); one request with priority **High** from 1024 px (LCP = the photo). Screenshots at 390 and 1280 px match mockup 1a.
- Lighthouse desktop: all pass; `/contact` 0.99 / 1 / 1 / 1.
- Lighthouse mobile: accessibility, best practices and SEO pass everywhere. **Performance fails on two pages:**
- `/` 0.78–0.80 vs 0.8 — pre-existing: identical on the unit 2 build (3 runs each); owner chose to handle it separately (recorded as an open follow-up).
- `/contact` 0.88 / 0.90 / 0.88 vs 0.9 — same client-rendering cause as the photo pages (text appears after the JavaScript); owner chose to keep 0.9.
- In CI, performance is report-only (D6), so these do not block a merge; locally `pnpm check` fails on them.
Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

@@ -0,0 +1,43 @@
# Business Logic Model — Unit 3: Contact page
## Route flow
```mermaid
sequenceDiagram
box rgba(99,179,237,0.4) Routing
participant R as Router
participant P as ContactRoute
end
box rgba(255,167,38,0.4) Components
participant Pn as ContactPanel
end
R->>P: render with validated search
P->>Pn: pakket and load eager
Pn->>Pn: preselect when the package is known
P->>R: navigate to contact page with empty search, replace, no scroll
```
Text alternative: the router renders the contact route with the validated search parameter; the route passes the package to the panel, which preselects a known package; the route then replaces the URL without the parameter, without scrolling.
## Head
`pageHead('/contact')` (title, description, canonical, Open Graph incl. the page's preview image, no `noindex`) plus `structuredDataScript(contactPage('/contact'))`.
## Pure helpers
### `contactPage(path: RoutePath)` in `seo.ts`
`webPage('ContactPage', path, { about: { '@id': businessId } })`.
### `withReplyTime(text: string, replyTime: string): string` in `lib/withReplyTime.ts`
Replaces every `{reactietermijn}` in `text` with `replyTime`; text without the placeholder comes back unchanged.
## Properties for property-based testing (PBT-01)
| Function | Property | Category |
|---|---|---|
| `withReplyTime` | No `{reactietermijn}` is left (when `replyTime` itself does not contain it) | Invariant |
| `withReplyTime` | Text without the placeholder is returned unchanged | Invariant |
| `withReplyTime` | Splitting the template on the placeholder and joining with `replyTime` gives the result | Oracle |
| `contactPage` | `@type` = `ContactPage`, `@id` = `url` = canonical URL, `about` = business id, never an e-mail address | Invariant |
| `contactPage` | Survives `jsonLdScript` unchanged | Round trip |
The layout, the photo loading and the URL clean-up are covered by component and route tests (they are rendering over helpers that are already property-tested).
@@ -0,0 +1,66 @@
# Business Rules — Unit 3: Contact page
Answers: [contact-page-fd-questions.md](../../plans/contact-page-fd-questions.md) (Q1 A, Q2 A).
## Layout
| Id | Rule |
|---|---|
| BR-CP-01 | From **1024 px** (`lg`): two columns, the form column (≈ 3/5) left and `ContactAside` (≈ 2/5) right, aligned at the top. *Q1 = A* |
| BR-CP-02 | Below 1024 px: one column — the narrow card (with the round portrait) above the form, both full width; `ContactAside` is not shown. |
| BR-CP-03 | DOM order = visual order on every width: narrow card, form column, aside. The narrow card is hidden from 1024 px, the aside below it (`display: none`, so also hidden from assistive technology). |
| BR-CP-04 | The section sits directly under the page head (`PageSection spacing="flushTop"`), as in the design. Both columns fade in with `Reveal`. |
```mermaid
graph TD
W{"Viewport at least 1024 px?"}
W -->|"yes"| Wide["Form left; photo with card right; narrow card hidden"]
W -->|"no"| Narrow["Card with portrait, then form; aside hidden and photo not fetched"]
classDef decision fill:#FFF59D,stroke:#F57F17,stroke-width:1px,color:#000;
classDef result fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
class W decision;
class Wide,Narrow result;
```
Text alternative: from 1024 px the page shows the form with the photo and card beside it; below that it shows the card with the portrait above the form and does not fetch the large photo.
## Photo
| Id | Rule |
|---|---|
| BR-CP-06 | The large photo is a `<picture>` whose source only applies from 1024 px; below that the `img` falls back to a tiny inline transparent image, so phones and portrait tablets never download the photo. (`data:` is already allowed by the CSP.) |
| BR-CP-07 | On wide screens the photo is the largest paint: no deferral, `fetchpriority="high"`, intrinsic width and height to reserve space. |
| BR-CP-08 | The portrait is a separate small crop, decorative (`alt=""`), only in the narrow card. |
| BR-CP-09 | The card overlaps the bottom edge of the photo (as in mockup 1a); the aside reserves room below the photo so the card never covers the next content. |
## `?pakket=` on this page
| Id | Rule |
|---|---|
| BR-CP-10 | The route keeps `pakket` from the search only when it is text (same `validateSearch` as the homepage). |
| BR-CP-11 | `ContactPanel load="eager"` receives it and applies the preselect per BR-CPN-02 (unit 2). |
| BR-CP-12 | After it was applied, the route replaces the URL with `/contact` without search, no history entry, no scroll, no focus move. An invalid value is removed the same way. |
## Texts and headings
| Id | Rule |
|---|---|
| BR-CP-05 | The intro is `head.intro` with `{reactietermijn}` replaced by the reply time; without the placeholder the text is used as is. |
| BR-CP-13 | One h1 "Contact" (`PageIntro`); h2 "Stuur me een bericht" visually hidden, labelling the form section; h2 "Direct contact" in each card with its own id (`contact-details-narrow`, `contact-details-wide`). |
| BR-CP-14 | The contact section is a landmark named by the form heading. |
## SEO and checks
| Id | Rule |
|---|---|
| BR-CP-15 | `sitePages['/contact']` gets the approved title and description, `indexed: true` and the preview image; head tags via `pageHead('/contact')`. |
| BR-CP-16 | The route adds the `ContactPage` JSON-LD via `structuredDataScript(contactPage('/contact'))`. |
| BR-CP-17 | `/contact` becomes an indexed path in Lighthouse CI with the standard mobile budget 0.9 (not a photo page). If it does not reach 0.9, report the measurement and cause to the owner before changing any budget. *Q2 = A* |
| BR-CP-18 | The sitemap test expects `/contact`. |
## Other pages
| Id | Rule |
|---|---|
| BR-CP-19 | Over mij: "neem contact op" and "Boek je shoot" link to `/contact` (no hash). The homepage "Boek …" links stay on the homepage form. |
| BR-CP-20 | LAYOUT.md "Contact": Intro over the full width, then Contact form beside Photo with contact details, per `.ai/layout-conventions.md`. |
@@ -0,0 +1,51 @@
# Domain Entities — Unit 3: Contact page
## Entity relationships
```mermaid
graph TD
Page["ContactPageContent"] -->|"has"| Head["head: eyebrow, title, intro template"]
Page -->|"has"| Titles["formTitle, detailsTitle"]
Page -->|"has"| Photo["image: ContentImage 4:5"]
Page -->|"has"| Portrait["portrait: ContentImage face crop"]
Site["SiteContent"] -->|"replyTime fills"| Head
Site -->|"email, socials"| Card["ContactDetails (twice)"]
Registry["sitePages /contact"] -->|"title, description, ogImage"| Head2["head tags + ContactPage JSON-LD"]
Business["ProfessionalService @id"] -->|"about"| Head2
classDef content fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
classDef derived fill:#FFA726,stroke:#E65100,stroke-width:1px,color:#000;
classDef registry fill:#e2e8f0,stroke:#4a5568,stroke-width:1px,color:#000;
class Page,Head,Titles,Photo,Portrait,Site content;
class Card,Head2 derived;
class Registry,Business registry;
```
Text alternative: the page content holds the head texts, the two section titles, the photo and the portrait; the site content fills in the reply time and feeds the contact card; the page registry and the business id produce the head tags and the ContactPage structured data.
## `ContactPageContent` (`content/types.ts`, values in `content/contactContent.ts`)
| Field | Type | Value |
|---|---|---|
| `head.eyebrow` | `string` | "Neem contact op" |
| `head.title` | `string` | "Contact" |
| `head.intro` | `string` | "Wil je een fotoshoot boeken of meer informatie ontvangen? Stuur me een berichtje, ik reageer binnen {reactietermijn}." |
| `formTitle` | `string` | "Stuur me een bericht" (visually hidden h2) |
| `detailsTitle` | `string` | "Direct contact" |
| `image` | `ContentImage` | the contact photo, 4:5, descriptive alt text |
| `portrait` | `ContentImage` | square face crop from the same photo, `alt: ''` is set by the card (decorative) |
`{reactietermijn}` is the one placeholder in the intro; it is replaced by `siteContent.contactForm.replyTime` (BR-CP-05). Plain strings, so the API can deliver the same shape.
## Images
| Image | Location | Size | Notes |
|---|---|---|---|
| Contact photo | `web/src/assets/contact/contact.jpg` | about 900×1125 (4:5), compressed | original from andreaslop.nl/contact, resized once |
| Portrait crop | `web/src/assets/contact/contact-portret.jpg` | 144×144 (72 px at 2×) | face crop, a few kB |
| Preview image | `web/public/og-contact.jpg` | 1200×630 | crop of the same photo, own alt text in `sitePages` |
## Structured data
`ContactPage` = `webPage('ContactPage', '/contact', { about: { '@id': businessId } })` — name and description from the registry, no e-mail address.
## Registry and test lists
- `sitePages['/contact']`: title "Contact – fotoshoot boeken in Huizen", description from SEO-CP-02, `indexed: true`, `ogImage` the preview image.
- `lighthouserc.cjs`: `/contact` moves from `noindexPaths` to `indexedPaths` (not in `photoPagePaths`, Q2 = A); `sitemap.test.ts`: `/contact` in the expected list.
@@ -0,0 +1,51 @@
# Frontend Components — Unit 3: Contact page
## Hierarchy
```mermaid
graph TD
Route["routes/contact.tsx"] --> Intro["PageIntro: eyebrow, h1, intro"]
Route --> Section["PageSection flushTop, labelled by the form heading"]
Section --> NarrowCard["ContactDetails with portrait (below lg)"]
Section --> Grid["Grid: one column, two from lg"]
Grid --> FormCol["Form column: hidden h2 + ContactPanel eager"]
Grid --> Aside["contact/ContactAside (from lg)"]
Aside --> Photo["picture: photo from lg only"]
Aside --> WideCard["ContactDetails (overlapping the photo)"]
classDef page fill:#2196F3,stroke:#0d47a1,color:#000;
classDef shared fill:#4CAF50,stroke:#2e7d32,color:#000;
classDef small fill:#e2e8f0,stroke:#4a5568,color:#000;
class Route,Section,Grid,FormCol page;
class Intro,NarrowCard,WideCard,Aside shared;
class Photo small;
```
Text alternative: the contact route renders PageIntro and one PageSection; inside it the narrow-screen card, then a grid with the form column and, from lg, ContactAside with the photo and the wide-screen card.
## `routes/contact.tsx`
- `validateSearch` keeps `pakket` when it is a string; `head` per the business logic model.
- Effect: when `pakket` is defined, `navigate({ to: '/contact', search: {}, replace: true, resetScroll: false })`.
- Renders `PageIntro` with `withReplyTime(head.intro, replyTime)`, then the section.
- **Section**: `PageSection labelledBy="contact-form-title" spacing="flushTop" data-testid="contact-page"`.
- **Narrow card**: wrapper `display={{ base: 'block', lg: 'none' }}`, `ContactDetails titleId="contact-details-narrow" portrait={portrait} data-testid="contact-details-narrow"`, margin below it.
- **Grid**: `templateColumns={{ base: '1fr', lg: '3fr 2fr' }}`, gap as `MediaText` (`clamp(2rem, 6vw, 5.5rem)`), `alignItems="start"`.
- **Form column**: `VisuallyHidden` `h2` with `id="contact-form-title"`, then `ContactPanel idPrefix="contact" load="eager"` with the route's `pakket`.
- Test ids: `contact-page`, `contact-details-narrow`, `contact-details-wide`, `contact-aside`, `contact-aside-photo`.
## `components/contact/ContactAside`
- Props: `image: ContentImage`, `children: ReactNode` (the card).
- Wrapper `display={{ base: 'none', lg: 'block' }}`, `position="relative"`, padding below the photo for the overlapping card.
- `chakra.picture` with `<source media="(min-width: 64em)" srcSet={image.src}>` and an `img` with a 1×1 transparent `data:` GIF as `src`, `alt={image.alt}`, intrinsic `width`/`height`, `fetchPriority="high"`, `decoding="async"`, aspect ratio 4:5, `objectFit="cover"`, background `paper.deep` while loading.
- Card position: absolutely placed over the bottom of the photo with side insets (`left`/`right` ≈ 1.5rem, `bottom` 0), as in the mockup.
## Responsive behaviour
| Width | What shows |
|---|---|
| < 480 px | intro, card with portrait, form (name and e-mail stacked) |
| 480–1023 px | same, name and e-mail side by side |
| ≥ 1024 px | intro, form left, photo with card right |
## Accessibility
- Reading and tab order: intro → (narrow card) → form → (wide card); hidden variants are `display: none`.
- The visually hidden form heading names the section; the cards each have a labelled list.
- Photo alt text describes the photo; portrait decorative.