Create unified notification system

This commit is contained in:
2025-09-23 18:39:01 +02:00
parent 980952807a
commit cbe9887efb
10 changed files with 55 additions and 123 deletions

View File

@@ -0,0 +1,24 @@
export enum NotificationLevel {
Error = "error",
Warning = "warning",
}
export function createNotification(message: string, level: NotificationLevel) {
const element = document.getElementById("notifications");
if (element === null) {
return false;
}
return element.dispatchEvent(
new CustomEvent("notification-add", {
detail: { text: message, tag: level },
}),
);
}
export function deleteNotifications() {
const element = document.getElementById("notifications");
if (element === null) {
return false;
}
return element.dispatchEvent(new CustomEvent("notification-delete"));
}