Extends the shared blocks for the shoot types page
FramedImage and MediaText take a colour for the block behind the photo (sand by default) and MediaText can put the photo in the right-hand column from lg, without changing the reading order. RichParagraph moves to the shared components, a new CallToAction closes a page with a heading, lead and action, and the homepage pricing section gets the anchor #prijzen. A test helper reads the generated CSS rules, since jsdom applies neither media queries nor pseudo-elements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user