Adds the Over mij section to the homepage
Adds the introduction block with a framed photo of Andrea and a link to the about page. Brings in FramedImage and an underline link variant for the later blocks, and narrows the load margin of deferred photos so nothing below the hero starts loading before the hero has painted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import homeContent from '@/content/homeContent';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import AboutBlock from './AboutBlock';
|
||||
|
||||
const about = homeContent.about;
|
||||
|
||||
describe('AboutBlock', () => {
|
||||
it('shows the label, heading, text, photo and link', async () => {
|
||||
const { container } = await renderWithProviders(
|
||||
<AboutBlock content={about} />,
|
||||
);
|
||||
const section = screen.getByRole('region', { name: about.title });
|
||||
expect(
|
||||
within(section).getByRole('heading', { level: 2 }),
|
||||
).toHaveTextContent(about.title);
|
||||
expect(within(section).getByText(about.eyebrow)).toBeInTheDocument();
|
||||
about.paragraphs.forEach((paragraph) =>
|
||||
expect(within(section).getByText(paragraph)).toBeInTheDocument(),
|
||||
);
|
||||
expect(within(section).getByRole('img')).toHaveAccessibleName(
|
||||
about.image.alt,
|
||||
);
|
||||
expect(
|
||||
within(section).getByRole('link', { name: about.link.label }),
|
||||
).toHaveAttribute('href', '/over-mij');
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import { Grid, Link, Stack, Text } from '@chakra-ui/react';
|
||||
import FramedImage from '@/components/FramedImage/FramedImage';
|
||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
||||
import Reveal from '@/components/Reveal/Reveal';
|
||||
import RouterLink from '@/components/RouterLink';
|
||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||
import type { HomeContent } from '@/content/types';
|
||||
|
||||
const TITLE_ID = 'about-title';
|
||||
|
||||
type AboutBlockProps = {
|
||||
content: HomeContent['about'];
|
||||
};
|
||||
|
||||
// "Over mij": a framed photo of Andrea next to a short introduction with a
|
||||
// link to the about page (design .about). Stacked on phones and tablets.
|
||||
export default function AboutBlock({ content }: AboutBlockProps) {
|
||||
return (
|
||||
<HomeSection labelledBy={TITLE_ID} tone="alt" data-testid="about-block">
|
||||
<Grid
|
||||
templateColumns={{ base: '1fr', lg: '1fr 1fr' }}
|
||||
gap="clamp(2rem, 6vw, 5.5rem)"
|
||||
alignItems="center"
|
||||
>
|
||||
<Reveal>
|
||||
<FramedImage image={content.image} aspectRatio="4 / 3" />
|
||||
</Reveal>
|
||||
<Reveal>
|
||||
<SectionHeading
|
||||
id={TITLE_ID}
|
||||
eyebrow={content.eyebrow}
|
||||
title={content.title}
|
||||
align="start"
|
||||
spacing="compact"
|
||||
/>
|
||||
<Stack gap={4} color="ink.soft">
|
||||
{content.paragraphs.map((paragraph) => (
|
||||
<Text key={paragraph}>{paragraph}</Text>
|
||||
))}
|
||||
<Text>
|
||||
<Link variant="underline" asChild>
|
||||
<RouterLink
|
||||
to={content.link.to}
|
||||
data-testid="about-block-link"
|
||||
>
|
||||
{content.link.label}
|
||||
</RouterLink>
|
||||
</Link>
|
||||
</Text>
|
||||
</Stack>
|
||||
</Reveal>
|
||||
</Grid>
|
||||
</HomeSection>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user