Skip to content

Commit cd8e710

Browse files
committed
feat(tag): add color variants
1 parent ac82f5b commit cd8e710

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

playground/src/pages/index.vue

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ const date = ref()
253253
<USlider v-model="isSliderOpen" />
254254
</div>
255255
<UTable v-model="tableCheck" class="w-full" :columns="columns" :rows="people" :sort="{ column: 'name' }" />
256+
<UTag size="xs" label="I'm a tag" />
256257
<UTag label="I'm a tag" />
257258
<div class="flex gap-2.5">
258259
<UTooltip text="Hi bro !" :popper="{ placement: 'left' }">

src/components/tag/UTag.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ const props = withDefaults(defineProps<{
1818
ui: () => useAppUi().tag,
1919
})
2020
21-
const config = computed(() => merge({}, useAppUi().tag, props.ui))
21+
const { primaryColor } = useAppTheme()
2222
23+
const config = computed(() => merge({}, useAppUi().tag, props.ui))
2324
const tagClass = computed(() => {
24-
const variant = config.value.variant[props.variant]
25+
const variant = config.value.color?.[props.color]?.[props.variant] || (props.color === 'primary' && config.value.color?.[primaryColor.value]?.[props.variant]) || config.value.variant[props.variant]
2526
return classNames(
2627
config.value.base,
2728
config.value.font,

src/components/tag/tag.ts

+20
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ export const tag = {
1212
md: 'text-13px px-3 py-1.25',
1313
lg: 'text-13px px-4 py-1.75',
1414
},
15+
color: {
16+
fluo: {
17+
solid: 'bg-{color}-50 dark:bg-{color}-950 text-{color}-600 dark:text-{color}-300',
18+
},
19+
cyan: {
20+
solid: 'bg-{color}-50 dark:bg-{color}-950 text-{color}-600 dark:text-{color}-300',
21+
},
22+
yellow: {
23+
solid: 'bg-{color}-50 dark:bg-{color}-950 text-{color}-600 dark:text-{color}-300',
24+
},
25+
silver: {
26+
solid: 'bg-{color}-50 dark:bg-{color}-950 text-{color}-600 dark:text-{color}-300',
27+
},
28+
dark: {
29+
solid: 'bg-{color}-50 dark:bg-{color}-600 text-dark-500 dark:text-light-500',
30+
},
31+
light: {
32+
solid: 'bg-{color}-200 dark:bg-{color}-600 text-{color}-800 dark:text-{color}-200',
33+
},
34+
},
1535
variant: {
1636
solid: 'bg-{color}-50 dark:bg-{color}-950 text-{color}-500 dark:text-{color}-400',
1737
},

0 commit comments

Comments
 (0)