update ActionButton interface

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-23 15:45:10 +02:00
parent d9d63df478
commit e7b8ec4223
6 changed files with 21 additions and 8 deletions

View File

@ -3,8 +3,6 @@
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
/** @type {('S', 'M', 'L', 'XL')} Size of button */
export let size = "M"
export let quiet = false export let quiet = false
export let emphasized = false export let emphasized = false
export let selected = false export let selected = false
@ -12,6 +10,12 @@
export let disabled = false export let disabled = false
export let icon = "" export let icon = ""
export let xl = false
export let l = false
export let m = false
export let s = false
$: useDefault = ![xl, l, m, s].includes(true)
function longPress(element) { function longPress(element) {
if (!longPressable) return if (!longPressable) return
let timer let timer
@ -38,7 +42,11 @@
class:spectrum-ActionButton--quiet={quiet} class:spectrum-ActionButton--quiet={quiet}
class:spectrum-ActionButton--emphasized={emphasized} class:spectrum-ActionButton--emphasized={emphasized}
class:is-selected={selected} class:is-selected={selected}
class="spectrum-ActionButton spectrum-ActionButton--size{size.toUpperCase()}" class:spectrum-ActionButton--sizeS={s}
class:spectrum-ActionButton--sizeM={m || useDefault}
class:spectrum-ActionButton--sizeL={l}
class:spectrum-ActionButton--sizeXL={xl}
class="spectrum-ActionButton"
{disabled} {disabled}
on:longPress on:longPress
on:click|preventDefault on:click|preventDefault
@ -54,7 +62,11 @@
{/if} {/if}
{#if icon} {#if icon}
<svg <svg
class="spectrum-Icon spectrum-Icon--size{size.toUpperCase()}" class:spectrum-Icon--sizeS={s}
class:spectrum-Icon--sizeM={m || useDefault}
class:spectrum-Icon--sizeL={l}
class:spectrum-Icon--sizeXL={xl}
class="spectrum-Icon"
focusable="false" focusable="false"
aria-hidden="true" aria-hidden="true"
aria-label={icon} aria-label={icon}

View File

@ -42,7 +42,7 @@
</div> </div>
<div class="buttons"> <div class="buttons">
<slot name="buttons" /> <slot name="buttons" />
<ActionButton selected quiet icon="Close" on:click={hide} /> <ActionButton quiet icon="Close" on:click={hide} />
</div> </div>
</header> </header>
<slot name="body" /> <slot name="body" />

View File

@ -13,5 +13,5 @@
<Checkbox value={selected} /> <Checkbox value={selected} />
{/if} {/if}
{#if allowEditRows} {#if allowEditRows}
<ActionButton size="s" on:click={onEdit}>Edit</ActionButton> <ActionButton s on:click={onEdit}>Edit</ActionButton>
{/if} {/if}

View File

@ -65,8 +65,8 @@
{#each tabs as tab, idx} {#each tabs as tab, idx}
<div bind:this={anchors[idx]}> <div bind:this={anchors[idx]}>
<ActionButton <ActionButton
size="S"
quiet quiet
s
icon={tab.icon} icon={tab.icon}
disabled={tab.disabled} disabled={tab.disabled}
on:click={tab.disabled ? null : () => onChangeTab(idx)}> on:click={tab.disabled ? null : () => onChangeTab(idx)}>

View File

@ -70,6 +70,7 @@
bindings={bindableProperties} bindings={bindableProperties}
on:change={event => updateFieldValue(idx, event.detail)} /> on:change={event => updateFieldValue(idx, event.detail)} />
<ActionButton <ActionButton
s
quiet quiet
icon="Delete" icon="Delete"
on:click={() => removeField(field[0])} /> on:click={() => removeField(field[0])} />

View File

@ -29,7 +29,7 @@
<Heading s>{name}</Heading> <Heading s>{name}</Heading>
<Spacer medium /> <Spacer medium />
<div class="card-footer" data-cy={`app-${name}`}> <div class="card-footer" data-cy={`app-${name}`}>
<ActionButton text medium blue on:click={() => $goto(`/builder/${_id}`)}> <ActionButton on:click={() => $goto(`/builder/${_id}`)}>
Open Open
{name} {name}