docs/.vitepress/theme/components/Badge.vue

33a4e4c6fa7d78deb08b14d2b151ff82c28e461a
wotaku/docs/.vitepress/theme/components/Badge.vue history · blame · raw

73 lines · 1607 bytes

 1<!--
 2  All Rights Reserved
 3
 4  Copyright (c) 2025 taskylizard
 5
 6  All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
 7-->
 8<script setup lang="ts">
 9interface Props {
10  text?: string
11  link?: string
12  type?: 'info' | 'tip' | 'warning' | 'danger' | 'green'
13  icon?: string
14}
15withDefaults(defineProps<Props>(), {
16  type: 'info'
17})
18</script>
19
20<template>
21  <component
22    :target="link ? '_blank' : undefined"
23    :is="link ? 'a' : 'span'"
24    class="VPBadge"
25    :class="link ? 'tip' : type"
26    :href="link"
27  >
28    <div v-if="icon" :class="icon" />
29    <slot>{{ text }}</slot>
30  </component>
31</template>
32
33<style scoped>
34.VPBadge {
35  display: inline-flex;
36  margin-left: 0.125em;
37  border: 1px solid transparent;
38  border-radius: 1em;
39  padding: 0 0.75em;
40  line-height: 1.5;
41  font-size: 0.75em;
42  font-weight: 500;
43  align-items: center;
44  gap: 0.25em;
45  vertical-align: middle;
46  text-decoration: none !important;
47}
48
49.VPBadge.info {
50  color: var(--vp-badge-info-text);
51  background-color: var(--vp-badge-info-bg);
52}
53
54.VPBadge.tip {
55  color: var(--vp-badge-tip-text);
56  background-color: var(--vp-badge-tip-bg);
57}
58
59.VPBadge.warning {
60  color: var(--vp-badge-warning-text);
61  background-color: var(--vp-badge-warning-bg);
62}
63
64.VPBadge.danger {
65  color: var(--vp-badge-danger-text);
66  background-color: var(--vp-badge-danger-bg);
67}
68
69.VPBadge.green {
70  color: var(--vp-custom-block-tip-text);
71  background-color: var(--vp-custom-block-tip-bg);
72}
73</style>