This commit is contained in:
Bilux 2023-05-19 01:32:28 +00:00 committed by GitHub
commit fced7b39c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View file

@ -25,6 +25,11 @@
*/
export let isSelected = false;
/**
* Set to `true` for the icon-only variant
*/
export let iconOnly = false;
/**
* Specify the icon to render
* @type {typeof import("svelte").SvelteComponent}
@ -85,7 +90,7 @@
$: if (ctx && ref) {
ctx.declareRef(ref);
}
$: hasIconOnly = icon && !$$slots.default;
$: hasIconOnly = iconOnly || (icon && !$$slots.default);
$: buttonProps = {
type: href && !disabled ? undefined : type,
tabindex,
@ -152,8 +157,10 @@
>
{#if hasIconOnly}
<span class:bx--assistive-text="{true}">{iconDescription}</span>
{:else}
<slot />
{/if}
<slot /><svelte:component
<svelte:component
this="{icon}"
aria-hidden="true"
class="bx--btn__icon"
@ -171,8 +178,10 @@
>
{#if hasIconOnly}
<span class:bx--assistive-text="{true}">{iconDescription}</span>
{:else}
<slot />
{/if}
<slot /><svelte:component
<svelte:component
this="{icon}"
aria-hidden="true"
class="bx--btn__icon"

View file

@ -38,6 +38,12 @@ export interface ButtonProps
*/
isSelected?: boolean;
/**
* Set to `true` for the icon-only variant
* @default false
*/
iconOnly?: boolean;
/**
* Specify the icon to render
* @default undefined