32 lines
942 B
Vue
32 lines
942 B
Vue
<script setup lang="ts">
|
|
import type { HTMLAttributes } from 'vue'
|
|
import { XIcon } from '@lucide/vue'
|
|
import { cn } from '@/lib/utils'
|
|
import { Button } from '@/components/ui/button'
|
|
import { alertVariants } from '.'
|
|
import AlertAction from './AlertAction.vue'
|
|
import type { AlertVariants } from '.'
|
|
|
|
const props = withDefaults(defineProps<{
|
|
class?: HTMLAttributes['class']
|
|
variant?: AlertVariants['variant']
|
|
closable?: boolean
|
|
}>(), {
|
|
variant: 'info',
|
|
closable: false,
|
|
})
|
|
|
|
const emit = defineEmits<{ close: [] }>()
|
|
</script>
|
|
|
|
<template>
|
|
<div data-slot="alert" role="alert" :class="cn(alertVariants({ variant }), props.class)">
|
|
<slot />
|
|
<AlertAction v-if="closable">
|
|
<Button variant="secondary" size="icon" class="size-6 bg-transparent hover:bg-black/10" @click="emit('close')">
|
|
<XIcon class="size-3.5" />
|
|
<span class="sr-only">Dismiss</span>
|
|
</Button>
|
|
</AlertAction>
|
|
</div>
|
|
</template>
|