Skip to content

Commit 98c91f2

Browse files
committed
fix(switch): add inlinePrompt
1 parent 08c3ad0 commit 98c91f2

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/switch/src/lib/switch.svelte

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,15 @@
110110
</span>
111111
{/if}
112112
<span class="svel-switch__core">
113-
<div class="svel-switch__inner">
114-
{#if inactiveText || activeIcon}
115-
<SvelIcon />
116-
{/if}
117-
</div>
113+
{#if inlinePrompt}
114+
<div class="svel-switch__inner">
115+
{#if activeIcon || inactiveIcon}
116+
<SvelIcon />
117+
{:else if activeText || inactiveText}
118+
<span class="is-text" aria-hidden="!checked">{checked ? activeText : inactiveText}</span>
119+
{/if}
120+
</div>
121+
{/if}
118122
<div class="svel-switch__action">
119123
{#if loading}
120124
<SvelIcon>

packages/switch/src/routes/+page.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
<SvelSwitch size="large" />
1616
<SvelSwitch size="small" />
1717

18+
<SvelSwitch activeValue="100" bind:value={value2} inactiveValue="0" />
1819
<div />
1920
<SvelSwitch activeText="Pay by month" inactiveText="Pay by year" />
21+
<SvelSwitch activeText="Y" inactiveText="N" inlinePrompt />
2022

2123
<div />
22-
23-
<SvelSwitch activeValue="100" bind:value={value2} inactiveValue="0" />
24-
{value2}

0 commit comments

Comments
 (0)