|
|
|
@ -1,5 +1,6 @@ |
|
|
|
<script> |
|
|
|
import "@spectrum-css/button/dist/index-vars.css" |
|
|
|
import Tooltip from "../Tooltip/Tooltip.svelte" |
|
|
|
|
|
|
|
export let disabled = false |
|
|
|
export let size = "M" |
|
|
|
@ -11,36 +12,55 @@ |
|
|
|
export let quiet = false |
|
|
|
export let icon = undefined |
|
|
|
export let active = false |
|
|
|
export let tooltip = undefined |
|
|
|
|
|
|
|
let showTooltip = false |
|
|
|
</script> |
|
|
|
|
|
|
|
<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 |
|
|
|
> |
|
|
|
{#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> |
|
|
|
<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} |
|
|
|
</button> |
|
|
|
{#if showTooltip && tooltip} |
|
|
|
<div class="position"> |
|
|
|
<div class="tooltip"> |
|
|
|
<Tooltip textWrapping={true} direction={"bottom"} text={tooltip} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{/if} |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<style> |
|
|
|
.container { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
flex-direction: column; |
|
|
|
} |
|
|
|
.spectrum-Button-label { |
|
|
|
white-space: nowrap; |
|
|
|
overflow: hidden; |
|
|
|
@ -49,4 +69,19 @@ |
|
|
|
.active { |
|
|
|
color: var(--spectrum-global-color-blue-600) !important; |
|
|
|
} |
|
|
|
.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; |
|
|
|
} |
|
|
|
</style> |
|
|
|
|