Merge pull request #1190 from ae-utbm/alpine-notifications

Add alpine notifications plugin
This commit is contained in:
Bartuccio Antoine
2025-09-26 18:29:04 +02:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -1,7 +1,9 @@
import { alpinePlugin } from "#core:utils/notifications";
import sort from "@alpinejs/sort";
import Alpine from "alpinejs";
Alpine.plugin(sort);
Alpine.magic("notifications", alpinePlugin);
window.Alpine = Alpine;
window.addEventListener("DOMContentLoaded", () => {

View File

@@ -23,3 +23,14 @@ export function deleteNotifications() {
}
return element.dispatchEvent(new CustomEvent("quick-notification-delete"));
}
export function alpinePlugin() {
return {
error: (message: string) => createNotification(message, NotificationLevel.Error),
warning: (message: string) =>
createNotification(message, NotificationLevel.Warning),
success: (message: string) =>
createNotification(message, NotificationLevel.Success),
clear: () => deleteNotifications(),
};
}