feat(button): derive hasIconOnly from icon and slots

Instead of explicitly defining hasIconOnly, its value can be inferred from a falsy icon prop and an empty slot.
This commit is contained in:
Eric Liu 2019-12-23 18:46:22 -08:00
commit 2d3edce3ca
2 changed files with 2 additions and 2 deletions

View file

@ -50,7 +50,7 @@
{:else if story === 'inline'} {:else if story === 'inline'}
<Button /> <Button />
{:else if story === 'icon-only buttons'} {:else if story === 'icon-only buttons'}
<Button {...iconOnlyProps} hasIconOnly /> <Button {...iconOnlyProps} />
{:else if story === 'set of buttons'} {:else if story === 'set of buttons'}
<div class={cx('--btn-set')}> <div class={cx('--btn-set')}>
<Button kind="secondary" {...setProps}>Secondary button</Button> <Button kind="secondary" {...setProps}>Secondary button</Button>

View file

@ -11,7 +11,6 @@
export let type = 'button'; export let type = 'button';
export let icon = undefined; export let icon = undefined;
export let iconDescription = undefined; export let iconDescription = undefined;
export let hasIconOnly = false;
export let tooltipPosition = undefined; export let tooltipPosition = undefined;
export let tooltipAlignment = undefined; export let tooltipAlignment = undefined;
export let style = undefined; export let style = undefined;
@ -19,6 +18,7 @@
import { getContext } from 'svelte'; import { getContext } from 'svelte';
import { cx } from '../../lib'; import { cx } from '../../lib';
const hasIconOnly = !!icon && !$$props.$$slots;
const ctx = getContext('ComposedModal'); const ctx = getContext('ComposedModal');
let buttonRef = undefined; let buttonRef = undefined;