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
+2
View File
@@ -12,6 +12,8 @@
}, },
"devDependencies": { "devDependencies": {
"@chakra-ui/cli": "^3.37.0", "@chakra-ui/cli": "^3.37.0",
"@iconify-icons/ant-design": "2.0.1",
"@iconify/react": "^6.0.2",
"@tanstack/router-plugin": "^1.168.40", "@tanstack/router-plugin": "^1.168.40",
"@types/react": "^19.3.0", "@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0", "@types/react-dom": "^19.3.0",
+28
View File
@@ -42,6 +42,12 @@ importers:
'@chakra-ui/cli': '@chakra-ui/cli':
specifier: ^3.37.0 specifier: ^3.37.0
version: 3.37.0(@chakra-ui/react@3.37.0(@emotion/react@11.14.0(@types/react@19.3.0)(react@19.3.0))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)) version: 3.37.0(@chakra-ui/react@3.37.0(@emotion/react@11.14.0(@types/react@19.3.0)(react@19.3.0))(react-dom@19.3.0(react@19.3.0))(react@19.3.0))
'@iconify-icons/ant-design':
specifier: 2.0.1
version: 2.0.1
'@iconify/react':
specifier: ^6.0.2
version: 6.0.2(react@19.3.0)
'@tanstack/router-plugin': '@tanstack/router-plugin':
specifier: ^1.168.40 specifier: ^1.168.40
version: 1.168.40(@tanstack/react-router@1.170.39(react-dom@19.3.0(react@19.3.0))(react@19.3.0))(esbuild@0.28.2)(rolldown@1.2.11)(vite@8.3.1(esbuild@0.28.2)(jiti@2.7.0)) version: 1.168.40(@tanstack/react-router@1.170.39(react-dom@19.3.0(react@19.3.0))(react@19.3.0))(esbuild@0.28.2)(rolldown@1.2.11)(vite@8.3.1(esbuild@0.28.2)(jiti@2.7.0))
@@ -420,6 +426,17 @@ packages:
'@fontsource/marcellus@5.3.0': '@fontsource/marcellus@5.3.0':
resolution: {integrity: sha512-cMnanjpiPIC7Rq4GXIA/Zal5WLSoDV5Mc681tMkWsWfKHXnRnLGlhuGeBnLF6HrqtFkiSdiuy4NCSPfOrz266w==} resolution: {integrity: sha512-cMnanjpiPIC7Rq4GXIA/Zal5WLSoDV5Mc681tMkWsWfKHXnRnLGlhuGeBnLF6HrqtFkiSdiuy4NCSPfOrz266w==}
'@iconify-icons/ant-design@2.0.1':
resolution: {integrity: sha512-trO0tSenYMXFX1FBNZ53uqWEsueCazWviIGMyoPAPZO7kUVfdsQFujljOmJtZmfGqBvG+cl7Sn8OVxhxxUmAiw==}
'@iconify/react@6.0.2':
resolution: {integrity: sha512-SMmC2sactfpJD427WJEDN6PMyznTFMhByK9yLW0gOTtnjzzbsi/Ke/XqsumsavFPwNiXs8jSiYeZTmLCLwO+Fg==}
peerDependencies:
react: '>=16'
'@iconify/types@2.0.0':
resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==}
'@internationalized/date@3.12.3': '@internationalized/date@3.12.3':
resolution: {integrity: sha512-fuLX+3ZKLsxI73y8b01EG/WjHb6gE6weCqlfawPO27kBWGMh9G1yH6Csv1uU7/cac9H2GHmOMt6CjmuQ1aia4Q==} resolution: {integrity: sha512-fuLX+3ZKLsxI73y8b01EG/WjHb6gE6weCqlfawPO27kBWGMh9G1yH6Csv1uU7/cac9H2GHmOMt6CjmuQ1aia4Q==}
@@ -2037,6 +2054,17 @@ snapshots:
'@fontsource/marcellus@5.3.0': {} '@fontsource/marcellus@5.3.0': {}
'@iconify-icons/ant-design@2.0.1':
dependencies:
'@iconify/types': 2.0.0
'@iconify/react@6.0.2(react@19.3.0)':
dependencies:
'@iconify/types': 2.0.0
react: 19.3.0
'@iconify/types@2.0.0': {}
'@internationalized/date@3.12.3': '@internationalized/date@3.12.3':
dependencies: dependencies:
'@swc/helpers': 0.5.23 '@swc/helpers': 0.5.23
Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

