From 20806692bb15efc8269e4cd3f00f08625716feae Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Tue, 17 Nov 2026 10:31:21 +0100 Subject: [PATCH 1/2] Hero: no pause on mouse hover (Bryan, 2026-11-17) The pause button, reduced motion, hidden tab and keyboard focus on the controls still pause. Co-Authored-By: Claude Sonnet 5.5 --- .../components/Hero/useHeroSlider.test.tsx | 8 +++---- web/src/components/Hero/useHeroSlider.ts | 24 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/web/src/components/Hero/useHeroSlider.test.tsx b/web/src/components/Hero/useHeroSlider.test.tsx index c51d1eb..774a819 100644 --- a/web/src/components/Hero/useHeroSlider.test.tsx +++ b/web/src/components/Hero/useHeroSlider.test.tsx @@ -45,7 +45,7 @@ describe('useHeroSlider', () => { expect(result.current.active).toBe(0); }); - it('afspelen via de knop heft ook de pauze door hover op', () => { + it('pauzeert niet bij hover met de muis, wel via de knop', () => { let slider!: ReturnType; function Probe() { slider = useHeroSlider(8); @@ -53,11 +53,11 @@ describe('useHeroSlider', () => { } const { getByTestId } = render(); fireEvent.pointerEnter(getByTestId('hero'), { pointerType: 'mouse' }); - expect(slider.paused).toBe(true); + fireEvent.mouseEnter(getByTestId('hero')); + expect(slider.paused).toBe(false); act(() => slider.toggleStopped()); - act(() => slider.toggleStopped()); - expect(slider.paused).toBe(false); + expect(slider.paused).toBe(true); }); it('afspelen via de knop heft ook de pauze door toetsenbordfocus op', () => { diff --git a/web/src/components/Hero/useHeroSlider.ts b/web/src/components/Hero/useHeroSlider.ts index 008d6d8..c900d20 100644 --- a/web/src/components/Hero/useHeroSlider.ts +++ b/web/src/components/Hero/useHeroSlider.ts @@ -22,7 +22,6 @@ export default function useHeroSlider(count: number) { const [announcement, setAnnouncement] = useState(null); // Pauzeknop: blijft gelden tot de bezoeker opnieuw klikt (WCAG 2.2.2) const [stopped, setStopped] = useState(false); - const [hovered, setHovered] = useState(false); const [focused, setFocused] = useState(false); // Server and hydrating render say "visible", like the HTML const hidden = useSyncExternalStore( @@ -49,16 +48,13 @@ export default function useHeroSlider(count: number) { announcement, reducedMotion, autoplay: count > 1 && !reducedMotion, - paused: stopped || hovered || focused || hidden, + paused: stopped || focused || hidden, stopped, - // Afspelen via de knop geldt ook terwijl de muis of de - // toetsenbordfocus nog in de hero staat (de klik zelf is een hover en - // vaak een focus); zonder dit gebeurt er na "afspelen" niets zichtbaars. + // Afspelen via de knop geldt ook terwijl de toetsenbordfocus nog in de + // hero staat (de klik zelf is vaak een focus); zonder dit gebeurt er na + // "afspelen" niets zichtbaars. toggleStopped: () => { - if (stopped) { - setHovered(false); - setFocused(false); - } + if (stopped) setFocused(false); setStopped(!stopped); setAnnouncement(stopped ? 'playing' : 'paused'); }, @@ -66,12 +62,10 @@ export default function useHeroSlider(count: number) { prev, advance: () => go(active + 1, false), handlers: { - // Alleen een echte muis pauzeert; een tik op mobiel niet. - onPointerEnter: (event: React.PointerEvent) => { - if (event.pointerType === 'mouse') setHovered(true); - }, - onPointerLeave: () => setHovered(false), - // Alleen toetsenbordfocus pauzeert, niet een klik op een pijl. + // Hover pauzeert bewust niet (Bryan, 2026-11-17): een beeldvullende hero + // heeft bijna altijd de muis erboven. Toetsenbordfocus op de besturing + // pauzeert wel, want dat is een bewuste handeling; een klik op een + // pijl niet. onFocus: (event: React.FocusEvent) => { if (event.target.matches(':focus-visible')) setFocused(true); }, -- 2.39.5 From 8050072ce582fb47cde1b2377a4a09feb664c3fe Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Tue, 17 Nov 2026 10:31:22 +0100 Subject: [PATCH 2/2] Hero: slow zoom on the first photo without replacing the plain HTML The plain HTML is painted at scale 1.06 and the slider zooms it out to 1 after hydration, like the other photos: same first frame (no CLS), and the LCP does not wait for hydration. Assumptions 15 and 16 recorded. Co-Authored-By: Claude Sonnet 5.5 --- .../assumptions-and-open-questions.md | 34 ++++++++++--------- web/src/components/Hero/Hero.test.tsx | 18 ++++++++++ web/src/components/Hero/Hero.tsx | 12 +++++-- web/src/theme.ts | 14 ++++++++ 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/aidlc-docs/features/hero-module/assumptions-and-open-questions.md b/aidlc-docs/features/hero-module/assumptions-and-open-questions.md index 15e1105..f156be4 100644 --- a/aidlc-docs/features/hero-module/assumptions-and-open-questions.md +++ b/aidlc-docs/features/hero-module/assumptions-and-open-questions.md @@ -2,22 +2,24 @@ Written while Bryan was away; he decides later. Each point: question, assumption, what changes with another answer, where in the code. -| # | Question | Assumption | If the answer differs | Where | -| --- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | -| 1 | Focus points of the 8 photos | Estimates from the seed (e.g. hero-8 0.50/0.55) | Change x/y in the seed (CMS) and in the baked values | `web/src/content/heroContent.ts`, `web/contract/host-injection/hero/seed.json` | -| 2 | Is the baked hero cropped around the focus point too? | Yes: object-position from the estimates, so baked and live look the same | Pass `focus: null` for the baked slides to get plain centre crop | `heroContent.ts` | -| 3 | Button target `#anchor` and https: plain link, `/path`: router link | As said | Make all plain links | `web/src/components/Hero/HeroButton.tsx` | -| 4 | Single display (one photo) or slideshow with one slide | No arrows, pause or progress bar for one slide | Show controls anyway | `Hero.tsx` (`shown.length > 1`) | -| 5 | Title with a new line | `
` in the plain HTML, `pre-line` in the slider | One line only | `heroHtml.ts`, `Hero.tsx` | -| 6 | Where does the head preload marker come from | Build step adds it to the finished HTML (React cannot write a head comment) | Host adds the head region itself | `web/config/heroPreload.ts` | -| 7 | Hero texts (aria, baked title, alts) | In `nl.json`, block `hero` | Other wording: edit the file | `web/src/i18n/nl.json` | -| 8 | Without a host block the site asks `/api/v1/hero` (8 s time-out) | Yes, like packages and banners | Remove the call: baked only | `web/src/components/Hero/useHero.ts` | -| 9 | Style of the plain hero before hydration | Matches the slider's first frame (checked by screenshot at 1280 and 390 px) | Adjust CSS | `.cms-hero-*` in `web/src/theme.ts` | -| 10 | AVIF for slides 2..n only | As agreed with the CMS session | Add AVIF to the first photo and its preload (then two fetches) | `Hero.tsx` (`SlidePicture`) | -| 11 | The first photo, title and buttons stay the plain HTML after hydration (never replaced); the slider adds the other photos on top | Yes: replacing the nodes at hydration risks a late LCP. Side effect: the first photo has no slow zoom and is not in a role=group slide | Go back to a full slider render (one component), accepting the DOM replacement | `Hero.tsx` (`HeroFrame`), `useHero.ts` (`regionHero`) | -| 12 | Planning (from/to dates) and a hero-wide on/off switch | Deliberately not built: the hero is always there, a hero without usable slides keeps the baked one | Add in the CMS; the site already handles a 204 and an empty hero | CMS (module), `useHero.ts` | -| 13 | Content of the ASF test seed | The 8 existing photos with focus estimates (#1), texts like the baked ones | Edit in the CMS admin; update `heroContent.ts` if the baked fallback should match | `web/contract/host-injection/hero/seed.json` | -| 14 | Baked hero after a CMS change | The baked hero is only a fallback and is not rebuilt from the CMS any more (no nightly build) | Re-bake by hand in `heroContent.ts` when the real hero changes for good | `heroContent.ts` | +| # | Question | Assumption | If the answer differs | Where | +| --- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | +| 1 | Focus points of the 8 photos | Estimates from the seed (e.g. hero-8 0.50/0.55) | Change x/y in the seed (CMS) and in the baked values | `web/src/content/heroContent.ts`, `web/contract/host-injection/hero/seed.json` | +| 2 | Is the baked hero cropped around the focus point too? | Yes: object-position from the estimates, so baked and live look the same | Pass `focus: null` for the baked slides to get plain centre crop | `heroContent.ts` | +| 3 | Button target `#anchor` and https: plain link, `/path`: router link | As said | Make all plain links | `web/src/components/Hero/HeroButton.tsx` | +| 4 | Single display (one photo) or slideshow with one slide | No arrows, pause or progress bar for one slide | Show controls anyway | `Hero.tsx` (`shown.length > 1`) | +| 5 | Title with a new line | `
` in the plain HTML, `pre-line` in the slider | One line only | `heroHtml.ts`, `Hero.tsx` | +| 6 | Where does the head preload marker come from | Build step adds it to the finished HTML (React cannot write a head comment) | Host adds the head region itself | `web/config/heroPreload.ts` | +| 7 | Hero texts (aria, baked title, alts) | In `nl.json`, block `hero` | Other wording: edit the file | `web/src/i18n/nl.json` | +| 8 | Without a host block the site asks `/api/v1/hero` (8 s time-out) | Yes, like packages and banners | Remove the call: baked only | `web/src/components/Hero/useHero.ts` | +| 9 | Style of the plain hero before hydration | Matches the slider's first frame (checked by screenshot at 1280 and 390 px) | Adjust CSS | `.cms-hero-*` in `web/src/theme.ts` | +| 10 | AVIF for slides 2..n only | As agreed with the CMS session | Add AVIF to the first photo and its preload (then two fetches) | `Hero.tsx` (`SlidePicture`) | +| 11 | The first photo, title and buttons stay the plain HTML after hydration (never replaced); the slider adds the other photos on top | Yes: replacing the nodes at hydration risks a late LCP. Side effect: the first photo has no slow zoom and is not in a role=group slide | Go back to a full slider render (one component), accepting the DOM replacement | `Hero.tsx` (`HeroFrame`), `useHero.ts` (`regionHero`) | +| 12 | Planning (from/to dates) and a hero-wide on/off switch | Deliberately not built: the hero is always there, a hero without usable slides keeps the baked one | Add in the CMS; the site already handles a 204 and an empty hero | CMS (module), `useHero.ts` | +| 13 | Content of the ASF test seed | The 8 existing photos with focus estimates (#1), texts like the baked ones | Edit in the CMS admin; update `heroContent.ts` if the baked fallback should match | `web/contract/host-injection/hero/seed.json` | +| 14 | Baked hero after a CMS change | The baked hero is only a fallback and is not rebuilt from the CMS any more (no nightly build) | Re-bake by hand in `heroContent.ts` when the real hero changes for good | `heroContent.ts` | +| 15 | Pause on mouse hover | Removed on purpose (Bryan, 2026-11-17): a full-screen hero almost always has the pointer over it. Kept: the explicit pause button (WCAG 2.2.2), no autoplay with `prefers-reduced-motion`, pause when the tab is hidden, and pause while keyboard focus is on the controls (a deliberate action; a click on an arrow does not pause). Touch and swipe do not pause either: a swipe restarts the progress bar of the new slide | Add hover back: `onPointerEnter`/`onPointerLeave` in `useHeroSlider.ts` | `web/src/components/Hero/useHeroSlider.ts` | +| 16 | Slow zoom on the first photo (supersedes #11 in part; Bryan chose the full slider render, 2026-11-17) | The first photo zooms like the others, without replacing the plain HTML: the plain HTML is painted at scale 1.06 (CSS `.cms-hero-image`), the slider sets `data-zoom` after hydration and it zooms out to 1 over 9 s. Same first frame before and after hydration, so no CLS, and the LCP does not wait for hydration (replacing the nodes made the LCP 5.3 s in the first design). Reduced motion: no scale at all | Replace the nodes at hydration (one component); measure LCP first | `theme.ts`, `Hero.tsx` | ## What Bryan has to check later diff --git a/web/src/components/Hero/Hero.test.tsx b/web/src/components/Hero/Hero.test.tsx index 1df7ca8..1d7e134 100644 --- a/web/src/components/Hero/Hero.test.tsx +++ b/web/src/components/Hero/Hero.test.tsx @@ -135,6 +135,24 @@ describe('Hero', () => { }); }); + it('laat de eerste foto inzoomen zolang hij de actieve is', async () => { + const { container } = await renderWithProviders( + , + ); + const picture = container.querySelector('.cms-hero-picture')!; + expect(picture).toHaveAttribute('data-zoom'); + expect(picture).not.toHaveAttribute('aria-hidden'); + await userEvent.click( + screen.getByRole('button', { name: 'Volgende foto' }), + ); + expect(picture).not.toHaveAttribute('data-zoom'); + expect(picture).toHaveAttribute('aria-hidden', 'true'); + await userEvent.click( + screen.getByRole('button', { name: 'Vorige foto' }), + ); + expect(picture).toHaveAttribute('data-zoom'); + }); + it('heeft pijlen met een toegankelijke naam', async () => { await renderWithProviders( , diff --git a/web/src/components/Hero/Hero.tsx b/web/src/components/Hero/Hero.tsx index e666bbf..5c1f49b 100644 --- a/web/src/components/Hero/Hero.tsx +++ b/web/src/components/Hero/Hero.tsx @@ -164,11 +164,17 @@ function HeroFrame({ content, socials, regionHtml, hydrated }: FrameProps) { }, [firstPainted]); // The first photo is hidden from screen readers while another one is on - // top of it + // top of it, and it zooms (data-zoom, see .cms-hero-image) while it is the + // active one useEffect(() => { const picture = section.current?.querySelector('.cms-hero-picture'); - if (active === 0) picture?.removeAttribute('aria-hidden'); - else picture?.setAttribute('aria-hidden', 'true'); + if (active === 0) { + picture?.removeAttribute('aria-hidden'); + picture?.setAttribute('data-zoom', ''); + } else { + picture?.setAttribute('aria-hidden', 'true'); + picture?.removeAttribute('data-zoom'); + } }, [active]); const loaded = firstPainted ? slidesToLoad(active, shown.length) : [active]; diff --git a/web/src/theme.ts b/web/src/theme.ts index 9afd53d..a480dab 100644 --- a/web/src/theme.ts +++ b/web/src/theme.ts @@ -55,6 +55,20 @@ const config = defineConfig({ width: '100%', height: '100%', objectFit: 'cover', + // Same slow zoom as the other photos of the slider: the plain HTML + // is painted at 1.06 and the slider (after hydration) sets + // data-zoom on the picture, which zooms out to 1 over 9 s. The + // photo itself is never replaced, so the LCP does not wait for + // hydration; the first frame is the same before and after it. + transform: 'scale(1.06)', + transition: 'transform 9s linear', + '@media (prefers-reduced-motion: reduce)': { + transform: 'none', + transition: 'none', + }, + }, + '.cms-hero-picture[data-zoom] .cms-hero-image': { + transform: 'scale(1)', }, '.cms-hero-title': { position: 'relative', -- 2.39.5