Adds the portfolio page

The ten live photos in a filterable masonry grid with an accessible
lightbox, filters per shoot type kept in the URL (?shoot=), the shared
Instagram block, and an indexed page with image gallery structured data
and its own preview image. Soorten fotoshoots now only links to the
portfolio for shoot types that have photos there.

The filter bar stays on one row, so the web font loading no longer
shifts the photos below it, and no photo loads before the page has: the
grid fades in, so loading its photos early only delayed the fonts and the
intro text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 19:05:13 +01:00
co-authored by Claude Opus 5.5
parent 18bf0311ef
commit 9efa7fc596
58 changed files with 1492 additions and 48 deletions
@@ -0,0 +1,39 @@
# Code Summary — Unit 3: Portfolio page
Plan: [portfolio-page-code-generation-plan.md](../../plans/portfolio-page-code-generation-plan.md) · Design: [functional-design/](../functional-design/)
## Created
| File | What |
|---|---|
| `web/src/assets/portfolio/*.jpg` | 10 photos × 2: grid 800 px wide (35–143 kB), large 1600 px long side (104–292 kB); one-off `System.Drawing` script, JPEG quality 80 |
| `web/public/og-portfolio.jpg` | 1200 × 630 centre crop of photo 7 (68 kB) |
| `web/src/content/portfolioContent.ts` | Intro + the 10 approved photos (id, shoot type, sizes, alt) |
| `web/src/lib/portfolioFilters.ts` (+ test) | `isShootTypeId`, `shootTypesWithPhotos`, `shootFromSearch`, `filterPhotos`, `filterOptions`, `toGalleryItems`, `photoCountLabel`; example + property-based tests (oracle, idempotence, round-trip, invariants) |
| `web/src/components/portfolio/PortfolioGallery/` (+ test) | Section with hidden h2 "Foto's", `FilterBar`, count announcement, `PortfolioGrid` (`eagerCount={0}`), lazy `Lightbox` (requested on intent or open), `lightboxReducer`, closes on any filter change, focus return to the last shown tile |
## Modified
| File | Change |
|---|---|
| `web/src/routes/portfolio.tsx` | Real page: typed `validateSearch` (`{ shoot?: ShootTypeId }`), head with `ImageGallery` JSON-LD, `PageIntro`, `PortfolioGallery` (replace navigation, no scroll), `InstagramGrid` |
| `web/src/content/types.ts` | `PortfolioPhoto`, `PortfolioContent` |
| `web/src/seo.ts` (+ tests) | `galleryImages(photos)` (`ImageObject`s, absolute URLs, creator/copyrightHolder ids) |
| `web/src/sitePages.ts` | `/portfolio` indexed, `ogImage` |
| `web/lighthouserc.cjs` | `/portfolio` in `indexedPaths` (default budget 0.9, not a photo page) |
| `web/src/test/arbitraries.ts` | `portfolioPhoto`, `portfolioPhotos` |
| `web/src/components/shoots/ShootList`, `ShootBlock`, `routes/soorten-fotoshoots.tsx` (+ tests) | `portfolioLive` → `portfolioShoots` / `portfolioLink`: "Bekijk meer …foto's" only for newborn, zwangerschap, gezin |
| `web/src/components/FilterBar/FilterBar.tsx`, `recipes/filterControl.ts` | One row that never wraps (`nowrap`, horizontal scroll if too narrow, `safe center`): fixes a layout shift (CLS 0.119 → 0.001) when the web font replaced the fallback |
| `web/src/app.test.tsx`, `seo.test.ts`, `sitemap.test.ts` | Portfolio route tests (outline, filters, `?shoot=` incl. invalid values, canonical, og:image, JSON-LD, replace navigation); placeholder examples moved to `/privacyverklaring`; Soorten expects 3 portfolio links |
| `LAYOUT.md` | Portfolio: Intro → Portfolio → Instagram |
| `aidlc-docs/_shared/reverse-engineering/*` | Own lines about `/portfolio`, the gallery, helpers and the Soorten links prop |
| `requirements.md` FR-PF-07, `business-rules.md` BR-LD-01 | No eager grid photos (user decision, see below) |
## Decisions during generation
- **Eager loading** (user decision 2026-10-27): the grid fades in (`Reveal`), so its photos are never the largest paint; the 3 eager photos only competed with the fonts and delayed the intro text (LCP 4.5 s → 2.9 s without). Measured twice each: 0.80 with, 0.91 without.
- **Filter bar layout shift**: diagnosed by measuring without the bar (CLS 0) and fixed at the cause (single non-wrapping row), not by reserving extra space.
## Verification
- `tsc`, ESLint, Prettier: clean.
- Tests: ✅ 82 files, 460 tests.
- Lighthouse desktop: ✅ all 7 URLs (one earlier run had a transient `ERR_CONNECTION_REFUSED` on port 4173 caused by the measuring runs just before; the rerun passed).
- Lighthouse mobile: ✅ `/portfolio` (≥ 0.9; 0.91 in the dedicated runs). ❌ pre-existing, same on master: `/` 0.77 (budget 0.8), `/soorten-fotoshoots` 0.84 (budget 0.85; master 0.84, this branch 0.86 in dedicated runs), `/contact` 0.87 (budget 0.9). Open item in the memory note "Open follow-ups".
- Visual check: no browser in this session; offered to the user via `deploy_test` (after "claim test").
@@ -0,0 +1,49 @@
# Business Logic Model — Unit 3: Portfolio page
## Flow — opening the page with a filter, changing it, opening a photo
```mermaid
sequenceDiagram
box rgba(246,224,94,0.4) Visitor
participant V as Visitor
end
box rgba(99,179,237,0.4) Page
participant R as Route
participant G as PortfolioGallery
participant B as Grid and Lightbox
end
V->>R: open /portfolio?shoot=gezin
R->>R: validateSearch keeps a ShootTypeId
R->>G: shoot, photos, shoot types
G->>G: shootFromSearch, filterOptions, filterPhotos, toGalleryItems
G->>B: two gezin photos
V->>G: choose Newborn
G->>R: onShootChange newborn
R->>R: navigate with replace, no scroll
G->>V: announce 6 foto's
V->>B: click photo 2
B->>G: onOpen 1
G->>B: lightbox at index 1 of the newborn list
```
Text alternative: the route validates ?shoot= and passes it with the content to PortfolioGallery, which derives the options, the filtered list and the gallery items with pure helpers; choosing a filter updates the URL without a history entry and announces the count; clicking a photo opens the lightbox within the filtered list.
## Pure Helpers and Properties (PBT-01)
New in `web/src/lib/` (100% coverage, example + property-based tests, generators: `shootTypeId`, `uniqueShootTypes` (existing), plus a new `portfolioPhoto` generator).
| Helper | Purpose | Properties |
|---|---|---|
| `shootTypesWithPhotos(shootTypes, photos)` | Shoot types that have at least one photo, in list order | Subset of `shootTypes` in the same order (invariant); a type is in the result iff some photo has it (oracle); adding a photo of a listed type does not change the result (invariant); idempotent when the photos are re-filtered by the result (idempotence) |
| `shootFromSearch(value, available)` | `?shoot=` → `ShootTypeId \| undefined` | Every available id round-trips, also in other letter case or with spaces (round-trip); result is always `undefined` or in `available` (invariant); non-strings → `undefined` |
| `filterPhotos(photos, shoot)` | Photos of one type, or all | Result ⊆ input, order kept (invariant); all of type `shoot` (invariant); `filterPhotos(filterPhotos(p, s), s) = filterPhotos(p, s)` (idempotence); `undefined` → identity (invariant); the union over all types = all photos (oracle) |
| `filterOptions(shootTypes, allLabel)` | "Alles" + one option per type | First is `{ id: 'alles', label: allLabel }`; length = types + 1; labels = `name` (invariant) |
| `toGalleryItems(photos, shootTypes)` | Photos → `GalleryItem`s with caption | Same length and order, ids kept (invariant); caption = `shootLabel` of the photo's type (oracle) |
| `photoCountLabel(n)` | "1 foto" / "n foto's" | Singular only for 1 (example-based; no further property) |
| `galleryImages(photos, base?)` in `seo.ts` | `ImageObject[]` | One per photo, same order (invariant); every URL starts with `https://` and the site URL (invariant); `description` = alt (oracle); serialised JSON contains no `@` e-mail pattern (invariant) |
The route's `validateSearch` uses `isShootTypeId` (a type guard derived from `shootTypes.ts`), covered through `shootFromSearch`.
## State
- **URL**: the active filter (validated).
- **PortfolioGallery**: `openIndex: number | null` via `lightboxReducer` from unit 2 (`listChanged` on filter change), the count announcement text, a `lightboxRequested` flag that starts the lazy import.
@@ -0,0 +1,57 @@
# Business Rules — Unit 3: Portfolio page
Requirements FR-PF-01..09, SEO-PF-01..05, NFR-PF-04/06; unit 2 rules BR-GR/LB/FB apply unchanged.
## Photos
- **BR-PH-01**: the 10 photos in the order of domain-entities.md; every photo has a valid `ShootTypeId`, a unique id and positive intrinsic sizes.
- **BR-PH-02**: grid image 800 px wide, large image 1600 px on the long side, same aspect ratio, compressed once by hand (no build step); stored in `web/src/assets/portfolio/`.
## Loading
- **BR-LD-01**: the page passes `eagerCount={0}` to `PortfolioGrid`: no grid photo loads before the page has (decision 2026-10-27, see requirements FR-PF-07).
## Filters
- **BR-FL-01 Options**: "Alles" (id `alles`) first, then one option per shoot type that has at least one photo, in `shootTypes.ts` order, labelled with `name`. For these photos: Alles, Newborn, Zwangerschap, Gezin.
- **BR-FL-02 Group name**: "Filter op soort shoot".
- **BR-FL-03 Filtered list**: "Alles" → all photos; a shoot type → only its photos, original relative order.
- **BR-FL-04 Announcement**: after a filter change, a polite live region says "{n} foto's" ("1 foto" for one).
- **BR-FL-05 Lightbox**: a filter change closes an open lightbox; the lightbox only browses the filtered list (C6).
## `?shoot=` parameter
- **BR-SP-01 Route validation**: `validateSearch` keeps `shoot` only when it is a `ShootTypeId` (exact, after trim + lower case); anything else (missing, unknown, non-string, array) becomes `{}`. Type: `{ shoot?: ShootTypeId }`.
- **BR-SP-02 Photos check**: the page uses the shoot only when that type has photos; otherwise it shows "Alles" (no message). `shootFromSearch(value, available)` implements both checks for the page; the value from the URL is never rendered.
- **BR-SP-03 Changing**: choosing "Alles" removes the parameter; choosing a type sets it; navigation with `replace: true` and without scrolling (Q4 of application design).
- **BR-SP-04 Canonical**: always `https://andreaslop.nl/portfolio`; the sitemap lists `/portfolio` only.
## Caption
- **BR-CP-01**: lightbox caption = the photo's shoot type `shootLabel` ("Newbornshoot", "Zwangerschapsshoot", "Gezinsshoot").
## SEO
- **BR-SEO-01**: `sitePages['/portfolio']`: `indexed: true`, title and description unchanged, `ogImage` `/og-portfolio.jpg` (1200 × 630, alt as in domain-entities.md).
- **BR-SEO-02**: `lighthouserc.cjs`: `/portfolio` moves from `noindexPaths` to `indexedPaths`. It is **not** added to `photoPagePaths` unless the measured mobile performance stays below 0.9 and the user agrees to 0.85 (open decision in aidlc-state.md).
- **BR-SEO-03**: structured data = `webPage('ImageGallery', '/portfolio', { associatedMedia: galleryImages(all 10 photos) })` through `structuredDataScript`; independent of the active filter; no e-mail; every URL absolute https.
- **BR-SEO-04**: one h1 (PageIntro "Portfolio"); grid section named by a visually hidden h2 "Foto's"; Instagram section h2 "Instagram".
## Soorten fotoshoots links (Q4 = A)
- **BR-SL-01**: on `/soorten-fotoshoots`, "Bekijk meer {photosLabel}" → `/portfolio?shoot={id}` shows only while `/portfolio` is indexed **and** only for shoot types that have portfolio photos (`shootTypesWithPhotos`). Now: newborn, zwangerschap, gezin (3 links instead of 5).
## LAYOUT.md
- **BR-LY-01**: the Portfolio diagram becomes Intro → Portfolio → Instagram (FR-PF-09).
## Decision Flow — the active filter
```mermaid
graph TD
Url["?shoot= in the URL"] --> Valid{"A ShootTypeId?"}
Valid -->|"no"| All["Alles"]
Valid -->|"yes"| Has{"Type has photos?"}
Has -->|"no"| All
Has -->|"yes"| Type["That shoot type"]
All --> Show["Show the filtered list"]
Type --> Show
classDef decision fill:#FF9800,stroke:#e65100,color:#000;
classDef state fill:#2196F3,stroke:#0d47a1,color:#000;
class Valid,Has decision;
class Url,All,Type,Show state;
```
Text alternative: a ?shoot= value that is not a known shoot type, or names a type without photos, falls back to Alles; otherwise that type is the active filter; either way the page shows the filtered list.
@@ -0,0 +1,71 @@
# Domain Entities — Unit 3: Portfolio page
Decisions: [portfolio-page-fd-questions.md](../../plans/portfolio-page-fd-questions.md) (all A).
## Relationships
```mermaid
graph TD
Content["PortfolioContent"] -->|"intro"| Intro["eyebrow, title, text"]
Content -->|"photos (10, in order)"| Photo["PortfolioPhoto"]
Photo -->|"shootType"| Shoot["ShootType (shootTypes.ts)"]
Photo -->|"thumb + full"| Images["ContentImage + ImageSource"]
Photo -->|"toGalleryItems"| Item["GalleryItem (unit 2)"]
Shoot -->|"shootLabel as caption"| Item
Shoot -->|"name as label"| Option["FilterOption (unit 2)"]
Photo -->|"galleryImages"| ImageObject["schema.org ImageObject"]
classDef entity fill:#2196F3,stroke:#0d47a1,color:#000;
classDef shared fill:#4CAF50,stroke:#2e7d32,color:#000;
classDef value fill:#e2e8f0,stroke:#4a5568,color:#000;
class Content,Photo entity;
class Shoot,Item,Option,ImageObject shared;
class Intro,Images value;
```
Text alternative: PortfolioContent holds the intro and ten PortfolioPhotos in order; each photo references a ShootType and has a grid and a large image; photos become generic GalleryItems with the shoot type's full label as caption, shoot types become FilterOptions with their short name, and photos become schema.org ImageObjects for the structured data.
## PortfolioContent (`content/portfolioContent.ts`)
| Field | Value |
|---|---|
| `intro.eyebrow` | "Werk" |
| `intro.title` | "Portfolio" |
| `intro.text` | "Een selectie uit mijn werk. Klik of tik op een foto om hem groot te bekijken." |
| `photos` | the 10 photos below, in this order |
## PortfolioPhoto
| Field | Type | Rule |
|---|---|---|
| `id` | `string` | Stable slug from the original file (e.g. `f41a1916`); unique |
| `shootType` | `ShootTypeId` | One of the ids in `shootTypes.ts` |
| `thumb` | `ContentImage` | 800 px wide, own aspect ratio, alt text below |
| `full` | `ImageSource` | 1600 px on the long side, same aspect ratio |
## The 10 photos (approved 2026-10-27)
| # | id | Shoot type | Orientation | Alt text |
|---|---|---|---|---|
| 1 | `f41a1916` | newborn | portrait | Pasgeboren baby in een wit pakje ligt op de onderarm van een ouder en kijkt in de camera |
| 2 | `f41a1922` | newborn | portrait | Vader kust zijn pasgeboren baby op het hoofd |
| 3 | `f41a7883` | zwangerschap | portrait | Aanstaande vader omarmt zijn zwangere partner op een zandvlakte in de avondzon |
| 4 | `f41a7176` | newborn | portrait | Moeder drukt haar gezicht tegen het hoofdje van haar pasgeboren baby |
| 5 | `f41a8700` | newborn | landscape | Slapende pasgeboren baby in een bruin-wit gestreept pakje |
| 6 | `f41a8206` | zwangerschap | landscape | Zwangere buik in een zwarte jurk, omarmd door twee handen |
| 7 | `f41a1579` | gezin | landscape | Grote broer kust zijn pasgeboren broertje of zusje op een wit bed |
| 8 | `f41a4650` | newborn | landscape | Babyvuistje tussen een gebreide deken en een geruite doek |
| 9 | `f41a7138` | gezin | portrait | Jonge ouders kijken samen naar hun slapende pasgeboren baby |
| 10 | `f41a7284` | newborn | portrait | Blote babyvoetjes in een gestreept gebreid broekje |
Portrait: thumb 800 × 1200, full 1067 × 1600. Landscape: thumb 800 × 533, full 1600 × 1067 (photo 8 scaled down from 2560 × 1707).
## Preview image
`web/public/og-portfolio.jpg`, 1200 × 630, cropped from photo 7; alt "Grote broer kust zijn pasgeboren broertje of zusje op een wit bed".
## ImageObject (structured data)
| Field | Value |
|---|---|
| `@type` | `ImageObject` |
| `contentUrl` | absolute https URL of `full.src` |
| `thumbnailUrl` | absolute https URL of `thumb.src` |
| `description` | the alt text |
| `width` / `height` | of the full image |
| `creator` | `{ '@id': personId }` |
| `copyrightHolder` | `{ '@id': businessId }` |
@@ -0,0 +1,42 @@
# Frontend Components — Unit 3: Portfolio page
## Hierarchy
```mermaid
graph TD
Route["routes/portfolio.tsx"] --> Intro["PageIntro (h1 Portfolio)"]
Route --> Gallery["portfolio/PortfolioGallery"]
Route --> Insta["InstagramGrid (shared)"]
Gallery --> Section["PageSection (h2 Foto's, hidden)"]
Section --> Filter["FilterBar"]
Section --> Count["live region: n foto's"]
Section --> Grid["PortfolioGrid"]
Section --> Lazy["Suspense + lazy Lightbox"]
Soorten["routes/soorten-fotoshoots.tsx"] --> List["shoots/ShootList + ShootBlock"]
classDef root fill:#4CAF50,stroke:#2e7d32,color:#000;
classDef ui fill:#2196F3,stroke:#0d47a1,color:#000;
classDef changed fill:#FF9800,stroke:#e65100,color:#000;
class Route root;
class Intro,Gallery,Insta,Section,Filter,Count,Grid,Lazy ui;
class Soorten,List changed;
```
Text alternative: the portfolio route renders PageIntro, the new PortfolioGallery and the shared InstagramGrid; the gallery renders a PageSection with a hidden h2, the FilterBar, a count live region, the PortfolioGrid and the lazily loaded Lightbox; the Soorten fotoshoots route and its ShootList/ShootBlock change to link only shoot types with photos.
## Route `routes/portfolio.tsx`
- `validateSearch: (search) => ({ shoot?: ShootTypeId })` via `isShootTypeId`
- `head`: `pageHead('/portfolio')` + `structuredDataScript(webPage('ImageGallery', '/portfolio', { associatedMedia: galleryImages(portfolioContent.photos) }))`
- component: `PageIntro eyebrow title` with intro text → `PortfolioGallery` → `InstagramGrid` (only with a valid Instagram link, as on the homepage)
- `onShootChange(shoot)` → `navigate({ search: shoot ? { shoot } : {}, replace: true, resetScroll: false })`
## PortfolioGallery (`components/portfolio/PortfolioGallery/`)
- **Props**: `photos`, `shootTypes`, `shoot: string | undefined` (raw from the route), `onShootChange(shoot: ShootTypeId | undefined)`
- **Derived**: available types, active shoot (`shootFromSearch`), options, filtered photos, gallery items
- **State**: `lightbox` (`lightboxReducer`), `announcement`, `lightboxRequested`
- **Markup**: `PageSection labelledBy="portfolio-title" spacing="flushTop"` with `VisuallyHidden as h2 id="portfolio-title"` "Foto's"; `FilterBar label="Filter op soort shoot"` (value `alles` when no shoot); `chakra.p srOnly aria-live="polite"` (`data-testid="portfolio-count"`); `PortfolioGrid` (`onOpen` → open, `onIntent` → request lightbox); `Suspense fallback={null}` → lazy `Lightbox` rendered once requested, with `finalFocusEl` returning the tile of the last shown item (`[data-testid="portfolio-tile-{n}"]`)
- **Test ids**: `portfolio-gallery`, plus those of the unit 2 blocks
## Soorten fotoshoots (changed)
- `ShootList` / `ShootBlock`: prop `portfolioLive: boolean` → `portfolioShoots: readonly ShootTypeId[]` (types that get a link); the block shows the link when its id is in the list
- `routes/soorten-fotoshoots.tsx`: `portfolioShoots = isPortfolioLive(sitePages) ? shootTypesWithPhotos(shootTypes, portfolioContent.photos).map(t => t.id) : []`
- `app.test.tsx`: expects 3 links (newborn, zwangerschap, gezin) when `/portfolio` is indexed