Adds the Soorten fotoshoots page #8

Merged
Sluijsens merged 10 commits from feature/soorten-fotoshoots-page into master 2026-10-25 16:54:55 +01:00
14 changed files with 253 additions and 44 deletions
Showing only changes of commit d2c1d2c1c4 - Show all commits
+16 -3
View File
@@ -199,10 +199,23 @@ describe('app', () => {
'/#contact',
'/#contact',
]);
// The portfolio is still a placeholder: no links to it yet
// Links to the filtered portfolio only once that page is live
// (indexed); they switch on by themselves when it is
expect(
within(main).queryAllByRole('link', { name: /^Bekijk meer/ }),
).toHaveLength(0);
within(main)
.queryAllByRole('link', { name: /^Bekijk meer/ })
.map((link) => link.getAttribute('href')),
).toEqual(
sitePages['/portfolio'].indexed
? [
'/portfolio?shoot=newborn',
'/portfolio?shoot=zwangerschap',
'/portfolio?shoot=gezin',
'/portfolio?shoot=loveshoot',
'/portfolio?shoot=portret',
]
: [],
);
expect(
screen.getByRole('link', { name: 'de pakketten' }),
).toHaveAttribute('href', '/#prijzen');
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

@@ -84,4 +84,87 @@ describe('MediaText', () => {
cssRulesFor(screen.getByRole('img').parentElement!).join(),
).toContain('var(--slp-colors-accent)');
});
// The grid is the parent of the photo column
const gridRules = () =>
cssRulesFor(photoColumnElement().parentElement!).join('\n');
const photoColumnElement = () =>
screen.getByRole('img').closest('[data-reveal]')!;
it('shares the width equally by default', async () => {
await renderWithProviders(
<MediaText image={image} aspectRatio="4 / 3">
<h2>Hoi! Ik ben Andrea</h2>
</MediaText>,
);
expect(gridRules()).toMatch(/grid-template-columns: 1fr 1fr/);
expect(cssRulesFor(photoColumnElement()).join()).not.toContain(
'max-width',
);
});
it('keeps a small photo at most 20rem wide and centres the text (at most 36rem) in the rest, also when reversed', async () => {
const { unmount } = await renderWithProviders(
<MediaText image={image} aspectRatio="4 / 5" mediaSize="small">
<h2>Newborn</h2>
</MediaText>,
);
expect(gridRules()).toMatch(
/grid-template-columns: minmax\(0, ?20rem\) minmax\(0, ?1fr\)/,
);
expect(cssRulesFor(photoColumnElement()).join()).toContain(
'max-width: 20rem',
);
const textRules = cssRulesFor(
screen.getByRole('heading').closest('[data-reveal]')!,
).join('\n');
expect(textRules).toContain('max-width: 36rem');
expect(textRules).toMatch(/min-width: 64rem.*margin-inline: auto/s);
unmount();
await renderWithProviders(
<MediaText
image={image}
aspectRatio="4 / 5"
mediaSize="small"
reverse
>
<h2>Zwangerschap</h2>
</MediaText>,
);
expect(gridRules()).toMatch(
/grid-template-columns: minmax\(0, ?1fr\) minmax\(0, ?20rem\)/,
);
});
it('adds a detail photo that overlaps the main one, in a wider column', async () => {
const detail: ContentImage = {
src: '/voetjes.jpg',
alt: 'Babyvoetjes',
width: 480,
height: 480,
};
const { container } = await renderWithProviders(
<MediaText
image={image}
aspectRatio="4 / 5"
mediaSize="small"
detailImage={detail}
>
<h2>Newborn</h2>
</MediaText>,
);
const [main, second] = screen.getAllByRole('img');
expect(main).toHaveAccessibleName(image.alt);
expect(second).toHaveAccessibleName('Babyvoetjes');
// Main photo first, so the reading order stays photo → detail → text
expect(
main.compareDocumentPosition(second) &
Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
expect(cssRulesFor(main.closest('[data-reveal]')!).join()).toContain(
'max-width: 28rem',
);
expect(await axeResults(container)).toHaveNoViolations();
});
});
+75 -11
View File
@@ -1,9 +1,17 @@
import type { ReactNode } from 'react';
import { Grid } from '@chakra-ui/react';
import { Box, Grid } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
import FramedImage from '@/components/FramedImage/FramedImage';
import Reveal from '@/components/Reveal/Reveal';
import type { ContentImage, FrameColor } from '@/content/types';
// Widest a small photo column gets, stacked or next to the text: the photo
// alone, or the photo with a detail photo overlapping it
const SMALL_MEDIA = '20rem';
const SMALL_MEDIA_WITH_DETAIL = '28rem';
// Widest the text next to a small photo gets: about 70 characters a line
const SMALL_TEXT = '36rem';
type MediaTextProps = {
image: ContentImage;
// CSS aspect ratio of the visible crop, e.g. '4 / 3'
@@ -13,6 +21,12 @@ type MediaTextProps = {
// Photo in the right-hand column from `lg` (design .about--reverse).
// Only the visual order changes: the photo stays first in the DOM.
reverse?: boolean;
// half: photo and text share the width equally (design .about);
// small: the photo column stays narrow (20rem, 28rem with a detail
// photo); the text, at most 36rem, is centred in the rest
mediaSize?: 'half' | 'small';
// A smaller square photo overlapping the main one's lower right corner
detailImage?: ContentImage;
// Colour of the block behind the photo (FramedImage)
frameColor?: FrameColor;
'data-testid'?: string;
@@ -22,32 +36,82 @@ type MediaTextProps = {
// A framed photo next to a text column (design .about), used on the
// homepage, the about page and the shoot types page. Stacked on phones and
// tablets, two equal columns from `lg`; both columns fade in on scroll.
// tablets, two columns from `lg`; both columns fade in on scroll.
export default function MediaText({
image,
aspectRatio,
priority,
reverse = false,
mediaSize = 'half',
detailImage,
frameColor,
'data-testid': testId,
children,
}: MediaTextProps) {
const small = mediaSize === 'small';
const mediaWidth = detailImage ? SMALL_MEDIA_WITH_DETAIL : SMALL_MEDIA;
const media = `minmax(0, ${mediaWidth})`;
const columns = small
? reverse
? `minmax(0, 1fr) ${media}`
: `${media} minmax(0, 1fr)`
: '1fr 1fr';
return (
<Grid
templateColumns={{ base: '1fr', lg: '1fr 1fr' }}
templateColumns={{ base: '1fr', lg: columns }}
gap="clamp(2rem, 6vw, 5.5rem)"
alignItems="center"
data-testid={testId}
>
<Reveal order={reverse ? { lg: 2 } : undefined}>
<FramedImage
image={image}
aspectRatio={aspectRatio}
priority={priority}
frameColor={frameColor}
/>
<Reveal
order={reverse ? { lg: 2 } : undefined}
maxW={small ? mediaWidth : undefined}
w={small ? 'full' : undefined}
>
{detailImage ? (
// The detail photo hangs below the main one: the padding
// (a share of the width) makes room for it
<Box position="relative" pb="15%">
<Box w="72%">
<FramedImage
image={image}
aspectRatio={aspectRatio}
priority={priority}
frameColor={frameColor}
/>
</Box>
<DeferredImage
image={detailImage}
position="absolute"
right={0}
bottom={0}
w="42%"
h="auto"
aspectRatio="1 / 1"
objectFit="cover"
borderWidth="6px"
borderColor="paper"
bg="paper.deep"
/>
</Box>
) : (
<FramedImage
image={image}
aspectRatio={aspectRatio}
priority={priority}
frameColor={frameColor}
/>
)}
</Reveal>
{/* Next to a small photo the text keeps a readable line length
and sits centred between the photo and the edge */}
<Reveal
maxW={small ? SMALL_TEXT : undefined}
mx={small ? { lg: 'auto' } : undefined}
>
{children}
</Reveal>
<Reveal>{children}</Reveal>
</Grid>
);
}
@@ -30,9 +30,14 @@ describe('ShootBlock', () => {
expect(
within(article).getByRole('heading', { level: 2 }),
).toHaveTextContent('Newborn');
expect(within(article).getByRole('img')).toHaveAccessibleName(
expect(
within(article)
.getAllByRole('img')
.map((img) => img.getAttribute('alt')),
).toEqual([
shoot('newborn').image.alt,
);
shoot('newborn').detailImage!.alt,
]);
expect(
within(article).getByText(/De fotoshoot vindt bij jou thuis/),
).toBeInTheDocument();
@@ -68,8 +73,10 @@ describe('ShootBlock', () => {
).toHaveAttribute('href', '/portfolio?shoot=portret');
});
it('loads a priority photo straight away and others lazily', async () => {
it('loads a priority photo straight away, its detail photo lazily', async () => {
await renderBlock('newborn', { priority: true });
expect(screen.getByRole('img')).not.toHaveAttribute('loading', 'lazy');
const [main, detail] = screen.getAllByRole('img');
expect(main).not.toHaveAttribute('loading', 'lazy');
expect(detail).toHaveAttribute('loading', 'lazy');
});
});
@@ -44,6 +44,8 @@ export default function ShootBlock({
<MediaText
image={shoot.image}
aspectRatio="4 / 5"
mediaSize="small"
detailImage={shoot.detailImage}
frameColor={shoot.frameColor}
reverse={reverse}
priority={priority}
@@ -1,4 +1,4 @@
import { screen } from '@testing-library/react';
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import packages from '@/content/packages';
import shootTypes from '@/content/shootTypes';
@@ -36,11 +36,16 @@ describe('ShootList', () => {
expect(await axeResults(container)).toHaveNoViolations();
});
// The main photo of each shoot: the first image in its article
const mainPhotos = () =>
screen
.getAllByRole('article')
.map((article) => within(article).getAllByRole('img')[0]);
it('alternates the photo side: every second shoot has it on the right', async () => {
await renderList();
const reversed = screen.getAllByRole('img').map((img) =>
// img → FramedImage wrapper → photo column
cssRulesFor(img.parentElement!.parentElement!).some((rule) =>
const reversed = mainPhotos().map((img) =>
cssRulesFor(img.closest('[data-reveal]')!).some((rule) =>
/order: 2;/.test(rule),
),
);
@@ -49,22 +54,24 @@ describe('ShootList', () => {
it('only loads the first photo straight away', async () => {
await renderList();
expect(
screen
.getAllByRole('img')
.map((img) => img.getAttribute('loading')),
).toEqual([null, 'lazy', 'lazy', 'lazy', 'lazy']);
expect(mainPhotos().map((img) => img.getAttribute('loading'))).toEqual([
null,
'lazy',
'lazy',
'lazy',
'lazy',
]);
});
it('draws a line between the shoots, not above the first', async () => {
it('alternates the background of the bands', async () => {
await renderList();
const borders = screen
const tones = screen
.getAllByRole('article')
.map((article) =>
cssRulesFor(article.parentElement!).some((rule) =>
/border-top-width: 1px/.test(rule),
cssRulesFor(article.closest('section')!).some((rule) =>
/background: var\(--slp-colors-paper-alt\)/.test(rule),
),
);
expect(borders).toEqual([false, true, true, true, true]);
expect(tones).toEqual([false, true, false, true, false]);
});
});
@@ -9,24 +9,23 @@ type ShootListProps = {
portfolioLive: boolean;
};
// The shoot types below the page head, photo and text alternating sides,
// with a hairline between them (design .shoot + .shoot). The section needs
// no name of its own: every shoot is an article named by its heading.
// The shoot types below the page head, each in its own full-width band:
// the background alternates paper and paper.alt, and so does the side of
// the photo. The bands need no name of their own: every shoot is an
// article named by its heading.
export default function ShootList({
shoots,
packages,
portfolioLive,
}: ShootListProps) {
return (
<PageSection spacing="flushTop" data-testid="shoot-list">
<Box data-testid="shoot-list">
{shoots.map((shoot, index) => (
<Box
<PageSection
key={shoot.id}
py="clamp(2.5rem, 6vw, 5rem)"
borderTopWidth={index > 0 ? '1px' : undefined}
borderColor="line"
// The first block sits right below the page head
pt={index === 0 ? 0 : undefined}
tone={index % 2 === 1 ? 'alt' : 'paper'}
// The first band sits right below the page head
spacing={index === 0 ? 'flushTop' : 'default'}
>
<ShootBlock
shoot={shoot}
@@ -35,8 +34,8 @@ export default function ShootList({
priority={index === 0}
portfolioLive={portfolioLive}
/>
</Box>
</PageSection>
))}
</PageSection>
</Box>
);
}
+32
View File
@@ -6,8 +6,15 @@ import zwangerschap from '../assets/shoots/zwangerschap.jpg';
import gezin from '../assets/shoots/gezin.jpg';
import loveshoot from '../assets/shoots/loveshoot.jpg';
import portret from '../assets/shoots/portret.jpg';
// Square detail photos (480×480) for the collage
import newbornDetail from '../assets/shoots/newborn-detail.jpg';
import zwangerschapDetail from '../assets/shoots/zwangerschap-detail.jpg';
import gezinDetail from '../assets/shoots/gezin-detail.jpg';
import loveshootDetail from '../assets/shoots/loveshoot-detail.jpg';
import portretDetail from '../assets/shoots/portret-detail.jpg';
const size = { width: 848, height: 1060 };
const detailSize = { width: 480, height: 480 };
// The shoot types until the CMS API exists, in page order. Texts from the
// live site (FR-SF-02); also used by the portfolio page for its filters.
@@ -26,6 +33,11 @@ const shootTypes: ShootType[] = [
alt: 'Een pasgeboren baby in een gestreept pakje slaapt met het hoofdje opzij',
...size,
},
detailImage: {
src: newbornDetail,
alt: 'Babyvoetjes die onder een gestreept gebreid pakje uitsteken',
...detailSize,
},
frameColor: 'frame.stone',
packageId: 'newborn',
},
@@ -42,6 +54,11 @@ const shootTypes: ShootType[] = [
alt: 'Een zwangere vrouw en haar partner kijken elkaar lachend aan op een zandvlakte, zijn hand op haar buik',
...size,
},
detailImage: {
src: zwangerschapDetail,
alt: 'Een zwangere vrouw in een lichte jurk houdt haar buik vast op een zandvlakte in de avondzon',
...detailSize,
},
frameColor: 'frame.rust',
packageId: 'zwangerschap',
},
@@ -59,6 +76,11 @@ const shootTypes: ShootType[] = [
alt: 'Vader en moeder kijken samen naar hun pasgeboren baby in de armen van de vader',
...size,
},
detailImage: {
src: gezinDetail,
alt: 'Een jongetje geeft de pasgeboren baby een kus op het bed',
...detailSize,
},
frameColor: 'accent',
packageId: 'gezin',
},
@@ -75,6 +97,11 @@ const shootTypes: ShootType[] = [
alt: 'Een stel ligt in de zon op een plaid in het gras, met de hoofden tegen elkaar',
...size,
},
detailImage: {
src: loveshootDetail,
alt: 'Een man schuift een ring om de vinger van zijn partner, met paarse heide op de achtergrond',
...detailSize,
},
frameColor: 'frame.taupe',
},
{
@@ -90,6 +117,11 @@ const shootTypes: ShootType[] = [
alt: 'Een vrouw met lang bruin haar in een witte blouse kijkt glimlachend omlaag, met bomen op de achtergrond',
...size,
},
detailImage: {
src: portretDetail,
alt: 'Een vrouw met lang blond haar in een jurk met bloemenprint houdt een takje heide vast op de heide',
...detailSize,
},
frameColor: 'frame.olive',
},
];
+2
View File
@@ -78,6 +78,8 @@ export interface ShootType {
paragraphs: string[];
// Cropped to 4:5
image: ContentImage;
// A smaller square photo that overlaps the main one (collage)
detailImage?: ContentImage;
frameColor: FrameColor;
// The matching price package, if there is one
packageId?: PricingPackage['id'];