import { chakra, useBreakpointValue } from '@chakra-ui/react'; import DeferredImage, { DEFERRED_LOAD_MARGIN, } from '@/components/DeferredImage/DeferredImage'; import PageSection from '@/components/PageSection/PageSection'; import Reveal from '@/components/Reveal/Reveal'; import SectionHeading from '@/components/SectionHeading/SectionHeading'; import type { HomeContent } from '@/content/types'; import useInView from '@/hooks/useInView'; 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)'; type IntroGalleryProps = { content: HomeContent['intro']; }; // "Lifestyle fotografie": heading with intro and a gallery of four photos // (design .intro-gallery). On phones the photos form a swipeable row, one // at a time with the next one peeking in; from `sm` a grid of 2, from `lg` // of 4 columns. export default function IntroGallery({ content }: IntroGalleryProps) { // Photos outside the row are clipped by the scroller and never intersect // on their own, so the whole gallery decides when they load. const { ref, inView } = useInView({ rootMargin: DEFERRED_LOAD_MARGIN, }); // Only the swipeable row scrolls, so only then is it a focus stop for // keyboard scrolling const scrollable = useBreakpointValue({ base: true, sm: false }) ?? false; return ( {content.photos.map((photo, index) => ( ))} ); }