mirror of
https://github.com/ae-utbm/sith.git
synced 2025-10-09 16:24:39 +00:00
Add alpine notifications plugin
This commit is contained in:
@@ -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", () => {
|
||||
|
@@ -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(),
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user