Adds the fallbacks for visitors without JavaScript
The mobile menu works through CSS, and controls that need JavaScript are hidden without it. The contact photo gets its own preload, and the tests cover the new Reveal behaviour, the first row and the noscript markup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -186,6 +186,7 @@ export default function Hero({ content, socials }: HeroProps) {
|
||||
key={active}
|
||||
aria-hidden
|
||||
data-testid="hero-progress"
|
||||
data-requires-js
|
||||
data-state={paused ? 'paused' : 'running'}
|
||||
position="absolute"
|
||||
left={0}
|
||||
|
||||
@@ -16,6 +16,7 @@ export default function HeroArrows({ onPrev, onNext }: HeroArrowsProps) {
|
||||
side="left"
|
||||
aria-label="Vorige foto"
|
||||
data-testid="hero-prev-button"
|
||||
data-requires-js
|
||||
onClick={onPrev}
|
||||
>
|
||||
<Icon icon={leftOutlined} aria-hidden />
|
||||
@@ -24,6 +25,7 @@ export default function HeroArrows({ onPrev, onNext }: HeroArrowsProps) {
|
||||
side="right"
|
||||
aria-label="Volgende foto"
|
||||
data-testid="hero-next-button"
|
||||
data-requires-js
|
||||
onClick={onNext}
|
||||
>
|
||||
<Icon icon={rightOutlined} aria-hidden />
|
||||
|
||||
@@ -25,6 +25,7 @@ export default function HeroPauseButton({
|
||||
: 'Diavoorstelling pauzeren'
|
||||
}
|
||||
data-testid="hero-pause-button"
|
||||
data-requires-js
|
||||
onClick={onToggle}
|
||||
css={iconControl()}
|
||||
position="absolute"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import heroContent from '@/content/heroContent';
|
||||
import siteContent from '@/content/siteContent';
|
||||
import { serverHtml } from '@/test/hydrate';
|
||||
import Hero from './Hero';
|
||||
|
||||
// Controls that do nothing without JavaScript carry the marker the head CSS
|
||||
// hides (BR-NJS-01, BR-NJS-03)
|
||||
describe('Hero in the prerendered HTML', () => {
|
||||
it('marks the arrows, the pause button and the progress bar', async () => {
|
||||
const html = await serverHtml(
|
||||
<Hero content={heroContent} socials={siteContent.socials} />,
|
||||
);
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
const marked = (testId: string) =>
|
||||
doc
|
||||
.querySelector(`[data-testid="${testId}"]`)
|
||||
?.hasAttribute('data-requires-js');
|
||||
|
||||
expect(marked('hero-prev-button')).toBe(true);
|
||||
expect(marked('hero-next-button')).toBe(true);
|
||||
expect(marked('hero-pause-button')).toBe(true);
|
||||
expect(marked('hero-progress')).toBe(true);
|
||||
expect(doc.querySelectorAll('[data-requires-js]')).toHaveLength(4);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user