mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
feat: make icons slottable
This commit is contained in:
parent
d9ee8cb2d9
commit
8591c592fe
7 changed files with 48 additions and 19 deletions
|
@ -245,7 +245,9 @@
|
||||||
>
|
>
|
||||||
{#if indented}
|
{#if indented}
|
||||||
<div class:bx--menu-option__icon="{true}">
|
<div class:bx--menu-option__icon="{true}">
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span class:bx--menu-option__label="{true}" title="{labelText}">
|
<span class:bx--menu-option__label="{true}" title="{labelText}">
|
||||||
|
@ -268,7 +270,9 @@
|
||||||
>
|
>
|
||||||
{#if indented}
|
{#if indented}
|
||||||
<div class:bx--menu-option__icon="{true}">
|
<div class:bx--menu-option__icon="{true}">
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span class:bx--menu-option__label="{true}" title="{labelText}">
|
<span class:bx--menu-option__label="{true}" title="{labelText}">
|
||||||
|
|
|
@ -45,9 +45,14 @@
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
on:mouseleave
|
on:mouseleave
|
||||||
>
|
>
|
||||||
<slot />{#if !inline && icon}<div class:bx--link__icon="{true}">
|
<slot />
|
||||||
|
{#if !inline && ($$slots.icon || icon)}
|
||||||
|
<div class:bx--link__icon="{true}">
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
</div>{/if}
|
</slot>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
<a
|
<a
|
||||||
|
@ -65,8 +70,14 @@
|
||||||
on:mouseover
|
on:mouseover
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
on:mouseleave
|
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}
|
{/if}
|
||||||
|
|
|
@ -120,9 +120,11 @@
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
on:mouseleave
|
on:mouseleave
|
||||||
>
|
>
|
||||||
{#if icon}
|
{#if $$slots.icon || icon}
|
||||||
<div class:bx--tag__custom-icon="{true}">
|
<div class:bx--tag__custom-icon="{true}">
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span>
|
<span>
|
||||||
|
@ -153,9 +155,11 @@
|
||||||
on:mouseenter
|
on:mouseenter
|
||||||
on:mouseleave
|
on:mouseleave
|
||||||
>
|
>
|
||||||
{#if icon}
|
{#if $$slots.icon || icon}
|
||||||
<div class:bx--tag__custom-icon="{true}">
|
<div class:bx--tag__custom-icon="{true}">
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span>
|
<span>
|
||||||
|
|
|
@ -64,9 +64,13 @@
|
||||||
}}"
|
}}"
|
||||||
>
|
>
|
||||||
{#if isOpen}
|
{#if isOpen}
|
||||||
|
<slot name="closeIcon">
|
||||||
<svelte:component this="{closeIcon}" />
|
<svelte:component this="{closeIcon}" />
|
||||||
|
</slot>
|
||||||
{:else}
|
{:else}
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
{/if}
|
{/if}
|
||||||
<slot name="text">
|
<slot name="text">
|
||||||
{#if text}<span>{text}</span>{/if}
|
{#if text}<span>{text}</span>{/if}
|
||||||
|
|
|
@ -26,7 +26,9 @@
|
||||||
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
|
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
>
|
>
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -35,12 +35,14 @@
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
>
|
>
|
||||||
{#if icon}
|
{#if $$slots.icon || icon}
|
||||||
<div
|
<div
|
||||||
class:bx--side-nav__icon="{true}"
|
class:bx--side-nav__icon="{true}"
|
||||||
class:bx--side-nav__icon--small="{true}"
|
class:bx--side-nav__icon--small="{true}"
|
||||||
>
|
>
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span class:bx--side-nav__link-text="{true}">{text}</span>
|
<span class:bx--side-nav__link-text="{true}">{text}</span>
|
||||||
|
|
|
@ -32,9 +32,11 @@
|
||||||
expanded = !expanded;
|
expanded = !expanded;
|
||||||
}}"
|
}}"
|
||||||
>
|
>
|
||||||
{#if icon}
|
{#if $$slots.icon || icon}
|
||||||
<div class:bx--side-nav__icon="{true}">
|
<div class:bx--side-nav__icon="{true}">
|
||||||
|
<slot name="icon">
|
||||||
<svelte:component this="{icon}" />
|
<svelte:component this="{icon}" />
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span class:bx--side-nav__submenu-title="{true}">{text}</span>
|
<span class:bx--side-nav__submenu-title="{true}">{text}</span>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue