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 ( {priority ? ( {image.alt} ) : ( )} ); }