-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBadge.vue
60 lines (54 loc) · 2.16 KB
/
Badge.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<script setup>
import {computed, reactive, ref} from 'vue';
import { wBadge } from '#components';
import { radio } from '#dev-util';
const badgeVariants = [
{ name: 'Undefined', radio },
{ name: 'neutral', radio },
{ name: 'info', radio },
{ name: 'positive', radio },
{ name: 'warning', radio },
{ name: 'negative', radio },
{ name: 'disabled', radio },
{ name: 'notification', radio },
{ name: 'price', radio },
];
const badgePositions = [
{ name: 'Undefined', radio },
{ name: 'top-left', radio },
{ name: 'top-right', radio },
{ name: 'bottom-left', radio },
{ name: 'bottom-right', radio },
];
const currentVariant = reactive({active: 'Undefined'});
const currentPosition = reactive({active: 'Undefined'});
const hasVariant = computed(() => currentVariant.active !== 'Undefined');
const hasPosition = computed(() => currentPosition.active !== 'Undefined');
</script>
<template>
<div>
<component-title title="Badge" />
<token v-if="hasVariant && hasPosition" :state="[currentVariant, currentPosition]">
<div class="relative border border-0 rounded-8 overflow-hidden h-96">
<img class="w-full h-96 object-cover" src="https://source.unsplash.com/random/768x96" />
<w-badge :variant="currentVariant.active" :position="currentPosition.active">{{currentVariant.active}}</w-badge>
</div>
</token>
<token v-else-if="hasPosition" :state="currentPosition">
<div class="relative border border-0 rounded-8 overflow-hidden h-96">
<img class="w-full h-96 object-cover" src="https://source.unsplash.com/random/768x96" />
<w-badge :position="currentPosition.active">default (rendered as neutral)</w-badge>
</div>
</token>
<token v-else-if="hasVariant" :state="currentVariant">
<w-badge :variant="currentVariant.active">{{currentVariant.active}}</w-badge>
</token>
<token v-else>
<w-badge>default (rendered as neutral)</w-badge>
</token>
<demo-controls y>
<demo-control label="Variant" :controls="badgeVariants" :state="currentVariant" />
<demo-control label="Position" :controls="badgePositions" :state="currentPosition" />
</demo-controls>
</div>
</template>