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

6d80d4e5c9c648e99ff1c61d4b090902f84098ed
wotaku/docs/.vitepress/theme/components/Tooltip.vue history · blame · raw

96 lines · 2203 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    icon: string
17  }>(),
18  {
19    title: 'Info',
20    // https://icon-sets.iconify.design/material-symbols/
21    icon: 'i-material-symbols-help'
22  }
23)
24</script>
25
26<template>
27  <VTooltip theme="vp-tooltip" @show="isOpen = true" @hide="isOpen = false">
28    <button
29      aria-label="Tooltip"
30      :class="[
31        'text-$vp-custom-block-tip-text-deep size-3 p-0 select-none font-bold cursor-pointer',
32        isOpen && 'tooltip-open-glow'
33      ]"
34    >
35      <div :class="icon" />
36    </button>
37
38    <template #popper>
39      <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">
40        <h3
41          class="text-$vp-c-text-1 mb-2 text-lg font-semibold"
42          v-text="title"
43        />
44        <div class="text-$vp-c-text-2 text-sm content">
45          <slot />
46        </div>
47      </div>
48    </template>
49  </VTooltip>
50</template>
51
52<style>
53.v-popper__popper {
54  --uno: z-9999;
55}
56
57.v-popper {
58  display: inline-flex !important;
59}
60
61.v-popper__popper .content ol {
62  list-style: decimal !important;
63}
64
65.v-popper__popper .content ul {
66  --uno: ml-4;
67  color: var(--vp-c-text-2);
68  list-style: disc !important;
69}
70
71.v-popper__popper .content table {
72  width: 100%;
73  border-collapse: collapse;
74  background-color: var(--vp-c-bg-soft);
75  color: var(--vp-c-text-1);
76  --uno: text-sm;
77}
78
79.v-popper__popper .content thead th {
80  background-color: var(--vp-c-bg-soft);
81  color: var(--vp-c-text-1);
82  font-weight: 600;
83  padding: 6px 8px;
84  border-bottom: 1px solid var(--vp-c-divider);
85}
86
87.v-popper__popper .content tbody td {
88  padding: 6px 8px;
89  border-bottom: 1px solid var(--vp-c-divider);
90}
91
92.tooltip-open-glow {
93  filter: drop-shadow(0 0 6px currentColor) drop-shadow(0 0 12px currentColor);
94  transition: filter 0.2s ease;
95}
96</style>