Builds the hero slider with arrows, swipe, and social icons

Replaces the placeholder hero with a crossfading slider (slow zoom, 6s per
slide) driven by the progress bar animation; it pauses on mouse hover,
keyboard focus, and hidden tabs, and skips autoplay with reduced motion.
Adds prev/next arrows and touch swipe, and Facebook/Instagram icons from a
fixed set of platforms using bundled Iconify data (@iconify/react/offline
and @iconify-icons/ant-design, so no runtime API calls).

Content (tagline, title, CTA, slides, socials) is plain data in
heroContent.ts and passed in as a prop, so it can come from the CMS API
later. The tagline sits inside the h1 together with the name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-13 23:12:42 +02:00
co-authored by Claude Opus 5.5
parent 8a8e2bd922
commit 614707bfff
15 changed files with 393 additions and 42 deletions
+105 -41
View File
@@ -1,41 +1,80 @@
import { Box, Button, Container, Heading, Text } from '@chakra-ui/react';
import { Link } from '@tanstack/react-router';
import { Box, chakra, Container, Heading, Image } from '@chakra-ui/react';
import LinkButton from '../LinkButton';
import HeroArrows from './HeroArrows';
import HeroSocials from './HeroSocials';
import useHeroSlider from './useHeroSlider';
import type { HeroContent } from './types';
// Images
import heroImage from '../../assets/hero-1.jpg';
const SLIDE_DURATION = '6s';
type HeroProps = {
content: HeroContent;
};
export default function Hero({ content }: HeroProps) {
const { title, tagline, cta, slides, socials } = content;
const { active, reducedMotion, autoplay, paused, next, prev, handlers } =
useHeroSlider(slides.length);
// TODO: slider met meerdere slides, thumbnails, progress-balk en socials
// zoals in design/andreaslop-static/index.html
export default function Hero() {
return (
<Box
as="section"
aria-label="Uitgelicht werk"
aria-roledescription="carousel"
position="relative"
// Eigen stacking context: de z-indexen hieronder gelden alleen
// binnen de hero en botsen niet met de navigatiebalk.
isolation="isolate"
h="100svh"
minH="560px"
overflow="hidden"
bg="gray.900"
backgroundImage={`url(${heroImage})`}
backgroundPosition="center"
backgroundSize="cover"
backgroundRepeat="no-repeat"
bg="ink"
touchAction="pan-y"
{...handlers}
>
{/* Slides: crossfade met een langzame inzoom */}
<Box position="absolute" inset={0}>
{slides.map((slide, i) => (
<Box
key={slide.id}
role="group"
aria-roledescription="slide"
aria-label={`${i + 1} van ${slides.length}`}
aria-hidden={i !== active}
position="absolute"
inset={0}
opacity={i === active ? 1 : 0}
transitionProperty="opacity"
transitionDuration="fade"
transitionTimingFunction="smooth"
>
<Image
src={slide.src}
alt={slide.alt}
fetchPriority={i === 0 ? 'high' : undefined}
loading={i === 0 ? undefined : 'lazy'}
w="100%"
h="100%"
objectFit="cover"
transform={
reducedMotion || i === active
? 'scale(1)'
: 'scale(1.06)'
}
transition="transform 9s linear"
/>
</Box>
))}
</Box>
{/* Scrim */}
<Box
aria-hidden
position="absolute"
inset={0}
bgGradient="to-b"
gradientFrom="rgba(35, 33, 32, 0.45)"
gradientVia="rgba(35, 33, 32, 0.18)"
gradientTo="rgba(35, 33, 32, 0.45)"
/>
<Box aria-hidden position="absolute" inset={0} bgGradient="scrim" />
<Container
position="relative"
zIndex={1}
h="100%"
pt="header"
display="flex"
flexDirection="column"
alignItems="center"
@@ -43,28 +82,53 @@ export default function Hero() {
textAlign="center"
color="white"
>
<Text
mb={4}
fontSize="sm"
letterSpacing="0.2em"
textTransform="uppercase"
opacity={0.8}
>
Fotografie
</Text>
<Heading
as="h1"
mb={9}
fontSize={{ base: '5xl', md: '7xl' }}
lineHeight={1}
color="white"
>
Andrea Slop
{/* Tagline en naam samen in één h1: zo staan de zoekwoorden
(wat en waar) in de belangrijkste kop van de pagina */}
<Heading as="h1" mb={9} color="white">
<chakra.span
display="block"
mb={4}
fontFamily="body"
textStyle="eyebrow"
// Zelfde regelhoogte als lopende tekst, niet die van de kop
lineHeight="1.5"
color="white/80"
>
{tagline}
</chakra.span>{' '}
<chakra.span display="block" textStyle="display">
{title}
</chakra.span>
</Heading>
<Button asChild variant="outline" color="white" borderColor="white">
<Link to="/over-mij">Lees meer</Link>
</Button>
<LinkButton to={cta.to} variant="light">
{cta.label}
</LinkButton>
</Container>
{slides.length > 1 && <HeroArrows onPrev={prev} onNext={next} />}
<HeroSocials socials={socials} />
{/* Voortgangsbalk: als de animatie klaar is, schuift de slider door.
Door de key start hij opnieuw bij elke slidewissel. */}
{autoplay && (
<Box
key={active}
aria-hidden
position="absolute"
left={0}
bottom={0}
zIndex={2}
h="2px"
bg="white"
animationName="expand-width"
animationDuration={SLIDE_DURATION}
animationTimingFunction="linear"
animationFillMode="forwards"
animationPlayState={paused ? 'paused' : 'running'}
css={{ '--width': '100%' }}
onAnimationEnd={next}
/>
)}
</Box>
);
}