budibase/packages/bbui/src/Button/Button.svelte

53 lines
1.3 KiB
Svelte
Raw Normal View History

2021-03-31 11:59:07 +02:00
<script>
2021-04-08 17:04:27 +02:00
import "@spectrum-css/button/dist/index-vars.css"
export let disabled = false
export let size = "M"
2021-04-23 09:41:49 +02:00
export let cta = false
export let primary = false
export let secondary = false
export let warning = false
2021-04-23 09:41:49 +02:00
export let overBackground = false
export let quiet = false
export let icon = undefined
2021-04-20 13:31:08 +02:00
export let active = false
</script>
2021-04-08 17:04:27 +02:00
<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}
2021-04-20 13:31:08 +02:00
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}
2021-04-08 17:04:27 +02:00
<span class="spectrum-Button-label"><slot /></span>
{/if}
</button>
2021-03-31 11:59:07 +02:00
<style>
2021-04-16 18:12:22 +02:00
.spectrum-Button-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
2021-04-26 17:02:03 +02:00
.active {
color: var(--spectrum-global-color-blue-600) !important;
}
2021-03-31 11:59:07 +02:00
</style>