From ca50e5dc81140006185a2b49c26a79736f95767d Mon Sep 17 00:00:00 2001 From: Sli Date: Fri, 26 Sep 2025 14:54:26 +0200 Subject: [PATCH] Add alpine notifications plugin --- core/static/bundled/alpine-index.js | 2 ++ core/static/bundled/utils/notifications.ts | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/core/static/bundled/alpine-index.js b/core/static/bundled/alpine-index.js index 211600a5..62d00178 100644 --- a/core/static/bundled/alpine-index.js +++ b/core/static/bundled/alpine-index.js @@ -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", () => { diff --git a/core/static/bundled/utils/notifications.ts b/core/static/bundled/utils/notifications.ts index 70e5fd91..8af936e3 100644 --- a/core/static/bundled/utils/notifications.ts +++ b/core/static/bundled/utils/notifications.ts @@ -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(), + }; +}