Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Button]: deprecate fab prop in favor of iconOnly #673

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/example-ui-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function App() {
</Dropdown>
</div>
<ButtonMenu>
<LeoButton fab kind="plain-faint" slot="anchor-content">
<LeoButton iconOnly kind="plain-faint" slot="anchor-content">
<Icon name="more-horizontal" />
</LeoButton>
<leo-menu-item onClick={handleAction}>Llama2-13b</leo-menu-item>
Expand Down
2 changes: 1 addition & 1 deletion src/components/alert/alert.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<Slot name="content-after" explanation="optional content after the main content of the alert">
<Alert {...args} mode="simple">
Some content
<Button kind='plain-faint' fab slot="content-after">
<Button kind='plain-faint' iconOnly slot="content-after">
<Icon name="close" />
</Button>
</Alert>
Expand Down
4 changes: 2 additions & 2 deletions src/components/alert/alertCenter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</div>
<svelte:fragment slot='content-after'>
{#if alert.canDismiss}
<Button kind="plain-faint" fab onClick={() => alert.dismiss()}>
<Button kind="plain-faint" iconOnly onClick={() => alert.dismiss()}>
<Icon name="close" />
</Button>
{/if}
Expand All @@ -111,7 +111,7 @@
{#each alert.actions as action}
<Button
size={alert.mode === "full" ? "medium" : "small"}
fab={action.icon && !action.text}
iconOnly={action.icon && !action.text}
kind={action.kind || 'filled'}
onClick={() => action.action(alert)}
>
Expand Down
13 changes: 7 additions & 6 deletions src/components/button/button.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
},
kind: { control: 'select', options: buttonKinds },
size: { control: 'select', options: buttonSizes },
isDisabled: { control: 'boolean' }
isDisabled: { control: 'boolean' },
fab: { table: { disable: true } }
}}
/>

Expand Down Expand Up @@ -91,20 +92,20 @@

<Story name="Plain Faint" source args={{ kind: 'plain-faint' }} />

<Story name="FAB" let:args>
<Button {...args} fab>
<Story name="Icon Only" let:args>
<Button {...args} iconOnly>
<Icon name="check-circle-outline" />
</Button>
</Story>

<Story name="All" let:args>
{#each [false, true] as fab}
{#each [false, true] as iconOnly}
{#each buttonSizes as size}
<h2 class="label capitalize">{size}</h2>
<div class="button-group">
{#each buttonKinds as kind}
<Button {kind} {size} {fab} {...args}>
{#if !fab}
<Button {kind} {size} {iconOnly} {...args}>
{#if !iconOnly}
<span class="capitalize">{kind}</span>
{:else}
<Icon name="check-circle-outline" />
Expand Down
36 changes: 23 additions & 13 deletions src/components/button/button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
interface CommonProps {
kind?: Props.ButtonKind
size?: Props.ButtonSize
/**
* @deprecated Use `iconOnly` instead.
*/
fab?: boolean
iconOnly?: boolean
onClick?: () => void
}

Expand All @@ -46,7 +50,13 @@
export let isLoading: boolean = false
export let isDisabled: Disabled = undefined
export let href: Href = undefined

/**
* @deprecated Use `iconOnly` instead.
*/
export let fab = false
export let iconOnly: boolean = false
$: iconOnly = iconOnly || fab

export let onClick: () => void = undefined

Expand All @@ -67,24 +77,24 @@
class:isMedium={size === 'medium'}
class:isSmall={size === 'small'}
class:isTiny={size === 'tiny'}
class:fab
class:iconOnly
class:isLoading
disabled={isLoading || isDisabled || undefined}
on:click={onClick}
{...$$restProps}
>
{#if isLoading}
<div class:content={!fab}>
<div class:content={!iconOnly}>
{#if $$slots.loading}
<slot name="loading" />
{:else if !fab}
{:else if !iconOnly}
<slot>Leo Button</slot>
{/if}
</div>
<ProgressRing />
{:else}
<slot name="icon-before" />
<div class:content={!fab}>
<div class:content={!iconOnly}>
<slot>Leo Button</slot>
</div>
<slot name="icon-after" />
Expand Down Expand Up @@ -150,7 +160,7 @@
padding: var(--leo-button-padding, var(--padding-y) var(--padding-x));
max-height: max-content;

&.fab {
&.iconOnly {
max-width: max-content;
}

Expand Down Expand Up @@ -224,7 +234,7 @@
--leo-icon-size: var(--leo-icon-xs);
--icon-gap: var(--leo-spacing-m);

&.fab {
&.iconOnly {
min-height: 0;
--padding-x: 6px;
--padding-y: 6px;
Expand All @@ -239,7 +249,7 @@
--leo-icon-size: var(--leo-icon-s);
--icon-gap: var(--leo-spacing-m);

&.fab {
&.iconOnly {
min-height: 0;
--padding-x: var(--leo-spacing-m);
}
Expand All @@ -253,7 +263,7 @@
--leo-icon-size: var(--leo-icon-m);
--icon-gap: var(--leo-spacing-m);

&.fab {
&.iconOnly {
min-height: 0;
--padding-x: var(--leo-spacing-l);
--padding-y: var(--leo-spacing-l);
Expand All @@ -268,7 +278,7 @@
--leo-icon-size: var(--leo-icon-m);
--icon-gap: 10px;

&.fab {
&.iconOnly {
min-height: 0;
--padding-x: var(--leo-spacing-xl);
--padding-y: var(--leo-spacing-xl);
Expand All @@ -283,7 +293,7 @@
--leo-icon-size: var(--leo-icon-l);
--icon-gap: var(--leo-spacing-l);

&.fab {
&.iconOnly {
min-height: 0;
--padding-x: 18px;
--padding-y: 18px;
Expand Down Expand Up @@ -350,7 +360,7 @@
--color: var(--leo-color-text-primary);
}

&.fab {
&.iconOnly {
--radius: var(--leo-radius-m);
--bg-hover: transparent;
--padding-y: 0;
Expand Down Expand Up @@ -412,7 +422,7 @@
}
}

&.fab {
&.iconOnly {
--radius: var(--leo-radius-m);
--bg-hover: transparent;
--padding-y: 0;
Expand Down Expand Up @@ -467,7 +477,7 @@
}
}

.leoButton.fab {
.leoButton.iconOnly {
aspect-ratio: 1 / 1;
}
</style>
2 changes: 1 addition & 1 deletion src/components/tooltip/tooltip.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<div class="close">
<Button
kind="plain-faint"
fab
iconOnly
size="tiny"
onClick={() => (showTooltip = false)}
>
Expand Down