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>
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { Box, Image, type ImageProps } from '@chakra-ui/react';
|
|
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
|
import type { ContentImage, FrameColor } from '@/content/types';
|
|
|
|
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;
|
|
// Colour token of the block behind the photo
|
|
frameColor?: FrameColor;
|
|
};
|
|
|
|
// 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',
|
|
w: '100%',
|
|
h: 'auto',
|
|
aspectRatio,
|
|
objectFit: 'cover',
|
|
// Shown until the photo arrives
|
|
bg: 'paper.deep',
|
|
};
|
|
|
|
return (
|
|
<Box
|
|
position="relative"
|
|
// Own stacking context, so the block can sit behind the photo
|
|
isolation="isolate"
|
|
_before={{
|
|
content: '""',
|
|
display: { base: 'none', sm: 'block' },
|
|
position: 'absolute',
|
|
left: '-1.5rem',
|
|
bottom: '-1.5rem',
|
|
width: '55%',
|
|
height: '55%',
|
|
bg: frameColor,
|
|
zIndex: -1,
|
|
}}
|
|
>
|
|
{priority ? (
|
|
<Image
|
|
src={image.src}
|
|
alt={image.alt}
|
|
htmlWidth={image.width}
|
|
htmlHeight={image.height}
|
|
fetchPriority="high"
|
|
decoding="async"
|
|
{...style}
|
|
/>
|
|
) : (
|
|
<DeferredImage image={image} {...style} />
|
|
)}
|
|
</Box>
|
|
);
|
|
}
|