diff --git a/client/src/componants/dashboard/Tabs.svelte b/client/src/componants/dashboard/Tabs.svelte index f2416994..c096b1da 100644 --- a/client/src/componants/dashboard/Tabs.svelte +++ b/client/src/componants/dashboard/Tabs.svelte @@ -1,13 +1,14 @@ diff --git a/client/src/componants/sidebar/NavBar.svelte b/client/src/componants/sidebar/NavBar.svelte index 6f29c4d6..43a40e44 100644 --- a/client/src/componants/sidebar/NavBar.svelte +++ b/client/src/componants/sidebar/NavBar.svelte @@ -1,82 +1,65 @@ diff --git a/client/src/componants/ui/TooltipFromAction.svelte b/client/src/componants/ui/TooltipFromAction.svelte new file mode 100644 index 00000000..6f24bbca --- /dev/null +++ b/client/src/componants/ui/TooltipFromAction.svelte @@ -0,0 +1,20 @@ + +
{title}
+ + diff --git a/client/src/utils/tooltip.ts b/client/src/utils/tooltip.ts new file mode 100644 index 00000000..7716515a --- /dev/null +++ b/client/src/utils/tooltip.ts @@ -0,0 +1,45 @@ +import Tooltip from '../componants/ui/TooltipFromAction.svelte'; + +export function tooltip(element) { + let div; + let title; + let tooltipComponent; + function mouseOver(event) { + // NOTE: remove the `title` attribute, to prevent showing the default browser tooltip + // remember to set it back on `mouseleave` + title = element.getAttribute('title'); + element.removeAttribute('title'); + + tooltipComponent = new Tooltip({ + props: { + title: title, + x: event.pageX, + y: event.pageY, + }, + target: document.body, + }); + } + function mouseMove(event) { + tooltipComponent.$set({ + x: event.pageX, + y: event.pageY, + }) + } + function mouseLeave() { + tooltipComponent.$destroy(); + // NOTE: restore the `title` attribute + element.setAttribute('title', title); + } + + element.addEventListener('mouseover', mouseOver); + element.addEventListener('mouseleave', mouseLeave); + element.addEventListener('mousemove', mouseMove); + + return { + destroy() { + element.removeEventListener('mouseover', mouseOver); + element.removeEventListener('mouseleave', mouseLeave); + element.removeEventListener('mousemove', mouseMove); + } + } +} \ No newline at end of file