@isoftdata/svelte-button
Advanced tools
@@ -44,2 +44,4 @@ <script>import ButtonContents from "./ButtonContents.svelte"; | ||
| }; | ||
| $: | ||
| console.log("button has default slot?", $$slots.default); | ||
| </script> | ||
@@ -106,3 +108,4 @@ | ||
| {wrap} | ||
| {textClass}><slot /></ButtonContents | ||
| {textClass} | ||
| showText={!!$$slots.default}><slot /></ButtonContents | ||
| > | ||
@@ -109,0 +112,0 @@ </button> |
@@ -5,4 +5,7 @@ <script>import Icon from "@isoftdata/svelte-icon"; | ||
| export let textClass = null; | ||
| export let showText = $$slots.default; | ||
| $: | ||
| hasTextAndIcon = !!icon.class && $$slots.default; | ||
| hasTextAndIcon = !!icon.icon && $$slots.default && showText; | ||
| $: | ||
| console.log({ hasTextAndIcon }); | ||
| </script> | ||
@@ -18,6 +21,8 @@ | ||
| {/if} | ||
| <span | ||
| id="buttonText" | ||
| class={textClass}><slot /></span | ||
| > | ||
| {#if showText} | ||
| <span | ||
| id="buttonText" | ||
| class={textClass}><slot /></span | ||
| > | ||
| {/if} | ||
| </span> | ||
@@ -24,0 +29,0 @@ |
@@ -15,2 +15,3 @@ import { SvelteComponent } from "svelte"; | ||
| textClass?: string | null | undefined; | ||
| showText?: boolean | undefined; | ||
| }; | ||
@@ -17,0 +18,0 @@ events: { |
+1
-1
| { | ||
| "name": "@isoftdata/svelte-button", | ||
| "version": "1.1.4", | ||
| "version": "1.1.5", | ||
| "scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "vite dev", |
+1
-0
| # Svelte Button | ||
| This component will conditionally render a HTML `<button>` or `<a>` element based on if a `href` prop is passed. This component uses Svelte's [`$$restProps`](https://svelte.dev/docs/basic-markup#attributes-and-props) to apply any additional props you pass as attributes on the HTML element. | ||
@@ -3,0 +4,0 @@ ## Install |
10859
5.87%92
1.1%59
1.72%