From 7e61cee8cae87bd926240627f88ffa2c12b231dc Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Thu, 1 Feb 2024 15:19:07 +0100 Subject: [PATCH] Frontend: Fixed left/right out of bound tooltip. --- frontend/src/lib/components/pill.svelte | 23 ++++++-- frontend/src/lib/css/pill.css | 13 ++++- frontend/src/lib/css/project-popup.css | 78 ++++++++++++++++--------- 3 files changed, 81 insertions(+), 33 deletions(-) diff --git a/frontend/src/lib/components/pill.svelte b/frontend/src/lib/components/pill.svelte index a76344c..f6fcecb 100644 --- a/frontend/src/lib/components/pill.svelte +++ b/frontend/src/lib/components/pill.svelte @@ -18,6 +18,7 @@ let pill_arrow; let pill_tooltip; let main_pill; + let innerWidth; if (shadow_color === null) { style = `background-color: ${color}; @@ -28,22 +29,34 @@ } function showingTooltip(visible) { + // Showing tooltip + const isOutofBoundLeft=(main_pill.offsetLeft+(main_pill.offsetWidth/2)<(pill_tooltip.offsetWidth/2)); + const isOutofBoundRight=((pill_tooltip.offsetLeft+pill_tooltip.offsetWidth)>innerWidth); if (visible && tooltip_data.length > 0) { pill_tooltip.style.visibility = "visible"; pill_arrow.style.visibility = "visible"; - // adjusting top + if(isOutofBoundLeft) + { + pill_tooltip.style.left = "0"; + } + if(isOutofBoundRight) + { + pill_tooltip.style.right = "0"; + } pill_tooltip.style.top = `${ main_pill.offsetTop - pill_tooltip.offsetHeight - 16 }px`; - pill_tooltip.style.boxShadow = `0px 8px 18px -1px #261C2C30`; - pill_arrow.style.filter = `drop-shadow(0px 8px 18px #261C2C20)`; - } else { + } + // Hiding tooltip + else { pill_tooltip.style.visibility = "hidden"; pill_arrow.style.visibility = "hidden"; } } + +
{#each tooltip_data as td}
-

{td.title}

+ {td.title}