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:
@@ -1,6 +1,7 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { cssRulesFor } from '@/test/cssRules';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import FramedImage from './FramedImage';
|
||||
|
||||
@@ -35,4 +36,32 @@ describe('FramedImage', () => {
|
||||
expect(img).toHaveAttribute('fetchpriority', 'high');
|
||||
expect(img).toHaveAttribute('width', '1200');
|
||||
});
|
||||
|
||||
// The block is a ::before on the photo's wrapper
|
||||
const frameRule = (img: Element) =>
|
||||
cssRulesFor(img.parentElement!).find((rule) =>
|
||||
rule.includes('::before {'),
|
||||
);
|
||||
|
||||
it('puts a sand block behind the photo by default', async () => {
|
||||
await renderWithProviders(
|
||||
<FramedImage image={image} aspectRatio="4 / 3" />,
|
||||
);
|
||||
expect(frameRule(screen.getByRole('img'))).toContain(
|
||||
'background: var(--slp-colors-sand)',
|
||||
);
|
||||
});
|
||||
|
||||
it('colours the block with the given token', async () => {
|
||||
await renderWithProviders(
|
||||
<FramedImage
|
||||
image={image}
|
||||
aspectRatio="4 / 5"
|
||||
frameColor="frame.rust"
|
||||
/>,
|
||||
);
|
||||
expect(frameRule(screen.getByRole('img'))).toContain(
|
||||
'background: var(--slp-colors-frame-rust)',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Box, Image, type ImageProps } from '@chakra-ui/react';
|
||||
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
||||
import type { ContentImage } from '@/content/types';
|
||||
import type { ContentImage, FrameColor } from '@/content/types';
|
||||
|
||||
type FramedImageProps = {
|
||||
image: ContentImage;
|
||||
@@ -9,16 +9,19 @@ type FramedImageProps = {
|
||||
// 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;
|
||||
// Colour token of the block behind the photo
|
||||
frameColor?: FrameColor;
|
||||
};
|
||||
|
||||
// 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.
|
||||
// A photo with a soft coloured block (sand by default) 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,
|
||||
priority = false,
|
||||
frameColor = 'sand',
|
||||
}: FramedImageProps) {
|
||||
const style: ImageProps = {
|
||||
display: 'block',
|
||||
@@ -43,7 +46,7 @@ export default function FramedImage({
|
||||
bottom: '-1.5rem',
|
||||
width: '55%',
|
||||
height: '55%',
|
||||
bg: 'sand',
|
||||
bg: frameColor,
|
||||
zIndex: -1,
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user