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,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.