Skip to content

Commit

Permalink
fix(switch): disabled bug
Browse files Browse the repository at this point in the history
  • Loading branch information
koory1st committed Mar 5, 2024
1 parent 72b2185 commit 1e9f693
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/src/lib/i18n/zh/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ export default {
cswitch06010: '扩展的 value 类型',
cswitch06020:
'你可以设置 activeValue 和 inactiveValue 属性, 它们接受 Boolean、String 或 Number 类型的值。',
cswitch07010: '禁用状态',
cswitch07020: '设置disabled属性,接受一个Boolean,设置true即可禁用。',
};
14 changes: 14 additions & 0 deletions docs/src/routes/component/switch/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
let value2 = true;
let value3 = '100';
let value4 = true;
</script>

<h1>{$langFn('cswitch01010')}</h1>
Expand Down Expand Up @@ -144,5 +145,18 @@
</SvelTooltip>
</Example>

<h2>{$langFn('cswitch07010')}</h2>
<p>{$langFn('cswitch07020')}</p>

<Example
code={`
<SvelSwitch bind:value={value4} disabled />
<SvelSwitch class="ml-2" />
`}
>
<SvelSwitch bind:value={value4} disabled />
<SvelSwitch class="ml-2" />
</Example>

<style>
</style>
2 changes: 1 addition & 1 deletion packages/switch/src/lib/switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$: isControlled = value !== false;
$: actualValue = value;
$: checked = actualValue === activeValue;
$: switchDisabled = loading;
$: switchDisabled = loading || disabled;
$: switchKls = a2s([
'svel-switch',
['is-checked', checked],
Expand Down

0 comments on commit 1e9f693

Please sign in to comment.