refactor(web): pushToast store + ToastHost; 8 sites migrated (W3)

This commit is contained in:
2026-05-08 05:45:34 -04:00
parent 970752a153
commit 617477b702
12 changed files with 229 additions and 223 deletions
+23
View File
@@ -0,0 +1,23 @@
<script lang="ts">
// Single global toast renderer. Mounted once in +layout.svelte; pages call
// pushToast() from $lib/stores/toast.svelte. The {#key} re-mount on id
// change is what makes screen readers re-announce a replacement toast.
import { toast } from '$lib/stores/toast.svelte';
</script>
{#if toast.value}
{#key toast.value.id}
<div
role="status"
aria-live="polite"
data-testid="toast"
class="fixed bottom-4 right-4 z-50 max-w-sm rounded-md border bg-surface px-4 py-3 text-sm shadow-lg"
class:border-border={toast.value.variant === 'info'}
class:text-text-primary={toast.value.variant === 'info'}
class:border-error={toast.value.variant === 'error'}
class:text-error={toast.value.variant === 'error'}
>
{toast.value.message}
</div>
{/key}
{/if}