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
@@ -5,7 +5,7 @@
- **Feature Slug**: homepage-sections - **Feature Slug**: homepage-sections
- **Project Type**: Brownfield - **Project Type**: Brownfield
- **Start Date**: 2026-10-19T19:19:38Z - **Start Date**: 2026-10-19T19:19:38Z
- **Current Stage**: CONSTRUCTION - Unit 3 Prijzen - Code Generation (awaiting approval) - **Current Stage**: CONSTRUCTION - Unit 4 Lieve woorden - Code Generation (awaiting approval)
- **Branch**: feature/homepage-sections - **Branch**: feature/homepage-sections
## Workspace State ## Workspace State
@@ -62,11 +62,11 @@
- [x] Units Generation - EXECUTE (approved) - [x] Units Generation - EXECUTE (approved)
### 🟢 CONSTRUCTION PHASE ### 🟢 CONSTRUCTION PHASE
- [ ] Functional Design - EXECUTE (Prijzen ✅, Lieve woorden, Contact) / SKIP (Lifestyle fotografie, Over mij, Instagram) - [ ] Functional Design - EXECUTE (Prijzen ✅, Lieve woorden ✅, Contact) / SKIP (Lifestyle fotografie, Over mij, Instagram)
- [ ] NFR Requirements - SKIP - [ ] NFR Requirements - SKIP
- [ ] NFR Design - SKIP - [ ] NFR Design - SKIP
- [ ] Infrastructure Design - SKIP - [ ] Infrastructure Design - SKIP
- [ ] Code Generation - EXECUTE (per unit) — Unit 1 Lifestyle fotografie ✅, Unit 2 Over mij ✅ (desktop review deferred by user) - [ ] Code Generation - EXECUTE (per unit) — Unit 1 Lifestyle fotografie ✅, Unit 2 Over mij ✅ (desktop review deferred by user), Unit 3 Prijzen ✅
- [ ] Build and Test - EXECUTE - [ ] Build and Test - EXECUTE
### 🟡 OPERATIONS PHASE ### 🟡 OPERATIONS PHASE
@@ -74,8 +74,8 @@
## Current Status ## Current Status
- **Lifecycle Phase**: CONSTRUCTION - **Lifecycle Phase**: CONSTRUCTION
- **Current Stage**: Unit 3 Prijzen — Code Generation complete, awaiting approval - **Current Stage**: Unit 4 Lieve woorden — Code Generation complete, awaiting approval
- **Next Stage**: Unit 3 Prijzen — Code Generation - **Next Stage**: Unit 4 Lieve woorden — Code Generation
## Reverse Engineering Status ## Reverse Engineering Status
- [x] Reverse Engineering - Artifacts refreshed on 2026-10-19T19:19:38Z at commit 38c5c3e (approved 2026-10-19T19:31:00Z) - [x] Reverse Engineering - Artifacts refreshed on 2026-10-19T19:19:38Z at commit 38c5c3e (approved 2026-10-19T19:31:00Z)
@@ -405,3 +405,113 @@ Nou is het nog een statische site zonder back-end dus het contactformulier kan n
**Context**: CONSTRUCTION - Unit 3 Code Generation (complete, awaiting approval) **Context**: CONSTRUCTION - Unit 3 Code Generation (complete, awaiting approval)
--- ---
## Unit 3 Prijzen — Approval, Push and Test Deploy
**Timestamp**: 2026-10-20T03:10:00Z
**User Input**: "Ziet er goed uit. Kan je de changes tot nu toe committed en pushen. Kan je dan een deploy naar test doen?"
**AI Response**: "Unit 3 approved. All work was already committed (5 commits on feature/homepage-sections). Pushed the branch to origin (new branch). Dispatched the CI workflow on feature/homepage-sections with deploy_test=true, deploy_production=false (run 552); following it until completion."
**Context**: CONSTRUCTION - Unit 3 complete; branch pushed; test deploy requested
---
## Unit 4 Lieve woorden — Functional Design Plan and Questions
**Timestamp**: 2026-10-20T03:15:00Z
**User Input**: "Ga ondertussen verder naar de volgende stage"
**AI Response**: "Started unit 4 Functional Design while CI run 552 (test deploy) is running. Created construction/plans/lieve-woorden-functional-design-plan.md (6 steps) and lieve-woorden-fd-questions.md with 3 questions: behaviour at the end of the list, slide vs crossfade transition, equal vs adaptive height."
**Context**: CONSTRUCTION - Unit 4 Functional Design (awaiting answers)
---
## Unit 4 Lieve woorden — Functional Design Answers
**Timestamp**: 2026-10-20T03:25:00Z
**User Input**: "1a
2a
3a"
**AI Response**: "Recorded answers (loop around at the ends; sliding transition via Chakra Carousel; all slides the height of the tallest). No ambiguities. Generating functional design artifacts."
**Context**: CONSTRUCTION - Unit 4 Functional Design (answers received)
---
## Unit 4 Lieve woorden — Functional Design Complete
**Timestamp**: 2026-10-20T03:40:00Z
**User Input**: (none — generation)
**AI Response**: "Generated construction/lieve-woorden/functional-design/: domain-entities.md (Testimonial invariants, live data with alt texts), business-rules.md (BR-REV-01..11, two decision flowcharts), business-logic-model.md (navigation sequence; carousel state is Chakra's; visibleTestimonials and slideLabel with 6 PBT properties; PBT-06 N/A), frontend-components.md (Testimonials with Chakra Carousel parts, TestimonialSlide, equal height, reduced motion, single live announcement). Prompt: Request Changes or Continue to Code Generation."
**Context**: CONSTRUCTION - Unit 4 Functional Design (awaiting approval)
---
## Unit 4 Lieve woorden — Functional Design Approval
**Timestamp**: 2026-10-20T03:45:00Z
**User Input**: "Ga verder naar de volgende stage"
**AI Response**: "Functional design approved. Proceeding to Code Generation Part 1 (planning) for unit 4."
**Context**: CONSTRUCTION - Unit 4 Functional Design approved
---
## Test Deploy Result (units 1–3)
**Timestamp**: 2026-10-20T03:50:00Z
**User Input**: (none — CI run finished)
**AI Response**: "CI run 552 (workflow_dispatch on feature/homepage-sections, deploy_test=true) completed: check success, deploy-test success, lighthouse success, deploy-production skipped. Verified test.andreaslop.nl serves the new route chunk containing the Lifestyle fotografie, Over mij and Prijzen content."
**Context**: Test environment updated with units 1–3
---
## Unit 4 Lieve woorden — Code Generation Plan
**Timestamp**: 2026-10-20T03:55:00Z
**User Input**: (none — AI-initiated)
**AI Response**: "Created construction/plans/lieve-woorden-code-generation-plan.md (14 steps). Findings from @zag-js/carousel 1.43.3 that shape it: built-in triggers/indicators/keys always scroll smoothly from JS (CSS cannot honour reduced motion) but the API accepts an instant flag → own prev/next/dots/arrow keys calling the API with instant = reduced motion; item group has aria-live polite → set off, one own live region; default translations English → item label via slideLabel. Prompt: approve plan or request changes."
**Context**: CONSTRUCTION - Unit 4 Code Generation Part 1 (awaiting plan approval)
---
## Unit 4 Lieve woorden — Plan Approval
**Timestamp**: 2026-10-20T04:00:00Z
**User Input**: "Approve plan"
**AI Response**: "Plan approved. Starting Code Generation Part 2."
**Context**: CONSTRUCTION - Unit 4 Code Generation Part 2 (start)
---
## Unit 4 Lieve woorden — Code Generation Complete
**Timestamp**: 2026-10-20T05:00:00Z
**User Input**: (none — generation)
**AI Response**: "Executed all 14 steps. Step 13.5 findings: jsdom cannot page Zag (no layout) — unit tests cover our wiring, paging/looping/dots verified in real Chrome via CDP; jsdom lacks IntersectionObserver/ResizeObserver/Element.scrollTo — ResizeObserver no-op added to test setup, the others stubbed per test; real-browser check showed slides clipping/overlapping the sand block — spacing and per-slide padding added; Lighthouse home mobile median 0.83 → 0.81 because the carousel joined the route chunk (measured with 5-run medians against a unit-3 worktree build) — React.lazy alone did not help, the carousel now loads only when the section is within 200px of the screen; median back to 0.83. Reduced motion verified: instant scroll in the first frame vs ±330ms smooth. Final pnpm check green: 190 tests, mobile 0.83, desktop 1.0, a11y/BP/SEO 1.0. Note: a git checkout of routes/index.tsx during the lazy experiment also reverted the uncommitted Testimonials wiring; it was restored immediately. Temporary worktree and preview servers cleaned up. Committing locally (incl. earlier pending audit/state updates), not pushed."
**Context**: CONSTRUCTION - Unit 4 Code Generation (complete, awaiting approval)
---
@@ -0,0 +1,44 @@
# Code Summary — Unit 4: Lieve woorden
Plan: [lieve-woorden-code-generation-plan.md](../../plans/lieve-woorden-code-generation-plan.md). Functional design: [../functional-design/](../functional-design/). Branch: `feature/homepage-sections`.
## Files
### Created
| File | Purpose |
|---|---|
| `web/src/assets/home/review-trouwshoot.jpg`, `review-newbornshoot.jpg` | Live photos, centre-cropped to 4:5, 880×1100, ±100 KB |
| `web/src/content/testimonials.ts` | The two live reviews |
| `web/src/lib/visibleTestimonials.ts` + test | Invariants filter, first-wins de-duplication (BR-REV-01) |
| `web/src/lib/slideLabel.ts` + test | "Review n van m" (BR-REV-08/09) |
| `web/src/recipes/carouselControl.ts` | Arrow and dot buttons under a carousel |
| `web/src/components/home/Testimonials/Testimonials.tsx` + test | The section; heading always rendered; carousel loaded when near the screen |
| `web/src/components/home/Testimonials/TestimonialCarousel.tsx` | Chakra `Carousel` (Zag) with our own controls and live region; separate chunk |
| `web/src/components/home/Testimonials/TestimonialSlide.tsx` + test | One review: framed photo, quotation mark, shoot, quote, names |
### Modified
| File | Change |
|---|---|
| `web/src/content/types.ts`, `homeContent.ts` | `Testimonial`; `HomeContent.testimonials` |
| `web/src/theme.ts` | Registers `carouselControl` |
| `web/src/test/arbitraries.ts` | `testimonial`, `uniqueTestimonials`, `anyTestimonial` |
| `web/src/test/setup.ts` | No-op `ResizeObserver` (jsdom lacks it; the carousel needs it) |
| `web/src/routes/index.tsx` | Renders `Testimonials` after `Pricing` |
| `web/src/app.test.tsx` | "Lieve woorden" in the page order; stubs `IntersectionObserver` and `Element.scrollTo` for the carousel |
## Decisions and fixes during generation
- **Own controls for reduced motion** (plan finding 1): Zag's built-in triggers, dots and keys scroll smoothly from JavaScript; ours pass `instant` when the visitor prefers reduced motion. Verified in real Chrome: normally the slide moves over ±330 ms, with reduced motion it is in place in the first frame.
- **One announcement** (finding 2): the item group's `aria-live` is off; our polite region says "Review n van m" on each change, nothing on load.
- **Slides clipped each other's frame**: the sand block sticks out 1.5 rem left and below the photo, and the item group clips everything outside a slide, so the next slide's block showed over the quote. Fixed with 4 rem `spacing` between slides and 1.5 rem padding left/bottom in each slide (from `sm`).
- **Carousel cost on page load**: the carousel in the route chunk lowered home mobile Lighthouse from a median **0.83** (unit 3, 5 runs) to **0.81**; `React.lazy` alone did not help (the chunk still loaded at once). Now the section and heading render immediately, and the carousel chunk loads only when the section comes within 200 px of the screen (same rule as the deferred photos), with a placeholder of the measured height. Median back to **0.83** (LCP 3.84 s).
- **Testing approach**: jsdom has no layout, so Zag cannot page there. Unit tests check our wiring (calls to `scrollNext/scrollPrev/scrollTo` with the right `instant`, announcements, labels, loop option, deferred loading); paging, looping, dots and the hidden off-screen slide were checked in real Chrome via the DevTools protocol (next → "Review 2 van 2", next again → back to review 1, dot 2 → review 2).
## Verification (`pnpm check`)
- Lint ✅, Prettier ✅, build ✅ — carousel in its own chunk (`TestimonialCarousel-*.js`, 43 KB raw)
- Tests: 42 files, **190 passed**; 100% coverage on the new `lib/` files
- Lighthouse home: mobile **0.83** (LCP 3.8 s), desktop **1.0** (LCP 0.8 s); accessibility, best practices, SEO **1.0**
- Visual check: 1440 and 390, both reviews
## Extension compliance
- **Security Baseline**: content rendered as text; no new dependencies (Chakra Carousel and Ant Design icons already installed); no external resources. Other rules N/A.
- **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 — the stateful part is Zag's.
@@ -0,0 +1,45 @@
# Business Logic Model — Unit 4: Lieve woorden
## Navigation flow
```mermaid
sequenceDiagram
box rgba(246,224,94,0.4) Visitor
participant V as Visitor
end
box rgba(99,179,237,0.4) Testimonials
participant C as Carousel
participant L as LiveRegion
end
V->>C: Next button, dot, arrow key or swipe
C->>C: Compute target page, looping at the ends
C->>C: Scroll to the target slide, instantly under reduced motion
C->>L: Page changed to n
L-->>V: Announces Review n van m
```
Text alternative: a navigation action makes the carousel compute the target page (looping), scroll to it (instantly under reduced motion) and report the new page to a polite live region, which announces "Review n van m".
The carousel state (current page, scrolling, dragging, looping) is Chakra's `Carousel` (Ark UI); this unit does not reimplement it. Our own logic is limited to the pure functions below and wiring `onPageChange` to the live region.
## Pure functions (`web/src/lib/`)
| Function | Input → output | Rules |
|---|---|---|
| `visibleTestimonials(items: Testimonial[]): Testimonial[]` | raw list → shown list | BR-REV-01 |
| `slideLabel(index: number, count: number): string` | `(1, 2)` → `'Review 2 van 2'` (index is zero-based) | BR-REV-08/09 |
## Testable properties (PBT-01)
| Function | Category | Property |
|---|---|---|
| `visibleTestimonials` | Invariant | Every result meets the invariants; ids unique |
| `visibleTestimonials` | Invariant | Result is a subsequence of the input |
| `visibleTestimonials` | Idempotency | Applying it twice equals applying it once |
| `visibleTestimonials` | Oracle | Valid, unique input comes back unchanged |
| `slideLabel` | Round-trip | The two numbers parsed back from the label are `index + 1` and `count` |
| `slideLabel` | Invariant | For `0 ≤ index < count` the label has the form `Review n van m` with `1 ≤ n ≤ m` |
The looping and paging itself is Chakra's (tested upstream); our component tests cover the behaviour at our boundary: loop from last to first, announcement text, controls hidden for one review, nothing rendered for none. PBT-06 (stateful) is N/A because the state machine is not ours.
Generators (PBT-07) in `src/test/arbitraries.ts`: `testimonial` (valid; slug ids, non-blank texts, image with positive size), `uniqueTestimonials`, `anyTestimonial` (incl. blank quote/author/shoot, empty src, zero size, duplicate ids).
@@ -0,0 +1,64 @@
# Business Rules — Unit 4: Lieve woorden
## Rules
| ID | Rule | Source |
|---|---|---|
| BR-REV-01 | Only testimonials that meet the invariants are shown; duplicates by id keep the first; order is kept. | domain-entities.md |
| BR-REV-02 | No valid testimonial → the section is not rendered. One → it is shown without arrows, dots or carousel semantics. Two or more → carousel. | FR-HP-05 |
| BR-REV-03 | One review is visible at a time; there is no autoplay. | FR-HP-05, design Q2 |
| BR-REV-04 | Navigation: previous/next buttons, one dot per review, arrow keys when focus is in the carousel, and swiping (and mouse dragging) on the slides. | FR-HP-05 |
| BR-REV-05 | At the ends the carousel loops: "next" on the last review goes to the first, "previous" on the first to the last. The buttons are never disabled. | Q1 = A |
| BR-REV-06 | A change slides horizontally (the slides lie side by side; a swipe follows the finger). Under `prefers-reduced-motion` the change is immediate, without animation. | Q2 = A |
| BR-REV-07 | Every slide has the height of the tallest one, so the page below does not move when the review changes. | Q3 = A |
| BR-REV-08 | Every manual change is announced once, politely, as "Review n van m". Nothing is announced on page load. | NFR-HP-01 |
| BR-REV-09 | Each slide is labelled "Review n van m"; the buttons are "Vorige review" / "Volgende review"; each dot is "Review n", and the current dot is marked as current. | NFR-HP-01 |
| BR-REV-10 | Off-screen slides are hidden from assistive technology and not focusable. | NFR-HP-01 |
| BR-REV-11 | The quote is shown as a blockquote with the author as its caption; the large quotation mark is decorative and hidden from assistive technology. | design |
## Decision flow: what is rendered (BR-REV-01/02)
```mermaid
graph TD
In["Testimonials from content"] --> Filter["Keep valid, first of each id"]
Filter --> Count{"How many remain?"}
Count -->|"none"| Nothing["Section not rendered"]
Count -->|"one"| Single["Single review, no controls"]
Count -->|"two or more"| Carousel["Carousel with arrows, dots, keyboard and swipe, looping"]
classDef input fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
classDef decision fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
classDef outcome fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
class In,Filter input;
class Count decision;
class Nothing,Single,Carousel outcome;
```
Text alternative: after filtering, no testimonials means no section, one means a single review without controls, two or more means a looping carousel with arrows, dots, keyboard and swipe.
## Decision flow: navigation (BR-REV-05/06/08)
```mermaid
graph TD
Act["Visitor uses arrow, dot, key or swipe"] --> Target{"Past the last or before the first?"}
Target -->|"yes"| Wrap["Wrap around to the other end"]
Target -->|"no"| Go["Go to the chosen review"]
Wrap --> Motion{"Prefers reduced motion?"}
Go --> Motion
Motion -->|"yes"| Jump["Switch immediately"]
Motion -->|"no"| Slide["Slide horizontally"]
Jump --> Say["Announce Review n van m once"]
Slide --> Say
classDef input fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
classDef decision fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
classDef outcome fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
class Act input;
class Target,Motion decision;
class Wrap,Go,Jump,Slide,Say outcome;
```
Text alternative: any navigation action wraps around at the ends, then either switches immediately (reduced motion) or slides, and is announced once as "Review n van m".
## Misuse considerations (SECURITY-11)
Testimonials are static content (later from the CMS) and rendered as text by React; no HTML from content is interpreted.
@@ -0,0 +1,57 @@
# Domain Entities — Unit 4: Lieve woorden
## Relationships
```mermaid
graph TD
List["Testimonial list"]
Item["Testimonial"]
Image["ContentImage"]
Slide["Carousel slide"]
List -->|"contains, in display order"| Item
Item -->|"has one photo"| Image
Item -->|"shown as"| Slide
classDef entity fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000;
classDef value fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000;
classDef ui fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
class List,Item entity;
class Image value;
class Slide ui;
```
Text alternative: the testimonial list holds testimonials in display order; each has one photo and is shown as one carousel slide (blue = data, orange = value, green = UI).
## Testimonial
| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | Stable, unique key (e.g. `majella-mark`) |
| `shoot` | string | yes | Shoot type as a label (e.g. "Trouwshoot") |
| `quote` | string | yes | The review text, without quotation marks (the design adds a decorative one) |
| `author` | string | yes | Names as they should appear (e.g. "Majella & Mark") |
| `image` | ContentImage | yes | Photo for the review, with alt text and size |
### Invariants
- `id` unique within the list.
- `shoot`, `quote` and `author` non-empty after trimming.
- `image.src` non-empty; `image.width` and `image.height` positive.
- List order is the display order.
Testimonials that break an invariant are skipped; of two with the same id the first is kept (same approach as packages and socials).
## Initial data (live site, 2026-10-19)
| id | shoot | author | quote (start) | photo |
|---|---|---|---|---|
| `majella-mark` | Trouwshoot | Majella & Mark | "Super mooie foto's door Andrea gemaakt op onze trouwdag en pré-wedding shoot. …" | live `IMG_2497-5.jpg` (rings), alt "Bruidegom schuift de trouwring om de vinger van de bruid" |
| `demi-kevin` | Newbornshoot | Demi & Kevin | "Heel tevreden met de newbornshoot. …" | live `5-F41A4650-scaled.jpg` (baby's fist), alt "Vuistje van een pasgeboren baby tussen gebreide dekens" |
Full texts: requirements FR-HP-05.
## Section content (`HomeContent.testimonials`)
| Field | Value |
|---|---|
| `title` | "Lieve woorden" |
@@ -0,0 +1,49 @@
# Frontend Components — Unit 4: Lieve woorden
## Hierarchy
```mermaid
graph TD
Route["routes/index.tsx"] --> T["home/Testimonials"]
T --> Section["HomeSection tone alt"]
T --> Heading["SectionHeading"]
T --> Root["Carousel.Root loop"]
Root --> Group["Carousel.ItemGroup"]
Group --> Item["Carousel.Item x n"]
Item --> Slide["home/Testimonials/TestimonialSlide"]
Slide --> Framed["FramedImage 4 by 5"]
Root --> Control["Carousel.Control: Prev, Indicators, Next"]
T --> Live["Live region"]
Lib["lib: visibleTestimonials, slideLabel"] -.-> T
classDef root fill:#4CAF50,stroke:#2e7d32,stroke-width:1px,color:#000;
classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000;
classDef logic fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000;
class Route root;
class T,Section,Heading,Root,Group,Item,Slide,Framed,Control,Live ui;
class Lib logic;
```
Text alternative: the home route renders Testimonials, which uses HomeSection, SectionHeading, a looping Chakra Carousel with one item per review (each a TestimonialSlide with a FramedImage) and a control bar with previous, dots and next, plus a live region; pure helpers supply the shown reviews and labels.
## Testimonials
- **Props**: `{ content: HomeContent['testimonials']; testimonials: Testimonial[] }`
- **Behaviour**: `visibleTestimonials`; none → `null`; one → the `TestimonialSlide` directly (no carousel); two or more → `Carousel.Root` with `slideCount`, `loop`, `allowMouseDrag`, one slide per page.
- **Layout**: `HomeSection` with `tone="alt"`, `data-testid="testimonials"`, centred `SectionHeading`. Controls centred below the slides, margin `clamp(2.5rem, 5vw, 4rem)`.
- **Equal height** (BR-REV-07): items stretch in the item group's row, so all slides take the tallest height; content vertically centred within.
- **Reduced motion** (BR-REV-06): the item group's scrolling is instant (`scroll-behavior: auto`).
- **Announcements** (BR-REV-08): a `VisuallyHidden` polite live region, empty on load, set to `slideLabel(page, count)` in `onPageChange`. Any live region Chakra adds itself is checked so only one announcement is made.
- **Controls**: `Carousel.PrevTrigger` / `NextTrigger` with Dutch `aria-label`s and arrow icons from the offline icon set (as the hero), 48 px square, `line` border, `ink` border on hover/focus; `Carousel.Indicator` per page, 44 px hit area around an 8 px dot (`accent.deep` outline, filled when current).
- **Test ids**: `testimonials`, `testimonials-prev`, `testimonials-next`, `testimonials-dot-{n}`, `testimonial-{id}`.
## TestimonialSlide
- **Props**: `{ testimonial: Testimonial }`
- **Layout**: grid `5fr 7fr` from `lg` with gap `clamp(2rem, 6vw, 5.5rem)`, centred vertically; stacked below `lg` with the photo max 420 px wide.
- **Photo**: `FramedImage` with aspect `4 / 5` (the source photos are cropped to 4:5 when prepared).
- **Text**: decorative quotation mark (Marcellus, `clamp(5rem, 9vw, 7.5rem)`, `accent`, `aria-hidden`); shoot as eyebrow (`accent.deep`); `figure` > `Blockquote` (Marcellus, `clamp(1.35rem, 2.2vw, 1.75rem)`, line-height 1.5, `ink`) > `figcaption` with "— " + author in small caps (`ink.soft`).
## Accessibility (NFR-HP-01)
- Region named by the h2 "Lieve woorden"; the carousel has `aria-roledescription` "carrousel" and a label "Reviews"; slides "Review n van m" (BR-REV-09).
- Hidden slides are inert to keyboard and screen readers (BR-REV-10).
- Focus ring from the theme on all controls; targets ≥ 44 px.
- Axe clean; Lighthouse accessibility stays 1.0.
@@ -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
+14 -1
View File
@@ -5,9 +5,10 @@ import {
RouterProvider, RouterProvider,
} from '@tanstack/react-router'; } from '@tanstack/react-router';
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import lighthouseConfig from '../lighthouserc.cjs'; import lighthouseConfig from '../lighthouserc.cjs';
import ErrorPage from './components/StatusPage/ErrorPage'; import ErrorPage from './components/StatusPage/ErrorPage';
import { FakeIntersectionObserver } from './test/fakeIntersectionObserver';
import { routeTree } from './routeTree.gen'; import { routeTree } from './routeTree.gen';
import sitePages from './sitePages'; import sitePages from './sitePages';
import { axeResults } from './test/axe'; import { axeResults } from './test/axe';
@@ -28,8 +29,19 @@ vi.mock('./components/PageIntro/PageIntro', async (importOriginal) => {
}; };
}); });
// The homepage's review carousel (Zag) needs an IntersectionObserver and
// Element.scrollTo, which jsdom lacks
beforeEach(() => {
vi.stubGlobal('IntersectionObserver', FakeIntersectionObserver);
Element.prototype.scrollTo = () => {};
});
afterEach(() => { afterEach(() => {
crash.enabled = false; crash.enabled = false;
vi.unstubAllGlobals();
FakeIntersectionObserver.reset();
// @ts-expect-error -- jsdom has no Element.scrollTo of its own
delete Element.prototype.scrollTo;
}); });
// De echte app: route tree, router-opties en thema zoals in main.tsx // De echte app: route tree, router-opties en thema zoals in main.tsx
@@ -133,6 +145,7 @@ describe('homepage', () => {
name: 'Lifestyle fotograaf met een passie voor storytelling', name: 'Lifestyle fotograaf met een passie voor storytelling',
}), }),
screen.getByRole('region', { name: 'Prijzen' }), screen.getByRole('region', { name: 'Prijzen' }),
screen.getByRole('region', { name: 'Lieve woorden' }),
]; ];
let previous: Element = hero; let previous: Element = hero;
Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

