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>
5.2 KiB
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.
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:dev8 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 previewon 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.