Announces manual hero slide changes and adds a pause button
Continuous Integration / check (pull_request) Successful in 59s
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) Successful in 3m59s
Continuous Integration / deploy-production (pull_request) Skipped

Screen readers now hear the new photo after an arrow or swipe, while automatic
changes stay silent. A pause button bottom right lets visitors stop the slide
show, which hover and keyboard focus alone did not allow on touch screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 19:31:31 +02:00
co-authored by Claude Opus 5.5
parent 8f0f32261c
commit 46fb2f6b5c
11 changed files with 424 additions and 7 deletions
+41 -4
View File
@@ -1,7 +1,15 @@
import { useState } from 'react';
import { Box, chakra, Container, Heading, Image } from '@chakra-ui/react';
import {
Box,
chakra,
Container,
Heading,
Image,
VisuallyHidden,
} from '@chakra-ui/react';
import LinkButton from '../LinkButton';
import HeroArrows from './HeroArrows';
import HeroPauseButton from './HeroPauseButton';
import HeroSocials from './HeroSocials';
import useHeroSlider from './useHeroSlider';
import type { HeroContent, SocialLink } from '@/content/types';
@@ -16,8 +24,19 @@ type HeroProps = {
export default function Hero({ content, socials }: HeroProps) {
const { title, tagline, cta, slides } = content;
const { active, reducedMotion, autoplay, paused, next, prev, handlers } =
useHeroSlider(slides.length);
const {
active,
announce,
reducedMotion,
autoplay,
paused,
stopped,
toggleStopped,
next,
prev,
advance,
handlers,
} = useHeroSlider(slides.length);
// De slides liggen op elkaar in beeld, dus loading="lazy" stelt niets uit.
// Eerst alleen de actieve foto; zodra die binnen en getekend is (twee
// frames later, dus na de eerste paint) ook de volgende en de vorige.
@@ -129,6 +148,22 @@ export default function Hero({ content, socials }: HeroProps) {
{slides.length > 1 && <HeroArrows onPrev={prev} onNext={next} />}
<HeroSocials socials={socials} />
{autoplay && (
<HeroPauseButton stopped={stopped} onToggle={toggleStopped} />
)}
{/* Meldt een wissel door de bezoeker; staat er altijd, want een
live-gebied moet al bestaan voordat de tekst verandert. Leeg na
een automatische wissel, zodat er geen oude melding blijft. */}
<VisuallyHidden
aria-live="polite"
aria-atomic="true"
data-testid="hero-announcement"
>
{announce
? `Foto ${active + 1} van ${slides.length}: ${slides[active].alt}`
: ''}
</VisuallyHidden>
{/* Voortgangsbalk: als de animatie klaar is, schuift de slider door.
Door de key start hij opnieuw bij elke slidewissel. */}
@@ -136,6 +171,8 @@ export default function Hero({ content, socials }: HeroProps) {
<Box
key={active}
aria-hidden
data-testid="hero-progress"
data-state={paused ? 'paused' : 'running'}
position="absolute"
left={0}
bottom={0}
@@ -148,7 +185,7 @@ export default function Hero({ content, socials }: HeroProps) {
animationFillMode="forwards"
animationPlayState={paused ? 'paused' : 'running'}
css={{ '--width': '100%' }}
onAnimationEnd={next}
onAnimationEnd={advance}
/>
)}
</Box>