All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 32s
28 lines
513 B
TypeScript
28 lines
513 B
TypeScript
import { writable } from "svelte/store";
|
|
|
|
|
|
type Type = 'success' | 'info' | 'warning' | 'error';
|
|
type Toast = {
|
|
message: string;
|
|
type: Type;
|
|
}
|
|
|
|
const toastStore = writable<Toast[]>([]);
|
|
|
|
|
|
const addToast = (message: string, type: Type) => {
|
|
const newToast = { message, type };
|
|
|
|
toastStore.update((toasts) => {
|
|
return [...toasts, newToast];
|
|
});
|
|
|
|
setTimeout(() => {
|
|
toastStore.update((toasts) => toasts.filter((t) => t !== newToast));
|
|
}, 5000);
|
|
}
|
|
|
|
|
|
export { toastStore, addToast, };
|
|
export type { Toast }
|