refactor(frontent): move components and ts to lib folder

This commit is contained in:
2025-12-29 18:38:20 +01:00
parent 54b9e1fc78
commit abf227d15d
30 changed files with 41 additions and 40 deletions
@@ -0,0 +1,28 @@
import { writable } from "svelte/store";
export type Notification = {
id: number;
title: string;
message: string;
duration: number;
className: string;
type?: "error" | "success" | "info";
};
function createNotifications() {
const { subscribe, update } = writable<Notification[]>([]);
function push(type: "error" | "success" | "info", title: string, message: string = "", className: string = "") {
const id = Date.now();
const duration = type === "error" ? 16000 : 4000;
update((n) => [...n, { id, title, message, duration, className, type }]);
setTimeout(() => {
update((n) => n.filter((x) => x.id !== id));
}, duration);
}
const remove = (id: number) => update(n => n.filter(x => x.id !== id));
return { subscribe, push, remove };
}
export const notifications = createNotifications();