Update tooltips to transition and to use friendly names when possible

This commit is contained in:
Andrew Kingston 2023-07-05 09:10:03 +01:00
parent aedd04b98a
commit 57242840b7
2 changed files with 7 additions and 27 deletions

View File

@ -16,8 +16,6 @@
export let tooltip = undefined export let tooltip = undefined
export let newStyles = true export let newStyles = true
export let id export let id
let showTooltip = false
</script> </script>
<button <button
@ -35,9 +33,6 @@
class="spectrum-Button spectrum-Button--size{size.toUpperCase()}" class="spectrum-Button spectrum-Button--size{size.toUpperCase()}"
{disabled} {disabled}
on:click|preventDefault on:click|preventDefault
on:mouseover={() => (showTooltip = true)}
on:focus={() => (showTooltip = true)}
on:mouseleave={() => (showTooltip = false)}
> >
{#if icon} {#if icon}
<svg <svg
@ -53,24 +48,7 @@
<span class="spectrum-Button-label"><slot /></span> <span class="spectrum-Button-label"><slot /></span>
{/if} {/if}
{#if tooltip} {#if tooltip}
<div <div class="tooltip">
class="tooltip-icon"
on:mouseover={() => (showTooltip = true)}
on:focus={() => (showTooltip = true)}
on:mouseleave={() => (showTooltip = false)}
>
<svg
class="spectrum-Icon spectrum-Icon--size{size.toUpperCase()}"
focusable="false"
aria-hidden="true"
aria-label="Info"
>
<use xlink:href="#spectrum-icon-18-InfoOutline" />
</svg>
</div>
{/if}
{#if tooltip}
<div class="tooltip" class:visible={showTooltip}>
<Tooltip textWrapping={true} direction={"bottom"} text={tooltip} /> <Tooltip textWrapping={true} direction={"bottom"} text={tooltip} />
</div> </div>
{/if} {/if}
@ -103,7 +81,7 @@
transition: opacity 130ms ease-out; transition: opacity 130ms ease-out;
pointer-events: none; pointer-events: none;
} }
.tooltip.visible { button:hover .tooltip {
opacity: 1; opacity: 1;
} }
.tooltip-icon { .tooltip-icon {

View File

@ -33,7 +33,7 @@
<Tooltip <Tooltip
direction={tooltipDirection} direction={tooltipDirection}
textWrapping textWrapping
text={user.email} text={helpers.getUserLabel(user)}
size="S" size="S"
/> />
</div> </div>
@ -46,13 +46,15 @@
position: relative; position: relative;
} }
.tooltip { .tooltip {
display: none;
position: absolute; position: absolute;
top: 0; top: 0;
left: 50%; left: 50%;
white-space: nowrap; white-space: nowrap;
pointer-events: none;
opacity: 0;
transition: opacity 130ms ease-out;
} }
.user-avatar:hover .tooltip { .user-avatar:hover .tooltip {
display: block; opacity: 1;
} }
</style> </style>