@isoftdata/svelte-button
Advanced tools
@@ -8,3 +8,2 @@ <script lang="ts"> | ||
| import { getIconProps } from '@isoftdata/svelte-icon' | ||
| import clsx from 'clsx' | ||
@@ -14,3 +13,2 @@ type IconProps = ComponentProps<Icon> | ||
| interface Props extends Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'class' | 'color' | 'disabled' | 'type' | keyof AriaAttributes | `bind:${string}` | `on:${string}`> { | ||
| block?: boolean | ||
| button?: HTMLButtonElement | HTMLAnchorElement | undefined | ||
@@ -41,3 +39,2 @@ class?: ClassValue | ||
| let { | ||
| block = false, | ||
| button = $bindable(undefined), | ||
@@ -75,3 +72,3 @@ class: className = '', | ||
| let computedSize = $derived(size ? `btn-${size}` : '') | ||
| let computedClass = $derived(clsx(`btn ${computedSize} ${computedColor}`, className)) | ||
| let computedClass = $derived(['btn', computedSize, computedColor, className]) | ||
@@ -93,3 +90,2 @@ let computedIcon: IconProps = $derived( | ||
| class={computedClass} | ||
| class:btn-block={block} | ||
| class:disabled={disabled || isLoading} | ||
@@ -113,3 +109,2 @@ class:cursor-not-allowed={disabled || isLoading} | ||
| {title} | ||
| class:btn-block={block} | ||
| class={computedClass} | ||
@@ -116,0 +111,0 @@ disabled={disabled || isLoading} |
@@ -8,3 +8,2 @@ import type { ComponentProps, Snippet } from 'svelte'; | ||
| interface Props extends Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'class' | 'color' | 'disabled' | 'type' | keyof AriaAttributes | `bind:${string}` | `on:${string}`> { | ||
| block?: boolean; | ||
| button?: HTMLButtonElement | HTMLAnchorElement | undefined; | ||
@@ -11,0 +10,0 @@ class?: ClassValue; |
+2
-1
| { | ||
| "name": "@isoftdata/svelte-button", | ||
| "version": "2.0.5", | ||
| "version": "2.1.0", | ||
| "scripts": { | ||
@@ -49,2 +49,3 @@ "dev": "vite dev", | ||
| "tslib": "^2.4.1", | ||
| "type-fest": "^4.39.1", | ||
| "typescript": "^5.5.0", | ||
@@ -51,0 +52,0 @@ "vite": "^6.2.0" |
+1
-1
@@ -17,2 +17,3 @@ # Svelte Button | ||
| - Deprecate `iconClass` prop. The `icon` prop can now accept an icon name or an object | ||
| - Removed `block` prop. Bootstrap 5 no longer supports the `btn-block` class. Apply `d-block w-100` classes for the same behavior. | ||
@@ -23,3 +24,2 @@ ## Props | ||
| | --- | --- | --- | --- | | ||
| | `block` | `boolean` | Render the button as block, spanning the whole width of its parent. | `false` | | ||
| | `button` | `HTMLButtonElement \| HTMLAnchorElement` | Either the `<button>` or `<a>`. Useful if you want to fire events directly on it. | (The button or anchor tag) | | ||
@@ -26,0 +26,0 @@ | `color` | `"primary" \| "secondary" \| "success" \| "danger" \| "warning" \| "info" \| "light" \| "dark"` | The bootstrap color of the button. | `"primary"` | |
9435
-3.65%21
5%36
-2.7%