From df455db3caeb689ac1f24f224606183d4f5135ea Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 20 Jul 2023 11:58:43 +0200 Subject: [PATCH] feat(Notification): support html with `title` and `description` slots (#431) --- docs/app.vue | 10 ++++- .../examples/NotificationExampleHtml.vue | 7 +++ docs/content/6.overlays/6.notification.md | 44 +++++++++++++++++++ .../components/overlays/Notification.vue | 8 +++- .../components/overlays/Notifications.vue | 6 ++- 5 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 docs/components/content/examples/NotificationExampleHtml.vue diff --git a/docs/app.vue b/docs/app.vue index da5b1e4d..ac5d7094 100644 --- a/docs/app.vue +++ b/docs/app.vue @@ -38,7 +38,15 @@ - + + + + + diff --git a/docs/components/content/examples/NotificationExampleHtml.vue b/docs/components/content/examples/NotificationExampleHtml.vue new file mode 100644 index 00000000..3ebfe186 --- /dev/null +++ b/docs/components/content/examples/NotificationExampleHtml.vue @@ -0,0 +1,7 @@ + + + diff --git a/docs/content/6.overlays/6.notification.md b/docs/content/6.overlays/6.notification.md index d2d1eeca..63d7dfec 100644 --- a/docs/content/6.overlays/6.notification.md +++ b/docs/content/6.overlays/6.notification.md @@ -316,6 +316,50 @@ excludedProps: --- :: +## Slots + +### `title` / `description` + +Use the `#title` and `#description` slots to customize the Notification. + +This can be handy when you want to display HTML content. To achieve this, you can define those slots in the top-level `` component in your `app.vue` and use the `v-html` directive. + +```vue [app.vue] + +``` + +This way, you can use HTML tags in the `title` and `description` props when using `useToast`. + +::component-example +#default +:notification-example-html + +#code +```vue + + + +``` +:: + +::callout{icon="i-heroicons-light-bulb"} +Slots defined in the `` component are automatically passed down to the `Notification` children. +:: + ## Props :component-props diff --git a/src/runtime/components/overlays/Notification.vue b/src/runtime/components/overlays/Notification.vue index 2e827e06..aa0a56e2 100644 --- a/src/runtime/components/overlays/Notification.vue +++ b/src/runtime/components/overlays/Notification.vue @@ -9,10 +9,14 @@

- {{ title }} + + {{ title }} +

- {{ description }} + + {{ description }} +

diff --git a/src/runtime/components/overlays/Notifications.vue b/src/runtime/components/overlays/Notifications.vue index f903ba09..b38c5a89 100644 --- a/src/runtime/components/overlays/Notifications.vue +++ b/src/runtime/components/overlays/Notifications.vue @@ -7,7 +7,11 @@ :class="notification.click && 'cursor-pointer'" @click="notification.click && notification.click(notification)" @close="toast.remove(notification.id)" - /> + > + +