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

1181c28da7f00dffc07621ad877fea1f9578faee
wotaku/docs/.vitepress/theme/components/Tooltip.vue

79 lines · 1737 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
28    theme="vp-tooltip"
29    @show="isOpen = true"
30    @hide="isOpen = false"
31  >
32    <button
33      aria-label="Tooltip"
34      :class="[
35        'text-$vp-custom-block-tip-text-deep h-9 e-9 p-0 select-none font-bold cursor-pointer',
36        isOpen && 'tooltip-open-glow'
37      ]"
38    >
39      <div :class="icon" />
40    </button>
41
42    <template #popper>
43      <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">
44        <h3
45          class="text-$vp-c-text-1 mb-2 text-lg font-semibold"
46          v-text="title"
47        />
48        <p class="text-$vp-c-text-2 text-sm content">
49          <slot />
50        </p>
51      </div>
52    </template>
53  </VTooltip>
54</template>
55
56<style>
57.v-popper__popper {
58  --uno: z-9999;
59}
60
61.v-popper {
62  display: inline-flex !important;
63}
64
65.v-popper__popper .content ol {
66  list-style: decimal !important;
67}
68
69.v-popper__popper .content ul {
70  --uno: ml-4;
71  color: var(--vp-c-text-2);
72  list-style: disc !important;
73}
74
75.tooltip-open-glow {
76  filter: drop-shadow(0 0 6px currentColor) drop-shadow(0 0 12px currentColor);
77  transition: filter 0.2s ease;
78}
79</style>