From cdcc21c6c65921cad41e1b3355bdd530c23f2362 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 16 Jun 2026 17:25:08 +0200 Subject: [PATCH] feat: add destructive variant to toast component --- static/toast.ts | 4 +++- templates/base.gohtml | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/static/toast.ts b/static/toast.ts index 074d502..61856fa 100644 --- a/static/toast.ts +++ b/static/toast.ts @@ -3,6 +3,7 @@ export {}; interface ToastOptions { message: string; duration?: number; + variant?: "default" | "destructive"; } /** Return the toast container element. */ @@ -12,7 +13,7 @@ const toastContainer = (): HTMLElement | null => document.getElementById("toast- * Show a toast notification with optional auto-dismiss. * Exposed globally via window.showToast. */ -const showToast = ({ message, duration = 3000 }: ToastOptions): void => { +const showToast = ({ message, duration = 3000, variant = "default" }: ToastOptions): void => { const container = toastContainer(); const template = document.getElementById("toast-template") as HTMLTemplateElement | null; @@ -23,6 +24,7 @@ const showToast = ({ message, duration = 3000 }: ToastOptions): void => { const toast = (template.content.cloneNode(true) as DocumentFragment) .firstElementChild as HTMLElement; if (!toast) return; + toast.dataset.variant = variant; toast.setAttribute("role", "status"); toast.setAttribute("aria-live", "polite"); const messageEl = toast.querySelector(".toast-message"); diff --git a/templates/base.gohtml b/templates/base.gohtml index 4911671..af7a15d 100644 --- a/templates/base.gohtml +++ b/templates/base.gohtml @@ -28,12 +28,12 @@