File tree Expand file tree Collapse file tree 2 files changed +58
-40
lines changed
Expand file tree Collapse file tree 2 files changed +58
-40
lines changed Original file line number Diff line number Diff line change 1+ <template >
2+ <span :class =" badgeClasses" >
3+ <Icon v-if =" icon" :icon =" icon" :height =" iconSize" />
4+ {{ label }}
5+ </span >
6+ </template >
7+
8+ <script setup lang="ts">
9+ import { Icon } from ' @iconify/vue' ;
10+ import { computed } from ' vue' ;
11+
12+ interface Props {
13+ label: string ;
14+ variant? : ' success' | ' warning' | ' danger' | ' important' | ' primary' | ' default' ;
15+ icon? : string ;
16+ iconSize? : number ;
17+ size? : ' sm' | ' md' ;
18+ }
19+
20+ const props = withDefaults (defineProps <Props >(), {
21+ variant: ' default' ,
22+ iconSize: 14 ,
23+ size: ' sm'
24+ });
25+
26+ const badgeClasses = computed (() => {
27+ const baseClasses = ' inline-flex items-center rounded-2xl font-medium border' ;
28+
29+ // Size classes
30+ const sizeClasses = props .size === ' md'
31+ ? ' gap-2 px-4 py-1.5 text-sm'
32+ : ' gap-1.5 px-3 py-1 text-xs' ;
33+
34+ // Variant classes
35+ let variantClasses = ' ' ;
36+ switch (props .variant ) {
37+ case ' success' :
38+ variantClasses = ' bg-success-soft text-success-3 border-success-3' ;
39+ break ;
40+ case ' warning' :
41+ variantClasses = ' bg-warning-soft text-warning-3 border-warning-3' ;
42+ break ;
43+ case ' danger' :
44+ variantClasses = ' bg-danger-soft text-danger-3 border-danger-3' ;
45+ break ;
46+ case ' important' :
47+ variantClasses = ' bg-important-soft text-important-3 border-important-3' ;
48+ break ;
49+ case ' primary' :
50+ variantClasses = ' bg-primary2/10 text-primary2 border-primary2/30' ;
51+ break ;
52+ default :
53+ variantClasses = ' bg-soft-bg text-text2 border-border' ;
54+ }
55+
56+ return ` ${baseClasses } ${sizeClasses } ${variantClasses } ` ;
57+ });
58+ </script >
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments