mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
feat(button): add iconPosition
This commit is contained in:
parent
bcc7058ddf
commit
01494e60ba
2 changed files with 29 additions and 2 deletions
|
@ -23,6 +23,12 @@
|
|||
*/
|
||||
export let icon = undefined;
|
||||
|
||||
/**
|
||||
* Specify the position of the icon
|
||||
* @type {"left" | "right"} [iconPosition="right"]
|
||||
*/
|
||||
export let iconPosition = undefined;
|
||||
|
||||
/**
|
||||
* Specify the ARIA label for the button icon
|
||||
* @type {string} [iconDescription]
|
||||
|
@ -144,11 +150,19 @@
|
|||
on:mouseenter
|
||||
on:mouseleave
|
||||
>
|
||||
{#if icon && iconPosition === "left"}
|
||||
<svelte:component
|
||||
this="{icon}"
|
||||
aria-hidden="true"
|
||||
class="bx--btn__icon"
|
||||
aria-label="{iconDescription}"
|
||||
/>
|
||||
{/if}
|
||||
{#if hasIconOnly}
|
||||
<span class:bx--assistive-text="{true}">{iconDescription}</span>
|
||||
{/if}
|
||||
<slot />
|
||||
{#if icon}
|
||||
{#if icon && iconPosition === "right"}
|
||||
<svelte:component
|
||||
this="{icon}"
|
||||
aria-hidden="true"
|
||||
|
@ -166,11 +180,19 @@
|
|||
on:mouseenter
|
||||
on:mouseleave
|
||||
>
|
||||
{#if icon && iconPosition=== "left"}
|
||||
<svelte:component
|
||||
this="{icon}"
|
||||
aria-hidden="true"
|
||||
class="bx--btn__icon"
|
||||
aria-label="{iconDescription}"
|
||||
/>
|
||||
{/if}
|
||||
{#if hasIconOnly}
|
||||
<span class:bx--assistive-text="{true}">{iconDescription}</span>
|
||||
{/if}
|
||||
<slot />
|
||||
{#if icon}
|
||||
{#if icon && iconPosition=== "right"}
|
||||
<svelte:component
|
||||
this="{icon}"
|
||||
aria-hidden="true"
|
||||
|
|
5
types/index.d.ts
vendored
5
types/index.d.ts
vendored
|
@ -145,6 +145,11 @@ export class Button extends CarbonSvelteComponent {
|
|||
*/
|
||||
icon?: typeof import("carbon-icons-svelte/lib/Add16").default;
|
||||
|
||||
/**
|
||||
* Specify the position of the icon
|
||||
*/
|
||||
iconPosition?: "left" | "right";
|
||||
|
||||
/**
|
||||
* Specify the ARIA label for the button icon
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue