From cd646824c220a22e2de425019d236a3188c0aea0 Mon Sep 17 00:00:00 2001 From: Aex Date: Sat, 30 Oct 2021 21:23:29 +0800 Subject: [PATCH] feat(components): el-switch add inline content support (#4091) * refactor(components): el-swtich custom texts and icons * fix: test * fix: font size * fix: example margin * feat(components): el-switch add inline-prompt support * revert: paly * docs: update icons * feat: add inner text * fix: switch test * refactor: icon inline --- docs/en-US/component/switch.md | 13 ++++- docs/examples/switch/custom-icons.vue | 20 ++++++-- docs/examples/switch/text-description.vue | 15 +++++- .../switch/__tests__/switch.spec.ts | 19 +++++++ packages/components/switch/src/index.vue | 45 ++++++++++++++++- packages/theme-chalk/src/switch.scss | 49 ++++++++++++++++++- 6 files changed, 151 insertions(+), 10 deletions(-) diff --git a/docs/en-US/component/switch.md b/docs/en-US/component/switch.md index 56757670cc..6745df3603 100644 --- a/docs/en-US/component/switch.md +++ b/docs/en-US/component/switch.md @@ -7,6 +7,14 @@ lang: en-US Switch is used for switching between two opposing states. + + ## Basic usage :::demo Bind `v-model` to a `Boolean` typed variable. The `active-color` and `inactive-color` attribute decides the background color in two states. @@ -17,6 +25,8 @@ switch/basic ## Text description +You can add `active-text` and `inactive-text` attribute to show texts. use `inline-prompt` attribute to control text is displayed inside dot. + :::demo You can add `active-text` and `inactive-text` attribute to show texts. switch/text-description @@ -31,7 +41,7 @@ Use the `active-icon` and `active-icon` attribute to add icon. You can pass eith ::: -:::demo You can add `active-icon` and `active-icon` attribute to show icons. +:::demo You can add `active-icon` and `inactive-icon` attribute to show icons. use `inline-prompt` attribute to control icon is displayed inside dot. switch/custom-icons @@ -77,6 +87,7 @@ switch/prevent-switching | disabled | whether Switch is disabled | boolean | — | false | | loading | whether Switch is in loading state | boolean | — | false | | width | width of Switch | number | — | 40 | +| inline-prompt | whether icon or text is displayed inside dot | boolean | — | false | | active-icon | component of the icon displayed when in `on` state, overrides `active-text` | string / Component | — | — | | inactive-icon | component of the icon displayed when in `off` state, overrides `inactive-text` | string / Component | — | — | | active-text | text displayed when in `on` state | string | — | — | diff --git a/docs/examples/switch/custom-icons.vue b/docs/examples/switch/custom-icons.vue index aa3bc2ba87..7084c475cf 100644 --- a/docs/examples/switch/custom-icons.vue +++ b/docs/examples/switch/custom-icons.vue @@ -1,16 +1,26 @@