chore(Alert/Toast): remove description as VNode

This commit is contained in:
Benjamin Canac
2024-06-28 11:45:55 +02:00
parent 369e0b1952
commit f85eb8ed40
2 changed files with 4 additions and 8 deletions

View File

@@ -1,5 +1,4 @@
<script lang="ts">
import { isVNode, type VNode } from 'vue'
import { tv, type VariantProps } from 'tailwind-variants'
import type { PrimitiveProps } from 'radix-vue'
import type { AppConfig } from '@nuxt/schema'
@@ -15,7 +14,7 @@ type AlertVariants = VariantProps<typeof alert>
export interface AlertProps extends Omit<PrimitiveProps, 'asChild'> {
title?: string
description?: string | VNode | (() => VNode)
description?: string
icon?: string
avatar?: AvatarProps
color?: AlertVariants['color']
@@ -88,8 +87,7 @@ const ui = computed(() => tv({ extend: alert, slots: props.ui })({
</slot>
</div>
<template v-if="description || !!slots.description">
<component :is="description" v-if="description && isVNode(description)" />
<div v-else :class="ui.description()">
<div :class="ui.description()">
<slot name="description">
{{ description }}
</slot>

View File

@@ -1,5 +1,4 @@
<script lang="ts">
import { isVNode, type VNode } from 'vue'
import { tv, type VariantProps } from 'tailwind-variants'
import type { ToastRootProps, ToastRootEmits } from 'radix-vue'
import type { AppConfig } from '@nuxt/schema'
@@ -15,7 +14,7 @@ type ToastVariants = VariantProps<typeof toast>
export interface ToastProps extends Omit<ToastRootProps, 'asChild' | 'forceMount'> {
title?: string
description?: string | VNode | (() => VNode)
description?: string
icon?: string
avatar?: AvatarProps
color?: ToastVariants['color']
@@ -109,8 +108,7 @@ defineExpose({
</slot>
</ToastTitle>
<template v-if="description || !!slots.description">
<ToastDescription v-if="description && isVNode(description)" :as="description" />
<ToastDescription v-else :class="ui.description()">
<ToastDescription :class="ui.description()">
<slot name="description">
{{ description }}
</slot>