2022-08-05 21:32:55 +12:00
|
|
|
<script>
|
|
|
|
import Icon from "./Icon.svelte"
|
|
|
|
|
2024-02-28 02:43:45 +13:00
|
|
|
import Tooltip from "../Tooltip/Tooltip.svelte"
|
|
|
|
import { fade } from "svelte/transition"
|
|
|
|
|
2022-08-05 21:32:55 +12:00
|
|
|
export let icon
|
|
|
|
export let background
|
|
|
|
export let color
|
|
|
|
export let size = "M"
|
2024-02-28 02:43:45 +13:00
|
|
|
export let tooltip
|
|
|
|
|
|
|
|
let showTooltip = false
|
2022-08-05 21:32:55 +12:00
|
|
|
</script>
|
|
|
|
|
2024-02-28 02:43:45 +13:00
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
2022-08-05 21:32:55 +12:00
|
|
|
<div
|
|
|
|
class="icon size--{size}"
|
|
|
|
style="background: {background || `transparent`};"
|
|
|
|
class:filled={!!background}
|
2024-02-28 02:43:45 +13:00
|
|
|
on:mouseover={() => (showTooltip = true)}
|
|
|
|
on:mouseleave={() => (showTooltip = false)}
|
2024-03-08 02:02:54 +13:00
|
|
|
on:focus={() => (showTooltip = true)}
|
|
|
|
on:blur={() => (showTooltip = false)}
|
2024-02-28 02:43:45 +13:00
|
|
|
on:click={() => (showTooltip = false)}
|
2022-08-05 21:32:55 +12:00
|
|
|
>
|
|
|
|
<Icon name={icon} color={background ? "white" : color} />
|
2024-02-28 02:43:45 +13:00
|
|
|
{#if tooltip && showTooltip}
|
|
|
|
<div class="tooltip" in:fade={{ duration: 130, delay: 250 }}>
|
2024-02-28 02:47:56 +13:00
|
|
|
<Tooltip textWrapping direction="right" text={tooltip} />
|
2024-02-28 02:43:45 +13:00
|
|
|
</div>
|
|
|
|
{/if}
|
2022-08-05 21:32:55 +12:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.icon {
|
2024-02-28 02:43:45 +13:00
|
|
|
position: relative;
|
2022-08-05 21:32:55 +12:00
|
|
|
width: 28px;
|
|
|
|
height: 28px;
|
2023-01-19 02:56:53 +13:00
|
|
|
flex: 0 0 28px;
|
2022-08-05 21:32:55 +12:00
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
.icon :global(.spectrum-Icon) {
|
2022-08-05 21:37:35 +12:00
|
|
|
width: 22px;
|
|
|
|
height: 22px;
|
2022-08-05 21:32:55 +12:00
|
|
|
}
|
|
|
|
.icon.filled :global(.spectrum-Icon) {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
}
|
2024-02-26 22:53:02 +13:00
|
|
|
.icon.size--XS {
|
|
|
|
width: 18px;
|
|
|
|
height: 18px;
|
|
|
|
flex: 0 0 18px;
|
|
|
|
}
|
|
|
|
.icon.size--XS :global(.spectrum-Icon) {
|
|
|
|
width: 10px;
|
|
|
|
height: 10px;
|
|
|
|
}
|
2022-08-05 21:32:55 +12:00
|
|
|
.icon.size--S {
|
|
|
|
width: 22px;
|
|
|
|
height: 22px;
|
2023-01-19 02:56:53 +13:00
|
|
|
flex: 0 0 22px;
|
2022-08-05 21:32:55 +12:00
|
|
|
}
|
|
|
|
.icon.size--S :global(.spectrum-Icon) {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
}
|
|
|
|
.icon.size--S.filled :global(.spectrum-Icon) {
|
|
|
|
width: 12px;
|
|
|
|
height: 12px;
|
|
|
|
}
|
|
|
|
.icon.size--L {
|
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
2023-01-19 02:56:53 +13:00
|
|
|
flex: 0 0 40px;
|
2022-08-05 21:32:55 +12:00
|
|
|
}
|
|
|
|
.icon.size--L :global(.spectrum-Icon) {
|
|
|
|
width: 28px;
|
|
|
|
height: 28px;
|
|
|
|
}
|
|
|
|
.icon.size--L.filled :global(.spectrum-Icon) {
|
|
|
|
width: 22px;
|
|
|
|
height: 22px;
|
|
|
|
}
|
2024-02-28 02:43:45 +13:00
|
|
|
|
|
|
|
.tooltip {
|
|
|
|
position: absolute;
|
|
|
|
pointer-events: none;
|
2024-02-28 02:47:56 +13:00
|
|
|
left: calc(50% + 8px);
|
|
|
|
bottom: calc(-50% + 6px);
|
|
|
|
/* transform: translateY(-50%); */
|
2024-02-28 02:43:45 +13:00
|
|
|
text-align: center;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
2022-08-05 21:32:55 +12:00
|
|
|
</style>
|