Adds the Prijzen section to the homepage

Shows the three live packages as cards with their price and what is
included. Each card links to the contact section with ?pakket=<id>, so
the contact form can preselect it. Invalid packages from the CMS are
skipped and the pakket value is only accepted when it names a package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 01:07:36 +02:00
co-authored by Claude Opus 5.5
parent 0b54a67dc4
commit 30dab1af42
32 changed files with 1250 additions and 6 deletions
@@ -0,0 +1,45 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import packages from '@/content/packages';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import PriceCard from './PriceCard';
const newborn = packages[1];
describe('PriceCard', () => {
it('shows the name, price, features and a booking link with the package', async () => {
const { container } = await renderWithProviders(
<PriceCard pkg={newborn} />,
);
const card = screen.getByTestId('price-card-newborn');
expect(
within(card).getByRole('heading', { level: 3 }),
).toHaveTextContent('Newborn');
// Raw text: Testing Library's matchers would turn the non-breaking
// space into a normal one
expect(card.textContent).toContain('€\u00a0185');
expect(
within(card)
.getAllByRole('listitem')
.map((item) => item.textContent),
).toEqual(newborn.features);
const link = within(card).getByRole('link', { name: 'Boek Newborn' });
expect(link).toHaveAttribute('href', '/?pakket=newborn#contact');
expect(await axeResults(container)).toHaveNoViolations();
});
it('uses "Boek je shoot" with the name for screen readers when the name is long', async () => {
await renderWithProviders(
<PriceCard
pkg={{ ...newborn, id: 'bruiloft', name: 'Bruiloft en feest' }}
/>,
);
const link = screen.getByRole('link', {
name: 'Boek je shoot: Bruiloft en feest',
});
expect(link).toHaveTextContent('Boek je shoot');
expect(link).toHaveAttribute('href', '/?pakket=bruiloft#contact');
});
});
@@ -0,0 +1,98 @@
import {
Box,
Heading,
List,
Text,
useRecipe,
VisuallyHidden,
} from '@chakra-ui/react';
import { Link } from '@tanstack/react-router';
import type { PricingPackage } from '@/content/types';
import { bookLabel } from '@/lib/bookLabel';
import { formatPrice } from '@/lib/formatPrice';
type PriceCardProps = {
pkg: PricingPackage;
};
// One package (design .price-card): name, price, what is included and a
// link that takes the visitor to the contact form with this package chosen.
export default function PriceCard({ pkg }: PriceCardProps) {
const label = bookLabel(pkg.name);
const linkButton = useRecipe({ key: 'linkButton' });
return (
<Box
as="article"
data-testid={`price-card-${pkg.id}`}
display="flex"
flexDirection="column"
h="100%"
px="clamp(1.5rem, 3vw, 2.5rem)"
py="clamp(2rem, 3.5vw, 3rem)"
bg="white"
borderWidth="1px"
borderColor="line"
textAlign="center"
transitionProperty="transform, box-shadow, border-color"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_hover={{
transform: 'translateY(-6px)',
borderColor: 'accent',
boxShadow: 'lift',
}}
_motionReduce={{ _hover: { transform: 'none' } }}
>
<Heading as="h3" fontSize="1.75rem" mb={3}>
{pkg.name}
</Heading>
{/* accent.deep instead of the design's accent: meets 4.5:1 (NFR-HP-01) */}
<Text
fontFamily="heading"
fontSize="2.25rem"
lineHeight="1"
color="accent.deep"
mb={6}
>
{formatPrice(pkg.price)}
</Text>
<List.Root
listStyleType="none"
display="grid"
gap={3}
mb={8}
py={6}
borderBlockWidth="1px"
borderColor="line"
color="ink.soft"
fontSize="sm"
>
{pkg.features.map((feature) => (
<List.Item key={feature}>{feature}</List.Item>
))}
</List.Root>
{/* The router's own Link keeps the route types, so search is
checked against the homepage's ?pakket=; the button style
goes on via asChild */}
<Box
asChild
css={linkButton({ size: 'fit' })}
alignSelf="center"
mt="auto"
>
<Link
to="/"
search={{ pakket: pkg.id }}
hash="contact"
data-testid={`price-card-${pkg.id}-book`}
>
{label.visible}
{label.hidden && (
<VisuallyHidden>{label.hidden}</VisuallyHidden>
)}
</Link>
</Box>
</Box>
);
}
@@ -0,0 +1,67 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import homeContent from '@/content/homeContent';
import packages from '@/content/packages';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import Pricing from './Pricing';
const content = homeContent.pricing;
describe('Pricing', () => {
it('shows the heading and one card per package, in order', async () => {
const { container } = await renderWithProviders(
<Pricing content={content} packages={packages} />,
);
const section = screen.getByRole('region', { name: 'Prijzen' });
expect(within(section).getByText('Pakketten')).toBeInTheDocument();
expect(
within(section)
.getAllByRole('heading', { level: 3 })
.map((heading) => heading.textContent),
).toEqual(['Zwangerschap', 'Newborn', 'Gezin']);
expect(
within(section)
.getAllByRole('link')
.map((link) => link.getAttribute('href')),
).toEqual([
'/?pakket=zwangerschap#contact',
'/?pakket=newborn#contact',
'/?pakket=gezin#contact',
]);
expect(await axeResults(container)).toHaveNoViolations();
});
it('keeps the decorations away from assistive technology', async () => {
const { container } = await renderWithProviders(
<Pricing content={content} packages={packages} />,
);
// The only images here are the decorations: empty alt and aria-hidden
expect(screen.queryAllByRole('img')).toHaveLength(0);
const images = container.querySelectorAll('img');
expect(images).toHaveLength(content.decorations.length);
images.forEach((image) => {
expect(image).toHaveAttribute('alt', '');
expect(image).toHaveAttribute('aria-hidden', 'true');
});
});
it('skips invalid packages', async () => {
await renderWithProviders(
<Pricing
content={content}
packages={[{ ...packages[0], price: 0 }, packages[1]]}
/>,
);
expect(
screen
.getAllByRole('heading', { level: 3 })
.map((h) => h.textContent),
).toEqual(['Newborn']);
});
it('leaves the section out when no package is valid', async () => {
await renderWithProviders(<Pricing content={content} packages={[]} />);
expect(screen.queryByRole('region', { name: 'Prijzen' })).toBeNull();
});
});
@@ -0,0 +1,73 @@
import { Box, Grid } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
import HomeSection from '@/components/HomeSection/HomeSection';
import Reveal from '@/components/Reveal/Reveal';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
import type { HomeContent, PricingPackage } from '@/content/types';
import { visiblePackages } from '@/lib/visiblePackages';
import PriceCard from './PriceCard';
const TITLE_ID = 'pricing-title';
const STAGGER = 0.08;
// Where the two decorations sit (design .pricing__deco--1 and --2). The
// design measures from the whole section; here they sit in the content box,
// so the second one moves down into the section's bottom padding, or the
// last card would cover it.
const decorationPositions = [
{ top: '8%', left: '2%' },
{ bottom: 'calc(-0.6 * {spacing.sectionY})', right: '2%' },
];
type PricingProps = {
content: HomeContent['pricing'];
packages: PricingPackage[];
};
// "Prijzen": the shoot packages as cards (design .pricing). One column on
// phones and tablets, three from `lg`. Without a valid package the section
// is left out entirely.
export default function Pricing({ content, packages }: PricingProps) {
const shown = visiblePackages(packages);
if (shown.length === 0) return null;
return (
<HomeSection labelledBy={TITLE_ID} data-testid="pricing">
<Box position="relative" isolation="isolate">
{content.decorations.map((decoration, index) => (
<DeferredImage
key={decoration.src}
image={decoration}
aria-hidden="true"
position="absolute"
zIndex={-1}
w="clamp(90px, 10vw, 160px)"
h="auto"
opacity={0.55}
pointerEvents="none"
{...decorationPositions[index % 2]}
/>
))}
<Reveal>
<SectionHeading
id={TITLE_ID}
title={content.title}
lead={content.lead}
/>
</Reveal>
<Grid
templateColumns={{ base: '1fr', lg: 'repeat(3, 1fr)' }}
gap="gridGap"
maxW={{ base: '460px', lg: 'none' }}
mx="auto"
>
{shown.map((pkg, index) => (
<Reveal key={pkg.id} delay={index * STAGGER} h="100%">
<PriceCard pkg={pkg} />
</Reveal>
))}
</Grid>
</Box>
</HomeSection>
);
}