Adds the Lifestyle fotografie section to the homepage
Adds the first block below the hero: heading, intro and a staggered gallery of four live photos. Brings in the shared section building blocks (HomeSection, SectionHeading, Reveal) and DeferredImage, which holds back below-the-fold photos until the page has loaded so they do not compete with the hero for bandwidth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
# Code Summary — Unit 1: Lifestyle fotografie
|
||||
|
||||
Plan: [lifestyle-fotografie-code-generation-plan.md](../../plans/lifestyle-fotografie-code-generation-plan.md). Branch: `feature/homepage-sections`.
|
||||
|
||||
## Files
|
||||
|
||||
### Created
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `web/src/assets/home/intro-1…4.jpg` | Gallery photos, 800×1200, 92–141 KB |
|
||||
| `web/src/content/homeContent.ts` | Homepage section content (intro part) |
|
||||
| `web/src/hooks/useInView.ts` | Shared "has come into/near view, once" hook (IntersectionObserver; immediate without it) |
|
||||
| `web/src/hooks/useReveal.ts` + test | Reveal trigger on top of `useInView`; immediate under reduced motion |
|
||||
| `web/src/hooks/usePageLoaded.ts` + test | True once the window load event has fired |
|
||||
| `web/src/components/Reveal/Reveal.tsx` + test | Fade-in-and-up wrapper, optional stagger delay, passes Box props |
|
||||
| `web/src/components/DeferredImage/DeferredImage.tsx` + test | Below-the-fold image that loads after the load event and within 600 px of the viewport |
|
||||
| `web/src/components/SectionHeading/SectionHeading.tsx` + test | Eyebrow, h2 with id, lead |
|
||||
| `web/src/components/HomeSection/HomeSection.tsx` + test | Section frame: rhythm, tone, width, `aria-labelledby`, anchor |
|
||||
| `web/src/components/home/IntroGallery/IntroGallery.tsx` + test | The "Lifestyle fotografie" section |
|
||||
| `web/src/test/fakeIntersectionObserver.ts` | Shared, controllable IntersectionObserver test double |
|
||||
|
||||
### Modified
|
||||
| File | Change |
|
||||
|---|---|
|
||||
| `web/src/theme.ts` | Spacing `sectionY`, `sectionYTight`, `sectionHeadGap`, `gridGap`; size `contentNarrow`; duration `reveal`; text styles `sectionTitle`, `lead` |
|
||||
| `web/src/content/types.ts` | `ContentImage`, `HomeContent` (intro) |
|
||||
| `web/src/routes/index.tsx` | Renders `IntroGallery` after the Hero |
|
||||
| `web/src/app.test.tsx` | Homepage: sections follow the hero in order, one h1, axe clean |
|
||||
|
||||
## Deviation from the plan (Step 18a)
|
||||
The first `pnpm check` failed on Lighthouse home mobile performance (0.78, budget 0.8). The LCP rose from 3.8 s to 5.3 s because Chrome fetches `loading="lazy"` images within ±1250 px of the viewport straight away: the gallery photos right under the hero were downloaded together with the first hero photo and, under Lighthouse's throttling, took its bandwidth. `DeferredImage` now holds back the `src` until the page has loaded and the image is near the viewport. Every later unit uses it for its photos.
|
||||
|
||||
## Image script
|
||||
Images are resized with a one-off PowerShell script (not part of the project; .NET `System.Drawing`, Windows). Command used:
|
||||
|
||||
```powershell
|
||||
1..4 | ForEach-Object {
|
||||
& .\resize-image.ps1 -Source "design\andreaslop-static\assets\img\intro-$_.jpg" `
|
||||
-Target "web\src\assets\home\intro-$_.jpg" -Width 800 -Quality 80
|
||||
}
|
||||
```
|
||||
|
||||
```powershell
|
||||
param(
|
||||
[Parameter(Mandatory)] [string] $Source,
|
||||
[Parameter(Mandatory)] [string] $Target,
|
||||
[Parameter(Mandatory)] [int] $Width,
|
||||
[int] $Quality = 80
|
||||
)
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
$image = [System.Drawing.Image]::FromFile((Resolve-Path $Source))
|
||||
try {
|
||||
$height = [int][Math]::Round($image.Height * $Width / $image.Width)
|
||||
$bitmap = New-Object System.Drawing.Bitmap $Width, $height
|
||||
try {
|
||||
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
||||
$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||
$graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
||||
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality
|
||||
$graphics.DrawImage($image, 0, 0, $Width, $height)
|
||||
$graphics.Dispose()
|
||||
$codec = [System.Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object MimeType -eq 'image/jpeg'
|
||||
$params = New-Object System.Drawing.Imaging.EncoderParameters 1
|
||||
$params.Param[0] = New-Object System.Drawing.Imaging.EncoderParameter ([System.Drawing.Imaging.Encoder]::Quality), ([long]$Quality)
|
||||
$bitmap.Save($Target, $codec, $params)
|
||||
}
|
||||
finally { $bitmap.Dispose() }
|
||||
}
|
||||
finally { $image.Dispose() }
|
||||
```
|
||||
|
||||
Results: intro-1 92 KB, intro-2 141 KB, intro-3 137 KB, intro-4 110 KB.
|
||||
|
||||
## Verification (`pnpm check`)
|
||||
- Lint ✅, Prettier ✅ (after reformatting CRLF line endings introduced by an edit script)
|
||||
- Tests: 30 files, **138 passed** (incl. existing property-based tests; coverage thresholds met)
|
||||
- Build ✅ (`tsc` + Vite) — after rewriting constructor parameter properties in a test (`erasableSyntaxOnly`)
|
||||
- `audit:deps` ✅ no known vulnerabilities; `audit:dev` 8 findings in dev tooling (report-only, unchanged from master)
|
||||
- Lighthouse home: mobile performance **0.85** (LCP 3.8 s, equal to master), desktop **1.0**; accessibility, best practices and SEO **1.0** on all 7 URLs
|
||||
- Note: a leftover `vite preview` on port 4173 from an earlier session blocked the first Lighthouse run; it was stopped.
|
||||
|
||||
## Extension compliance
|
||||
- **Security Baseline**: SECURITY-10 compliant (no new dependencies); SECURITY-13 compliant (no external resources); SECURITY-04 compliant (headers unchanged); other rules N/A (no input, server, data store or auth in this unit).
|
||||
- **PBT**: PBT-01 N/A — no business logic, data transformation or algorithm in this unit; PBT-10 compliant (example-based tests for every component and hook); PBT-08/09 unchanged.
|
||||
+23
-20
@@ -18,13 +18,13 @@
|
||||
## Steps
|
||||
|
||||
### Branch and baseline
|
||||
- [ ] **Step 1** — Create branch `feature/homepage-sections` from `master`. First commit: the inception artifacts so far (`aidlc-docs/…/homepage-sections/`, refreshed `aidlc-docs/_shared/reverse-engineering/`, `active-features.md`) and the static design update (`design/andreaslop-static/`, `LAYOUT.md`, `.ai/layout-conventions.md`). Not pushed.
|
||||
- [x] **Step 1** — Create branch `feature/homepage-sections` from `master`. First commit: the inception artifacts so far (`aidlc-docs/…/homepage-sections/`, refreshed `aidlc-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, into `web/src/assets/home/intro-1.jpg … intro-4.jpg`. Tool: a one-off PowerShell script using .NET `System.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.
|
||||
- [x] **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, into `web/src/assets/home/intro-1.jpg … intro-4.jpg`. Tool: a one-off PowerShell script using .NET `System.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:
|
||||
- [x] **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) and `lead` (1.25rem, weight 300, line-height 1.6)
|
||||
@@ -32,33 +32,36 @@
|
||||
- then run `pnpm typegen`
|
||||
|
||||
### Content
|
||||
- [ ] **Step 4** — `web/src/content/types.ts`: add `ContentImage` and `HomeContent` with the `intro` part only (`{ title, lead, photos: ContentImage[] }`); later units extend `HomeContent`.
|
||||
- [ ] **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:
|
||||
- [x] **Step 4** — `web/src/content/types.ts`: add `ContentImage` and `HomeContent` with the `intro` part only (`{ title, lead, photos: ContentImage[] }`); later units extend `HomeContent`.
|
||||
- [x] **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:
|
||||
1. "Babyhandje in de hand van de moeder, op een gebreid dekentje"
|
||||
2. "Moeder drukt haar pasgeboren baby in een gebreid truitje tegen zich aan"
|
||||
3. "Zwangere vrouw op blote voeten in het zand bij zonsondergang"
|
||||
4. "Aanstaande vader omarmt zijn zwangere partner in de duinen"
|
||||
|
||||
### Shared blocks
|
||||
- [ ] **Step 6** — `web/src/hooks/useReveal.ts`: returns `{ ref, visible }`; visible immediately when `prefers-reduced-motion: reduce` or `IntersectionObserver` is missing; otherwise observes once (threshold 0.12, rootMargin `0px 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 a `Box`; opacity 0 + translateY(24px) until visible, transition `reveal` duration with the `smooth` easing; optional `delay` (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 (`eyebrow` text style, `accent.deep`), h2 with `id` (`sectionTitle` text style), optional lead (`lead` text style, `ink.soft`); `align` center (default, max width 620px, centred) or start; bottom margin `sectionHeadGap`.
|
||||
- [ ] **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>` with `py="sectionY"` (or `sectionYTight`), `bg` `paper` or `paper.alt` (`tone`), inner `Container` (`content` or `contentNarrow` width), optional `id` and `data-testid`.
|
||||
- [ ] **Step 13** — `web/src/components/HomeSection/HomeSection.test.tsx`: region named by its heading, tone and width variants render, id passes through.
|
||||
- [x] **Step 6** — `web/src/hooks/useReveal.ts`: returns `{ ref, visible }`; visible immediately when `prefers-reduced-motion: reduce` or `IntersectionObserver` is missing; otherwise observes once (threshold 0.12, rootMargin `0px 0px -60px 0px`, as in the design) and disconnects on reveal and on unmount.
|
||||
- [x] **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.
|
||||
- [x] **Step 8** — `web/src/components/Reveal/Reveal.tsx`: wraps children in a `Box`; opacity 0 + translateY(24px) until visible, transition `reveal` duration with the `smooth` easing; optional `delay` (seconds) for staggering.
|
||||
- [x] **Step 9** — `web/src/components/Reveal/Reveal.test.tsx`: children always in the DOM and accessible; visible state without observer.
|
||||
- [x] **Step 10** — `web/src/components/SectionHeading/SectionHeading.tsx`: optional eyebrow (`eyebrow` text style, `accent.deep`), h2 with `id` (`sectionTitle` text style), optional lead (`lead` text style, `ink.soft`); `align` center (default, max width 620px, centred) or start; bottom margin `sectionHeadGap`.
|
||||
- [x] **Step 11** — `web/src/components/SectionHeading/SectionHeading.test.tsx`: h2 with id, optional eyebrow/lead, axe clean.
|
||||
- [x] **Step 12** — `web/src/components/HomeSection/HomeSection.tsx`: `<section aria-labelledby>` with `py="sectionY"` (or `sectionYTight`), `bg` `paper` or `paper.alt` (`tone`), inner `Container` (`content` or `contentNarrow` width), optional `id` and `data-testid`.
|
||||
- [x] **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` (in `Reveal`) + grid of four `figure`s, each in a `Reveal` with a staggered delay; 4 columns from `lg`, 2 from `sm`, 1 below; 2nd and 4th photo offset downward from `sm` (design `margin-top`); image `aspectRatio 3/4`, `objectFit cover`, `loading="lazy"`, explicit width/height; slow hover zoom (1.05, `fade` duration), 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`: render `IntroGallery` with `homeContent.intro` after 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).
|
||||
- [x] **Step 14** — `web/src/components/home/IntroGallery/IntroGallery.tsx`: `HomeSection` + `SectionHeading` (in `Reveal`) + grid of four `figure`s, each in a `Reveal` with a staggered delay; 4 columns from `lg`, 2 from `sm`, 1 below; 2nd and 4th photo offset downward from `sm` (design `margin-top`); image `aspectRatio 3/4`, `objectFit cover`, `loading="lazy"`, explicit width/height; slow hover zoom (1.05, `fade` duration), none under reduced motion.
|
||||
- [x] **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.
|
||||
- [x] **Step 16** — `web/src/routes/index.tsx`: render `IntroGallery` with `homeContent.intro` after the Hero.
|
||||
- [x] **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.
|
||||
- [x] **Step 18** — Run `pnpm check` (lint, format, tests incl. coverage thresholds, build, audits, Lighthouse mobile + desktop). Fix and rerun until green.
|
||||
- [x] **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.
|
||||
- [x] **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)
|
||||
- [x] **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; `useReveal` now builds on it), `hooks/usePageLoaded.ts`, `components/DeferredImage` (sets `src` only 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 a `paper.deep` placeholder. Result: mobile 0.85 (LCP 3.8 s, equal to master).
|
||||
|
||||
## Requirement traceability
|
||||
| Requirement | Steps |
|
||||
|
||||
Reference in New Issue
Block a user