Adds the first block below the hero: heading, intro and a staggered gallery of four live photos. Brings in the shared section building blocks (HomeSection, SectionHeading, Reveal) and DeferredImage, which holds back below-the-fold photos until the page has loaded so they do not compete with the hero for bandwidth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
import { Box, Grid } from '@chakra-ui/react';
|
|
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
|
import HomeSection from '@/components/HomeSection/HomeSection';
|
|
import Reveal from '@/components/Reveal/Reveal';
|
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
|
import type { HomeContent } from '@/content/types';
|
|
|
|
const TITLE_ID = 'intro-title';
|
|
|
|
// Every other photo sits lower, so the row is not a rigid block (design
|
|
// .intro-gallery figure:nth-child(2|4))
|
|
const OFFSET = 'clamp(1.5rem, 4vw, 3.5rem)';
|
|
|
|
// Delay between photos fading in, as in the design's .reveal:nth-child
|
|
const STAGGER = 0.08;
|
|
|
|
type IntroGalleryProps = {
|
|
content: HomeContent['intro'];
|
|
};
|
|
|
|
// "Lifestyle fotografie": heading with intro and a gallery of four photos
|
|
// (design .intro-gallery). 4 columns on desktop, 2 on tablet, 1 on phones.
|
|
export default function IntroGallery({ content }: IntroGalleryProps) {
|
|
return (
|
|
<HomeSection labelledBy={TITLE_ID} data-testid="intro-gallery">
|
|
<Reveal>
|
|
<SectionHeading
|
|
id={TITLE_ID}
|
|
title={content.title}
|
|
lead={content.lead}
|
|
/>
|
|
</Reveal>
|
|
<Grid
|
|
templateColumns={{
|
|
base: '1fr',
|
|
sm: 'repeat(2, 1fr)',
|
|
lg: 'repeat(4, 1fr)',
|
|
}}
|
|
gap="gridGap"
|
|
alignItems="start"
|
|
>
|
|
{content.photos.map((photo, index) => (
|
|
<Reveal
|
|
key={photo.src}
|
|
as="figure"
|
|
delay={index * STAGGER}
|
|
mt={index % 2 === 1 ? { base: 0, sm: OFFSET } : 0}
|
|
data-testid={`intro-gallery-photo-${index + 1}`}
|
|
>
|
|
<Box
|
|
overflow="hidden"
|
|
// Shown until the deferred photo arrives
|
|
bg="paper.deep"
|
|
css={{
|
|
'&:hover img': { transform: 'scale(1.05)' },
|
|
}}
|
|
>
|
|
<DeferredImage
|
|
image={photo}
|
|
w="100%"
|
|
h="auto"
|
|
aspectRatio="3 / 4"
|
|
objectFit="cover"
|
|
transitionProperty="transform"
|
|
transitionDuration="fade"
|
|
transitionTimingFunction="smooth"
|
|
_motionReduce={{ transition: 'none' }}
|
|
/>
|
|
</Box>
|
|
</Reveal>
|
|
))}
|
|
</Grid>
|
|
</HomeSection>
|
|
);
|
|
}
|