Adds the Over mij page
Replaces the placeholder with the page from the design and the texts from the live site: Andrea's introduction with her portrait, how it started, two photos, life outside photography and a booking button. The page is now indexed, with its own title, description, preview image and AboutPage data about Andrea. The portrait loads straight away instead of after the page, since on phones it is the largest paint. Lighthouse no longer lets every indexed page use the homepage's lower mobile performance target; it now only applies to the homepage itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,4 +24,15 @@ describe('FramedImage', () => {
|
||||
expect(img).toHaveAttribute('loading', 'lazy');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('loads a priority photo straight away, not lazily', async () => {
|
||||
await renderWithProviders(
|
||||
<FramedImage image={image} aspectRatio="4 / 3" priority />,
|
||||
);
|
||||
const img = screen.getByRole('img');
|
||||
expect(img).toHaveAttribute('src', '/andrea.jpg');
|
||||
expect(img).not.toHaveAttribute('loading', 'lazy');
|
||||
expect(img).toHaveAttribute('fetchpriority', 'high');
|
||||
expect(img).toHaveAttribute('width', '1200');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import { Box, Image, type ImageProps } from '@chakra-ui/react';
|
||||
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
|
||||
@@ -6,13 +6,30 @@ type FramedImageProps = {
|
||||
image: ContentImage;
|
||||
// CSS aspect ratio of the visible crop, e.g. '4 / 3'
|
||||
aspectRatio: string;
|
||||
// For a photo at the top of a page, likely the largest paint: load it
|
||||
// straight away with high priority instead of after the page has loaded
|
||||
priority?: boolean;
|
||||
};
|
||||
|
||||
// A photo with a soft sand-coloured block offset behind its lower left
|
||||
// corner (design .about__media). The block is pure decoration (a CSS
|
||||
// pseudo-element), so assistive technology never announces it. On phones it
|
||||
// is left out, since it would stick out past the page edge.
|
||||
export default function FramedImage({ image, aspectRatio }: FramedImageProps) {
|
||||
export default function FramedImage({
|
||||
image,
|
||||
aspectRatio,
|
||||
priority = false,
|
||||
}: FramedImageProps) {
|
||||
const style: ImageProps = {
|
||||
display: 'block',
|
||||
w: '100%',
|
||||
h: 'auto',
|
||||
aspectRatio,
|
||||
objectFit: 'cover',
|
||||
// Shown until the photo arrives
|
||||
bg: 'paper.deep',
|
||||
};
|
||||
|
||||
return (
|
||||
<Box
|
||||
position="relative"
|
||||
@@ -30,16 +47,19 @@ export default function FramedImage({ image, aspectRatio }: FramedImageProps) {
|
||||
zIndex: -1,
|
||||
}}
|
||||
>
|
||||
<DeferredImage
|
||||
image={image}
|
||||
display="block"
|
||||
w="100%"
|
||||
h="auto"
|
||||
aspectRatio={aspectRatio}
|
||||
objectFit="cover"
|
||||
// Shown until the deferred photo arrives
|
||||
bg="paper.deep"
|
||||
/>
|
||||
{priority ? (
|
||||
<Image
|
||||
src={image.src}
|
||||
alt={image.alt}
|
||||
htmlWidth={image.width}
|
||||
htmlHeight={image.height}
|
||||
fetchPriority="high"
|
||||
decoding="async"
|
||||
{...style}
|
||||
/>
|
||||
) : (
|
||||
<DeferredImage image={image} {...style} />
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ type MediaTextProps = {
|
||||
image: ContentImage;
|
||||
// CSS aspect ratio of the visible crop, e.g. '4 / 3'
|
||||
aspectRatio: string;
|
||||
// The photo is at the top of the page and should not wait (FramedImage)
|
||||
priority?: boolean;
|
||||
'data-testid'?: string;
|
||||
// The text column; each page fills in its own heading and text
|
||||
children: ReactNode;
|
||||
@@ -19,6 +21,7 @@ type MediaTextProps = {
|
||||
export default function MediaText({
|
||||
image,
|
||||
aspectRatio,
|
||||
priority,
|
||||
'data-testid': testId,
|
||||
children,
|
||||
}: MediaTextProps) {
|
||||
@@ -30,7 +33,11 @@ export default function MediaText({
|
||||
data-testid={testId}
|
||||
>
|
||||
<Reveal>
|
||||
<FramedImage image={image} aspectRatio={aspectRatio} />
|
||||
<FramedImage
|
||||
image={image}
|
||||
aspectRatio={aspectRatio}
|
||||
priority={priority}
|
||||
/>
|
||||
</Reveal>
|
||||
<Reveal>{children}</Reveal>
|
||||
</Grid>
|
||||
|
||||
@@ -57,6 +57,17 @@ describe('PageSection', () => {
|
||||
expect(regular.paddingTop).not.toBe('0px');
|
||||
});
|
||||
|
||||
it('is no landmark without a heading to name it', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<PageSection data-testid="photos">
|
||||
<p>Foto's</p>
|
||||
</PageSection>,
|
||||
);
|
||||
expect(screen.getByTestId('photos').tagName).toBe('SECTION');
|
||||
expect(screen.queryByRole('region')).not.toBeInTheDocument();
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('leaves out the content column at full width', async () => {
|
||||
await renderWithProviders(
|
||||
<PageSection labelledBy="insta-title" width="full">
|
||||
|
||||
@@ -2,8 +2,9 @@ import type { ReactNode } from 'react';
|
||||
import { Box, Container } from '@chakra-ui/react';
|
||||
|
||||
type PageSectionProps = {
|
||||
// Id of the heading that names this section for assistive technology
|
||||
labelledBy: string;
|
||||
// Id of the heading that names this section for assistive technology.
|
||||
// Without it (a block without a heading) the section is no landmark.
|
||||
labelledBy?: string;
|
||||
id?: string;
|
||||
tone?: 'paper' | 'alt';
|
||||
// full: no content column, for edge-to-edge content; the section then
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import PhotoDuo from './PhotoDuo';
|
||||
|
||||
const photos: [ContentImage, ContentImage] = [
|
||||
{
|
||||
src: '/concert.jpg',
|
||||
alt: 'Concert vanaf het podium',
|
||||
width: 1200,
|
||||
height: 798,
|
||||
},
|
||||
{ src: '/kat.jpg', alt: 'Slapende grijze kat', width: 1200, height: 800 },
|
||||
];
|
||||
|
||||
describe('PhotoDuo', () => {
|
||||
it('shows both photos in a named list', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<PhotoDuo photos={photos} label="Foto's" />,
|
||||
);
|
||||
const list = screen.getByRole('list', { name: "Foto's" });
|
||||
const images = within(list).getAllByRole('img');
|
||||
expect(images).toHaveLength(2);
|
||||
expect(images[0]).toHaveAccessibleName('Concert vanaf het podium');
|
||||
expect(images[1]).toHaveAccessibleName('Slapende grijze kat');
|
||||
expect(images[0]).toHaveAttribute('width', '1200');
|
||||
expect(images[0]).toHaveAttribute('height', '798');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import { chakra } from '@chakra-ui/react';
|
||||
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
||||
import Reveal from '@/components/Reveal/Reveal';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
|
||||
type PhotoDuoProps = {
|
||||
photos: [ContentImage, ContentImage];
|
||||
// Accessible name of the photo list, e.g. "Foto's"
|
||||
label: string;
|
||||
'data-testid'?: string;
|
||||
};
|
||||
|
||||
// Two landscape photos side by side (design .intro-gallery--duo), one below
|
||||
// the other on phones. Each zooms in gently on hover, as in the homepage
|
||||
// gallery, except with reduced motion.
|
||||
export default function PhotoDuo({
|
||||
photos,
|
||||
label,
|
||||
'data-testid': testId,
|
||||
}: PhotoDuoProps) {
|
||||
return (
|
||||
<Reveal>
|
||||
<chakra.ul
|
||||
listStyleType="none"
|
||||
aria-label={label}
|
||||
data-testid={testId}
|
||||
display="grid"
|
||||
gridTemplateColumns={{ base: '1fr', sm: 'repeat(2, 1fr)' }}
|
||||
gap="gridGap"
|
||||
>
|
||||
{photos.map((photo) => (
|
||||
<chakra.li key={photo.src}>
|
||||
<chakra.figure
|
||||
overflow="hidden"
|
||||
// Shown until the deferred photo arrives
|
||||
bg="paper.deep"
|
||||
css={{
|
||||
'&:hover img': { transform: 'scale(1.05)' },
|
||||
}}
|
||||
>
|
||||
<DeferredImage
|
||||
image={photo}
|
||||
display="block"
|
||||
w="100%"
|
||||
h="auto"
|
||||
aspectRatio="3 / 2"
|
||||
objectFit="cover"
|
||||
transitionProperty="transform"
|
||||
transitionDuration="fade"
|
||||
transitionTimingFunction="smooth"
|
||||
_motionReduce={{ transition: 'none' }}
|
||||
/>
|
||||
</chakra.figure>
|
||||
</chakra.li>
|
||||
))}
|
||||
</chakra.ul>
|
||||
</Reveal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import aboutContent from '@/content/aboutContent';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import AboutIntro from './AboutIntro';
|
||||
|
||||
const intro = aboutContent.intro;
|
||||
|
||||
describe('AboutIntro', () => {
|
||||
it('shows the label, heading, text, portrait and links', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<AboutIntro content={intro} />,
|
||||
);
|
||||
const section = screen.getByRole('region', { name: intro.title });
|
||||
expect(
|
||||
within(section).getByRole('heading', { level: 2 }),
|
||||
).toHaveTextContent(intro.title);
|
||||
expect(within(section).getByText(intro.eyebrow)).toBeInTheDocument();
|
||||
expect(within(section).getByRole('img')).toHaveAccessibleName(
|
||||
intro.image.alt,
|
||||
);
|
||||
expect(section).toHaveTextContent(
|
||||
'Bekijk mijn portfolio of neem contact op voor een fotoshoot!',
|
||||
);
|
||||
expect(
|
||||
within(section).getByRole('link', { name: 'mijn portfolio' }),
|
||||
).toHaveAttribute('href', '/portfolio');
|
||||
expect(
|
||||
within(section).getByRole('link', { name: 'neem contact op' }),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Stack } from '@chakra-ui/react';
|
||||
import RichParagraph from '@/components/about/RichParagraph/RichParagraph';
|
||||
import MediaText from '@/components/MediaText/MediaText';
|
||||
import PageSection from '@/components/PageSection/PageSection';
|
||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||
import type { AboutPageContent } from '@/content/types';
|
||||
|
||||
const TITLE_ID = 'about-intro-title';
|
||||
|
||||
type AboutIntroProps = {
|
||||
content: AboutPageContent['intro'];
|
||||
};
|
||||
|
||||
// "Hoi! Ik ben Andrea": the framed portrait next to the introduction, right
|
||||
// below the page head (design .about in a .section--flush-top)
|
||||
export default function AboutIntro({ content }: AboutIntroProps) {
|
||||
return (
|
||||
<PageSection
|
||||
labelledBy={TITLE_ID}
|
||||
spacing="flushTop"
|
||||
data-testid="about-intro"
|
||||
>
|
||||
{/* Right below the page head: on phones the portrait is the
|
||||
largest paint, so it must not wait for the page to load */}
|
||||
<MediaText image={content.image} aspectRatio="4 / 3" priority>
|
||||
<SectionHeading
|
||||
id={TITLE_ID}
|
||||
eyebrow={content.eyebrow}
|
||||
title={content.title}
|
||||
align="start"
|
||||
spacing="compact"
|
||||
/>
|
||||
<Stack gap={4} color="ink.soft">
|
||||
{content.paragraphs.map((paragraph, index) => (
|
||||
<RichParagraph key={index} paragraph={paragraph} />
|
||||
))}
|
||||
</Stack>
|
||||
</MediaText>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import RichParagraph from './RichParagraph';
|
||||
|
||||
describe('RichParagraph', () => {
|
||||
it('renders text and links in reading order', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<RichParagraph
|
||||
paragraph={[
|
||||
'Bekijk ',
|
||||
{ text: 'mijn portfolio', to: '/portfolio' },
|
||||
' of ',
|
||||
{ text: 'neem contact op', to: '/', hash: 'contact' },
|
||||
'!',
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
expect(container).toHaveTextContent(
|
||||
'Bekijk mijn portfolio of neem contact op!',
|
||||
);
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'mijn portfolio' }),
|
||||
).toHaveAttribute('href', '/portfolio');
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'neem contact op' }),
|
||||
).toHaveAttribute('href', '/#contact');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('renders a paragraph without links as plain text', async () => {
|
||||
await renderWithProviders(<RichParagraph paragraph={['Hoi!']} />);
|
||||
expect(screen.getByText('Hoi!')).toBeInTheDocument();
|
||||
expect(screen.queryByRole('link')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Link, Text } from '@chakra-ui/react';
|
||||
import RouterLink from '@/components/RouterLink';
|
||||
import type { RichText } from '@/content/types';
|
||||
|
||||
type RichParagraphProps = {
|
||||
paragraph: RichText;
|
||||
};
|
||||
|
||||
// One paragraph of running text with links in it (BR-OM-03): text pieces as
|
||||
// they are, link pieces as underlined router links.
|
||||
export default function RichParagraph({ paragraph }: RichParagraphProps) {
|
||||
return (
|
||||
<Text>
|
||||
{paragraph.map((piece, index) =>
|
||||
typeof piece === 'string' ? (
|
||||
piece
|
||||
) : (
|
||||
// Static content: the order never changes, so the index
|
||||
// is a stable key
|
||||
<Link key={index} variant="underline" asChild>
|
||||
<RouterLink to={piece.to} hash={piece.hash}>
|
||||
{piece.text}
|
||||
</RouterLink>
|
||||
</Link>
|
||||
),
|
||||
)}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import aboutContent from '@/content/aboutContent';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import StorySection from './StorySection';
|
||||
|
||||
const personal = aboutContent.personal;
|
||||
|
||||
describe('StorySection', () => {
|
||||
it('is a region named by its h3 label, with the text', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
// An h2 above it, as on the page, so the outline is complete
|
||||
<>
|
||||
<h2>Hoi! Ik ben Andrea</h2>
|
||||
<StorySection
|
||||
content={personal}
|
||||
titleId="personal-title"
|
||||
tone="alt"
|
||||
/>
|
||||
</>,
|
||||
);
|
||||
const section = screen.getByRole('region', { name: personal.title });
|
||||
expect(
|
||||
within(section).getByRole('heading', { level: 3 }),
|
||||
).toHaveAttribute('id', 'personal-title');
|
||||
personal.paragraphs.forEach((paragraph) =>
|
||||
expect(within(section).getByText(paragraph)).toBeInTheDocument(),
|
||||
);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('shows extra content below the text', async () => {
|
||||
await renderWithProviders(
|
||||
<StorySection content={personal} titleId="personal-title">
|
||||
<a href="/#contact">Boek je shoot</a>
|
||||
</StorySection>,
|
||||
);
|
||||
const section = screen.getByRole('region', { name: personal.title });
|
||||
expect(
|
||||
within(section).getByRole('link', { name: 'Boek je shoot' }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, Stack, Text } from '@chakra-ui/react';
|
||||
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
||||
import PageSection from '@/components/PageSection/PageSection';
|
||||
import Reveal from '@/components/Reveal/Reveal';
|
||||
import type { AboutPageContent } from '@/content/types';
|
||||
|
||||
type StorySectionProps = {
|
||||
content: AboutPageContent['background'];
|
||||
// Id of the h3, which names the section
|
||||
titleId: string;
|
||||
tone?: 'paper' | 'alt';
|
||||
spacing?: 'default' | 'flushTop';
|
||||
'data-testid'?: string;
|
||||
// Shown below the text, e.g. the booking button
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
// One part of Andrea's story in the narrow column. Its heading is an h3 in
|
||||
// the small label style: the story continues "Hoi! Ik ben Andrea" (FR-OM-03).
|
||||
export default function StorySection({
|
||||
content,
|
||||
titleId,
|
||||
tone,
|
||||
spacing,
|
||||
'data-testid': testId,
|
||||
children,
|
||||
}: StorySectionProps) {
|
||||
return (
|
||||
<PageSection
|
||||
labelledBy={titleId}
|
||||
width="narrow"
|
||||
tone={tone}
|
||||
spacing={spacing}
|
||||
data-testid={testId}
|
||||
>
|
||||
<Reveal>
|
||||
<Eyebrow as="h3" id={titleId}>
|
||||
{content.title}
|
||||
</Eyebrow>
|
||||
<Stack gap={4} color="ink.soft">
|
||||
{content.paragraphs.map((paragraph) => (
|
||||
<Text key={paragraph}>{paragraph}</Text>
|
||||
))}
|
||||
</Stack>
|
||||
{/* design .mt-lg */}
|
||||
{children && (
|
||||
<Box mt="clamp(2rem, 4vw, 2.5rem)">{children}</Box>
|
||||
)}
|
||||
</Reveal>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user