Skip to content

Commit

Permalink
fix(switch): activeAction
Browse files Browse the repository at this point in the history
  • Loading branch information
koory1st committed Mar 9, 2024
1 parent 27294ba commit b318429
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
17 changes: 13 additions & 4 deletions docs/src/routes/component/switch/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@

<Example
code={`
<SvelSwitch bind:value={value5} loading />
<SvelSwitch class="ml-2" loading />
<SvelSwitch bind:value={value5} loading />
<SvelSwitch class="ml-2" loading />
`}
>
<SvelSwitch bind:value={value5} loading />
Expand Down Expand Up @@ -226,8 +226,8 @@
});
};
@@@/>
<SvelSwitch beforeChange={beforeChange1} bind:value={value6} loading={loading1} />
<SvelSwitch beforeChange={beforeChange2} bind:value={value7} loading={loading2} />
<SvelSwitch beforeChange={beforeChange1} bind:value={value6} loading={loading1} />
<SvelSwitch beforeChange={beforeChange2} bind:value={value7} loading={loading2} />
`}
>
<SvelSwitch beforeChange={beforeChange1} bind:value={value6} loading={loading1} />
Expand All @@ -239,12 +239,21 @@

<Example
code={`
<SvelSwitch>
<View slot="activeActionIcon" />
<Hide slot="inactiveActionIcon" />
</SvelSwitch>
`}
>
<SvelSwitch>
<View slot="activeActionIcon" />
<Hide slot="inactiveActionIcon" />
</SvelSwitch>

<SvelSwitch>
<span slot="activeAction">T</span>
<span slot="inactiveAction">F</span>
</SvelSwitch>
</Example>

<style>
Expand Down
4 changes: 4 additions & 0 deletions packages/switch/src/lib/switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@
<SvelIcon>
<slot name="activeActionIcon" />
</SvelIcon>
{:else if $$slots.activeAction && checked}
<slot name="activeAction" />
{:else if $$slots.inactiveActionIcon && !checked}
<SvelIcon>
<slot name="inactiveActionIcon" />
</SvelIcon>
{:else if $$slots.inactiveAction && !checked}
<slot name="inactiveAction" />
{/if}
</div>
</span>
Expand Down
4 changes: 2 additions & 2 deletions packages/switch/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@

<div />
<SvelSwitch bind:value>
<span slot="activeActionIcon">T</span>
<span slot="inactiveActionIcon">F</span>
<span slot="activeAction">T</span>
<span slot="inactiveAction">F</span>
</SvelSwitch>

<SvelSwitch bind:focus bind:value />
Expand Down

0 comments on commit b318429

Please sign in to comment.