2021-03-31 22:59:07 +13:00
|
|
|
<script>
|
2021-04-09 03:04:27 +12:00
|
|
|
import "@spectrum-css/button/dist/index-vars.css"
|
2022-02-08 07:47:10 +13:00
|
|
|
import Tooltip from "../Tooltip/Tooltip.svelte"
|
2021-04-09 03:04:27 +12:00
|
|
|
|
|
|
|
export let disabled = false
|
2021-04-15 22:50:56 +12:00
|
|
|
export let size = "M"
|
2021-04-23 19:41:49 +12:00
|
|
|
export let cta = false
|
|
|
|
export let primary = false
|
|
|
|
export let secondary = false
|
2021-04-22 01:59:08 +12:00
|
|
|
export let warning = false
|
2021-04-23 19:41:49 +12:00
|
|
|
export let overBackground = false
|
2021-04-09 04:04:03 +12:00
|
|
|
export let quiet = false
|
2021-04-15 22:50:56 +12:00
|
|
|
export let icon = undefined
|
2021-04-20 23:31:08 +12:00
|
|
|
export let active = false
|
2022-02-08 07:47:10 +13:00
|
|
|
export let tooltip = undefined
|
|
|
|
|
|
|
|
let showTooltip = false
|
2021-04-15 22:50:56 +12:00
|
|
|
</script>
|
2021-04-09 03:04:27 +12:00
|
|
|
|
2022-02-08 07:47:10 +13:00
|
|
|
<div class:container={!!tooltip}>
|
|
|
|
<button
|
|
|
|
class:spectrum-Button--cta={cta}
|
|
|
|
class:spectrum-Button--primary={primary}
|
|
|
|
class:spectrum-Button--secondary={secondary}
|
|
|
|
class:spectrum-Button--warning={warning}
|
|
|
|
class:spectrum-Button--overBackground={overBackground}
|
|
|
|
class:spectrum-Button--quiet={quiet}
|
|
|
|
class:active
|
|
|
|
class="spectrum-Button spectrum-Button--size{size.toUpperCase()}"
|
|
|
|
{disabled}
|
|
|
|
on:click|preventDefault
|
|
|
|
on:mouseover={() => (showTooltip = true)}
|
|
|
|
on:mouseleave={() => (showTooltip = false)}
|
|
|
|
>
|
|
|
|
{#if icon}
|
|
|
|
<svg
|
|
|
|
class="spectrum-Icon spectrum-Icon--size{size.toUpperCase()}"
|
|
|
|
focusable="false"
|
|
|
|
aria-hidden="true"
|
|
|
|
aria-label={icon}
|
|
|
|
>
|
|
|
|
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
|
|
</svg>
|
|
|
|
{/if}
|
|
|
|
{#if $$slots}
|
|
|
|
<span class="spectrum-Button-label"><slot /></span>
|
|
|
|
{/if}
|
2022-02-09 06:17:00 +13:00
|
|
|
{#if !disabled && tooltip}
|
|
|
|
<div class="tooltip-icon">
|
|
|
|
<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}
|
2022-02-08 07:47:10 +13:00
|
|
|
</button>
|
|
|
|
{#if showTooltip && tooltip}
|
|
|
|
<div class="position">
|
|
|
|
<div class="tooltip">
|
|
|
|
<Tooltip textWrapping={true} direction={"bottom"} text={tooltip} />
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-10 01:21:51 +12:00
|
|
|
{/if}
|
2022-02-08 07:47:10 +13:00
|
|
|
</div>
|
2021-03-31 22:59:07 +13:00
|
|
|
|
|
|
|
<style>
|
2022-02-08 07:47:10 +13:00
|
|
|
.container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
2021-04-17 04:12:22 +12:00
|
|
|
.spectrum-Button-label {
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
2021-04-27 03:02:03 +12:00
|
|
|
.active {
|
|
|
|
color: var(--spectrum-global-color-blue-600) !important;
|
|
|
|
}
|
2022-02-08 07:47:10 +13:00
|
|
|
.tooltip {
|
|
|
|
position: absolute;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
z-index: 100;
|
|
|
|
width: 160px;
|
|
|
|
text-align: center;
|
|
|
|
transform: translateX(-50%);
|
|
|
|
top: -5px;
|
|
|
|
}
|
|
|
|
.position {
|
|
|
|
position: relative;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
}
|
2022-02-09 06:17:00 +13:00
|
|
|
.tooltip-icon {
|
|
|
|
padding-left: var(--spacing-m);
|
|
|
|
line-height: 0;
|
|
|
|
}
|
2021-03-31 22:59:07 +13:00
|
|
|
</style>
|