Skip to content

Commit

Permalink
UBER-428: displaying tooltips with a delay (#3442)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Platov <sas_lord@mail.ru>
  • Loading branch information
SasLord authored Jun 20, 2023
1 parent e9319ac commit 0bc097f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions packages/ui/src/components/TooltipInstance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
let clWidth: number
let docWidth: number
let docHeight: number
let shown: boolean = false
$: tooltipSW = !$tooltip.component && $tooltip.kind !== 'submenu'
$: onUpdate = $tooltip.onUpdate
$: kind = $tooltip.kind
const clearStyles = (): void => {
shown = false
tooltipHTML.style.top =
tooltipHTML.style.bottom =
tooltipHTML.style.left =
Expand Down Expand Up @@ -122,7 +124,11 @@
tooltipHTML.classList.add('no-arrow')
}
tooltipHTML.style.visibility = 'visible'
} else if (tooltipHTML) tooltipHTML.style.visibility = 'hidden'
shown = true
} else if (tooltipHTML) {
shown = false
tooltipHTML.style.visibility = 'hidden'
}
}
const fitSubmenu = (): void => {
Expand Down Expand Up @@ -203,11 +209,11 @@
{#if $tooltip.component && $tooltip.kind !== 'submenu'}
<div
class="popup-tooltip"
class:shown
class:doublePadding={$tooltip.label}
use:resizeObserver={(element) => {
clWidth = element.clientWidth
if (kind === 'submenu') fitSubmenu()
else fitTooltip(tooltipHTML)
fitTooltip(tooltipHTML)
}}
bind:this={tooltipHTML}
>
Expand All @@ -233,7 +239,7 @@
/>
{/if}
</div>
<div bind:this={nubHTML} class="nub {nubDirection ?? ''}" />
<div bind:this={nubHTML} class="nub {nubDirection ?? ''}" class:shown />
{:else if $tooltip.label && $tooltip.kind !== 'submenu'}
<div class="tooltip {dir ?? ''}" bind:this={tooltipHTML}>
<Label label={$tooltip.label} params={$tooltip.props ?? {}} />
Expand Down Expand Up @@ -302,6 +308,7 @@
border-radius: 0.75rem;
box-shadow: var(--theme-popup-shadow);
user-select: none;
opacity: 0;
z-index: 10000;
&.doublePadding {
Expand All @@ -314,6 +321,7 @@
// background-color: rgba(255, 255, 0, .5);
user-select: none;
pointer-events: none;
opacity: 0;
z-index: 10000;
&::after,
Expand Down Expand Up @@ -380,6 +388,10 @@
transform: rotate(-90deg);
}
}
.shown {
transition: opacity 0.1s ease-in-out 0.15s;
opacity: 1;
}
.keys {
margin-left: 0.5rem;
Expand Down
4 changes: 2 additions & 2 deletions plugins/chunter-resources/src/components/CommentPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

<div class="container">
<div
class="flex flex-between flex-grow header"
class="flex-between header"
use:resizeObserver={() => {
dispatch('changeContent')
}}
Expand Down Expand Up @@ -117,10 +117,10 @@
}
.container {
max-height: 30rem;
overflow: hidden;
display: flex;
flex-direction: column;
max-height: 30rem;
}
.header {
Expand Down

0 comments on commit 0bc097f

Please # to comment.