mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
feat: improve dock tooltip and add i18n translation
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
options: OptionType[]
|
||||
modelValue: string
|
||||
@@ -9,8 +6,6 @@ const props = defineProps<{
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const { locale } = useI18n()
|
||||
|
||||
interface OptionType {
|
||||
value: string
|
||||
label: string
|
||||
|
||||
50
src/components/Tooltip.vue
Normal file
50
src/components/Tooltip.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<script lang="ts" setup>
|
||||
defineProps<{
|
||||
content: string
|
||||
placement: 'left' | 'right' | 'top'
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="tooltip-wrapper">
|
||||
<div
|
||||
class="tooltip"
|
||||
:class="placement"
|
||||
>
|
||||
{{ content }}
|
||||
</div>
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tooltip-wrapper {
|
||||
--at-apply: flex items-center relative;
|
||||
|
||||
.tooltip {
|
||||
--at-apply: absolute px-2 py-1 rounded-8
|
||||
bg-black dark:bg-white
|
||||
pointer-events-none
|
||||
text-sm text-white dark:text-black
|
||||
opacity-0 duration-300;
|
||||
white-space: nowrap;
|
||||
|
||||
&.right {
|
||||
--at-apply: left-[calc(100%+1em)];
|
||||
}
|
||||
|
||||
&.left{
|
||||
--at-apply: right-[calc(100%+1em)];
|
||||
}
|
||||
|
||||
&.top {
|
||||
--at-apply: top--3em left-1/2;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover .tooltip {
|
||||
--at-apply: opacity-100;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user