From 3da1e1a5183852011beadb91af4edbeb3f233e39 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Wed, 10 Apr 2024 18:22:09 +0200 Subject: [PATCH] feat(Toast): new component (#50) --- playground/app.config.ts | 5 ++ playground/app.vue | 5 +- playground/pages/toast.vue | 124 ++++++++++++++++++++++++++++ src/runtime/components/App.vue | 22 ++--- src/runtime/components/Toast.vue | 106 ++++++++++++++++++++++++ src/runtime/components/Toaster.vue | 116 ++++++++++++++++++++++++++ src/runtime/composables/useToast.ts | 59 +++++++++++++ src/runtime/types/index.d.ts | 2 + src/templates.ts | 23 +++++- src/theme/index.ts | 2 + src/theme/toast.ts | 33 ++++++++ src/theme/toaster.ts | 56 +++++++++++++ test/components/Toast.spec.ts | 25 ++++++ 13 files changed, 566 insertions(+), 12 deletions(-) create mode 100644 playground/pages/toast.vue create mode 100644 src/runtime/components/Toast.vue create mode 100644 src/runtime/components/Toaster.vue create mode 100644 src/runtime/composables/useToast.ts create mode 100644 src/theme/toast.ts create mode 100644 src/theme/toaster.ts create mode 100644 test/components/Toast.spec.ts diff --git a/playground/app.config.ts b/playground/app.config.ts index dce4c0e6..a8795b04 100644 --- a/playground/app.config.ts +++ b/playground/app.config.ts @@ -1,4 +1,9 @@ export default defineAppConfig({ + toaster: { + position: 'bottom-right' as const, + expand: true, + duration: 60000 + }, ui: { primary: 'sky', gray: 'cool' diff --git a/playground/app.vue b/playground/app.vue index 08c58dc3..e1a1590f 100644 --- a/playground/app.vue +++ b/playground/app.vue @@ -7,6 +7,8 @@ useHead({ } }) +const appConfig = useAppConfig() + const components = [ 'accordion', 'avatar', @@ -31,6 +33,7 @@ const components = [ 'switch', 'tabs', 'textarea', + 'toast', 'tooltip' ] @@ -40,7 +43,7 @@ function upperName (name: string) {