First version running with npm run dev

This commit is contained in:
pascalyazid committed 2026-03-11 15:11:57 +00:00
commit f90ec06a4f
28 files changed
+12042

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
import { ref } from "vue";
interface Toast {
id: number;
message: string;
type: "success" | "error" | "info";
}
const toasts = ref<Toast[]>([]);
let nextId = 0;
export function useToast() {
function show(
message: string,
type: Toast["type"] = "success",
duration = 2500,
): void {
const id = nextId++;
toasts.value.push({ id, message, type });
setTimeout(() => {
dismiss(id);
}, duration);
}
function dismiss(id: number): void {
const index = toasts.value.findIndex((t) => t.id === id);
if (index !== -1) {
toasts.value.splice(index, 1);
}
}
return {
toasts,
show,
dismiss,
};
}