Adds the Soorten fotoshoots page
Replaces the placeholder with the five shoot types (Newborn, Zwangerschap, Gezin, Loveshoot, Portretten), each an article with its own anchor, photo, text and a link to the contact form that preselects the matching package. A portfolio link per shoot shows once the portfolio page is live. A closing call to action links to the prices and the contact form. The page is indexed with its own description and preview image, and describes the shoots as services of the business in structured data. That data is rendered in the page component, so the shoot texts stay out of the main bundle. The shoot photos are cropped at 848x1060, no longer upscaled. Photo pages get a mobile Lighthouse performance target of 0.85: their largest paint is a photo that the simulated slow connection only requests after the scripts have run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import packages from '@/content/packages';
|
||||
import shootTypes from '@/content/shootTypes';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import ShootBlock from './ShootBlock';
|
||||
|
||||
const shoot = (id: string) => shootTypes.find((item) => item.id === id)!;
|
||||
|
||||
const renderBlock = (
|
||||
id: string,
|
||||
{ portfolioLive = false, reverse = false, priority = false } = {},
|
||||
) =>
|
||||
renderWithProviders(
|
||||
<ShootBlock
|
||||
shoot={shoot(id)}
|
||||
packages={packages}
|
||||
reverse={reverse}
|
||||
priority={priority}
|
||||
portfolioLive={portfolioLive}
|
||||
/>,
|
||||
);
|
||||
|
||||
describe('ShootBlock', () => {
|
||||
it('is an article named by its heading, with the anchor id', async () => {
|
||||
const { container } = await renderBlock('newborn');
|
||||
const article = screen.getByRole('article', { name: 'Newborn' });
|
||||
expect(article).toHaveAttribute('id', 'newborn');
|
||||
expect(
|
||||
within(article).getByRole('heading', { level: 2 }),
|
||||
).toHaveTextContent('Newborn');
|
||||
expect(within(article).getByRole('img')).toHaveAccessibleName(
|
||||
shoot('newborn').image.alt,
|
||||
);
|
||||
expect(
|
||||
within(article).getByText(/De fotoshoot vindt bij jou thuis/),
|
||||
).toBeInTheDocument();
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('links to the contact form with the package preselected', async () => {
|
||||
await renderBlock('zwangerschap');
|
||||
const link = screen.getByRole('link', {
|
||||
name: 'Stuur een berichtje over een zwangerschapsshoot',
|
||||
});
|
||||
expect(link).toHaveAttribute('href', '/?pakket=zwangerschap#contact');
|
||||
});
|
||||
|
||||
it('links to the contact form without a package when the shoot has none', async () => {
|
||||
await renderBlock('loveshoot');
|
||||
expect(
|
||||
screen.getByRole('link', {
|
||||
name: 'Stuur een berichtje over een loveshoot',
|
||||
}),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
});
|
||||
|
||||
it('only links to the portfolio once it is live', async () => {
|
||||
await renderBlock('portret');
|
||||
expect(screen.queryByTestId('shoot-portret-portfolio')).toBeNull();
|
||||
});
|
||||
|
||||
it('links to the portfolio filtered on the shoot type when live', async () => {
|
||||
await renderBlock('portret', { portfolioLive: true });
|
||||
expect(
|
||||
screen.getByRole('link', { name: "Bekijk meer portretfoto's" }),
|
||||
).toHaveAttribute('href', '/portfolio?shoot=portret');
|
||||
});
|
||||
|
||||
it('loads a priority photo straight away and others lazily', async () => {
|
||||
await renderBlock('newborn', { priority: true });
|
||||
expect(screen.getByRole('img')).not.toHaveAttribute('loading', 'lazy');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
import { Box, Flex, Heading, Link, Stack, Text } from '@chakra-ui/react';
|
||||
// The router's own Link keeps the route types, so `search` is checked
|
||||
// against the target route (as on the price cards)
|
||||
import { Link as RouterLink } from '@tanstack/react-router';
|
||||
import MediaText from '@/components/MediaText/MediaText';
|
||||
import type { PricingPackage, ShootType } from '@/content/types';
|
||||
import { shootContactLink, shootPortfolioLink } from '@/lib/shootLinks';
|
||||
|
||||
type ShootBlockProps = {
|
||||
shoot: ShootType;
|
||||
packages: readonly PricingPackage[];
|
||||
// Photo in the right-hand column from `lg`
|
||||
reverse: boolean;
|
||||
// The first photo on the page loads straight away
|
||||
priority: boolean;
|
||||
// Show "Bekijk meer …foto's" (BR-SF-04)
|
||||
portfolioLive: boolean;
|
||||
};
|
||||
|
||||
// Links in the text column: room around them for a 44px touch target
|
||||
const linkStyle = { py: 2.5, display: 'inline-block' } as const;
|
||||
|
||||
// One kind of shoot (design .shoot): its photo next to the name, the text
|
||||
// and the links. The article is the anchor (#newborn) and is named by its
|
||||
// heading.
|
||||
export default function ShootBlock({
|
||||
shoot,
|
||||
packages,
|
||||
reverse,
|
||||
priority,
|
||||
portfolioLive,
|
||||
}: ShootBlockProps) {
|
||||
const titleId = `shoot-${shoot.id}-title`;
|
||||
|
||||
return (
|
||||
<Box
|
||||
as="article"
|
||||
id={shoot.id}
|
||||
aria-labelledby={titleId}
|
||||
// An anchor lands right below the fixed header
|
||||
scrollMarginTop="header.sticky"
|
||||
data-testid={`shoot-${shoot.id}`}
|
||||
>
|
||||
<MediaText
|
||||
image={shoot.image}
|
||||
aspectRatio="4 / 5"
|
||||
frameColor={shoot.frameColor}
|
||||
reverse={reverse}
|
||||
priority={priority}
|
||||
>
|
||||
<Heading as="h2" id={titleId} textStyle="sectionTitle" mb={5}>
|
||||
{shoot.name}
|
||||
</Heading>
|
||||
<Stack gap={4} color="ink.soft">
|
||||
{shoot.paragraphs.map((paragraph) => (
|
||||
<Text key={paragraph}>{paragraph}</Text>
|
||||
))}
|
||||
</Stack>
|
||||
<Flex wrap="wrap" columnGap={6} mt={3}>
|
||||
<Link variant="underline" asChild {...linkStyle}>
|
||||
{/* Five links say "Stuur een berichtje"; the full name
|
||||
tells screen reader users which shoot each is about.
|
||||
It starts with the visible text, so voice control
|
||||
still finds it (BR-SF-06). An aria-label, because
|
||||
accessible names drop the leading space of a
|
||||
visually hidden span. */}
|
||||
<RouterLink
|
||||
{...shootContactLink(shoot, packages)}
|
||||
aria-label={`Stuur een berichtje over een ${shoot.shootLabel.toLowerCase()}`}
|
||||
data-testid={`shoot-${shoot.id}-contact`}
|
||||
>
|
||||
Stuur een berichtje
|
||||
</RouterLink>
|
||||
</Link>
|
||||
{portfolioLive && (
|
||||
<Link variant="underline" asChild {...linkStyle}>
|
||||
<RouterLink
|
||||
{...shootPortfolioLink(shoot)}
|
||||
data-testid={`shoot-${shoot.id}-portfolio`}
|
||||
>
|
||||
Bekijk meer {shoot.photosLabel}
|
||||
</RouterLink>
|
||||
</Link>
|
||||
)}
|
||||
</Flex>
|
||||
</MediaText>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import packages from '@/content/packages';
|
||||
import shootTypes from '@/content/shootTypes';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { cssRulesFor } from '@/test/cssRules';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import ShootList from './ShootList';
|
||||
|
||||
const renderList = () =>
|
||||
renderWithProviders(
|
||||
<ShootList
|
||||
shoots={shootTypes}
|
||||
packages={packages}
|
||||
portfolioLive={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
describe('ShootList', () => {
|
||||
it('shows the shoots in order, each named by its heading', async () => {
|
||||
const { container } = await renderList();
|
||||
expect(
|
||||
screen.getAllByRole('article').map((article) => article.id),
|
||||
).toEqual(['newborn', 'zwangerschap', 'gezin', 'loveshoot', 'portret']);
|
||||
expect(
|
||||
screen
|
||||
.getAllByRole('heading', { level: 2 })
|
||||
.map((heading) => heading.textContent),
|
||||
).toEqual([
|
||||
'Newborn',
|
||||
'Zwangerschap',
|
||||
'Gezin',
|
||||
'Loveshoot',
|
||||
'Portretten',
|
||||
]);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
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) =>
|
||||
/order: 2;/.test(rule),
|
||||
),
|
||||
);
|
||||
expect(reversed).toEqual([false, true, false, true, false]);
|
||||
});
|
||||
|
||||
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']);
|
||||
});
|
||||
|
||||
it('draws a line between the shoots, not above the first', async () => {
|
||||
await renderList();
|
||||
const borders = screen
|
||||
.getAllByRole('article')
|
||||
.map((article) =>
|
||||
cssRulesFor(article.parentElement!).some((rule) =>
|
||||
/border-top-width: 1px/.test(rule),
|
||||
),
|
||||
);
|
||||
expect(borders).toEqual([false, true, true, true, true]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import PageSection from '@/components/PageSection/PageSection';
|
||||
import type { PricingPackage, ShootType } from '@/content/types';
|
||||
import ShootBlock from '../ShootBlock/ShootBlock';
|
||||
|
||||
type ShootListProps = {
|
||||
shoots: readonly ShootType[];
|
||||
packages: readonly PricingPackage[];
|
||||
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.
|
||||
export default function ShootList({
|
||||
shoots,
|
||||
packages,
|
||||
portfolioLive,
|
||||
}: ShootListProps) {
|
||||
return (
|
||||
<PageSection spacing="flushTop" data-testid="shoot-list">
|
||||
{shoots.map((shoot, index) => (
|
||||
<Box
|
||||
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}
|
||||
>
|
||||
<ShootBlock
|
||||
shoot={shoot}
|
||||
packages={packages}
|
||||
reverse={index % 2 === 1}
|
||||
priority={index === 0}
|
||||
portfolioLive={portfolioLive}
|
||||
/>
|
||||
</Box>
|
||||
))}
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user