budibase/packages/bbui/src/Icon/Icon.svelte

53 lines
1.1 KiB
Svelte
Raw Normal View History

2021-04-16 12:24:06 +02:00
<script context="module">
export const directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"]
2021-04-16 12:24:06 +02:00
</script>
<script>
export let direction = "n"
export let name = "Add"
export let hidden = false
2021-04-27 16:30:13 +02:00
export let size = "M"
export let hoverable = false
export let disabled = false
export let color
export let dataCy = null
2021-04-16 12:24:06 +02:00
2021-06-15 20:36:56 +02:00
$: rotation = getRotation(direction)
const getRotation = direction => {
return directions.indexOf(direction) * 45
}
2021-04-16 12:24:06 +02:00
</script>
<svg
on:click
data-cy={dataCy}
class:hoverable
class:disabled
2021-04-27 16:30:13 +02:00
class="spectrum-Icon spectrum-Icon--size{size}"
focusable="false"
aria-hidden={hidden}
aria-label={name}
style={`transform: rotate(${rotation}deg); ${
color ? `color: ${color};` : ""
}`}
2021-04-23 10:33:41 +02:00
>
<use xlink:href="#spectrum-icon-18-{name}" />
</svg>
<style>
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);
cursor: pointer;
}
svg.disabled {
color: var(--spectrum-global-color-gray-500) !important;
pointer-events: none !important;
}
</style>