mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-27 16:59:37 +02:00
migration to new backend
This commit is contained in:
parent
28a5d423c2
commit
9abe9fb315
309 changed files with 21476 additions and 24132 deletions
19
frontend/src/lib/toasts.ts
Normal file
19
frontend/src/lib/toasts.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { writable } from 'svelte/store';
|
||||
|
||||
export const toasts = writable<{ type: any; message: any; id: number }[]>([]);
|
||||
|
||||
export const addToast = (type: any, message: any, duration = 5000) => {
|
||||
const id = Date.now();
|
||||
toasts.update((currentToasts) => {
|
||||
return [...currentToasts, { type, message, id, duration }];
|
||||
});
|
||||
setTimeout(() => {
|
||||
removeToast(id);
|
||||
}, duration);
|
||||
};
|
||||
|
||||
export const removeToast = (id: number) => {
|
||||
toasts.update((currentToasts) => {
|
||||
return currentToasts.filter((toast) => toast.id !== id);
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue