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
+8 -2
View File
@@ -6,8 +6,14 @@
const origin = 'http://localhost:4173';
// Moet gelijk lopen met src/sitePages.ts (een test bewaakt dat)
const indexedPaths = ['/', '/over-mij', '/soorten-fotoshoots', '/contact'];
const noindexPaths = ['/portfolio', '/privacyverklaring'];
const indexedPaths = [
'/',
'/over-mij',
'/portfolio',
'/soorten-fotoshoots',
'/contact',
];
const noindexPaths = ['/privacyverklaring'];
const notFoundPath = '/bestaat-niet';
// Homepage mobiel voorlopig 0,8: de foto's zijn nog niet responsive en de
Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

+86 -7
View File
@@ -101,12 +101,17 @@ describe('app', () => {
);
it('zet titel en noindex van een placeholder in de head', async () => {
await renderApp('/portfolio');
await screen.findByRole('heading', { level: 1, name: 'Portfolio' });
expect(document.title).toBe('Portfolio | Andrea Slop Fotografie');
await renderApp('/privacyverklaring');
await screen.findByRole('heading', {
level: 1,
name: 'Privacyverklaring',
});
expect(document.title).toBe(
'Privacyverklaring | Andrea Slop Fotografie',
);
expect(
document.head.querySelector('link[rel="canonical"]'),
).toHaveAttribute('href', 'https://andreaslop.nl/portfolio');
).toHaveAttribute('href', 'https://andreaslop.nl/privacyverklaring');
expect(
document.head.querySelector('meta[name="robots"]'),
).toHaveAttribute('content', 'noindex');
@@ -265,7 +270,7 @@ describe('app', () => {
'/contact',
]);
// Links to the filtered portfolio only once that page is live
// (indexed); they switch on by themselves when it is
// (indexed), and only for shoot types with portfolio photos
expect(
within(main)
.queryAllByRole('link', { name: /^Bekijk meer/ })
@@ -276,8 +281,6 @@ describe('app', () => {
'/portfolio?shoot=newborn',
'/portfolio?shoot=zwangerschap',
'/portfolio?shoot=gezin',
'/portfolio?shoot=loveshoot',
'/portfolio?shoot=portret',
]
: [],
);
@@ -304,6 +307,82 @@ describe('app', () => {
expect(await axeResults(container)).toHaveNoViolations();
});
it('shows the portfolio with its outline, filters, photos and structured data', async () => {
const { container } = await renderApp('/portfolio');
await screen.findByRole('heading', { level: 1, name: 'Portfolio' });
expectShell();
const main = screen.getByRole('main');
expect(
within(main)
.getAllByRole('heading', { level: 2 })
.map((heading) => heading.textContent),
).toEqual(["Foto's", 'Instagram']);
expect(
within(main).getByRole('button', { name: 'Alles', pressed: true }),
).toBeInTheDocument();
expect(
within(screen.getByTestId('portfolio-grid')).getAllByRole('link'),
).toHaveLength(10);
expect(document.title).toBe('Portfolio | Andrea Slop Fotografie');
expect(document.head.querySelector('meta[name="robots"]')).toBeNull();
expect(
document.head.querySelector('link[rel="canonical"]'),
).toHaveAttribute('href', 'https://andreaslop.nl/portfolio');
expect(
document.head.querySelector('meta[property="og:image"]'),
).toHaveAttribute('content', 'https://andreaslop.nl/og-portfolio.jpg');
const data = [
...document.querySelectorAll('script[type="application/ld+json"]'),
].map((script) => JSON.parse(script.textContent!));
const gallery = data.find((item) => item['@type'] === 'ImageGallery');
expect(gallery.associatedMedia).toHaveLength(10);
expect(await axeResults(container)).toHaveNoViolations();
});
it('starts the portfolio filtered on ?shoot= and keeps the canonical URL plain', async () => {
await renderApp('/portfolio?shoot=gezin');
await screen.findByRole('heading', { level: 1, name: 'Portfolio' });
expect(
screen.getByRole('button', { name: 'Gezin', pressed: true }),
).toBeInTheDocument();
expect(
within(screen.getByTestId('portfolio-grid')).getAllByRole('link'),
).toHaveLength(2);
expect(
document.head.querySelector('link[rel="canonical"]'),
).toHaveAttribute('href', 'https://andreaslop.nl/portfolio');
});
it.each(['onzin', 'loveshoot', '%3Cscript%3E'])(
'shows the whole portfolio for ?shoot=%s',
async (value) => {
await renderApp(`/portfolio?shoot=${value}`);
await screen.findByRole('heading', { level: 1, name: 'Portfolio' });
expect(
screen.getByRole('button', { name: 'Alles', pressed: true }),
).toBeInTheDocument();
expect(
within(screen.getByTestId('portfolio-grid')).getAllByRole(
'link',
),
).toHaveLength(10);
},
);
it('puts the chosen filter in the URL without a history entry', async () => {
const { router } = await renderApp('/portfolio');
await screen.findByRole('heading', { level: 1, name: 'Portfolio' });
const user = userEvent.setup();
await user.click(screen.getByRole('button', { name: 'Newborn' }));
await waitFor(() =>
expect(router.state.location.search).toEqual({ shoot: 'newborn' }),
);
expect(router.history.length).toBe(1);
await user.click(screen.getByRole('button', { name: 'Alles' }));
await waitFor(() => expect(router.state.location.search).toEqual({}));
});
it('toont een onbekende URL als 404 binnen de shell', async () => {
const { container } = await renderApp('/bestaat-niet');
expect(
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+8 -2
View File
@@ -29,8 +29,14 @@ export default function FilterBar({
aria-label={label}
data-testid="filter-bar"
display="flex"
flexWrap="wrap"
justifyContent="center"
// One row, always: when the web font replaces the fallback, a
// wrapping row could gain or lose a line and push the photos
// below it down (layout shift). Too narrow: the row scrolls.
flexWrap="nowrap"
overflowX="auto"
// Centred while it fits; from the start when it scrolls, so the
// first choice is never cut off
justifyContent="safe center"
columnGap={{ base: 4, md: 6 }}
>
{options.map((option) => {
@@ -0,0 +1,145 @@
import { useEffect, useState } from 'react';
import { act, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import portfolioContent from '@/content/portfolioContent';
import shootTypes from '@/content/shootTypes';
import type { ShootTypeId } from '@/content/types';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import PortfolioGallery from './PortfolioGallery';
const photos = portfolioContent.photos;
// Lets a test change the shoot from outside, as the route would
let setShootFromOutside: (shoot: string | undefined) => void = () => {};
// The route's part: it keeps the chosen shoot (in the URL)
function Harness({
start,
onShootChange = () => {},
}: {
start?: string;
onShootChange?: (shoot: ShootTypeId | undefined) => void;
}) {
const [shoot, setShoot] = useState<string | undefined>(start);
useEffect(() => {
setShootFromOutside = setShoot;
}, []);
return (
<PortfolioGallery
photos={photos}
shootTypes={shootTypes}
shoot={shoot}
onShootChange={(next) => {
setShoot(next);
onShootChange(next);
}}
/>
);
}
// By test id: while the closed dialog fades out (in jsdom it never
// finishes), the page behind it is still hidden from the accessibility tree
const tiles = () =>
screen
.getByTestId('portfolio-grid')
.querySelectorAll('[data-testid^="portfolio-tile-"]');
describe('PortfolioGallery', () => {
it('is a section named by a hidden heading, with filters for the types that have photos', async () => {
const { container } = await renderWithProviders(<Harness />);
expect(
screen.getByRole('region', { name: "Foto's" }),
).toBeInTheDocument();
const group = screen.getByRole('group', {
name: 'Filter op soort shoot',
});
expect(
within(group)
.getAllByRole('button')
.map((b) => b.textContent),
).toEqual(['Alles', 'Newborn', 'Zwangerschap', 'Gezin']);
expect(
screen.getByRole('button', { name: 'Alles', pressed: true }),
).toBeInTheDocument();
expect(tiles()).toHaveLength(10);
// Every photo waits until the page has loaded (none eager)
for (const image of screen.getAllByRole('img')) {
expect(image).not.toHaveAttribute('fetchpriority');
expect(image).toHaveAttribute('loading', 'lazy');
}
expect(await axeResults(container)).toHaveNoViolations();
});
it('filters on a shoot type, announces the count and reports the choice', async () => {
const onShootChange = vi.fn();
await renderWithProviders(<Harness onShootChange={onShootChange} />);
const user = userEvent.setup();
await user.click(screen.getByRole('button', { name: 'Gezin' }));
expect(onShootChange).toHaveBeenLastCalledWith('gezin');
expect(tiles()).toHaveLength(2);
expect(screen.getByTestId('portfolio-count')).toHaveTextContent(
"2 foto's",
);
await user.click(screen.getByRole('button', { name: 'Alles' }));
expect(onShootChange).toHaveBeenLastCalledWith(undefined);
expect(tiles()).toHaveLength(10);
});
it('starts with the shoot from the URL', async () => {
await renderWithProviders(<Harness start="zwangerschap" />);
expect(
screen.getByRole('button', { name: 'Zwangerschap', pressed: true }),
).toBeInTheDocument();
expect(tiles()).toHaveLength(2);
});
it.each(['loveshoot', 'onzin', '<script>'])(
'shows everything for ?shoot=%s',
async (value) => {
await renderWithProviders(<Harness start={value} />);
expect(
screen.getByRole('button', { name: 'Alles', pressed: true }),
).toBeInTheDocument();
expect(tiles()).toHaveLength(10);
expect(document.body).not.toHaveTextContent(value);
},
);
it('opens the lightbox within the filtered photos, captioned with the shoot type', async () => {
await renderWithProviders(<Harness start="gezin" />);
const user = userEvent.setup();
await user.click(screen.getByTestId('portfolio-tile-2'));
const counter = await screen.findByTestId('lightbox-counter');
expect(counter).toHaveTextContent('2 / 2');
expect(screen.getByTestId('lightbox-caption')).toHaveTextContent(
'Gezinsshoot',
);
expect(screen.getByTestId('lightbox-image')).toHaveAttribute(
'src',
photos.find((p) => p.id === 'f41a7138')?.full.src,
);
});
it('closes the lightbox when the filter changes', async () => {
await renderWithProviders(<Harness />);
const user = userEvent.setup();
await user.click(screen.getByTestId('portfolio-tile-1'));
expect(await screen.findByTestId('lightbox')).toHaveAttribute(
'data-state',
'open',
);
// The dialog makes the page inert, so the filter changes from
// outside, as through the URL
act(() => setShootFromOutside('newborn'));
expect(tiles()).toHaveLength(6);
// A close from the parent reaches the dialog in an effect
await waitFor(() =>
expect(screen.getByTestId('lightbox')).toHaveAttribute(
'data-state',
'closed',
),
);
});
});
@@ -0,0 +1,136 @@
import { lazy, Suspense, useReducer, useRef, useState } from 'react';
import { Box, chakra, Heading, VisuallyHidden } from '@chakra-ui/react';
import FilterBar from '@/components/FilterBar/FilterBar';
import PageSection from '@/components/PageSection/PageSection';
import PortfolioGrid from '@/components/PortfolioGrid/PortfolioGrid';
import type { PortfolioPhoto, ShootType, ShootTypeId } from '@/content/types';
import { closedLightbox, lightboxReducer } from '@/lib/lightboxReducer';
import {
ALL_FILTER,
filterOptions,
filterPhotos,
photoCountLabel,
shootFromSearch,
shootTypesWithPhotos,
toGalleryItems,
} from '@/lib/portfolioFilters';
// Loaded on the first hover, focus or click on a photo (application design Q7)
const Lightbox = lazy(() => import('@/components/Lightbox/Lightbox'));
const TITLE_ID = 'portfolio-title';
type PortfolioGalleryProps = {
photos: readonly PortfolioPhoto[];
shootTypes: readonly ShootType[];
// The shoot from ?shoot=; checked here against the types with photos
shoot: string | undefined;
onShootChange: (shoot: ShootTypeId | undefined) => void;
};
// The portfolio's photos: filters per shoot type, the masonry grid and the
// lightbox, connected. The URL holds the chosen filter (via the route); this
// component holds which photo is open.
export default function PortfolioGallery({
photos,
shootTypes,
shoot,
onShootChange,
}: PortfolioGalleryProps) {
const available = shootTypesWithPhotos(shootTypes, photos);
const active = shootFromSearch(
shoot,
available.map((type) => type.id),
);
const shown = filterPhotos(photos, active);
const items = toGalleryItems(shown, shootTypes);
const [lightbox, dispatch] = useReducer(lightboxReducer, closedLightbox);
const [lightboxRequested, setLightboxRequested] = useState(false);
const [announcement, setAnnouncement] = useState('');
const grid = useRef<HTMLDivElement>(null);
// Another list, however the filter changed: the open photo may no longer
// be in it, so the lightbox closes (BR-FL-05). Adjusted during render,
// as React advises for state that follows a prop.
const [listFor, setListFor] = useState(active);
if (listFor !== active) {
setListFor(active);
dispatch({ type: 'listChanged', count: items.length });
}
const chooseFilter = (id: string) => {
const next = id === ALL_FILTER ? undefined : (id as ShootTypeId);
setAnnouncement(photoCountLabel(filterPhotos(photos, next).length));
onShootChange(next);
};
const open = (index: number) => {
setLightboxRequested(true);
dispatch({ type: 'open', index, count: items.length });
};
// Back to the tile of the photo shown last (BR-LB-08)
const tileOfShownPhoto = () =>
lightbox.open
? (grid.current?.querySelector<HTMLElement>(
`[data-testid="portfolio-tile-${lightbox.index + 1}"]`,
) ?? null)
: null;
return (
<PageSection
labelledBy={TITLE_ID}
spacing="flushTop"
data-testid="portfolio-gallery"
>
{/* The design shows no heading here; one for screen readers
names the section */}
<VisuallyHidden>
<Heading as="h2" id={TITLE_ID}>
Foto's
</Heading>
</VisuallyHidden>
<Box mb={{ base: 6, md: 10 }}>
<FilterBar
options={filterOptions(available, 'Alles')}
value={active ?? ALL_FILTER}
onChange={chooseFilter}
label="Filter op soort shoot"
/>
</Box>
<chakra.p srOnly aria-live="polite" data-testid="portfolio-count">
{announcement}
</chakra.p>
<Box ref={grid}>
<PortfolioGrid
items={items}
// No photo loads before the page has: the grid fades in, so
// its photos are never the largest paint, and loading them
// early only slowed the fonts and the intro text (measured
// 0.80 vs 0.91 on mobile; decision 2026-10-27)
eagerCount={0}
onOpen={open}
onIntent={() => setLightboxRequested(true)}
/>
</Box>
{lightboxRequested && (
<Suspense fallback={null}>
<Lightbox
items={items}
index={lightbox.open ? lightbox.index : null}
onIndexChange={(index) =>
dispatch({
type: 'open',
index,
count: items.length,
})
}
onClose={() => dispatch({ type: 'close' })}
finalFocusEl={tileOfShownPhoto}
/>
</Suspense>
)}
</PageSection>
);
}
@@ -10,7 +10,7 @@ const shoot = (id: string) => shootTypes.find((item) => item.id === id)!;
const renderBlock = (
id: string,
{ portfolioLive = false, reverse = false, priority = false } = {},
{ portfolioLink = false, reverse = false, priority = false } = {},
) =>
renderWithProviders(
<ShootBlock
@@ -18,7 +18,7 @@ const renderBlock = (
packages={packages}
reverse={reverse}
priority={priority}
portfolioLive={portfolioLive}
portfolioLink={portfolioLink}
/>,
);
@@ -67,7 +67,7 @@ describe('ShootBlock', () => {
});
it('links to the portfolio filtered on the shoot type when live', async () => {
await renderBlock('portret', { portfolioLive: true });
await renderBlock('portret', { portfolioLink: true });
expect(
screen.getByRole('link', { name: "Bekijk meer portretfoto's" }),
).toHaveAttribute('href', '/portfolio?shoot=portret');
@@ -13,8 +13,8 @@ type ShootBlockProps = {
reverse: boolean;
// The first photo on the page loads straight away
priority: boolean;
// Show "Bekijk meer …foto's" (BR-SF-04)
portfolioLive: boolean;
// Show "Bekijk meer …foto's" (BR-SF-04, BR-SL-01)
portfolioLink: boolean;
};
// Links in the text column: room around them for a 44px touch target
@@ -28,7 +28,7 @@ export default function ShootBlock({
packages,
reverse,
priority,
portfolioLive,
portfolioLink,
}: ShootBlockProps) {
const titleId = `shoot-${shoot.id}-title`;
@@ -74,7 +74,7 @@ export default function ShootBlock({
Stuur een berichtje
</RouterLink>
</Link>
{portfolioLive && (
{portfolioLink && (
<Link variant="underline" asChild {...linkStyle}>
<RouterLink
{...shootPortfolioLink(shoot)}
@@ -12,7 +12,7 @@ const renderList = () =>
<ShootList
shoots={shootTypes}
packages={packages}
portfolioLive={false}
portfolioShoots={[]}
/>,
);
@@ -1,12 +1,14 @@
import { Box } from '@chakra-ui/react';
import PageSection from '@/components/PageSection/PageSection';
import type { PricingPackage, ShootType } from '@/content/types';
import type { PricingPackage, ShootType, ShootTypeId } from '@/content/types';
import ShootBlock from '../ShootBlock/ShootBlock';
type ShootListProps = {
shoots: readonly ShootType[];
packages: readonly PricingPackage[];
portfolioLive: boolean;
// Shoot types that link to the portfolio: only while it is live, and
// only for types with portfolio photos (BR-SL-01)
portfolioShoots: readonly ShootTypeId[];
};
// The shoot types below the page head, each in its own full-width band:
@@ -16,7 +18,7 @@ type ShootListProps = {
export default function ShootList({
shoots,
packages,
portfolioLive,
portfolioShoots,
}: ShootListProps) {
return (
<Box data-testid="shoot-list">
@@ -32,7 +34,7 @@ export default function ShootList({
packages={packages}
reverse={index % 2 === 1}
priority={index === 0}
portfolioLive={portfolioLive}
portfolioLink={portfolioShoots.includes(shoot.id)}
/>
</PageSection>
))}
+136
View File
@@ -0,0 +1,136 @@
import type { PortfolioContent, PortfolioPhoto, ShootTypeId } from './types';
// Images: the live portfolio photos, 800 px wide for the grid and 1600 px
// on the long side for the lightbox, never cropped
import f41a1916 from '../assets/portfolio/f41a1916.jpg';
import f41a1916Groot from '../assets/portfolio/f41a1916-groot.jpg';
import f41a1922 from '../assets/portfolio/f41a1922.jpg';
import f41a1922Groot from '../assets/portfolio/f41a1922-groot.jpg';
import f41a7883 from '../assets/portfolio/f41a7883.jpg';
import f41a7883Groot from '../assets/portfolio/f41a7883-groot.jpg';
import f41a7176 from '../assets/portfolio/f41a7176.jpg';
import f41a7176Groot from '../assets/portfolio/f41a7176-groot.jpg';
import f41a8700 from '../assets/portfolio/f41a8700.jpg';
import f41a8700Groot from '../assets/portfolio/f41a8700-groot.jpg';
import f41a8206 from '../assets/portfolio/f41a8206.jpg';
import f41a8206Groot from '../assets/portfolio/f41a8206-groot.jpg';
import f41a1579 from '../assets/portfolio/f41a1579.jpg';
import f41a1579Groot from '../assets/portfolio/f41a1579-groot.jpg';
import f41a4650 from '../assets/portfolio/f41a4650.jpg';
import f41a4650Groot from '../assets/portfolio/f41a4650-groot.jpg';
import f41a7138 from '../assets/portfolio/f41a7138.jpg';
import f41a7138Groot from '../assets/portfolio/f41a7138-groot.jpg';
import f41a7284 from '../assets/portfolio/f41a7284.jpg';
import f41a7284Groot from '../assets/portfolio/f41a7284-groot.jpg';
const portrait = {
thumb: { width: 800, height: 1200 },
full: { width: 1067, height: 1600 },
};
const landscape = {
thumb: { width: 800, height: 534 },
full: { width: 1600, height: 1067 },
};
function photo(
id: string,
shootType: ShootTypeId,
files: { thumb: string; full: string },
size: typeof portrait,
alt: string,
): PortfolioPhoto {
return {
id,
shootType,
thumb: { src: files.thumb, alt, ...size.thumb },
full: { src: files.full, ...size.full },
};
}
// The portfolio until the CMS API exists: the photos of the live site in
// their order (2026-10-24), with the shoot type and description approved
// in the functional design (Andrea may still reword the descriptions)
const portfolioContent: PortfolioContent = {
intro: {
eyebrow: 'Werk',
title: 'Portfolio',
text: 'Een selectie uit mijn werk. Klik of tik op een foto om hem groot te bekijken.',
},
photos: [
photo(
'f41a1916',
'newborn',
{ thumb: f41a1916, full: f41a1916Groot },
portrait,
'Pasgeboren baby in een wit pakje ligt op de onderarm van een ouder en kijkt in de camera',
),
photo(
'f41a1922',
'newborn',
{ thumb: f41a1922, full: f41a1922Groot },
portrait,
'Vader kust zijn pasgeboren baby op het hoofd',
),
photo(
'f41a7883',
'zwangerschap',
{ thumb: f41a7883, full: f41a7883Groot },
portrait,
'Aanstaande vader omarmt zijn zwangere partner op een zandvlakte in de avondzon',
),
photo(
'f41a7176',
'newborn',
{ thumb: f41a7176, full: f41a7176Groot },
portrait,
'Moeder drukt haar gezicht tegen het hoofdje van haar pasgeboren baby',
),
photo(
'f41a8700',
'newborn',
{ thumb: f41a8700, full: f41a8700Groot },
landscape,
'Slapende pasgeboren baby in een bruin-wit gestreept pakje',
),
photo(
'f41a8206',
'zwangerschap',
{ thumb: f41a8206, full: f41a8206Groot },
landscape,
'Zwangere buik in een zwarte jurk, omarmd door twee handen',
),
photo(
'f41a1579',
'gezin',
{ thumb: f41a1579, full: f41a1579Groot },
landscape,
'Grote broer kust zijn pasgeboren broertje of zusje op een wit bed',
),
photo(
'f41a4650',
'newborn',
{ thumb: f41a4650, full: f41a4650Groot },
{
thumb: { width: 800, height: 533 },
full: { width: 1600, height: 1067 },
},
'Babyvuistje tussen een gebreide deken en een geruite doek',
),
photo(
'f41a7138',
'gezin',
{ thumb: f41a7138, full: f41a7138Groot },
portrait,
'Jonge ouders kijken samen naar hun slapende pasgeboren baby',
),
photo(
'f41a7284',
'newborn',
{ thumb: f41a7284, full: f41a7284Groot },
portrait,
'Blote babyvoetjes in een gestreept gebreid broekje',
),
],
};
export default portfolioContent;
+15
View File
@@ -72,6 +72,21 @@ export interface FilterOption {
label: string;
}
// One photo of the portfolio: which kind of shoot it is from (filters and
// lightbox caption) and the photo in two sizes, grid and lightbox
export interface PortfolioPhoto {
id: string;
shootType: ShootTypeId;
thumb: ContentImage;
full: ImageSource;
}
// The portfolio page until the CMS API exists (/api/portfolio)
export interface PortfolioContent {
intro: { eyebrow: string; title: string; text: string };
photos: PortfolioPhoto[];
}
// A priced shoot offer. id is a stable slug: it goes into ?pakket= and is
// the shoot value the contact form sends.
export interface PricingPackage {
+216
View File
@@ -0,0 +1,216 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import portfolioContent from '../content/portfolioContent';
import shootTypes from '../content/shootTypes';
import type { ShootTypeId } from '../content/types';
import {
portfolioPhotos,
shootTypeId,
uniqueShootTypes,
} from '../test/arbitraries';
import {
ALL_FILTER,
filterOptions,
filterPhotos,
isShootTypeId,
photoCountLabel,
shootFromSearch,
shootTypesWithPhotos,
toGalleryItems,
} from './portfolioFilters';
const photos = portfolioContent.photos;
const allIds = shootTypes.map((type) => type.id);
describe('isShootTypeId', () => {
it('accepts known ids only, exactly as written', () => {
expect(isShootTypeId('gezin', allIds)).toBe(true);
expect(isShootTypeId('Gezin', allIds)).toBe(false);
expect(isShootTypeId('onzin', allIds)).toBe(false);
expect(isShootTypeId(3, allIds)).toBe(false);
expect(isShootTypeId(['gezin'], allIds)).toBe(false);
});
});
describe('shootTypesWithPhotos', () => {
it('lists newborn, zwangerschap and gezin for the live photos', () => {
expect(
shootTypesWithPhotos(shootTypes, photos).map((t) => t.id),
).toEqual(['newborn', 'zwangerschap', 'gezin']);
});
it('keeps exactly the types with a photo, in list order (oracle)', () => {
fc.assert(
fc.property(uniqueShootTypes, portfolioPhotos, (types, list) => {
const result = shootTypesWithPhotos(types, list);
const expected = types.filter((type) =>
list.map((p) => p.shootType).includes(type.id),
);
expect(result).toEqual(expected);
}),
);
});
it('does not change when the photos are narrowed to those types (idempotence)', () => {
fc.assert(
fc.property(uniqueShootTypes, portfolioPhotos, (types, list) => {
const once = shootTypesWithPhotos(types, list);
const ids = once.map((type) => type.id);
const narrowed = list.filter((p) => ids.includes(p.shootType));
expect(shootTypesWithPhotos(once, narrowed)).toEqual(once);
}),
);
});
});
describe('shootFromSearch', () => {
const available: ShootTypeId[] = ['newborn', 'zwangerschap', 'gezin'];
it('accepts an available id in any letter case', () => {
expect(shootFromSearch('gezin', available)).toBe('gezin');
expect(shootFromSearch(' Newborn ', available)).toBe('newborn');
});
it('ignores unknown ids, types without photos and non-strings', () => {
expect(shootFromSearch('loveshoot', available)).toBeUndefined();
expect(shootFromSearch('<script>', available)).toBeUndefined();
expect(shootFromSearch(undefined, available)).toBeUndefined();
expect(shootFromSearch(['gezin'], available)).toBeUndefined();
expect(shootFromSearch('', available)).toBeUndefined();
});
it('returns every available id for its own value (round-trip)', () => {
fc.assert(
fc.property(
fc.uniqueArray(shootTypeId, { minLength: 1 }),
fc.constantFrom('', ' ', ' '),
fc.boolean(),
(ids, pad, upper) => {
for (const id of ids) {
const typed = upper ? id.toUpperCase() : id;
expect(shootFromSearch(pad + typed + pad, ids)).toBe(
id,
);
}
},
),
);
});
it('only ever returns an available id (invariant)', () => {
fc.assert(
fc.property(
fc.anything(),
fc.uniqueArray(shootTypeId),
(value, ids) => {
const result = shootFromSearch(value, ids);
expect(result === undefined || ids.includes(result)).toBe(
true,
);
},
),
);
});
});
describe('filterPhotos', () => {
it('shows all photos without a shoot, or one type in its own order', () => {
expect(filterPhotos(photos, undefined)).toEqual(photos);
expect(filterPhotos(photos, 'gezin').map((p) => p.id)).toEqual([
'f41a1579',
'f41a7138',
]);
expect(filterPhotos(photos, 'loveshoot')).toEqual([]);
});
it('keeps only that type, in the original order (invariant)', () => {
fc.assert(
fc.property(portfolioPhotos, shootTypeId, (list, shoot) => {
const result = filterPhotos(list, shoot);
expect(result.every((p) => p.shootType === shoot)).toBe(true);
const positions = result.map((p) => list.indexOf(p));
expect(positions).toEqual([...positions].sort((a, b) => a - b));
}),
);
});
it('changes nothing when filtered twice (idempotence)', () => {
fc.assert(
fc.property(portfolioPhotos, shootTypeId, (list, shoot) => {
const once = filterPhotos(list, shoot);
expect(filterPhotos(once, shoot)).toEqual(once);
}),
);
});
it('splits all photos over the types without losing any (oracle)', () => {
fc.assert(
fc.property(portfolioPhotos, (list) => {
const total = allIds.reduce(
(sum, id) => sum + filterPhotos(list, id).length,
0,
);
expect(total).toBe(list.length);
}),
);
});
});
describe('filterOptions', () => {
it('starts with Alles and labels each type with its short name', () => {
const types = shootTypesWithPhotos(shootTypes, photos);
expect(filterOptions(types, 'Alles')).toEqual([
{ id: ALL_FILTER, label: 'Alles' },
{ id: 'newborn', label: 'Newborn' },
{ id: 'zwangerschap', label: 'Zwangerschap' },
{ id: 'gezin', label: 'Gezin' },
]);
});
it('has one option per type after Alles (invariant)', () => {
fc.assert(
fc.property(uniqueShootTypes, (types) => {
const options = filterOptions(types, 'Alles');
expect(options).toHaveLength(types.length + 1);
expect(options[0].id).toBe(ALL_FILTER);
expect(options.slice(1).map((o) => o.label)).toEqual(
types.map((t) => t.name),
);
}),
);
});
});
describe('toGalleryItems', () => {
it('captions each photo with the full name of its shoot type', () => {
const items = toGalleryItems(photos, shootTypes);
expect(items[0].caption).toBe('Newbornshoot');
expect(items[2].caption).toBe('Zwangerschapsshoot');
expect(items[6].caption).toBe('Gezinsshoot');
expect(items[0].thumb).toBe(photos[0].thumb);
});
it('keeps order, ids and images, and takes the caption from the type (oracle)', () => {
fc.assert(
fc.property(portfolioPhotos, uniqueShootTypes, (list, types) => {
const items = toGalleryItems(list, types);
expect(items.map((i) => i.id)).toEqual(list.map((p) => p.id));
items.forEach((item, i) => {
expect(item.full).toBe(list[i].full);
expect(item.caption).toBe(
types.find((t) => t.id === list[i].shootType)
?.shootLabel,
);
});
}),
);
});
});
describe('photoCountLabel', () => {
it('uses the singular only for one photo', () => {
expect(photoCountLabel(1)).toBe('1 foto');
expect(photoCountLabel(0)).toBe("0 foto's");
expect(photoCountLabel(6)).toBe("6 foto's");
});
});
+86
View File
@@ -0,0 +1,86 @@
import type {
FilterOption,
GalleryItem,
PortfolioPhoto,
ShootType,
ShootTypeId,
} from '../content/types.ts';
// The filter that shows every photo; it has no ?shoot= value
export const ALL_FILTER = 'alles';
// Whether a value is one of the given shoot type ids (exactly as written)
export function isShootTypeId(
value: unknown,
known: readonly ShootTypeId[],
): value is ShootTypeId {
return (
typeof value === 'string' &&
(known as readonly string[]).includes(value)
);
}
// The shoot types that have at least one photo, in the order of the list
// (BR-FL-01). Only these get a filter, and a link from Soorten fotoshoots.
export function shootTypesWithPhotos(
shootTypes: readonly ShootType[],
photos: readonly PortfolioPhoto[],
): ShootType[] {
return shootTypes.filter((type) =>
photos.some((photo) => photo.shootType === type.id),
);
}
// The shoot type from ?shoot=, if it is one of `available` (BR-SP-02).
// Letter case and surrounding spaces do not matter; anything else
// (unknown id, a type without photos, number, missing) gives undefined, so
// the page shows "Alles" and the URL's value is never shown.
export function shootFromSearch(
value: unknown,
available: readonly ShootTypeId[],
): ShootTypeId | undefined {
if (typeof value !== 'string') return undefined;
const wanted = value.trim().toLowerCase();
return available.find((id) => id === wanted);
}
// The photos of one shoot type in their own order, or all of them
export function filterPhotos(
photos: readonly PortfolioPhoto[],
shoot: ShootTypeId | undefined,
): PortfolioPhoto[] {
return shoot === undefined
? [...photos]
: photos.filter((photo) => photo.shootType === shoot);
}
// "Alles" first, then one choice per shoot type, labelled with its short name
export function filterOptions(
shootTypes: readonly ShootType[],
allLabel: string,
): FilterOption[] {
return [
{ id: ALL_FILTER, label: allLabel },
...shootTypes.map((type) => ({ id: type.id, label: type.name })),
];
}
// Portfolio photos as items for the shared gallery blocks; the caption is
// the full name of the shoot type ("Newbornshoot", BR-CP-01)
export function toGalleryItems(
photos: readonly PortfolioPhoto[],
shootTypes: readonly ShootType[],
): GalleryItem[] {
return photos.map((photo) => ({
id: photo.id,
thumb: photo.thumb,
full: photo.full,
caption: shootTypes.find((type) => type.id === photo.shootType)
?.shootLabel,
}));
}
// "1 foto" or "6 foto's", for the announcement after a filter change
export function photoCountLabel(count: number): string {
return count === 1 ? '1 foto' : `${count} foto's`;
}
+3
View File
@@ -8,6 +8,9 @@ const filterControlRecipe = defineRecipe({
className: 'filter-control',
base: {
display: 'inline-flex',
// Labels never break or shrink inside the single filter row
flexShrink: 0,
whiteSpace: 'nowrap',
alignItems: 'center',
// 44px touch target (BR-RWD-04)
minH: '44px',
+70 -7
View File
@@ -1,17 +1,80 @@
import { createFileRoute } from '@tanstack/react-router';
import { createFileRoute, useNavigate } from '@tanstack/react-router';
import InstagramGrid from '../components/InstagramGrid/InstagramGrid';
import PageIntro from '../components/PageIntro/PageIntro';
import { pageHead } from '../seo';
import PortfolioGallery from '../components/portfolio/PortfolioGallery/PortfolioGallery';
import instagramContent from '../content/instagramContent';
import portfolioContent from '../content/portfolioContent';
import shootTypes from '../content/shootTypes';
import siteContent from '../content/siteContent';
import type { ShootTypeId } from '../content/types';
import { isShootTypeId } from '../lib/portfolioFilters';
import { visibleSocials } from '../lib/visibleSocials';
import { galleryImages, pageHead, structuredDataScript, webPage } from '../seo';
// ?shoot= from a filter or a "Bekijk meer …foto's" link: only a known shoot
// type is kept, so links to it are type-checked (BR-SP-01). Whether that
// type has photos is checked on the page.
type PortfolioSearch = { shoot?: ShootTypeId };
const shootTypeIds = shootTypes.map((type) => type.id);
export const Route = createFileRoute('/portfolio')({
head: () => pageHead('/portfolio'),
validateSearch: (search: Record<string, unknown>): PortfolioSearch => {
const value =
typeof search.shoot === 'string'
? search.shoot.trim().toLowerCase()
: undefined;
return isShootTypeId(value, shootTypeIds) ? { shoot: value } : {};
},
head: () => ({
...pageHead('/portfolio'),
scripts: [
structuredDataScript(
webPage('ImageGallery', '/portfolio', {
associatedMedia: galleryImages(portfolioContent.photos),
}),
),
],
}),
component: Portfolio,
});
// Placeholder tot de echte pagina er is (noindex via sitePages)
// The portfolio (LAYOUT.md: Intro → Portfolio → Instagram): the photos with
// filters and lightbox, then the same Instagram block as on the homepage
function Portfolio() {
const { shoot } = Route.useSearch();
const navigate = useNavigate({ from: Route.fullPath });
const { intro, photos } = portfolioContent;
// Without a valid https link the tiles would lead nowhere: no section
const instagram = visibleSocials(siteContent.socials).find(
(social) => social.platform === 'instagram',
);
return (
<PageIntro eyebrow="Werk" title="Portfolio">
Deze pagina is nog in de maak. Kom snel terug!
</PageIntro>
<>
<PageIntro eyebrow={intro.eyebrow} title={intro.title}>
{intro.text}
</PageIntro>
<PortfolioGallery
photos={photos}
shootTypes={shootTypes}
shoot={shoot}
// The filter is a view, not a step: no history entry per
// change and no jump to the top (application design Q4)
onShootChange={(next) =>
navigate({
search: next ? { shoot: next } : {},
replace: true,
resetScroll: false,
})
}
/>
{instagram && (
<InstagramGrid
content={instagramContent}
profileUrl={instagram.href}
/>
)}
</>
);
}
+10 -1
View File
@@ -5,9 +5,11 @@ import PageIntro from '../components/PageIntro/PageIntro';
import RichParagraph from '../components/RichParagraph/RichParagraph';
import ShootList from '../components/shoots/ShootList/ShootList';
import packages from '../content/packages';
import portfolioContent from '../content/portfolioContent';
import shootTypes from '../content/shootTypes';
import shootTypesPageContent from '../content/shootTypesPageContent';
import siteContent from '../content/siteContent';
import { shootTypesWithPhotos } from '../lib/portfolioFilters';
import { isPortfolioLive } from '../lib/shootLinks';
import { jsonLdScript, pageHead, shootServices, webPage } from '../seo';
import sitePages from '../sitePages';
@@ -43,7 +45,14 @@ function PhotoshootTypes() {
<ShootList
shoots={shootTypes}
packages={packages}
portfolioLive={isPortfolioLive(sitePages)}
portfolioShoots={
isPortfolioLive(sitePages)
? shootTypesWithPhotos(
shootTypes,
portfolioContent.photos,
).map((type) => type.id)
: []
}
/>
<CallToAction
title={closing.title}
+51 -3
View File
@@ -1,6 +1,7 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import aboutContent from './content/aboutContent';
import portfolioContent from './content/portfolioContent';
import shootTypes from './content/shootTypes';
import siteContent from './content/siteContent';
import { emailAddress } from './lib/emailAddress';
@@ -14,6 +15,7 @@ import {
canonicalUrl,
contactPage,
defaultOgImage,
galleryImages,
jsonLdScript,
pageHead,
person,
@@ -30,6 +32,7 @@ import sitePages from './sitePages';
import {
anySiteContent,
knowsAboutEntries,
portfolioPhotos,
routePath,
uniqueShootTypes,
} from './test/arbitraries';
@@ -93,9 +96,9 @@ describe('pageHead', () => {
});
it('zet noindex op een placeholder', () => {
const head = pageHead('/portfolio');
const head = pageHead('/privacyverklaring');
expect(meta(head, 'robots')).toMatchObject({ content: 'noindex' });
expect(head.links[0].href).toBe(`${siteUrl}/portfolio`);
expect(head.links[0].href).toBe(`${siteUrl}/privacyverklaring`);
});
});
@@ -312,7 +315,11 @@ describe('structured data about Andrea', () => {
});
it('falls back to the site preview image for a page without its own', () => {
const page = aboutPage('/portfolio', aboutContent.person, siteContent);
const page = aboutPage(
'/privacyverklaring',
aboutContent.person,
siteContent,
);
expect(page.mainEntity.image).toBe(`${siteUrl}/og-image.jpg`);
});
@@ -622,3 +629,44 @@ describe('the contact page', () => {
);
});
});
describe('galleryImages', () => {
it('describes each portfolio photo as an image by Andrea, owned by the business', () => {
const images = galleryImages(portfolioContent.photos);
expect(images).toHaveLength(10);
const first = portfolioContent.photos[0];
expect(images[0]).toEqual({
'@type': 'ImageObject',
contentUrl: absoluteUrl(first.full.src),
thumbnailUrl: absoluteUrl(first.thumb.src),
description: first.thumb.alt,
width: 1067,
height: 1600,
creator: { '@id': personId },
copyrightHolder: { '@id': businessId },
});
});
it('gives one image per photo in order, with absolute URLs and the alt text (invariant, oracle)', () => {
fc.assert(
fc.property(portfolioPhotos, (photos) => {
const images = galleryImages(photos);
expect(images).toHaveLength(photos.length);
images.forEach((image, i) => {
expect(image.contentUrl).toMatch(/^https:\/\//);
expect(image.thumbnailUrl).toMatch(/^https:\/\//);
expect(image.description).toBe(photos[i].thumb.alt);
});
}),
);
});
it('never puts an e-mail address in the gallery script (invariant)', () => {
const script = jsonLdScript(
webPage('ImageGallery', '/portfolio', {
associatedMedia: galleryImages(portfolioContent.photos),
}),
);
expect(script).not.toMatch(/@[a-z0-9-]+\.[a-z]/i);
});
});
+18
View File
@@ -2,6 +2,7 @@
// Titels en beschrijvingen staan in het pagina-register (sitePages.ts).
import type {
AboutPageContent,
PortfolioPhoto,
ServiceArea,
ShootType,
SiteContent,
@@ -228,3 +229,20 @@ export function siteHead(content: SiteContent) {
scripts: [structuredDataScript(professionalService(content))],
};
}
// The portfolio photos as schema.org images for the ImageGallery page
// (SEO-PF-03): the large version with the grid version as thumbnail, the
// description from the alt text, Andrea as creator and the business as
// copyright holder. Always every photo, whatever filter is on the page.
export function galleryImages(photos: readonly PortfolioPhoto[]) {
return photos.map((photo) => ({
'@type': 'ImageObject',
contentUrl: absoluteUrl(photo.full.src),
thumbnailUrl: absoluteUrl(photo.thumb.src),
description: photo.thumb.alt,
width: photo.full.width,
height: photo.full.height,
creator: { '@id': personId },
copyrightHolder: { '@id': businessId },
}));
}
+7 -1
View File
@@ -41,7 +41,13 @@ const sitePages: Record<RoutePath, PageMeta> = {
title: 'Portfolio',
description:
"Bekijk het portfolio van Andrea Slop Fotografie: spontane lifestylefoto's van gezinnen, stellen, zwangerschappen en newborns in Huizen en omgeving.",
indexed: false,
indexed: true,
ogImage: {
path: '/og-portfolio.jpg',
width: 1200,
height: 630,
alt: 'Grote broer kust zijn pasgeboren broertje of zusje op een wit bed',
},
},
'/soorten-fotoshoots': {
title: 'Soorten fotoshoots',
+1
View File
@@ -21,6 +21,7 @@ describe('sitemapXml', () => {
expect(locs(sitemapXml(pageList(sitePages), base))).toEqual([
`${base}/`,
`${base}/over-mij`,
`${base}/portfolio`,
`${base}/soorten-fotoshoots`,
`${base}/contact`,
]);
+25
View File
@@ -6,6 +6,7 @@ import type { Point } from '../lib/swipeDirection';
import type {
EmailAddress,
GalleryItem,
PortfolioPhoto,
FrameColor,
PricingPackage,
ShootType,
@@ -378,3 +379,27 @@ export const lightboxEvent: fc.Arbitrary<LightboxEvent> = fc.oneof(
count: fc.integer({ min: 0, max: 12 }),
}),
);
// A portfolio photo of any shoot type; ids are made unique by the list
export const portfolioPhoto: fc.Arbitrary<PortfolioPhoto> = fc
.tuple(
fc.stringMatching(/^[a-z0-9]{1,10}$/),
shootTypeId,
imageSize,
nonBlank,
)
.map(([id, shootType, size, alt]) => ({
id,
shootType,
thumb: { src: `/${id}.jpg`, alt, ...size },
full: {
src: `/${id}-groot.jpg`,
width: size.width * 2,
height: size.height * 2,
},
}));
export const portfolioPhotos = fc.uniqueArray(portfolioPhoto, {
selector: (photo) => photo.id,
maxLength: 15,
});