Adds the Lieve woorden section to the homepage

Shows client reviews one at a time with the framed photo, a large
quotation mark, the shoot type and the names. Uses Chakra's carousel for
paging, looping and swiping with our own controls, so visitors who
prefer reduced motion get instant changes, and loads the carousel only
when the section comes near the screen so the hero does not wait for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 01:52:41 +02:00
co-authored by Claude Opus 5.5
parent 30dab1af42
commit cb6a9b07f9
30 changed files with 1307 additions and 6 deletions
@@ -0,0 +1,64 @@
# Code Generation Plan — Unit 4: Lieve woorden
**This plan is the single source of truth for Code Generation of unit 4.**
## Unit context
- **Requirements**: FR-HP-05, FR-HP-11, FR-HP-12, NFR-HP-01/02/03/05/06
- **Functional design**: [lieve-woorden/functional-design/](../lieve-woorden/functional-design/) — BR-REV-01…11
- **Depends on**: unit 1 (`HomeSection`, `SectionHeading`, `Reveal`, `DeferredImage`), unit 2 (`FramedImage`)
- **PBT**: full — `visibleTestimonials`, `slideLabel`; PBT-06 N/A (carousel state machine is Chakra's/Zag's).
- Conventions as in units 1–3.
## Findings that shape the plan (from the installed `@zag-js/carousel` 1.43.3)
1. **Reduced motion**: the built-in triggers, indicators and arrow keys call `scrollTo({ behavior: 'smooth' })` from JavaScript; CSS `scroll-behavior` cannot override that. The API does accept an `instant` flag (`scrollPrev(instant)`, `scrollNext(instant)`, `scrollTo(page, instant)`). → We keep Chakra's carousel for state, snapping, looping, swiping, slide semantics and hidden off-screen slides, but render **our own** previous/next buttons and dots (and arrow-key handling on the controls) that pass `instant = prefersReducedMotion` (BR-REV-06).
2. **Double announcement**: the item group already carries `aria-live="polite"`. → We set it to `off` and keep one own polite live region with "Review n van m" (BR-REV-08).
3. **Labels**: Zag's default translations are English. → `translations.item = slideLabel` so slides are "Review n van m" (BR-REV-09).
## Steps
### Images and content
- [x] **Step 1** — Extend the one-off resize script with a centre crop to a target aspect ratio. Prepare the two live photos, cropped to **4:5** from the centre and resized to **880×1100**, quality 80: `IMG_2497-5.jpg` → `web/src/assets/home/review-trouwshoot.jpg`, `5-F41A4650-scaled.jpg` → `web/src/assets/home/review-newbornshoot.jpg`. Record the script change in the summary.
- [x] **Step 2** — `content/types.ts`: `Testimonial { id; shoot; quote; author; image: ContentImage }`; `HomeContent.testimonials { title }`.
- [x] **Step 3** — `content/testimonials.ts` with the two live reviews (full texts from FR-HP-05, alt texts from domain-entities.md); `homeContent.testimonials.title = 'Lieve woorden'`.
### Pure helpers
- [x] **Step 4** — `lib/visibleTestimonials.ts` (+ test): invariants filter, first-wins de-duplication. Properties: valid + unique; subsequence; idempotent; oracle.
- [x] **Step 5** — `lib/slideLabel.ts` (+ test): `slideLabel(index, count)` → `Review ${index + 1} van ${count}`. Properties: numbers round-trip; form and range invariant.
- [x] **Step 6** — `test/arbitraries.ts`: `testimonial`, `uniqueTestimonials`, `anyTestimonial`.
### Components
- [x] **Step 7** — `components/home/Testimonials/TestimonialSlide.tsx`: grid `5fr 7fr` from `lg` (stacked below, photo max 420 px), `FramedImage` 4/5, decorative quotation mark (`aria-hidden`), shoot as eyebrow (`accent.deep`), `figure` > `Blockquote` > `figcaption` "— author"; `data-testid="testimonial-<id>"`.
- [x] **Step 8** — `components/home/Testimonials/Testimonials.tsx`: `visibleTestimonials`; none → `null`; one → `TestimonialSlide` without carousel; two or more → `useCarousel({ slideCount, loop: true, allowMouseDrag: true, translations })` + `Carousel.RootProvider` (`aria-label="Reviews"`, `aria-roledescription="carrousel"`), `Carousel.ItemGroup` with `aria-live="off"` and stretched items (equal height, BR-REV-07), one `Carousel.Item` per review; own controls: "Vorige review" / "Volgende review" buttons (Ant Design left/right outlined icons, offline), one dot per review (`aria-label="Review n"`, `aria-current` on the current one, 44 px hit area), arrow keys on the control bar; every control calls the API with `instant = reducedMotion`; `onPageChange` sets the polite `VisuallyHidden` live region to `slideLabel`. `HomeSection tone="alt"`, centred heading.
- [x] **Step 9** — Tests: `TestimonialSlide.test.tsx` (photo alt, shoot, quote in a blockquote, author caption, quotation mark hidden, axe) and `Testimonials.test.tsx` (region "Lieve woorden"; two slides labelled "Review 1 van 2" / "Review 2 van 2"; buttons and dots named in Dutch; next from the last review goes to the first (loop) and is announced; a dot jumps to its review and marks itself current; arrow keys move; with reduced motion the API is called with `instant`; one review → no controls; none → no section; invalid reviews skipped; live region empty on load; axe clean).
### Route
- [x] **Step 10** — `routes/index.tsx`: render `Testimonials` after `Pricing` with `homeContent.testimonials` and `testimonials`.
- [x] **Step 11** — `app.test.tsx`: "Lieve woorden" in the page-order check.
### Verification and wrap-up
- [x] **Step 12** — `pnpm check` (incl. Lighthouse); visual check at 1440, 390 (CDP), including a swipe/next to the second review.
- [x] **Step 13** — `construction/lieve-woorden/code/code-summary.md`.
- [x] **Step 14** — Commit (including the pending audit/state updates) — "Adds the Lieve woorden section to the homepage" + attribution. Not pushed.
### Fixes during Step 12
- [x] **Step 12a** — Real-browser check showed the next slide's sand block over the quote and the own block clipped: 4 rem `spacing` between slides, 1.5 rem padding left/bottom per slide (from `sm`).
- [x] **Step 12b** — Home mobile Lighthouse median 0.83 → 0.81 with the carousel in the route chunk. `React.lazy` alone did not help; the carousel moved to `TestimonialCarousel.tsx` and loads only when the section is within 200 px of the screen (heading always rendered, placeholder of the measured height). Median back to 0.83.
## Requirement / rule traceability
| Item | Steps |
|---|---|
| FR-HP-05 | 2, 3, 7–11 |
| BR-REV-01 | 4, 8, 9 |
| BR-REV-02 | 8, 9 |
| BR-REV-03/04/05 | 8, 9 |
| BR-REV-06 | 8, 9 (finding 1) |
| BR-REV-07 | 8, 12 |
| BR-REV-08 | 5, 8, 9 (finding 2) |
| BR-REV-09 | 5, 8, 9 (finding 3) |
| BR-REV-10 | 8 (Zag sets `aria-hidden` on off-screen slides), 9 |
| BR-REV-11 | 7, 9 |
| NFR-HP-05 | 1, 7 (deferred image), 12 |
## Extension compliance (planned)
- **Security**: content rendered as text; no new dependencies (Chakra Carousel and Ant Design icons already installed); no external resources.
- **PBT**: PBT-02 (slideLabel round-trip), PBT-03 (invariants), PBT-04 (idempotency), PBT-05 (oracle), PBT-07 (generators), PBT-08/09 (existing), PBT-10 (example tests); PBT-06 N/A.
@@ -0,0 +1,31 @@
# Functional Design Questions — Unit 4: Lieve woorden
Vul per vraag de letter in na `[Answer]:` (of geef ze in de chat, bijv. "1A, 2A, 3A"). Past geen enkele optie, kies dan de laatste (Anders) en licht toe. Waar ik een voorkeur heb staat **(aanbevolen)**.
## Vraag 1: Aan het einde van de reeks
Een bezoeker staat op de laatste review en klikt op "volgende".
- A) Hij gaat rond naar de eerste review. Met maar een paar reviews voelt dat natuurlijk, en de knoppen werken altijd. (aanbevolen)
- B) Het stopt: op de laatste review is "volgende" uitgeschakeld, op de eerste "vorige"
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: A
## Vraag 2: Hoe wisselt een review?
- A) **Schuiven**: de reviews liggen naast elkaar en schuiven opzij; bij vegen op een telefoon volgt de review je vinger. Zo werkt Chakra's Carousel uit zichzelf, en het sluit aan bij het vegen in de galerij. (aanbevolen)
- B) **Overvloeien**: de oude review vervaagt en de nieuwe verschijnt, zoals in het statische ontwerp. Vegen werkt dan als "volgende/vorige", zonder dat de review je vinger volgt.
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
Bij "minder beweging" (systeeminstelling) wisselt de review in beide gevallen direct, zonder animatie.
[Answer]: A
## Vraag 3: Verschillende lengtes
De trouwshoot-review is ongeveer twee keer zo lang als de newbornshoot-review.
- A) Alle reviews krijgen de hoogte van de langste. Bij het wisselen springt de rest van de pagina (Contact eronder) dan niet op en neer. (aanbevolen)
- B) De hoogte past zich per review aan; minder witruimte bij korte reviews, maar de pagina eronder verschuift bij elke wissel
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: A
@@ -0,0 +1,10 @@
# Functional Design Plan — Unit 4: Lieve woorden
Scope: FR-HP-05 — one review at a time with photo, quotation mark, shoot label, quote and names; previous/next and dots; no autoplay; announcements; Chakra `Carousel`. Questions: [lieve-woorden-fd-questions.md](lieve-woorden-fd-questions.md).
- [x] 1. Collect and analyze answers (follow-up questions if needed)
- [x] 2. `domain-entities.md` — `Testimonial`, its invariants, initial data, relation to `ContentImage`
- [x] 3. `business-rules.md` — which reviews are shown, 0 / 1 / many reviews, navigation at the ends, transitions and reduced motion, height of the slides, announcements, accessible names; decision flowchart
- [x] 4. `business-logic-model.md` — navigation flow (buttons, dots, keyboard, swipe), pure functions (`visibleTestimonials`, `slideLabel`), PBT-01 properties
- [x] 5. `frontend-components.md` — `Testimonials` (Chakra Carousel parts), `TestimonialSlide`; props, states, responsive layout, accessibility
- [x] 6. Validate against FR-HP-05, NFR-HP-01/02/03/05/06 and the Security/PBT extensions