2022-04-21 16:11:07 +02:00
|
|
|
<script>
|
|
|
|
import Icon from "../Icon/Icon.svelte"
|
|
|
|
import Tooltip from "../Tooltip/Tooltip.svelte"
|
|
|
|
import { fade } from "svelte/transition"
|
|
|
|
|
|
|
|
export let icon
|
|
|
|
export let active = false
|
|
|
|
export let tooltip
|
|
|
|
|
|
|
|
let showTooltip = false
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
|
|
|
class="icon-side-nav-item"
|
|
|
|
class:active
|
|
|
|
on:mouseover={() => (showTooltip = true)}
|
|
|
|
on:focus={() => (showTooltip = true)}
|
|
|
|
on:mouseleave={() => (showTooltip = false)}
|
|
|
|
on:click
|
|
|
|
>
|
|
|
|
<Icon name={icon} hoverable />
|
|
|
|
{#if tooltip && showTooltip}
|
|
|
|
<div class="tooltip" in:fade={{ duration: 130, delay: 250 }}>
|
|
|
|
<Tooltip textWrapping direction="right" text={tooltip} />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.icon-side-nav-item {
|
|
|
|
width: 36px;
|
|
|
|
height: 36px;
|
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
|
|
|
border-radius: 4px;
|
|
|
|
position: relative;
|
|
|
|
cursor: pointer;
|
2022-04-27 17:02:30 +02:00
|
|
|
transition: background 130ms ease-out;
|
2022-04-21 16:11:07 +02:00
|
|
|
}
|
|
|
|
.icon-side-nav-item:hover :global(svg),
|
|
|
|
.active :global(svg) {
|
2022-07-01 12:26:11 +02:00
|
|
|
color: var(--spectrum-global-color-gray-900);
|
2022-04-21 16:11:07 +02:00
|
|
|
}
|
|
|
|
.active {
|
2022-05-24 16:43:52 +02:00
|
|
|
background: var(--spectrum-global-color-gray-300);
|
2022-04-21 16:11:07 +02:00
|
|
|
}
|
|
|
|
.tooltip {
|
|
|
|
position: absolute;
|
|
|
|
pointer-events: none;
|
|
|
|
left: calc(100% - 4px);
|
|
|
|
top: 50%;
|
|
|
|
white-space: nowrap;
|
|
|
|
transform: translateY(-50%);
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
</style>
|