Files
AndreaSlopFotografie/aidlc-docs/features/homepage-sections/construction/lifestyle-fotografie/code/code-summary.md
T
SluijsensandClaude Opus 5.5 3e530df0af Shows the Lifestyle fotografie photos as a swipeable row on phones
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>
2026-10-20 00:14:47 +02:00

6.4 KiB
Raw Blame History

Code Summary — Unit 1: Lifestyle fotografie

Plan: 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.

Change request after review: swipeable row on phones

Requested: on phones the four photos stacked vertically were too much; show one at a time and swipe to the next.

  • IntroGallery now renders the photos as a list (ul named "Foto's"). Below sm it is a full-bleed row with CSS scroll snap: each photo 85% of the width, centred on snap, the next one peeking in; scrollbar hidden; the list is focusable (tabIndex=0, only while it scrolls, via useBreakpointValue) so keyboard users can scroll it with the arrow keys. From sm the grid (2 / 4 columns, staggered offsets) is unchanged.
  • Photos clipped by the scroller never intersect on their own, so the gallery observes its list once (useInView, 600 px margin) and passes near to each DeferredImage (new optional prop). The gallery now fades in as one block instead of per photo.
  • Static design updated to match (style.css, ≤ 680 px); FR-HP-02 updated.
  • Verified at an emulated 390×844 phone via the Chrome DevTools Protocol (one photo with the next peeking in; second photo snaps to the centre after swiping).
  • pnpm check green: 139 tests, Lighthouse home mobile 0.84 (LCP 3.9 s), desktop 1.0, accessibility/best practices/SEO 1.0.

Image script

Images are resized with a one-off PowerShell script (not part of the project; .NET System.Drawing, Windows). Command used:

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