Four stacked photos were too much on a phone screen. Below the small breakpoint the gallery is now a scroll-snap row with one photo at a time and the next one peeking in; tablets and desktops keep the grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.4 KiB
8.4 KiB
Code Generation Plan — Unit 1: Lifestyle fotografie
This plan is the single source of truth for Code Generation of unit 1.
Unit context
- Requirements: FR-HP-02 (section), FR-HP-11 (scroll reveal, introduced), FR-HP-12 (content + images), NFR-HP-01/02/03/05/06
- Design: unit-of-work.md unit 1; components.md; component-methods.md
- Design reference:
design/andreaslop-static/index.html(.section,.section__head--center,.lead,.intro-gallery) andassets/css/style.css§4, §11, §19 - Depends on: nothing (first unit); introduces the shared blocks every later unit uses
- Functional Design: skipped (presentational). PBT-01: no business logic, data transformation or algorithm in this unit → no property-based tests; this is recorded as N/A, not skipped silently. Example-based tests cover the components and hook (PBT-10).
- Workspace:
K:\Development\SlpSoftware\Projects\AndreaSlopFotografie, code inweb/
Conventions for this unit
- Code comments in English; visitor-facing text (headings, alt texts) in Dutch. Test names in English too, since they are code, not visitor-facing (existing tests stay Dutch).
data-testidon the section and its gallery (intro-gallery,intro-gallery-photo-{n}).- Styling via theme tokens/text styles and Chakra primitives; no CSS files, no hard-coded colours.
Steps
Branch and baseline
- Step 1 — Create branch
feature/homepage-sectionsfrommaster. First commit: the inception artifacts so far (aidlc-docs/…/homepage-sections/, refreshedaidlc-docs/_shared/reverse-engineering/,active-features.md) and the static design update (design/andreaslop-static/,LAYOUT.md,.ai/layout-conventions.md). Not pushed.
Images
- Step 2 — Resize the four live gallery photos (
design/andreaslop-static/assets/img/intro-1…4.jpg, 1067×1600) to 800×1200, JPEG quality ~80, intoweb/src/assets/home/intro-1.jpg … intro-4.jpg. Tool: a one-off PowerShell script using .NETSystem.Drawing(already on Windows; not added to the project). The script and its parameters are recorded in the code summary so later units reuse them. Target ≤ ~150 KB per photo.
Theme (shared)
- Step 3 —
web/src/theme.ts: add tokens from the design that later units also need:- spacing
sectionY(clamp(4.5rem, 9vw, 8.5rem)),sectionYTight(60% of it),gridGap(clamp(1rem, 2.2vw, 2rem)),sectionHeadGap(clamp(2.5rem, 5vw, 4.5rem)) - size
contentNarrow(820px) - text styles
sectionTitle(Marcellus; 1.85 / 2.125 / 2.5rem, line-height 1.15) andlead(1.25rem, weight 300, line-height 1.6) - duration
reveal(0.8s) - then run
pnpm typegen
- spacing
Content
- Step 4 —
web/src/content/types.ts: addContentImageandHomeContentwith theintropart only ({ title, lead, photos: ContentImage[] }); later units extendHomeContent. - Step 5 — Create
web/src/content/homeContent.ts: title "Lifestyle fotografie", lead "Jouw favoriete momenten, vastgelegd op een natuurlijke en ongedwongen manier.", four photos with width/height 800×1200 and alt texts:- "Babyhandje in de hand van de moeder, op een gebreid dekentje"
- "Moeder drukt haar pasgeboren baby in een gebreid truitje tegen zich aan"
- "Zwangere vrouw op blote voeten in het zand bij zonsondergang"
- "Aanstaande vader omarmt zijn zwangere partner in de duinen"
Shared blocks
- Step 6 —
web/src/hooks/useReveal.ts: returns{ ref, visible }; visible immediately whenprefers-reduced-motion: reduceorIntersectionObserveris missing; otherwise observes once (threshold 0.12, rootMargin0px 0px -60px 0px, as in the design) and disconnects on reveal and on unmount. - Step 7 —
web/src/hooks/useReveal.test.tsx: visible without IntersectionObserver (jsdom); visible under reduced motion; hidden until intersecting with a mocked observer, then visible, then unobserved; disconnect on unmount. - Step 8 —
web/src/components/Reveal/Reveal.tsx: wraps children in aBox; opacity 0 + translateY(24px) until visible, transitionrevealduration with thesmootheasing; optionaldelay(seconds) for staggering. - Step 9 —
web/src/components/Reveal/Reveal.test.tsx: children always in the DOM and accessible; visible state without observer. - Step 10 —
web/src/components/SectionHeading/SectionHeading.tsx: optional eyebrow (eyebrowtext style,accent.deep), h2 withid(sectionTitletext style), optional lead (leadtext style,ink.soft);aligncenter (default, max width 620px, centred) or start; bottom marginsectionHeadGap. - Step 11 —
web/src/components/SectionHeading/SectionHeading.test.tsx: h2 with id, optional eyebrow/lead, axe clean. - Step 12 —
web/src/components/HomeSection/HomeSection.tsx:<section aria-labelledby>withpy="sectionY"(orsectionYTight),bgpaperorpaper.alt(tone), innerContainer(contentorcontentNarrowwidth), optionalidanddata-testid. - Step 13 —
web/src/components/HomeSection/HomeSection.test.tsx: region named by its heading, tone and width variants render, id passes through.
The section
- Step 14 —
web/src/components/home/IntroGallery/IntroGallery.tsx:HomeSection+SectionHeading(inReveal) + grid of fourfigures, each in aRevealwith a staggered delay; 4 columns fromlg, 2 fromsm, 1 below; 2nd and 4th photo offset downward fromsm(designmargin-top); imageaspectRatio 3/4,objectFit cover,loading="lazy", explicit width/height; slow hover zoom (1.05,fadeduration), none under reduced motion. - Step 15 —
web/src/components/home/IntroGallery/IntroGallery.test.tsx: region "Lifestyle fotografie", h2 + lead, four images with their alt texts and lazy loading, works with any number of photos (0 shows only the heading), axe clean. - Step 16 —
web/src/routes/index.tsx: renderIntroGallerywithhomeContent.introafter the Hero. - Step 17 —
web/src/app.test.tsx: the homepage shows the "Lifestyle fotografie" section after the hero, still exactly one h1, axe clean (extend the existing home checks).
Verification and wrap-up
- Step 18 — Run
pnpm check(lint, format, tests incl. coverage thresholds, build, audits, Lighthouse mobile + desktop). Fix and rerun until green. - Step 19 — Write
aidlc-docs/features/homepage-sections/construction/lifestyle-fotografie/code/code-summary.md: files created/modified, image script + parameters and resulting sizes, test results, Lighthouse scores, extension compliance. - Step 20 — Commit unit 1 on
feature/homepage-sections("Adds the Lifestyle fotografie section to the homepage" + attribution). Not pushed.
Fix during Step 18 (Step 13.5 self-check)
- Step 18a — Lighthouse home mobile failed (0.78 < 0.8; LCP 3.8 s → 5.3 s). Root cause: Chrome fetches
loading="lazy"images within ±1250 px of the viewport immediately, so the gallery photos right under the hero competed with the hero for bandwidth under Lighthouse's throttling. Fix:hooks/useInView.ts(shared observer logic;useRevealnow builds on it),hooks/usePageLoaded.ts,components/DeferredImage(setssrconly after the load event and when within 600 px of the viewport; width/height reserve the space),test/fakeIntersectionObserver.ts(shared test double); IntroGallery uses DeferredImage with apaper.deepplaceholder. Result: mobile 0.85 (LCP 3.8 s, equal to master).
Change request at review
- Step 21 — Phones: one photo at a time in a swipeable scroll-snap row with the next photo peeking in; keyboard-scrollable list; gallery-level loading via
DeferredImage near; static design and FR-HP-02 updated;pnpm checkgreen.
Requirement traceability
| Requirement | Steps |
|---|---|
| FR-HP-02 | 5, 14–17 |
| FR-HP-11 | 6–9, 14 |
| FR-HP-12 | 2, 4, 5 |
| NFR-HP-01 | 10–15, 17, 18 (Lighthouse a11y) |
| NFR-HP-02 | 3, 8–14 |
| NFR-HP-03 | 7, 9, 11, 13, 15, 17, 18 |
| NFR-HP-05 | 2, 14, 18 |
| NFR-HP-06 | 4, 5 |
Extension compliance (planned)
- Security: no new dependencies or external resources (SECURITY-10/13); no input handling; other rules N/A.
- PBT: PBT-01 N/A for this unit (no logic); PBT-08/09 unchanged; PBT-10 example-based tests present.