diff options
| author | benj <benj@rse8.com> | 2026-04-10 11:13:34 +0800 |
|---|---|---|
| committer | benj <benj@rse8.com> | 2026-04-10 11:13:34 +0800 |
| commit | 493746b14c1251a45b061d2e3edd9160c929d2b9 (patch) | |
| tree | 1607cceb94c1aac1a17a01bb5c0d71b97342e892 /web/ui/src/lib/stores/toasts.ts | |
| parent | c041641634650c31e03c70dcad132fd94cb08e63 (diff) | |
| download | tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.tar tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.tar.gz tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.tar.bz2 tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.tar.lz tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.tar.xz tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.tar.zst tidyindex-493746b14c1251a45b061d2e3edd9160c929d2b9.zip | |
a basic ui and landing web interface for tidyindex.com
Diffstat (limited to 'web/ui/src/lib/stores/toasts.ts')
| -rw-r--r-- | web/ui/src/lib/stores/toasts.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/web/ui/src/lib/stores/toasts.ts b/web/ui/src/lib/stores/toasts.ts new file mode 100644 index 0000000..27dd8c4 --- /dev/null +++ b/web/ui/src/lib/stores/toasts.ts @@ -0,0 +1,21 @@ +import { writable } from 'svelte/store'; + +export type ToastKind = 'info' | 'success' | 'error'; + +export interface Toast { + id: number; + kind: ToastKind; + message: string; +} + +let nextId = 1; + +export const toasts = writable<Toast[]>([]); + +export function pushToast(message: string, kind: ToastKind = 'info'): void { + const id = nextId++; + toasts.update((list) => [...list, { id, kind, message }]); + setTimeout(() => { + toasts.update((list) => list.filter((t) => t.id !== id)); + }, 2500); +} |
