forked from iview/iview
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71a091b
commit e08998c
Showing
3 changed files
with
276 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
<template> | ||
<div> | ||
<i-switch v-model="m1" true-value="yes" false-value="no"> | ||
<i-switch class="bsc-switch-only-text"> | ||
<span slot="open">开</span> | ||
<span slot="close">关</span> | ||
</i-switch> | ||
<i-switch> | ||
<span slot="open">开</span> | ||
<span slot="close">关</span> | ||
</i-switch> | ||
<i-switch disabled> | ||
<span slot="open">开</span> | ||
<span slot="close">关</span> | ||
</i-switch> | ||
<i-switch class="bsc-switch-only-text" disabled> | ||
<span slot="open">开</span> | ||
<span slot="close">关</span> | ||
</i-switch> | ||
{{ m1 }} | ||
<div @click="m1 = 'no'">toggle</div> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
data () { | ||
return { | ||
m1: 'yes' | ||
} | ||
}; | ||
}, | ||
methods: { | ||
change (status) { | ||
console.log(status) | ||
} | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
@switch-prefix-cls: ~"@{css-prefix}switch"; | ||
@switch-prefix-cls-only-text: ~"@{css-prefix}switch-only-text"; | ||
|
||
.@{switch-prefix-cls} { | ||
display: inline-block; | ||
width: 48px; | ||
height: 24px; | ||
line-height: 22px; | ||
border-radius: 24px; | ||
vertical-align: middle; | ||
border: 1px solid #53626d; | ||
background-color: #414d56; | ||
position: relative; | ||
cursor: pointer; | ||
user-select: none; | ||
transition: all @transition-time @ease-in-out; | ||
|
||
&-inner { | ||
color: #71818d; | ||
font-size: @font-size-small; | ||
position: absolute; | ||
left: 25px; | ||
|
||
i { | ||
width: 12px; | ||
height: 12px; | ||
text-align: center; | ||
} | ||
} | ||
|
||
&:after { | ||
content: ''; | ||
width: 20px; | ||
height: 20px; | ||
border-radius: 20px; | ||
background-color: #71818d; | ||
position: absolute; | ||
left: 1px; | ||
top: 1px; | ||
cursor: pointer; | ||
transition: left @transition-time @ease-in-out, width @transition-time @ease-in-out; | ||
} | ||
|
||
&:active:after { | ||
width: 26px; | ||
} | ||
|
||
&:focus { | ||
box-shadow: 0 0 0 2px fade(@primary-color, 20%); | ||
outline: 0; | ||
} | ||
|
||
&:focus:hover { | ||
box-shadow: none; | ||
} | ||
|
||
&-small { | ||
width: 24px; | ||
height: 12px; | ||
line-height: 10px; | ||
&:after { | ||
width: 10px; | ||
height: 10px; | ||
top: 0; | ||
left: 0; | ||
} | ||
&:active:after { | ||
width: 14px; | ||
} | ||
} | ||
|
||
&-small&-checked:after { | ||
left: 12px; | ||
} | ||
|
||
&-small:active&-checked:after { | ||
left: 8px; | ||
} | ||
|
||
&-large{ | ||
width: 60px; | ||
&:active:after { | ||
width: 26px; | ||
} | ||
} | ||
|
||
&-large:active:after { | ||
width: 32px; | ||
} | ||
|
||
&-large&-checked:after { | ||
left: 37px; | ||
} | ||
|
||
&-large:active&-checked:after { | ||
left: 25px; | ||
} | ||
|
||
&-checked { | ||
border-color: @btn-primary-bg; | ||
background-color: @btn-primary-bg; | ||
|
||
.@{switch-prefix-cls}-inner { | ||
left: 8px; | ||
color: #fff; | ||
} | ||
|
||
&:after { | ||
left: 25px; | ||
background-color: #fff; | ||
} | ||
|
||
&:active:after { | ||
left: 19px; | ||
} | ||
} | ||
|
||
&-disabled { | ||
cursor: @cursor-disabled; | ||
background: #414d56; | ||
border-color: #53626d; | ||
|
||
&:after { | ||
background: #53626d; | ||
cursor: not-allowed; | ||
} | ||
|
||
.@{switch-prefix-cls}-inner { | ||
color: #53626d; | ||
} | ||
} | ||
} | ||
|
||
.@{switch-prefix-cls-only-text} { | ||
display: inline-block; | ||
width: 50px; | ||
height: 26px; | ||
line-height: 24px; | ||
border-radius: 24px; | ||
vertical-align: middle; | ||
border: 2px solid #53626d; | ||
background-color: @btn-primary-bg; | ||
position: relative; | ||
cursor: pointer; | ||
user-select: none; | ||
transition: all @transition-time @ease-in-out; | ||
|
||
&-inner { | ||
color: #71818d; | ||
font-size: @font-size-small; | ||
position: absolute; | ||
left: 25px; | ||
|
||
i { | ||
width: 12px; | ||
height: 12px; | ||
text-align: center; | ||
} | ||
} | ||
|
||
&:after { | ||
content: ''; | ||
width: 20px; | ||
height: 20px; | ||
border-radius: 20px; | ||
background-color: #71818d; | ||
position: absolute; | ||
left: 1px; | ||
top: 1px; | ||
cursor: pointer; | ||
transition: left @transition-time @ease-in-out, width @transition-time @ease-in-out; | ||
} | ||
|
||
&:active:after { | ||
width: 26px; | ||
} | ||
|
||
&:focus { | ||
box-shadow: 0 0 0 2px fade(@primary-color, 20%); | ||
outline: 0; | ||
} | ||
|
||
&:focus:hover { | ||
box-shadow: none; | ||
} | ||
|
||
&-small { | ||
width: 24px; | ||
height: 12px; | ||
line-height: 10px; | ||
&:after { | ||
width: 10px; | ||
height: 10px; | ||
top: 0; | ||
left: 0; | ||
} | ||
&:active:after { | ||
width: 14px; | ||
} | ||
} | ||
|
||
&-small&-checked:after { | ||
left: 12px; | ||
} | ||
|
||
&-small:active&-checked:after { | ||
left: 8px; | ||
} | ||
|
||
&-large{ | ||
width: 60px; | ||
&:active:after { | ||
width: 26px; | ||
} | ||
} | ||
|
||
&-large:active:after { | ||
width: 32px; | ||
} | ||
|
||
&-large&-checked:after { | ||
left: 37px; | ||
} | ||
|
||
&-large:active&-checked:after { | ||
left: 25px; | ||
} | ||
|
||
&-checked { | ||
background-color: @btn-primary-bg; | ||
|
||
.@{switch-prefix-cls-only-text}-inner { | ||
left: 8px; | ||
color: #fff; | ||
} | ||
|
||
&:after { | ||
left: 25px; | ||
} | ||
|
||
&:active:after { | ||
left: 19px; | ||
} | ||
} | ||
|
||
&-disabled { | ||
cursor: @cursor-disabled; | ||
background: #414d56; | ||
border-color: #53626d; | ||
|
||
&:after { | ||
background: #53626d; | ||
cursor: not-allowed; | ||
} | ||
|
||
.@{switch-prefix-cls-only-text}-inner { | ||
color: #53626d; | ||
} | ||
} | ||
} |