uni-badge.vue
1.99 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
<text class="uni-badge" v-if="text" :class="setClass" @click="onClick()">{{text}}</text>
</template>
<script>
export default {
name: 'uni-badge',
props: {
type: {
type: String,
default: 'default'
},
inverted: {
type: Boolean,
default: false
},
text: {
type: String,
default: ''
},
size: { //small.normal
type: String,
default: 'normal'
}
},
computed: {
setClass() {
let classList = ['uni-badge-' + this.type, 'uni-badge--' + this.size];
if (this.inverted === true) {
classList.push('uni-badge-inverted')
}
return classList.join(" ")
}
},
methods: {
onClick() {
this.$emit('click')
}
}
}
</script>
<style lang="scss">
$bage-size:12px;
$bage-small:scale(0.8);
.uni-badge {
font-family: 'Helvetica Neue', Helvetica, sans-serif;
box-sizing: border-box;
font-size: $bage-size;
line-height: 1;
display: inline-block;
padding: 3px 6px;
color: $uni-text-color;
border-radius: 100px;
background-color: $uni-bg-color-hover;
&.uni-badge-inverted {
padding: 0 5px 0 0;
color: $uni-text-color-grey;
background-color: transparent;
}
&-primary {
color: $uni-text-color-inverse;
background-color: $uni-color-primary;
&.uni-badge-inverted {
color: $uni-color-primary;
background-color: transparent
}
}
&-success {
color: $uni-text-color-inverse;
background-color: $uni-color-success;
&.uni-badge-inverted {
color: $uni-color-success;
background-color: transparent
}
}
&-warning {
color: $uni-text-color-inverse;
background-color: $uni-color-warning;
&.uni-badge-inverted {
color: $uni-color-warning;
background-color: transparent
}
}
&-error {
color: $uni-text-color-inverse;
background-color: $uni-color-error;
&.uni-badge-inverted {
color: $uni-color-error;
background-color: transparent
}
}
&--small {
transform: $bage-small;
transform-origin: center center;
}
}
</style>