feat: make icons slottable (#1186)

This commit is contained in:
metonym 2022-03-19 11:37:20 -07:00 committed by GitHub
commit e23b121143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 139 additions and 46 deletions

View file

@ -245,7 +245,9 @@
>
{#if indented}
<div class:bx--menu-option__icon="{true}">
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
<span class:bx--menu-option__label="{true}" title="{labelText}">
@ -268,7 +270,9 @@
>
{#if indented}
<div class:bx--menu-option__icon="{true}">
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
<span class:bx--menu-option__label="{true}" title="{labelText}">

View file

@ -45,9 +45,14 @@
on:mouseenter
on:mouseleave
>
<slot />{#if !inline && icon}<div class:bx--link__icon="{true}">
<svelte:component this="{icon}" />
</div>{/if}
<slot />
{#if !inline && ($$slots.icon || icon)}
<div class:bx--link__icon="{true}">
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
</p>
{:else}
<a
@ -65,8 +70,14 @@
on:mouseover
on:mouseenter
on:mouseleave
><slot />{#if !inline && icon}<div class:bx--link__icon="{true}">
<svelte:component this="{icon}" />
</div>{/if}</a
>
<slot />
{#if !inline && ($$slots.icon || icon)}
<div class:bx--link__icon="{true}">
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
</a>
{/if}

View file

@ -120,9 +120,11 @@
on:mouseenter
on:mouseleave
>
{#if icon}
{#if $$slots.icon || icon}
<div class:bx--tag__custom-icon="{true}">
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
<span>
@ -153,9 +155,11 @@
on:mouseenter
on:mouseleave
>
{#if icon}
{#if $$slots.icon || icon}
<div class:bx--tag__custom-icon="{true}">
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
<span>

View file

@ -64,9 +64,13 @@
}}"
>
{#if isOpen}
<svelte:component this="{closeIcon}" />
<slot name="closeIcon">
<svelte:component this="{closeIcon}" />
</slot>
{:else}
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
{/if}
<slot name="text">
{#if text}<span>{text}</span>{/if}

View file

@ -26,7 +26,9 @@
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
{...$$restProps}
>
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</a>
<style>

View file

@ -35,12 +35,14 @@
{...$$restProps}
on:click
>
{#if icon}
{#if $$slots.icon || icon}
<div
class:bx--side-nav__icon="{true}"
class:bx--side-nav__icon--small="{true}"
>
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
<span class:bx--side-nav__link-text="{true}">{text}</span>

View file

@ -32,9 +32,11 @@
expanded = !expanded;
}}"
>
{#if icon}
{#if $$slots.icon || icon}
<div class:bx--side-nav__icon="{true}">
<svelte:component this="{icon}" />
<slot name="icon">
<svelte:component this="{icon}" />
</slot>
</div>
{/if}
<span class:bx--side-nav__submenu-title="{true}">{text}</span>