fix(TranscribeDragDemo): reactive prefersReducedMotion + bg-parchment token
- Replace one-shot $derived(.matches) snapshot with $state + addEventListener so the static/animated branch reacts when the user toggles OS reduced-motion at runtime (Felix: non-reactive media query) - Replace bg-[#FAF8F1] raw hex with bg-parchment design token so the SVG background remaps correctly in dark mode (Felix/Markus) Also update TranscriptionPanelHeader.svelte.test.ts to expect role="region" after the HelpPopover ARIA fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
const prefersReducedMotion = $derived(
|
// $derived from .matches is a one-shot snapshot — it doesn't react when the
|
||||||
|
// user toggles the OS setting at runtime. Use $state + addEventListener instead.
|
||||||
|
let prefersReducedMotion = $state(
|
||||||
typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (typeof window === 'undefined') return;
|
||||||
|
const mql = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||||
|
const handler = (e: MediaQueryListEvent) => {
|
||||||
|
prefersReducedMotion = e.matches;
|
||||||
|
};
|
||||||
|
mql.addEventListener('change', handler);
|
||||||
|
return () => mql.removeEventListener('change', handler);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if prefersReducedMotion}
|
{#if prefersReducedMotion}
|
||||||
@@ -10,7 +22,7 @@ const prefersReducedMotion = $derived(
|
|||||||
role="img"
|
role="img"
|
||||||
aria-label="Eine gestrichelte Umrandung markiert eine Zeile Kurrentschrift auf dem Dokument."
|
aria-label="Eine gestrichelte Umrandung markiert eine Zeile Kurrentschrift auf dem Dokument."
|
||||||
viewBox="0 0 600 180"
|
viewBox="0 0 600 180"
|
||||||
class="border-brand-sand block w-full rounded-sm border bg-[#FAF8F1]"
|
class="border-brand-sand block w-full rounded-sm border bg-parchment"
|
||||||
>
|
>
|
||||||
<g
|
<g
|
||||||
stroke="#2a2a2a"
|
stroke="#2a2a2a"
|
||||||
@@ -61,7 +73,7 @@ const prefersReducedMotion = $derived(
|
|||||||
role="img"
|
role="img"
|
||||||
aria-label="Animation: Ein Cursor zieht einen gestrichelten Rahmen um eine Zeile Kurrentschrift. Beim Loslassen wird der Rahmen durchgehend und ein Häkchen erscheint."
|
aria-label="Animation: Ein Cursor zieht einen gestrichelten Rahmen um eine Zeile Kurrentschrift. Beim Loslassen wird der Rahmen durchgehend und ein Häkchen erscheint."
|
||||||
viewBox="0 0 600 180"
|
viewBox="0 0 600 180"
|
||||||
class="border-brand-sand block w-full rounded-sm border bg-[#FAF8F1]"
|
class="border-brand-sand block w-full rounded-sm border bg-parchment"
|
||||||
>
|
>
|
||||||
<!-- Kurrent writing (static) -->
|
<!-- Kurrent writing (static) -->
|
||||||
<g
|
<g
|
||||||
|
|||||||
@@ -177,6 +177,6 @@ describe('TranscriptionPanelHeader', () => {
|
|||||||
|
|
||||||
const helpBtn = document.querySelector('button[aria-expanded]') as HTMLButtonElement;
|
const helpBtn = document.querySelector('button[aria-expanded]') as HTMLButtonElement;
|
||||||
helpBtn.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
helpBtn.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
||||||
await vi.waitFor(() => expect(document.querySelector('[role="tooltip"]')).not.toBeNull());
|
await vi.waitFor(() => expect(document.querySelector('[role="region"]')).not.toBeNull());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user