feat(ui) : error toasts persist until dismissed, add progress bar on auto-dismiss toasts
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user