This repository has been archived on 2025-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
Files
vitepress-theme-blog-charle…/docs/.vitepress/theme/components/Badge.vue
2022-09-03 11:31:54 +08:00

47 lines
942 B
Vue

<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>