docs/.vitepress/theme/components/Tooltip.vue

5f52e6ba0fd1abcf193bc72b0810f83dd455def0
wotaku/docs/.vitepress/theme/components/Tooltip.vue history · blame · raw

87 lines · 2001 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">
 9import { ref } from 'vue'
10
11const isOpen = ref(false)
12
13withDefaults(
14  defineProps<{
15    title: string
16  }>(),
17  {
18    title: 'Info',
19  }
20)
21</script>
22
23<template>
24  <VTooltip theme="vp-tooltip" @show="isOpen = true" @hide="isOpen = false">
25    <button
26      aria-label="Tooltip"
27      class="size-3 p-0 select-none font-bold cursor-pointer" style="color: var(--vp-custom-block-tip-text)"
28    >
29      <div :class="isOpen ? 'i-ic-twotone-add-circle' : 'i-ic-twotone-add-circle-outline'" />
30    </button>
31
32    <template #popper>
33      <div class="border-$vp-c-divider bg-$vp-c-bg-alt b-rd-4 max-w-md max-h-md border-2 border-solid p-4 transition-all">
34        <h3
35          class="text-$vp-c-text-1 mb-2 text-lg font-semibold"
36          v-text="title"
37        />
38        <div class="text-$vp-c-text-2 text-sm content">
39          <slot />
40        </div>
41      </div>
42    </template>
43  </VTooltip>
44</template>
45
46<style>
47.v-popper__popper {
48  --uno: z-9999;
49}
50
51.v-popper {
52  display: inline-flex !important;
53  vertical-align: -0.125em;
54}
55
56.v-popper__popper .content ol {
57  list-style: decimal !important;
58}
59
60.v-popper__popper .content ul {
61  --uno: ml-4;
62  color: var(--vp-c-text-2);
63  list-style: disc !important;
64}
65
66.v-popper__popper .content table {
67  width: 100%;
68  border-collapse: collapse;
69  background-color: var(--vp-c-bg-soft);
70  color: var(--vp-c-text-1);
71  --uno: text-sm;
72}
73
74.v-popper__popper .content thead th {
75  background-color: var(--vp-c-bg-soft);
76  color: var(--vp-c-text-1);
77  font-weight: 600;
78  padding: 6px 8px;
79  border-bottom: 1px solid var(--vp-c-divider);
80}
81
82.v-popper__popper .content tbody td {
83  padding: 6px 8px;
84  border-bottom: 1px solid var(--vp-c-divider);
85}
86
87</style>