docs/.vitepress/theme/components/Button.vue
65 lines · 1587 bytes
1<!--
2 Copyright (c) 2024 taskylizard
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16<script setup lang="ts">
17withDefaults(
18 defineProps<{
19 text?: string
20 type?: 'info' | 'tip' | 'warning' | 'danger'
21 link: string
22 icon?: string
23 }>(),
24 { icon: 'i-octicon-link-external-16', type: 'tip' }
25)
26</script>
27
28<template>
29 <component
30 :target="link ? '_blank' : undefined"
31 :is="link ? 'a' : 'span'"
32 :href="link"
33 :class="type"
34 class="VButton px4 py3 mt2 gap2 block flex items-center rounded-md"
35 >
36 <div :class="icon" />
37 <slot>{{ text }}</slot>
38 </component>
39</template>
40
41<style scoped>
42.VButton {
43 text-decoration: none !important;
44}
45
46.VButton.info {
47 color: var(--vp-badge-info-text);
48 background-color: var(--vp-badge-info-bg);
49}
50
51.VButton.tip {
52 color: var(--vp-badge-tip-text);
53 background-color: var(--vp-badge-tip-bg);
54}
55
56.VButton.warning {
57 color: var(--vp-badge-warning-text);
58 background-color: var(--vp-badge-warning-bg);
59}
60
61.VButton.danger {
62 color: var(--vp-badge-danger-text);
63 background-color: var(--vp-badge-danger-bg);
64}
65</style>