From 025f556023c29f8f31dc00870c80a9d790bbb2f4 Mon Sep 17 00:00:00 2001
From: Corentin THOMASSET <corentin.thomasset74@gmail.com>
Date: Sat, 14 Oct 2023 18:24:54 +0200
Subject: refactor(ui): switched naive tooltip components to custom ones (#661)

---
 src/ui/c-tooltip/c-tooltip.vue | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

(limited to 'src/ui/c-tooltip/c-tooltip.vue')

diff --git a/src/ui/c-tooltip/c-tooltip.vue b/src/ui/c-tooltip/c-tooltip.vue
index 095315f..0f47e71 100644
--- a/src/ui/c-tooltip/c-tooltip.vue
+++ b/src/ui/c-tooltip/c-tooltip.vue
@@ -1,23 +1,30 @@
 <script setup lang="ts">
-const props = withDefaults(defineProps<{ tooltip?: string }>(), { tooltip: '' });
-const { tooltip } = toRefs(props);
+const props = withDefaults(defineProps<{ tooltip?: string; position?: 'top' | 'bottom' | 'left' | 'right' }>(), {
+  tooltip: undefined,
+  position: 'top',
+});
+const { tooltip, position } = toRefs(props);
 
 const targetRef = ref();
 const isTargetHovered = useElementHover(targetRef);
 </script>
 
 <template>
-  <div class="relative" inline-block>
+  <div relative inline-block>
     <div ref="targetRef">
       <slot />
     </div>
 
     <div
       v-if="tooltip || $slots.tooltip"
-      class="absolute bottom-100% left-50% z-10 mb-5px whitespace-nowrap rounded bg-black px-12px py-6px text-sm text-white shadow-lg transition transition transition-duration-0.2s -translate-x-1/2"
+      class="absolute z-10 whitespace-nowrap rounded bg-black px-12px py-6px text-sm text-white shadow-lg transition transition transition-duration-0.2s"
       :class="{
         'op-0 scale-0': isTargetHovered === false,
         'op-100 scale-100': isTargetHovered,
+        'bottom-100% left-50% -translate-x-1/2 mb-5px': position === 'top',
+        'top-100% left-50% -translate-x-1/2 mt-5px': position === 'bottom',
+        'right-100% top-50% -translate-y-1/2 mr-5px': position === 'left',
+        'left-100% top-50% -translate-y-1/2 ml-5px': position === 'right',
       }"
     >
       <slot
-- 
cgit v1.2.3

