chore(toast): improve notifications

This commit is contained in:
Benjamin Canac
2022-07-21 00:39:06 +02:00
parent 487f253e14
commit 1ff9fd4f69
3 changed files with 64 additions and 54 deletions

View File

@@ -28,37 +28,17 @@ export default defineNuxtPlugin(() => {
toast: {
addNotification,
removeNotification,
success ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
addNotification({
type: 'success',
title,
description,
timeout
})
success (notification: Partial<ToastNotification> = {}) {
return addNotification({ type: 'success', ...notification })
},
info ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
addNotification({
type: 'info',
title,
description,
timeout
})
info (notification: Partial<ToastNotification> = {}) {
return addNotification({ type: 'info', ...notification })
},
warning ({ title, description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
addNotification({
type: 'warning',
title,
description,
timeout
})
warning (notification: Partial<ToastNotification> = {}) {
return addNotification({ type: 'warning', ...notification })
},
error ({ title = 'An error occurred!', description, timeout }: { title?: string, description?: string, timeout?: number } = {}) {
addNotification({
type: 'error',
title,
description,
timeout
})
error (notification: Partial<ToastNotification>) {
return addNotification({ type: 'error', title: 'An error occurred!', ...notification })
}
}
}