Announces pausing and resuming the hero slide show
The pause button only changed its name, which screen readers often do not read for the focused button. The live region now also says when the slide show is paused or plays again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,12 +11,25 @@ import LinkButton from '../LinkButton';
|
||||
import HeroArrows from './HeroArrows';
|
||||
import HeroPauseButton from './HeroPauseButton';
|
||||
import HeroSocials from './HeroSocials';
|
||||
import useHeroSlider from './useHeroSlider';
|
||||
import useHeroSlider, { type HeroAnnouncement } from './useHeroSlider';
|
||||
import type { HeroContent, SocialLink } from '@/content/types';
|
||||
import { slidesToLoad } from '@/lib/slidesToLoad';
|
||||
|
||||
const SLIDE_DURATION = '6s';
|
||||
|
||||
function announcementText(announcement: HeroAnnouncement, slide: string) {
|
||||
switch (announcement) {
|
||||
case 'slide':
|
||||
return slide;
|
||||
case 'paused':
|
||||
return 'Diavoorstelling gepauzeerd';
|
||||
case 'playing':
|
||||
return 'Diavoorstelling speelt weer af';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
type HeroProps = {
|
||||
content: HeroContent;
|
||||
socials: SocialLink[];
|
||||
@@ -26,7 +39,7 @@ export default function Hero({ content, socials }: HeroProps) {
|
||||
const { title, tagline, cta, slides } = content;
|
||||
const {
|
||||
active,
|
||||
announce,
|
||||
announcement,
|
||||
reducedMotion,
|
||||
autoplay,
|
||||
paused,
|
||||
@@ -152,7 +165,7 @@ export default function Hero({ content, socials }: HeroProps) {
|
||||
<HeroPauseButton stopped={stopped} onToggle={toggleStopped} />
|
||||
)}
|
||||
|
||||
{/* Meldt een wissel door de bezoeker; staat er altijd, want een
|
||||
{/* Meldt een wissel of pauze 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
|
||||
@@ -160,9 +173,10 @@ export default function Hero({ content, socials }: HeroProps) {
|
||||
aria-atomic="true"
|
||||
data-testid="hero-announcement"
|
||||
>
|
||||
{announce
|
||||
? `Foto ${active + 1} van ${slides.length}: ${slides[active].alt}`
|
||||
: ''}
|
||||
{announcementText(
|
||||
announcement,
|
||||
`Foto ${active + 1} van ${slides.length}: ${slides[active].alt}`,
|
||||
)}
|
||||
</VisuallyHidden>
|
||||
|
||||
{/* Voortgangsbalk: als de animatie klaar is, schuift de slider door.
|
||||
|
||||
Reference in New Issue
Block a user