initial commit with full project

This commit is contained in:
2026-04-26 17:50:04 +03:00
commit 53044e7d40
68 changed files with 34115 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import type { Toast, ToastType } from '$lib/types';
const defaultDurations: Record<ToastType, number> = {
success: 4000,
info: 4000,
warning: 6000,
error: 0
};
let nextId = 0;
class ToastStore {
items: Toast[] = $state([]);
add(type: ToastType, message: string, duration?: number): string {
const id = String(nextId++);
const dur = duration ?? defaultDurations[type];
this.items.push({ id, type, message, duration: dur });
if (dur > 0) {
setTimeout(() => this.remove(id), dur);
}
return id;
}
remove(id: string) {
const idx = this.items.findIndex((t) => t.id === id);
if (idx !== -1) this.items.splice(idx, 1);
}
}
export const toasts = new ToastStore();