2021-04-16 12:24:06 +02:00
|
|
|
<script context="module">
|
2021-04-20 21:06:27 +02:00
|
|
|
export const directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"]
|
2021-04-16 12:24:06 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script>
|
2022-04-12 16:34:34 +02:00
|
|
|
import Tooltip from "../Tooltip/Tooltip.svelte"
|
|
|
|
import { fade } from "svelte/transition"
|
|
|
|
|
2021-04-20 21:06:27 +02:00
|
|
|
export let direction = "n"
|
|
|
|
export let name = "Add"
|
|
|
|
export let hidden = false
|
2021-04-27 16:30:13 +02:00
|
|
|
export let size = "M"
|
2021-04-22 11:58:04 +02:00
|
|
|
export let hoverable = false
|
|
|
|
export let disabled = false
|
2021-12-09 14:08:16 +01:00
|
|
|
export let color
|
2022-04-12 16:34:34 +02:00
|
|
|
export let tooltip
|
2021-04-16 12:24:06 +02:00
|
|
|
|
2021-06-15 20:36:56 +02:00
|
|
|
$: rotation = getRotation(direction)
|
|
|
|
|
2022-04-12 16:34:34 +02:00
|
|
|
let showTooltip = false
|
|
|
|
|
2021-06-15 20:36:56 +02:00
|
|
|
const getRotation = direction => {
|
|
|
|
return directions.indexOf(direction) * 45
|
|
|
|
}
|
2021-04-16 12:24:06 +02:00
|
|
|
</script>
|
|
|
|
|
2022-04-12 16:34:34 +02:00
|
|
|
<div
|
|
|
|
on:mouseover={() => (showTooltip = true)}
|
|
|
|
on:focus={() => (showTooltip = true)}
|
|
|
|
on:mouseleave={() => (showTooltip = false)}
|
2021-04-23 10:33:41 +02:00
|
|
|
>
|
2022-04-12 16:34:34 +02:00
|
|
|
<svg
|
|
|
|
on:click
|
|
|
|
class:hoverable
|
|
|
|
class:disabled
|
|
|
|
class="spectrum-Icon spectrum-Icon--size{size}"
|
|
|
|
focusable="false"
|
|
|
|
aria-hidden={hidden}
|
|
|
|
aria-label={name}
|
|
|
|
style={`transform: rotate(${rotation}deg); ${
|
|
|
|
color ? `color: ${color};` : ""
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
<use style="pointer-events: none;" xlink:href="#spectrum-icon-18-{name}" />
|
|
|
|
</svg>
|
|
|
|
{#if tooltip && showTooltip}
|
|
|
|
<div class="tooltip" in:fade={{ duration: 130, delay: 250 }}>
|
|
|
|
<Tooltip textWrapping={true} direction={"bottom"} text={tooltip} />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2021-04-22 11:58:04 +02:00
|
|
|
|
|
|
|
<style>
|
2022-04-12 16:34:34 +02:00
|
|
|
div {
|
|
|
|
position: relative;
|
|
|
|
display: grid;
|
|
|
|
place-items: center;
|
|
|
|
}
|
|
|
|
|
2021-04-22 11:58:04 +02:00
|
|
|
svg.hoverable {
|
|
|
|
pointer-events: all;
|
|
|
|
transition: color var(--spectrum-global-animation-duration-100, 130ms);
|
|
|
|
}
|
|
|
|
svg.hoverable:hover {
|
2021-09-03 12:53:25 +02:00
|
|
|
color: var(--spectrum-alias-icon-color-selected-hover);
|
2021-04-22 11:58:04 +02:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
svg.disabled {
|
|
|
|
color: var(--spectrum-global-color-gray-500) !important;
|
|
|
|
pointer-events: none !important;
|
|
|
|
}
|
2022-04-12 16:34:34 +02:00
|
|
|
|
|
|
|
.tooltip {
|
|
|
|
position: absolute;
|
|
|
|
pointer-events: none;
|
|
|
|
left: 50%;
|
|
|
|
top: 100%;
|
|
|
|
white-space: nowrap;
|
|
|
|
transform: translateX(-50%);
|
|
|
|
}
|
2021-04-22 11:58:04 +02:00
|
|
|
</style>
|