feat(ui) : error toasts persist until dismissed, add progress bar on auto-dismiss toasts

This commit is contained in:
2026-04-04 17:25:00 +02:00
parent 8e0e3a3b33
commit 7f91b30bf6
2 changed files with 21 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ export interface Toast {
message: string
type: ToastType
visible: boolean
duration: number
}
const toasts = ref<Toast[]>([])
@@ -32,6 +33,7 @@ export function useToast() {
message,
type,
visible: true,
duration: type === 'error' ? 0 : duration,
}
if (toasts.value.length >= MAX_TOASTS) {
@@ -40,10 +42,12 @@ export function useToast() {
toasts.value.push(toast)
// Auto-remove after duration
setTimeout(() => {
removeToast(id)
}, duration)
// Only auto-dismiss non-error toasts
if (type !== 'error' && duration > 0) {
setTimeout(() => {
removeToast(id)
}, duration)
}
return id
}