forked from vuejs/vitepress
/
VPBadge.vue
51 lines (45 loc) · 946 Bytes
/
VPBadge.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
<script setup lang="ts">
const props = withDefaults(
defineProps<{
text?: string,
type?: 'warning' | 'tip' | 'error' | 'info'
vertical?: 'top' | 'middle'
}>(), {
text: '',
type: 'tip',
vertical: 'top',
}
);
</script>
<template>
<span
class='VPBadge'
:class="[ `VPBadge-type-${props.type}` ]"
:style="{ 'vertical-align': props.vertical }"
>
<slot>{{ props.text }}</slot>
</span>
</template>
<style scoped>
.VPBadge {
display: inline-block;
font-size: 14px;
height: 18px;
line-height: 18px;
border-radius: 3px;
padding: 0 6px;
color: #fff;
}
.VPBadge.VPBadge-type-warning {
background-color: var(--vp-c-badge-type-warning);
}
.VPBadge.VPBadge-type-tip {
background-color: var(--vp-c-badge-type-tip);
}
.VPBadge.VPBadge-type-error {
background-color: var(--vp-c-badge-type-error);
}
.VPBadge.VPBadge-type-info {
background-color: var(--vp-c-badge-type-info);
}
</style>