import { writable } from "svelte/store"; export interface Toast { color?: string | undefined; title?: string | undefined; message?: string | undefined; } export const toastList = writable([]); export function addToast(toast: Toast) { toast ??= { color: "red", title: "Error", message: "An error occurred" }; toast.color ??= "red"; toast.title ??= "Error"; toast.message ??= "An error occurred"; toastList.update((list) => [...list, toast]); setTimeout(() => { toastList.update((list) => list.filter((t) => t !== toast)); }, 5000); }