Skip to content

Commit aebf462

Browse files
committed
docs(switch): active text
1 parent 7d3397f commit aebf462

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

docs/src/lib/i18n/zh/switch.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ export default {
55
cswitch02020:
66
'绑定 value 到一个 Boolean 类型的变量。 可以使用 --svel-switch-on-color 属性与 --svel-switch-off-color 属性来设置开关的背景色。',
77
cswitch03010: '尺寸',
8+
cswitch04010: '文字描述',
9+
cswitch04020:
10+
'使用activeText属性与inactiveText属性来设置开关的文字描述。 使用 inlinePrompt 属性来控制文本是否显示在点内。',
11+
cswitch04030: '使用activeText属性与inactiveText属性来设置开关的文字描述。',
812
};

docs/src/routes/component/switch/+page.svelte

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,11 @@
4141

4242
<Example
4343
code={`
44-
<script>
45-
import { SvelSwitch } from '@svelement-ui/all';
46-
let value1 = true;
47-
let value2 = true;
48-
@@@/>
49-
<SvelSwitch bind:value={value1} />
50-
<SvelSwitch
51-
bind:value={value2}
52-
class="ml-2"
53-
style="--svel-switch-on-color: #13ce66; --svel-switch-off-color: #ff4949"
54-
/>
44+
<SvelSwitch activeText="Open" inactiveText="Close" size="large" />
45+
<br />
46+
<SvelSwitch activeText="Open" inactiveText="Close" />
47+
<br />
48+
<SvelSwitch activeText="Open" inactiveText="Close" size="small" />
5549
`}
5650
>
5751
<SvelSwitch activeText="Open" inactiveText="Close" size="large" />
@@ -61,5 +55,45 @@
6155
<SvelSwitch activeText="Open" inactiveText="Close" size="small" />
6256
</Example>
6357

58+
<h2>{$langFn('cswitch04010')}</h2>
59+
<p>{$langFn('cswitch04020')}</p>
60+
<p>{$langFn('cswitch04030')}</p>
61+
62+
<Example
63+
code={`
64+
<SvelSwitch activeText="Open" inactiveText="Close" size="large" />
65+
<br />
66+
<SvelSwitch activeText="Open" inactiveText="Close" />
67+
<br />
68+
<SvelSwitch activeText="Open" inactiveText="Close" size="small" />
69+
`}
70+
>
71+
<SvelSwitch activeText="Pay by month" class="mb-2" inactiveText="Pay by year" />
72+
<br />
73+
<SvelSwitch
74+
activeText="Pay by month"
75+
class="mb-2"
76+
inactiveText="Pay by year"
77+
style="--svel-switch-on-color: #13ce66; --svel-switch-off-color: #ff4949"
78+
/>
79+
<br />
80+
<SvelSwitch activeText="" inactiveText="" inlinePrompt />
81+
<SvelSwitch
82+
activeText="Y"
83+
class="ml-2"
84+
inactiveText="N"
85+
inlinePrompt
86+
style="--svel-switch-on-color: #13ce66; --svel-switch-off-color: #ff4949"
87+
/>
88+
<SvelSwitch activeText="超出省略" class="ml-2" inactiveText="超出省略" inlinePrompt width="60" />
89+
<SvelSwitch
90+
activeText="完整展示多个内容"
91+
class="ml-2"
92+
inactiveText="多个内容"
93+
inlinePrompt
94+
style="--svel-switch-on-color: #13ce66; --svel-switch-off-color: #ff4949"
95+
/>
96+
</Example>
97+
6498
<style>
6599
</style>

0 commit comments

Comments
 (0)