+105 -41
View File
@@ -1,41 +1,80 @@
import { Box, Button, Container, Heading, Text } from '@chakra-ui/react'; import { Box, chakra, Container, Heading, Image } from '@chakra-ui/react';
import { Link } from '@tanstack/react-router'; import LinkButton from '../LinkButton';
import HeroArrows from './HeroArrows';
import HeroSocials from './HeroSocials';
import useHeroSlider from './useHeroSlider';
import type { HeroContent } from './types';
// Images const SLIDE_DURATION = '6s';
import heroImage from '../../assets/hero-1.jpg';
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 ( return (
<Box <Box
as="section" as="section"
aria-label="Uitgelicht werk" aria-label="Uitgelicht werk"
aria-roledescription="carousel"
position="relative" position="relative"
// Eigen stacking context: de z-indexen hieronder gelden alleen
// binnen de hero en botsen niet met de navigatiebalk.
isolation="isolate"
h="100svh" h="100svh"
minH="560px" minH="560px"
overflow="hidden" overflow="hidden"
bg="gray.900" bg="ink"
backgroundImage={`url(${heroImage})`} touchAction="pan-y"
backgroundPosition="center" {...handlers}
backgroundSize="cover"
backgroundRepeat="no-repeat"
> >
{/* 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 */} {/* Scrim */}
<Box <Box aria-hidden position="absolute" inset={0} bgGradient="scrim" />
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)"
/>
<Container <Container
position="relative" position="relative"
zIndex={1} zIndex={1}
h="100%" h="100%"
pt="header"
display="flex" display="flex"
flexDirection="column" flexDirection="column"
alignItems="center" alignItems="center"
@@ -43,28 +82,53 @@ export default function Hero() {
textAlign="center" textAlign="center"
color="white" color="white"
> >
<Text {/* Tagline en naam samen in één h1: zo staan de zoekwoorden
mb={4} (wat en waar) in de belangrijkste kop van de pagina */}
fontSize="sm" <Heading as="h1" mb={9} color="white">
letterSpacing="0.2em" <chakra.span
textTransform="uppercase" display="block"
opacity={0.8} mb={4}
> fontFamily="body"
Fotografie textStyle="eyebrow"
</Text> // Zelfde regelhoogte als lopende tekst, niet die van de kop
<Heading lineHeight="1.5"
as="h1" color="white/80"
mb={9} >
fontSize={{ base: '5xl', md: '7xl' }} {tagline}
lineHeight={1} </chakra.span>{' '}
color="white" <chakra.span display="block" textStyle="display">
> {title}
Andrea Slop </chakra.span>
</Heading> </Heading>
<Button asChild variant="outline" color="white" borderColor="white"> <LinkButton to={cta.to} variant="light">
<Link to="/over-mij">Lees meer</Link> {cta.label}
</Button> </LinkButton>
</Container> </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> </Box>
); );
} }
+55
View File
@@ -0,0 +1,55 @@
import { chakra } from '@chakra-ui/react';
import { Icon } from '@iconify/react/offline';
import leftOutlined from '@iconify-icons/ant-design/left-outlined';
import rightOutlined from '@iconify-icons/ant-design/right-outlined';
type HeroArrowsProps = {
onPrev: () => void;
onNext: () => void;
};
// Pijlen links en rechts, verticaal gecentreerd
export default function HeroArrows({ onPrev, onNext }: HeroArrowsProps) {
return (
<>
<ArrowButton side="left" aria-label="Vorige foto" onClick={onPrev}>
<Icon icon={leftOutlined} aria-hidden />
</ArrowButton>
<ArrowButton side="right" aria-label="Volgende foto" onClick={onNext}>
<Icon icon={rightOutlined} aria-hidden />
</ArrowButton>
</>
);
}
type ArrowButtonProps = React.ComponentProps<typeof chakra.button> & {
side: 'left' | 'right';
};
const ARROW_OFFSET = 'clamp(0.5rem, 3vw, 2.5rem)';
function ArrowButton({ side, ...props }: ArrowButtonProps) {
return (
<chakra.button
type="button"
position="absolute"
top="50%"
left={side === 'left' ? ARROW_OFFSET : undefined}
right={side === 'right' ? ARROW_OFFSET : undefined}
zIndex={2}
transform="translateY(-50%)"
display="flex"
p={2}
color="white"
fontSize={{ base: '1.5rem', md: '2rem' }}
cursor="pointer"
opacity={0.6}
transitionProperty="opacity"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_hover={{ opacity: 1 }}
_focusVisible={{ opacity: 1, outline: '1px solid white', outlineOffset: '2px' }}
{...props}
/>
);
}
+48
View File
@@ -0,0 +1,48 @@
import { chakra, HStack } from '@chakra-ui/react';
import { Icon } from '@iconify/react/offline';
import socialPlatforms from './socialPlatforms';
import type { HeroSocial } from './types';
type HeroSocialsProps = {
socials: HeroSocial[];
};
// Socials linksonder, naast elkaar
export default function HeroSocials({ socials }: HeroSocialsProps) {
return (
<HStack
position="absolute"
left="gutter"
bottom={{ base: 6, md: 10 }}
zIndex={2}
gap={5}
color="white"
fontSize="1.5rem"
>
{socials
.filter((social) => social.href)
.map((social) => {
const { name, icon } = socialPlatforms[social.platform];
return (
<chakra.a
key={social.platform}
href={social.href}
target="_blank"
rel="noopener noreferrer"
aria-label={name}
display="flex"
opacity={0.6}
transitionProperty="opacity"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_hover={{ opacity: 1 }}
_focusVisible={{ opacity: 1 }}
>
<Icon icon={icon} aria-hidden />
</chakra.a>
);
})}
</HStack>
);
}
+36
View File
@@ -0,0 +1,36 @@
import type { HeroContent } from './types';
// Images
import hero1 from '../../assets/hero-1.jpg';
import hero2 from '../../assets/hero-2.jpg';
import newborn from '../../assets/newborn.jpg';
import hero4 from '../../assets/hero-4.jpg';
import hero5 from '../../assets/hero-5.jpg';
import hero6 from '../../assets/hero-6.jpg';
// Statische content tot de CMS-API er is. Daarna komt dit object uit de API.
const heroContent: HeroContent = {
title: 'Andrea Slop',
tagline: 'Lifestyle fotograaf · Huizen',
cta: { label: 'Lees meer', to: '/over-mij' },
slides: [
{ id: 'hero-1', src: hero1, alt: 'Lifestyle fotografie van Andrea Slop' },
{ id: 'hero-2', src: hero2, alt: 'Zwangerschapsshoot in de buitenlucht' },
{ id: 'newborn', src: newborn, alt: 'Newbornshoot van een pasgeboren baby' },
{ id: 'hero-4', src: hero4, alt: 'Spontaan portret buiten' },
{ id: 'hero-5', src: hero5, alt: 'Natuurlijke lifestylefoto' },
{ id: 'hero-6', src: hero6, alt: 'Portret in de natuur' },
],
socials: [
{
platform: 'facebook',
href: 'https://www.facebook.com/andreaslopfotografie/',
},
{
platform: 'instagram',
href: 'https://www.instagram.com/andreaslopfotografie/',
},
],
};
export default heroContent;
@@ -0,0 +1,13 @@
import facebookFilled from '@iconify-icons/ant-design/facebook-filled';
import instagramFilled from '@iconify-icons/ant-design/instagram-filled';
// Vaste set ondersteunde platforms. De icon-data zit in de build, dus er gaat
// geen request naar de Iconify API. Het CMS levert alleen de links aan.
const socialPlatforms = {
facebook: { name: 'Facebook', icon: facebookFilled },
instagram: { name: 'Instagram', icon: instagramFilled },
};
export type SocialPlatform = keyof typeof socialPlatforms;
export default socialPlatforms;
+30
View File
@@ -0,0 +1,30 @@
import type { SocialPlatform } from './socialPlatforms';
// Vorm van de hero-content. Deze types zijn bewust platte data (strings en
// arrays) zodat ze later 1-op-1 uit de CMS-API kunnen komen.
export interface HeroSlide {
id: string;
src: string;
alt: string;
}
export interface HeroCta {
label: string;
to: string;
}
export interface HeroSocial {
platform: SocialPlatform;
href: string; // leeg = niet tonen
}
export interface HeroContent {
title: string;
// Klein label in hoofdletters boven de titel: wat en waar, voor bezoekers
// en zoekmachines (bv. "Lifestyle fotograaf · Huizen")
tagline: string;
cta: HeroCta;
slides: HeroSlide[];
socials: HeroSocial[];
}
+74
View File
@@ -0,0 +1,74 @@
import { useEffect, useRef, useState } from 'react';
import { useMediaQuery } from '@chakra-ui/react';
// Minimale horizontale afstand in px voordat een veeg als swipe telt
const SWIPE_THRESHOLD = 50;
// Houdt de actieve slide bij en of autoplay mag lopen. Het doorschuiven zelf
// gebeurt via de animatie van de voortgangsbalk (zie Hero.tsx), zodat pauzeren
// simpelweg die animatie stilzet.
export default function useHeroSlider(count: number) {
const [index, setIndex] = useState(0);
const [hovered, setHovered] = useState(false);
const [focused, setFocused] = useState(false);
const [hidden, setHidden] = useState(() => document.hidden);
const [reducedMotion] = useMediaQuery(['(prefers-reduced-motion: reduce)'], {
ssr: false,
});
const touchStart = useRef<{ x: number; y: number } | null>(null);
useEffect(() => {
const onVisibilityChange = () => setHidden(document.hidden);
document.addEventListener('visibilitychange', onVisibilityChange);
return () => document.removeEventListener('visibilitychange', onVisibilityChange);
}, []);
// Als de API minder slides teruggeeft dan de huidige index, begin vooraan.
const active = index < count ? index : 0;
const next = () => setIndex((active + 1) % count);
const prev = () => setIndex((active - 1 + count) % count);
return {
active,
reducedMotion,
autoplay: count > 1 && !reducedMotion,
paused: hovered || focused || hidden,
next,
prev,
handlers: {
// Alleen een echte muis pauzeert; een tik op mobiel niet.
onPointerEnter: (event: React.PointerEvent<HTMLElement>) => {
if (event.pointerType === 'mouse') setHovered(true);
},
onPointerLeave: () => setHovered(false),
// Alleen toetsenbordfocus pauzeert, niet een klik op een pijl.
onFocus: (event: React.FocusEvent<HTMLElement>) => {
if (event.target.matches(':focus-visible')) setFocused(true);
},
onBlur: (event: React.FocusEvent<HTMLElement>) => {
if (!event.currentTarget.contains(event.relatedTarget)) {
setFocused(false);
}
},
onTouchStart: (event: React.TouchEvent<HTMLElement>) => {
const touch = event.touches[0];
touchStart.current = { x: touch.clientX, y: touch.clientY };
},
onTouchEnd: (event: React.TouchEvent<HTMLElement>) => {
const start = touchStart.current;
touchStart.current = null;
if (!start || count < 2) return;
const touch = event.changedTouches[0];
const dx = touch.clientX - start.x;
const dy = touch.clientY - start.y;
// Horizontaal genoeg, en niet bedoeld als verticaal scrollen
if (Math.abs(dx) < SWIPE_THRESHOLD || Math.abs(dx) < Math.abs(dy)) return;
if (dx < 0) next();
else prev();
},
},
};
}
+2 -1
View File
@@ -1,10 +1,11 @@
import { createFileRoute } from '@tanstack/react-router'; import { createFileRoute } from '@tanstack/react-router';
import Hero from '../components/Hero/Hero'; import Hero from '../components/Hero/Hero';
import heroContent from '../components/Hero/heroContent';
export const Route = createFileRoute('/')({ export const Route = createFileRoute('/')({
component: Index, component: Index,
}); });
function Index() { function Index() {
return <Hero />; return <Hero content={heroContent} />;
} }