From dfb77ed72e35fc153caffd99f8a7c5683e543011 Mon Sep 17 00:00:00 2001 From: militant_gnome Date: Mon, 15 Jan 2024 18:06:21 +0200 Subject: [PATCH 1/9] Button: "icon" named slot added as an alternative to the icon prop --- src/Button/Button.svelte | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Button/Button.svelte b/src/Button/Button.svelte index 400e68d06d..e182f29311 100644 --- a/src/Button/Button.svelte +++ b/src/Button/Button.svelte @@ -27,6 +27,8 @@ /** * Specify the icon to render + * Alternatively, use the named slot "icon" (e.g., ``) + * * @type {typeof import("svelte").SvelteComponent} */ export let icon = undefined; @@ -85,7 +87,12 @@ $: if (ctx && ref) { ctx.declareRef(ref); } - $: hasIconOnly = icon && !$$slots.default; + $: hasIconOnly = (icon || $$slots.icon) && !$$slots.default; + $: iconProps = { + "aria-hidden": "true", + class: "bx--btn__icon", + "aria-label": iconDescription, + }; $: buttonProps = { type: href && !disabled ? undefined : type, tabindex, @@ -158,12 +165,12 @@ {#if hasIconOnly} {iconDescription} {/if} -