@@ -0,0 +1,129 @@
import { useState } from 'react';
import {
Box,
Carousel,
chakra,
Flex,
useCarousel,
useMediaQuery,
useRecipe,
VisuallyHidden,
} from '@chakra-ui/react';
import { Icon } from '@iconify/react/offline';
import leftOutlined from '@iconify-icons/ant-design/left-outlined';
import rightOutlined from '@iconify-icons/ant-design/right-outlined';
import type { Testimonial } from '@/content/types';
import { slideLabel } from '@/lib/slideLabel';
import TestimonialSlide from './TestimonialSlide';
// The carousel itself. Chakra's carousel (Zag) handles paging, snapping,
// looping, swiping and hiding off-screen slides. The buttons, dots and arrow
// keys are our own: the built-in ones always scroll smoothly from
// JavaScript, which CSS cannot switch off for visitors who prefer reduced
// motion; ours pass the API's `instant` flag instead (BR-REV-06).
export default function TestimonialCarousel({
testimonials,
}: {
testimonials: Testimonial[];
}) {
const count = testimonials.length;
const [reducedMotion] = useMediaQuery(
['(prefers-reduced-motion: reduce)'],
{ ssr: false },
);
// Empty on load; filled only by a change, so nothing is read out then
const [announcement, setAnnouncement] = useState('');
const carousel = useCarousel({
slideCount: count,
loop: true,
allowMouseDrag: true,
// Room between slides, so the next one never peeks in
spacing: '4rem',
translations: { item: slideLabel },
onPageChange: ({ page }) => setAnnouncement(slideLabel(page, count)),
});
const control = useRecipe({ key: 'carouselControl' });
const previous = () => carousel.scrollPrev(reducedMotion);
const next = () => carousel.scrollNext(reducedMotion);
return (
<Carousel.RootProvider
value={carousel}
aria-label="Reviews"
aria-roledescription="carrousel"
gap={0}
>
{/* Our own live region announces changes, so the item group's
built-in one is switched off to avoid hearing it twice */}
<Carousel.ItemGroup aria-live="off">
{testimonials.map((testimonial, index) => (
// The photo's sand block sticks out 1.5rem to the left
// and below (FramedImage); the item group clips
// everything outside a slide, so each slide makes room
<Carousel.Item
key={testimonial.id}
index={index}
ps={{ base: 0, sm: '1.5rem' }}
pb={{ base: 0, sm: '1.5rem' }}
>
<TestimonialSlide testimonial={testimonial} />
</Carousel.Item>
))}
</Carousel.ItemGroup>
<Flex
justifyContent="center"
alignItems="center"
gap={6}
mt="clamp(2.5rem, 5vw, 4rem)"
onKeyDown={(event) => {
if (event.key === 'ArrowLeft') previous();
else if (event.key === 'ArrowRight') next();
else return;
event.preventDefault();
}}
>
<chakra.button
type="button"
aria-label="Vorige review"
data-testid="testimonials-prev"
css={control({ kind: 'arrow' })}
onClick={previous}
>
<Icon icon={leftOutlined} aria-hidden />
</chakra.button>
<Flex gap={1}>
{testimonials.map((testimonial, index) => (
<chakra.button
key={testimonial.id}
type="button"
aria-label={`Review ${index + 1}`}
aria-current={
carousel.page === index ? 'true' : undefined
}
data-testid={`testimonials-dot-${index + 1}`}
css={control({ kind: 'dot' })}
onClick={() =>
carousel.scrollTo(index, reducedMotion)
}
/>
))}
</Flex>
<chakra.button
type="button"
aria-label="Volgende review"
data-testid="testimonials-next"
css={control({ kind: 'arrow' })}
onClick={next}
>
<Icon icon={rightOutlined} aria-hidden />
</chakra.button>
</Flex>
<Box aria-live="polite" data-testid="testimonials-status">
<VisuallyHidden>{announcement}</VisuallyHidden>
</Box>
</Carousel.RootProvider>
);
}
@@ -0,0 +1,35 @@
import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import testimonials from '@/content/testimonials';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import TestimonialSlide from './TestimonialSlide';
const review = testimonials[1];
describe('TestimonialSlide', () => {
it('shows the photo, shoot, quote and names', async () => {
const { container } = await renderWithProviders(
<TestimonialSlide testimonial={review} />,
);
expect(screen.getByRole('img')).toHaveAccessibleName(review.image.alt);
expect(screen.getByText(review.shoot)).toBeInTheDocument();
const quote = container.querySelector('blockquote');
expect(quote).toHaveTextContent(review.quote);
expect(container.querySelector('figcaption')).toHaveTextContent(
review.author,
);
expect(await axeResults(container)).toHaveNoViolations();
});
it('keeps the decorative quotation mark away from assistive technology', async () => {
const { container } = await renderWithProviders(
<TestimonialSlide testimonial={review} />,
);
const mark = [
...container.querySelectorAll('[aria-hidden="true"]'),
].find((element) => element.textContent === '“');
expect(mark).toBeDefined();
});
});
@@ -0,0 +1,60 @@
import { Blockquote, Box, Grid, Text } from '@chakra-ui/react';
import FramedImage from '@/components/FramedImage/FramedImage';
import type { Testimonial } from '@/content/types';
type TestimonialSlideProps = {
testimonial: Testimonial;
};
// One review (design .testimonial): framed photo next to a large quotation
// mark, the shoot type, the quote and the names. Stacked below `lg`.
export default function TestimonialSlide({
testimonial,
}: TestimonialSlideProps) {
return (
<Grid
data-testid={`testimonial-${testimonial.id}`}
templateColumns={{ base: '1fr', lg: '5fr 7fr' }}
gap="clamp(2rem, 6vw, 5.5rem)"
alignItems="center"
h="100%"
>
<Box maxW={{ base: '420px', lg: 'none' }} w="100%">
<FramedImage image={testimonial.image} aspectRatio="4 / 5" />
</Box>
<Box>
<Text
aria-hidden="true"
fontFamily="heading"
fontSize="clamp(5rem, 9vw, 7.5rem)"
lineHeight="1"
h="0.55em"
color="accent"
>
“
</Text>
{/* accent.deep instead of the design's accent: meets 4.5:1 (NFR-HP-01) */}
<Text textStyle="eyebrow" color="accent.deep" mb={4}>
{testimonial.shoot}
</Text>
<Blockquote.Root variant="plain" px={0} gap={7}>
<Blockquote.Content
fontFamily="heading"
fontSize="clamp(1.35rem, 2.2vw, 1.75rem)"
lineHeight="1.5"
color="ink"
>
{testimonial.quote}
</Blockquote.Content>
<Blockquote.Caption
textStyle="eyebrow"
color="ink.soft"
_before={{ content: '"— "' }}
>
{testimonial.author}
</Blockquote.Caption>
</Blockquote.Root>
</Box>
</Grid>
);
}
@@ -0,0 +1,198 @@
import { act, fireEvent, screen, within } from '@testing-library/react';
import type { UseCarouselProps } from '@chakra-ui/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import homeContent from '@/content/homeContent';
import testimonials from '@/content/testimonials';
import { axeResults } from '@/test/axe';
import { FakeIntersectionObserver } from '@/test/fakeIntersectionObserver';
import { renderWithProviders } from '@/test/renderWithProviders';
import { visibleTestimonials } from '@/lib/visibleTestimonials';
import Testimonials from './Testimonials';
// jsdom has no layout, so the carousel (Zag) cannot compute pages and
// cannot really move; paging, looping and swiping are Zag's own and are
// checked in a real browser (see the unit's code summary). These tests check
// our wiring: which API calls our controls make, and what is announced.
const carousel = vi.hoisted(() => ({
props: undefined as UseCarouselProps | undefined,
calls: [] as Array<[string, ...unknown[]]>,
}));
vi.mock('@chakra-ui/react', async (importOriginal) => {
const chakra = await importOriginal<typeof import('@chakra-ui/react')>();
return {
...chakra,
useCarousel: (props: UseCarouselProps) => {
const api = chakra.useCarousel(props);
carousel.props = props;
const record =
(name: string, real: (...args: never[]) => void) =>
(...args: unknown[]) => {
carousel.calls.push([name, ...args]);
(real as (...args: unknown[]) => void)(...args);
};
return {
...api,
scrollNext: record('scrollNext', api.scrollNext),
scrollPrev: record('scrollPrev', api.scrollPrev),
scrollTo: record('scrollTo', api.scrollTo),
};
},
};
});
beforeEach(() => {
carousel.calls = [];
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 content = homeContent.testimonials;
// Renders the section and brings it into view, so the lazily loaded
// carousel appears
async function renderTestimonials(items = testimonials) {
const result = await renderWithProviders(
<Testimonials content={content} testimonials={items} />,
);
act(() => {
FakeIntersectionObserver.instances.forEach((observer) =>
observer.trigger(true),
);
});
if (visibleTestimonials(items).length > 1) {
await screen.findByRole('region', { name: 'Reviews' });
}
return result;
}
const status = () => screen.getByTestId('testimonials-status');
const button = (name: string) => screen.getByRole('button', { name });
const preferReducedMotion = () =>
vi.spyOn(window, 'matchMedia').mockImplementation(
(query: string) =>
({
matches: query.includes('reduce'),
media: query,
onchange: null,
addEventListener: () => {},
removeEventListener: () => {},
addListener: () => {},
removeListener: () => {},
dispatchEvent: () => false,
}) as MediaQueryList,
);
describe('Testimonials', () => {
it('shows the heading at once but loads the carousel only near the screen', async () => {
await renderWithProviders(
<Testimonials content={content} testimonials={testimonials} />,
);
expect(
screen.getByRole('region', { name: 'Lieve woorden' }),
).toBeInTheDocument();
expect(screen.queryByRole('region', { name: 'Reviews' })).toBeNull();
act(() => {
FakeIntersectionObserver.instances.forEach((observer) =>
observer.trigger(true),
);
});
expect(
await screen.findByRole('region', { name: 'Reviews' }),
).toBeInTheDocument();
});
it('shows a looping carousel of the reviews with Dutch labels', async () => {
const { container } = await renderTestimonials();
const section = screen.getByRole('region', { name: 'Lieve woorden' });
const region = within(section).getByRole('region', {
name: 'Reviews',
});
expect(region).toHaveAttribute('aria-roledescription', 'carrousel');
expect(carousel.props).toMatchObject({
slideCount: 2,
loop: true,
allowMouseDrag: true,
});
expect(button('Vorige review')).toBeInTheDocument();
expect(button('Volgende review')).toBeInTheDocument();
expect(button('Review 1')).toHaveAttribute('aria-current', 'true');
expect(button('Review 2')).not.toHaveAttribute('aria-current');
const slides = container.querySelectorAll(
'[aria-roledescription="slide"]',
);
expect(slides[0]).toHaveAttribute('aria-label', 'Review 1 van 2');
expect(slides[1]).toHaveAttribute('aria-label', 'Review 2 van 2');
expect(await axeResults(container)).toHaveNoViolations();
});
it('announces nothing on load and only through its own live region', async () => {
const { container } = await renderTestimonials();
expect(status()).toHaveTextContent('');
const live = [...container.querySelectorAll('[aria-live]')].filter(
(element) => element.getAttribute('aria-live') !== 'off',
);
expect(live).toEqual([status()]);
});
it('announces a page change as "Review n van m"', async () => {
await renderTestimonials();
act(() => {
carousel.props?.onPageChange?.({ page: 1, pageSnapPoint: 0 });
});
expect(status()).toHaveTextContent('Review 2 van 2');
});
it('moves with the arrows, the dots and the arrow keys', async () => {
await renderTestimonials();
fireEvent.click(button('Volgende review'));
fireEvent.click(button('Vorige review'));
fireEvent.click(button('Review 2'));
fireEvent.keyDown(button('Review 2'), { key: 'ArrowRight' });
fireEvent.keyDown(button('Review 2'), { key: 'ArrowLeft' });
fireEvent.keyDown(button('Review 2'), { key: 'Enter' });
expect(carousel.calls).toEqual([
['scrollNext', false],
['scrollPrev', false],
['scrollTo', 1, false],
['scrollNext', false],
['scrollPrev', false],
]);
});
it('scrolls instantly for visitors who prefer reduced motion', async () => {
preferReducedMotion();
await renderTestimonials();
fireEvent.click(button('Volgende review'));
fireEvent.click(button('Review 1'));
fireEvent.keyDown(button('Review 1'), { key: 'ArrowLeft' });
expect(carousel.calls).toEqual([
['scrollNext', true],
['scrollTo', 0, true],
['scrollPrev', true],
]);
});
it('shows a single review without carousel controls', async () => {
await renderTestimonials([testimonials[0]]);
expect(
screen.getByTestId(`testimonial-${testimonials[0].id}`),
).toBeInTheDocument();
expect(screen.queryByRole('button')).toBeNull();
});
it('leaves the section out when no review is valid', async () => {
await renderTestimonials([{ ...testimonials[0], quote: '' }]);
expect(
screen.queryByRole('region', { name: 'Lieve woorden' }),
).toBeNull();
});
});
@@ -0,0 +1,71 @@
import { lazy, Suspense } from 'react';
import { Box } from '@chakra-ui/react';
import { DEFERRED_LOAD_MARGIN } from '@/components/DeferredImage/DeferredImage';
import HomeSection from '@/components/HomeSection/HomeSection';
import Reveal from '@/components/Reveal/Reveal';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
import type { HomeContent, Testimonial } from '@/content/types';
import useInView from '@/hooks/useInView';
import { visibleTestimonials } from '@/lib/visibleTestimonials';
import TestimonialSlide from './TestimonialSlide';
// The carousel (Chakra/Zag) is the heaviest code on the page and sits far
// below the hero. It is loaded only when this section comes near the screen,
// so the hero (the largest contentful paint) never waits for it: loading it
// with the page cost ±0.02 Lighthouse performance on mobile.
const TestimonialCarousel = lazy(() => import('./TestimonialCarousel'));
const TITLE_ID = 'testimonials-title';
// Keeps about the space of the carousel while it loads, so the page below
// does not jump when it arrives (measured: ±920px on phones and tablets,
// ±570px at 1024px, ±790px at 1440px)
const PLACEHOLDER_HEIGHT = { base: '920px', lg: '570px', xl: '790px' };
type TestimonialsProps = {
content: HomeContent['testimonials'];
testimonials: Testimonial[];
};
// "Lieve woorden": client reviews, one at a time (design .testimonials).
// Without a valid review the section is left out; a single review is shown
// without carousel controls. The heading is always rendered.
export default function Testimonials({
content,
testimonials,
}: TestimonialsProps) {
const shown = visibleTestimonials(testimonials);
const { ref, inView } = useInView<HTMLDivElement>({
rootMargin: DEFERRED_LOAD_MARGIN,
});
if (shown.length === 0) return null;
return (
<HomeSection
labelledBy={TITLE_ID}
tone="alt"
data-testid="testimonials"
>
<Reveal>
<SectionHeading id={TITLE_ID} title={content.title} />
</Reveal>
<Reveal>
{shown.length === 1 ? (
<TestimonialSlide testimonial={shown[0]} />
) : (
<Box ref={ref}>
{inView ? (
<Suspense
fallback={<Box minH={PLACEHOLDER_HEIGHT} />}
>
<TestimonialCarousel testimonials={shown} />
</Suspense>
) : (
<Box minH={PLACEHOLDER_HEIGHT} />
)}
</Box>
)}
</Reveal>
</HomeSection>
);
}
+3
View File
@@ -66,6 +66,9 @@ const homeContent: HomeContent = {
{ src: deco2, alt: '', width: 239, height: 224 }, { src: deco2, alt: '', width: 239, height: 224 },
], ],
}, },
testimonials: {
title: 'Lieve woorden',
},
}; };
export default homeContent; export default homeContent;
+36
View File
@@ -0,0 +1,36 @@
import type { Testimonial } from './types';
// Images
import trouwshoot from '../assets/home/review-trouwshoot.jpg';
import newbornshoot from '../assets/home/review-newbornshoot.jpg';
// Reviews from clients until the CMS API exists (live site, October 2026),
// in display order
const testimonials: Testimonial[] = [
{
id: 'majella-mark',
shoot: 'Trouwshoot',
quote: "Super mooie foto's door Andrea gemaakt op onze trouwdag en pré-wedding shoot. Wij zijn er super blij mee! Een aantal hebben wij laten afdrukken en hangen nu ingelijst aan de muur, dus wij genieten er nog elke dag van.",
author: 'Majella & Mark',
image: {
src: trouwshoot,
alt: 'Bruidegom schuift de trouwring om de vinger van de bruid',
width: 880,
height: 1100,
},
},
{
id: 'demi-kevin',
shoot: 'Newbornshoot',
quote: "Heel tevreden met de newbornshoot. De foto's zijn prachtig geworden en we zijn erg blij met het resultaat. Zeker aan te raden!",
author: 'Demi & Kevin',
image: {
src: newbornshoot,
alt: 'Vuistje van een pasgeboren baby tussen gebreide dekens',
width: 880,
height: 1100,
},
},
];
export default testimonials;
+13
View File
@@ -40,6 +40,16 @@ export interface PricingPackage {
features: string[]; features: string[];
} }
// A review from a client ("Lieve woorden"). quote is plain text without
// quotation marks; the design adds a decorative one.
export interface Testimonial {
id: string;
shoot: string;
quote: string;
author: string;
image: ContentImage;
}
// Content of the homepage sections below the hero // Content of the homepage sections below the hero
export interface HomeContent { export interface HomeContent {
intro: { intro: {
@@ -61,6 +71,9 @@ export interface HomeContent {
// Purely decorative illustrations, alt="" // Purely decorative illustrations, alt=""
decorations: ContentImage[]; decorations: ContentImage[];
}; };
testimonials: {
title: string;
};
} }
export interface HeroSlide { export interface HeroSlide {
+44
View File
@@ -0,0 +1,44 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { slideLabel } from './slideLabel';
// A position within a carousel: 1 to 20 slides, index within range
const position = fc
.integer({ min: 1, max: 20 })
.chain((count) =>
fc
.integer({ min: 0, max: count - 1 })
.map((index) => ({ index, count })),
);
describe('slideLabel', () => {
it('counts from one', () => {
expect(slideLabel(0, 2)).toBe('Review 1 van 2');
expect(slideLabel(1, 2)).toBe('Review 2 van 2');
});
it('gives back its numbers (round-trip)', () => {
fc.assert(
fc.property(position, ({ index, count }) => {
const [, n, m] =
/^Review (\d+) van (\d+)$/.exec(slideLabel(index, count)) ??
[];
expect(Number(n)).toBe(index + 1);
expect(Number(m)).toBe(count);
}),
);
});
it('always reads "Review n van m" with 1 <= n <= m (invariant)', () => {
fc.assert(
fc.property(position, ({ index, count }) => {
const match = /^Review (\d+) van (\d+)$/.exec(
slideLabel(index, count),
);
expect(match).not.toBeNull();
const [n, m] = [Number(match?.[1]), Number(match?.[2])];
expect(n >= 1 && n <= m).toBe(true);
}),
);
});
});
+5
View File
@@ -0,0 +1,5 @@
// Name of a review in the carousel and what is announced when it changes,
// e.g. "Review 2 van 3". index is zero-based (BR-REV-08, BR-REV-09).
export function slideLabel(index: number, count: number): string {
return `Review ${index + 1} van ${count}`;
}
+73
View File
@@ -0,0 +1,73 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import testimonials from '../content/testimonials';
import { anyTestimonial, uniqueTestimonials } from '../test/arbitraries';
import { isValidTestimonial, visibleTestimonials } from './visibleTestimonials';
const valid = testimonials[0];
describe('visibleTestimonials', () => {
it('keeps the live reviews as they are', () => {
expect(visibleTestimonials(testimonials)).toEqual(testimonials);
});
it('skips reviews that break an invariant', () => {
const broken = [
{ ...valid, id: ' ' },
{ ...valid, id: 'zonder-shoot', shoot: '' },
{ ...valid, id: 'zonder-tekst', quote: ' ' },
{ ...valid, id: 'zonder-naam', author: '' },
{ ...valid, id: 'zonder-foto', image: { ...valid.image, src: '' } },
{ ...valid, id: 'nul-breed', image: { ...valid.image, width: 0 } },
{ ...valid, id: 'nul-hoog', image: { ...valid.image, height: 0 } },
];
expect(visibleTestimonials([...broken, valid])).toEqual([valid]);
});
it('keeps the first of two reviews with the same id', () => {
expect(
visibleTestimonials([valid, { ...valid, author: 'Dubbel' }]),
).toEqual([valid]);
});
it('only returns valid reviews with unique ids (invariant)', () => {
fc.assert(
fc.property(fc.array(anyTestimonial), (input) => {
const result = visibleTestimonials(input);
expect(result.every(isValidTestimonial)).toBe(true);
const ids = result.map((item) => item.id);
expect(new Set(ids).size).toBe(ids.length);
}),
);
});
it('is a subsequence of the input in the same order (invariant)', () => {
fc.assert(
fc.property(fc.array(anyTestimonial), (input) => {
const result = visibleTestimonials(input);
let i = 0;
for (const item of input) {
if (item === result[i]) i++;
}
return i === result.length;
}),
);
});
it('is idempotent', () => {
fc.assert(
fc.property(fc.array(anyTestimonial), (input) => {
const once = visibleTestimonials(input);
expect(visibleTestimonials(once)).toEqual(once);
}),
);
});
it('returns valid, unique reviews unchanged (oracle)', () => {
fc.assert(
fc.property(uniqueTestimonials, (input) => {
expect(visibleTestimonials(input)).toEqual(input);
}),
);
});
});
+29
View File
@@ -0,0 +1,29 @@
import type { Testimonial } from '../content/types.ts';
const filled = (text: string) => text.trim() !== '';
// Whether a review meets the invariants in domain-entities.md
export function isValidTestimonial(item: Testimonial): boolean {
return (
filled(item.id) &&
filled(item.shoot) &&
filled(item.quote) &&
filled(item.author) &&
filled(item.image.src) &&
item.image.width > 0 &&
item.image.height > 0
);
}
// The reviews that can be shown: broken ones from the CMS are skipped, and of
// two with the same id the first wins. The order stays the same (BR-REV-01).
export function visibleTestimonials(
items: readonly Testimonial[],
): Testimonial[] {
const seen = new Set<string>();
return items.filter((item) => {
if (!isValidTestimonial(item) || seen.has(item.id)) return false;
seen.add(item.id);
return true;
});
}
+57
View File
@@ -0,0 +1,57 @@
import { defineRecipe } from '@chakra-ui/react';
// Buttons under a carousel on a light background (design .testimonials__arrow
// and .testimonials__dot): square arrows with a hairline, and dots with a
// 44px hit area around a small visible circle.
const carouselControlRecipe = defineRecipe({
className: 'carousel-control',
base: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
cursor: 'pointer',
bg: 'transparent',
color: 'ink',
transitionDuration: 'interaction',
transitionTimingFunction: 'smooth',
},
variants: {
kind: {
arrow: {
w: '48px',
h: '48px',
borderWidth: '1px',
borderColor: 'line',
fontSize: '1.1rem',
transitionProperty: 'border-color, background',
_hover: { borderColor: 'ink', bg: 'paper' },
_focusVisible: { borderColor: 'ink', bg: 'paper' },
},
dot: {
position: 'relative',
w: '44px',
h: '44px',
_after: {
content: '""',
position: 'absolute',
top: '50%',
left: '50%',
w: '8px',
h: '8px',
borderWidth: '1px',
borderColor: 'accent.deep',
rounded: 'full',
transform: 'translate(-50%, -50%)',
transitionProperty: 'background',
transitionDuration: 'interaction',
},
'&[aria-current="true"]::after': { bg: 'accent.deep' },
},
},
},
defaultVariants: {
kind: 'arrow',
},
});
export default carouselControlRecipe;
+6
View File
@@ -2,10 +2,12 @@ import { createFileRoute } from '@tanstack/react-router';
import Hero from '../components/Hero/Hero'; import Hero from '../components/Hero/Hero';
import AboutBlock from '../components/home/AboutBlock/AboutBlock'; import AboutBlock from '../components/home/AboutBlock/AboutBlock';
import Pricing from '../components/home/Pricing/Pricing'; import Pricing from '../components/home/Pricing/Pricing';
import Testimonials from '../components/home/Testimonials/Testimonials';
import IntroGallery from '../components/home/IntroGallery/IntroGallery'; import IntroGallery from '../components/home/IntroGallery/IntroGallery';
import heroContent from '../content/heroContent'; import heroContent from '../content/heroContent';
import homeContent from '../content/homeContent'; import homeContent from '../content/homeContent';
import packages from '../content/packages'; import packages from '../content/packages';
import testimonials from '../content/testimonials';
import siteContent from '../content/siteContent'; import siteContent from '../content/siteContent';
import { pageHead } from '../seo'; import { pageHead } from '../seo';
@@ -28,6 +30,10 @@ function Index() {
<IntroGallery content={homeContent.intro} /> <IntroGallery content={homeContent.intro} />
<AboutBlock content={homeContent.about} /> <AboutBlock content={homeContent.about} />
<Pricing content={homeContent.pricing} packages={packages} /> <Pricing content={homeContent.pricing} packages={packages} />
<Testimonials
content={homeContent.testimonials}
testimonials={testimonials}
/>
</> </>
); );
} }
+43
View File
@@ -3,6 +3,7 @@ import type {
EmailAddress, EmailAddress,
PricingPackage, PricingPackage,
SocialLink, SocialLink,
Testimonial,
} from '../content/types'; } from '../content/types';
// Gedeelde generators voor de property-based tests (fast-check) // Gedeelde generators voor de property-based tests (fast-check)
@@ -95,3 +96,45 @@ export const anyPackage: fc.Arbitrary<PricingPackage> = fc.oneof(
), ),
}), }),
); );
const image = fc.record({
src: fc.webPath().map((path) => `/assets${path}.jpg`),
alt: fc.string({ maxLength: 40 }),
width: fc.integer({ min: 1, max: 4000 }),
height: fc.integer({ min: 1, max: 4000 }),
});
// A review that meets every invariant
export const testimonial: fc.Arbitrary<Testimonial> = fc.record({
id: fc.oneof(
fc.constantFrom('majella-mark', 'demi-kevin'),
fc.stringMatching(/^[a-z0-9-]{1,16}$/),
),
shoot: nonBlank,
quote: nonBlank,
author: nonBlank,
image,
});
// Valid reviews with unique ids
export const uniqueTestimonials = fc.uniqueArray(testimonial, {
selector: (item) => item.id,
maxLength: 6,
});
// Valid and broken reviews mixed, as a CMS might deliver them
export const anyTestimonial: fc.Arbitrary<Testimonial> = fc.oneof(
testimonial,
fc.record({
id: fc.oneof(fc.constantFrom('majella-mark', '', ' '), fc.string()),
shoot: fc.oneof(nonBlank, fc.constantFrom('', ' ')),
quote: fc.oneof(nonBlank, fc.constantFrom('', ' ')),
author: fc.oneof(nonBlank, fc.constantFrom('', ' ')),
image: fc.record({
src: fc.oneof(fc.constant(''), fc.constant('/a.jpg')),
alt: fc.string({ maxLength: 10 }),
width: fc.integer({ min: -1, max: 10 }),
height: fc.integer({ min: -1, max: 10 }),
}),
}),
);
+10
View File
@@ -32,3 +32,13 @@ Object.defineProperty(window, 'matchMedia', {
}), }),
}); });
window.scrollTo = () => {}; window.scrollTo = () => {};
// jsdom has no ResizeObserver either; the carousel (Zag) needs one. Nothing
// is measured in jsdom, so a no-op is enough. IntersectionObserver is left
// out on purpose: useInView and DeferredImage are tested without it, and
// tests that render the carousel stub it themselves.
globalThis.ResizeObserver ??= class {
observe() {}
unobserve() {}
disconnect() {}
};
+2
View File
@@ -1,4 +1,5 @@
import { createSystem, defaultConfig, defineConfig } from '@chakra-ui/react'; import { createSystem, defaultConfig, defineConfig } from '@chakra-ui/react';
import carouselControlRecipe from './recipes/carouselControl';
import containerRecipe from './recipes/container'; import containerRecipe from './recipes/container';
import iconControlRecipe from './recipes/iconControl'; import iconControlRecipe from './recipes/iconControl';
import linkRecipe from './recipes/link'; import linkRecipe from './recipes/link';
@@ -214,6 +215,7 @@ const config = defineConfig({
skipNavLink: skipNavLinkRecipe, skipNavLink: skipNavLinkRecipe,
linkButton: linkButtonRecipe, linkButton: linkButtonRecipe,
iconControl: iconControlRecipe, iconControl: iconControlRecipe,
carouselControl: carouselControlRecipe,
}, },
}, },
}); });