fix: useForwardProps for vue-sonner props

This commit is contained in:
sadeghbarati 2024-01-23 10:07:01 +03:30
parent 42f0086586
commit 9ad7fcfd6d
6 changed files with 11 additions and 6 deletions

View File

@ -328,7 +328,6 @@ export const docsConfig: DocsConfig = {
{ {
title: 'Toast', title: 'Toast',
href: '/docs/components/toast', href: '/docs/components/toast',
label: 'New',
items: [], items: [],
}, },
{ {

View File

@ -46,7 +46,7 @@ const sourceLink = 'https://github.com/radix-vue/shadcn-vue/tree/dev/'
> >
{{ doc.title }} {{ doc.title }}
<Badge v-if="doc.label" class="ml-2" :variant="'secondary'"> <Badge v-if="doc.label" class="ml-2 rounded-md !bg-[#adfa1d] px-1.5 py-0.5 text-xs leading-none text-[#000000] no-underline group-hover:no-underline" variant="default">
{{ doc.label }} {{ doc.label }}
</Badge> </Badge>
</a> </a>

View File

@ -1,7 +1,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useForwardProps } from 'radix-vue'
import { Toaster as Sonner, type ToasterProps } from 'vue-sonner' import { Toaster as Sonner, type ToasterProps } from 'vue-sonner'
const props = defineProps<ToasterProps>() const props = defineProps<ToasterProps>()
const forwardedProps = useForwardProps(props)
</script> </script>
<template> <template>
@ -16,6 +19,6 @@ const props = defineProps<ToasterProps>()
cancelButton: cancelButton:
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground', 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
}" }"
v-bind="props" v-bind="forwardedProps"
/> />
</template> </template>

View File

@ -1,7 +1,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useForwardProps } from 'radix-vue'
import { Toaster as Sonner, type ToasterProps } from 'vue-sonner' import { Toaster as Sonner, type ToasterProps } from 'vue-sonner'
const props = defineProps<ToasterProps>() const props = defineProps<ToasterProps>()
const forwardedProps = useForwardProps(props)
</script> </script>
<template> <template>
@ -16,6 +19,6 @@ const props = defineProps<ToasterProps>()
cancelButton: cancelButton:
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground', 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
}" }"
v-bind="props" v-bind="forwardedProps"
/> />
</template> </template>

View File

@ -7,7 +7,7 @@
"files": [ "files": [
{ {
"name": "Sonner.vue", "name": "Sonner.vue",
"content": "<script lang=\"ts\" setup>\nimport { Toaster as Sonner, type ToasterProps } from 'vue-sonner'\n\nconst props = defineProps<ToasterProps>()\n</script>\n\n<template>\n <Sonner\n class=\"toaster group\"\n :class-names=\"{\n toast:\n 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',\n description: 'group-[.toast]:text-muted-foreground',\n actionButton:\n 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',\n cancelButton:\n 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',\n }\"\n v-bind=\"props\"\n />\n</template>\n" "content": "<script lang=\"ts\" setup>\nimport { useForwardProps } from 'radix-vue'\nimport { Toaster as Sonner, type ToasterProps } from 'vue-sonner'\n\nconst props = defineProps<ToasterProps>()\n\nconst forwardedProps = useForwardProps(props)\n</script>\n\n<template>\n <Sonner\n class=\"toaster group\"\n :class-names=\"{\n toast:\n 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',\n description: 'group-[.toast]:text-muted-foreground',\n actionButton:\n 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',\n cancelButton:\n 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',\n }\"\n v-bind=\"forwardedProps\"\n />\n</template>\n"
}, },
{ {
"name": "index.ts", "name": "index.ts",

View File

@ -7,7 +7,7 @@
"files": [ "files": [
{ {
"name": "Sonner.vue", "name": "Sonner.vue",
"content": "<script lang=\"ts\" setup>\nimport { Toaster as Sonner, type ToasterProps } from 'vue-sonner'\n\nconst props = defineProps<ToasterProps>()\n</script>\n\n<template>\n <Sonner\n class=\"toaster group\"\n :class-names=\"{\n toast:\n 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',\n description: 'group-[.toast]:text-muted-foreground',\n actionButton:\n 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',\n cancelButton:\n 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',\n }\"\n v-bind=\"props\"\n />\n</template>\n" "content": "<script lang=\"ts\" setup>\nimport { useForwardProps } from 'radix-vue'\nimport { Toaster as Sonner, type ToasterProps } from 'vue-sonner'\n\nconst props = defineProps<ToasterProps>()\n\nconst forwardedProps = useForwardProps(props)\n</script>\n\n<template>\n <Sonner\n class=\"toaster group\"\n :class-names=\"{\n toast:\n 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',\n description: 'group-[.toast]:text-muted-foreground',\n actionButton:\n 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',\n cancelButton:\n 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',\n }\"\n v-bind=\"forwardedProps\"\n />\n</template>\n"
}, },
{ {
"name": "index.ts", "name": "index.ts",