Line data Source code
1 16 : <script setup lang="ts">
2 : import type { HTMLAttributes } from 'vue'
3 :
4 : import { cn } from '@comfyorg/tailwind-utils'
5 :
6 : import Button from '@comfyorg/design-system/button/Button'
7 :
8 : import type { BadgeVariants } from './badge.variants'
9 : import { badgeVariants } from './badge.variants'
10 :
11 : const {
12 : variant,
13 : severity,
14 : removable,
15 : removeLabel,
16 : class: customClass = ''
17 : } = defineProps<
18 : {
19 : variant?: BadgeVariants['variant']
20 : severity?: BadgeVariants['severity']
21 : class?: HTMLAttributes['class']
22 : } & (
23 : | { removable: true; removeLabel: string }
24 : | { removable?: false; removeLabel?: string }
25 : )
26 : >()
27 :
28 8610 : const emit = defineEmits<{ remove: [event: MouseEvent] }>()
29 : </script>
30 :
31 : <template>
32 : <span :class="cn(badgeVariants({ variant, severity }), customClass)">
33 : <slot name="icon" />
34 : <slot />
35 : <Button
36 : v-if="removable"
37 : type="button"
38 : variant="textonly"
39 : size="icon-sm"
40 : class="-mr-1 rounded-full text-current"
41 : :aria-label="removeLabel"
42 : @click="emit('remove', $event)"
43 : >
44 : <i class="icon-[lucide--x] size-3" aria-hidden="true" />
45 : </Button>
46 : </span>
47 : </template>
|