Adds the Instagram section to the homepage

Shows the handle as a link to the profile and six square photos from edge
to edge (2, 3 or 6 per row), each linking to the profile in a new tab.
The photos are ones the page already loads, so the section adds no
downloads; the API will later fill it with the real feed. Without a valid
https link to Instagram the section is left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 00:26:41 +02:00
co-authored by Claude Opus 5.5
parent f8905f5586
commit 52c1864a38
13 changed files with 511 additions and 36 deletions
@@ -0,0 +1,25 @@
# Code Summary — Unit 6: Instagram
Plan: [instagram-code-generation-plan.md](../../plans/instagram-code-generation-plan.md)
## Files
| File | Change |
|---|---|
| `web/src/content/types.ts` | `HomeContent.instagram: { title; handle; photos: ContentImage[] }` |
| `web/src/content/homeContent.ts` | Intro photos moved to a shared `introPhotos` constant; `instagram` content reuses them plus the two review photos (`testimonials`), so one photo keeps one alt text and the section adds no image downloads |
| `web/src/components/HomeSection/HomeSection.tsx` + test | `width="full"`: no `Container`, for edge-to-edge content |
| `web/src/components/SectionHeading/SectionHeading.tsx` | `lead` accepts a `ReactNode` (the handle link) |
| `web/src/components/home/InstagramGrid/InstagramGrid.tsx` + test | New section: centred heading with the handle as external link, full-bleed list of square tiles (2 / 3 from `md` / 6 from `xl`, 2px gap), each an external link named by the photo's alt plus "(Instagram, opent in nieuw tabblad)"; hover and keyboard focus zoom 1.06 and fade to 85%, fade only under reduced motion; focused tile lifted above its neighbours so the ring is not covered |
| `web/src/routes/index.tsx` | Renders `InstagramGrid` last, only when `visibleSocials` yields an Instagram link (https) |
| `web/src/app.test.tsx` | Instagram added to the page-order check; section absent when the link is missing or not https (`siteContent.socials` overridable through a hoisted mock) |
`LAYOUT.md` already lists Instagram as the last homepage block: unchanged.
## Verification
- Lint, Prettier, typecheck/build, dependency audit: ✅
- Tests: 244 passed (53 files); new: 3 InstagramGrid, 1 HomeSection, 3 app (order + two absent cases)
- Visual (headless Chrome, preview build): 6 columns at 1440px, 3 at 1024px, 2 at 390px; grid as wide as the viewport; h2 30px; the page requests the same 15 images as before (no new ones)
- Lighthouse (`pnpm lighthouse`, production build): ✅ homepage mobile 0.81 (TBT 230 ms, LCP 3.8 s), desktop 1.0; other pages mobile 0.93–0.94, desktop 1.0; accessibility, best practices and SEO 1.0 everywhere.
- A first run failed (home mobile 0.73, /contact 0.84) while the machine was under load (a game and a Vite dev server). Back-to-back runs of the unit 5 build and this build both scattered between 0.68 and 0.84, with no difference between them; with the game closed the gate passed. Scores measured in the browser against the Vite dev server (desktop 0.55, mobile 0.36, 137 unbundled requests) say nothing about the production site.
@@ -0,0 +1,58 @@
# Code Generation Plan — Unit 6: Instagram
**This plan is the single source of truth for Code Generation of unit 6.**
## Unit context
- **Requirements**: FR-HP-10, FR-HP-11 (reveal, reused), FR-HP-12, NFR-HP-01/02/03/05/06; security NFR on external links
- **Design**: [unit-of-work.md](../../inception/application-design/unit-of-work.md) unit 6; [component-methods.md](../../inception/application-design/component-methods.md) (`HomeContent.instagram`, `InstagramGrid` props); design reference `design/andreaslop-static/index.html` (Instagram section: `.section--tight`, centred `.section__head`, handle as `.lead` with `.link-underline`) and `style.css` §17 (`.instagram__grid`, `.instagram__tile`) plus the 1100px (3 columns) and 680px (2 columns) breakpoints
- **Depends on**: unit 1 (`HomeSection` incl. `spacing="tight"`, `SectionHeading`, `Reveal`, `DeferredImage`), unit 2 (`underline` link variant), the existing `visibleSocials` helper (BR-SOC-01) and the footer's external-link pattern
- **Functional Design**: skipped (presentational). **PBT-01**: N/A, no new business logic; picking the Instagram link reuses `visibleSocials`, which already has tests. Example-based tests (PBT-10).
- Conventions as in the earlier units: English comments and test names, Dutch visitor text, `data-testid`, theme tokens, deferred images.
## Decisions taken in this plan
- **Full-bleed grid**: in the design the tile grid sits outside `.container` and runs from edge to edge, while the heading stays in the content column. `HomeSection` gets a `width="full"` option (no `Container`), and `InstagramGrid` puts its heading in its own `Container`.
- **Images, no new files**: the six tiles reuse photos that the homepage already bundles and loads (`intro-1` to `intro-4`, `review-newbornshoot`, `review-trouwshoot`). The browser fetches them only once, so the section adds no image bytes. They show as squares (`object-fit: cover`). Andrea can replace them later, and the API feature replaces them with the real feed.
- **Accessible names**: each tile is a link to the profile. Its name is the photo's alt text plus a hidden "(Instagram, opent in nieuw tabblad)". Six links with the same name "Instagramfoto", as in the design, would tell a screen reader user nothing.
- **Hidden without a valid link**: the route picks the Instagram entry from `visibleSocials(siteContent.socials)`. Without one, the section is not rendered at all, because the handle and every tile would have nowhere to link to.
- **Hover**: as in the design, the photo scales to 1.06 and drops to 85% opacity on hover and on keyboard focus. Under reduced motion it changes opacity only, without scaling. Focus gets the theme's visible focus ring.
## Steps
### Content
- [x] **Step 1** — `content/types.ts`: extend `HomeContent` with `instagram: { title: string; handle: string; photos: ContentImage[] }`.
- [x] **Step 2** — `content/homeContent.ts`: title "Instagram", handle "@andreaslopfotografie", the six reused photos with their existing alt texts (shared constants where the intro gallery already defines them, so the texts do not drift apart).
### Shared pieces
- [x] **Step 3** — `HomeSection`: `width` gains `'full'` (children rendered without `Container`). Test for the full-width variant.
### The section
- [x] **Step 4** — `components/home/InstagramGrid/InstagramGrid.tsx`: `HomeSection` with `spacing="tight"`, `width="full"`; a `Container` with a `Reveal` around the centred `SectionHeading` (h2 "Instagram") and below it the handle as a `lead`-sized external link (`underline` variant, `target="_blank"`, `rel="noopener noreferrer"`, hidden "(opent in nieuw tabblad)"), `data-testid="instagram-handle-link"`. Below it a `Reveal` with the grid: plain `ul`/`li` (a list of six), 2 columns, 3 from `md`, 6 from `xl` (the design's 680/1100px steps mapped onto the theme breakpoints), 2px gap; each tile is an external link (`data-testid="instagram-tile-{n}"`) with a square `DeferredImage` on a `paper.deep` background, hover and focus as decided above.
- [x] **Step 5** — `components/home/InstagramGrid/InstagramGrid.test.tsx`: region named by the h2; handle link with href, `target`, `rel` and the hidden hint; six tiles, each linking to the profile with `target`/`rel` and a name made of the alt text plus the hint; zero photos still renders heading and handle; axe clean.
- [x] **Step 6** — `routes/index.tsx`: find the Instagram link in `visibleSocials(siteContent.socials)` and render `InstagramGrid` after `ContactSection` only when it exists.
- [x] **Step 7** — `app.test.tsx`: add "Instagram" (named by its h2) as the last section in the page-order check; a test that the section is absent when there is no valid Instagram link (mocked `siteContent`, as the earlier unit tests do for the contact form).
### Verification and wrap-up
- [x] **Step 8** — `pnpm check` (incl. Lighthouse); fix and rerun until green. Visual check at desktop width (6 columns, full-bleed), at 1024px (3 columns) and at an emulated 390px phone (2 columns); confirm in the network panel that no extra image requests appear.
- [x] **Step 9** — `LAYOUT.md`: check the homepage diagram against the finished section order (following `.ai/layout-conventions.md`), update it only if it differs.
- [x] **Step 10** — `construction/instagram/code/code-summary.md`.
- [ ] **Step 11** — Commit on `feature/homepage-sections` ("Adds the Instagram section to the homepage" + attribution), together with the typography changes from the unit 5 review in a separate commit before it. Not pushed unless the owner asks.
## Requirement traceability
| Requirement | Steps |
|---|---|
| FR-HP-10 | 1, 2, 4–7 |
| FR-HP-11 | 4 |
| FR-HP-12 | 2 |
| NFR-HP-01 (accessibility) | 4, 5, 8 |
| NFR-HP-02 (design fidelity) | 3, 4, 8 |
| NFR-HP-03 (tests) | 3, 5, 7, 8 |
| NFR-HP-05 (performance) | 2, 4, 8 |
| NFR-HP-06 (API-ready content) | 1, 2 |
| External links (security NFR) | 4–6 |
## Extension compliance (planned)
- **Security**: no new dependencies or external resources (no embed, no third-party script, no request to Instagram); external links use `noopener noreferrer`; only `https:` links are rendered (BR-SOC-01 via `visibleSocials`). Other rules N/A.
- **PBT**: PBT-01 N/A (no new logic); PBT-10 example-based tests present.
### Note on Step 8
- Everything except the Lighthouse performance gate is green. The homepage mobile score scattered between 0.68 and 0.84 for both the unit 5 build and this build in back-to-back runs (machine under load), so the gate was rerun on a quiet machine: passed (home mobile 0.81, desktop 1.0).