yyzone
Version:
yyzone vue components and utils
146 lines (125 loc) • 3.11 kB
text/less
@prefixSwitchCls: ~"@{yy-css-prefix}switch";
.@{prefixSwitchCls} {
display: inline-block;
box-sizing: border-box;
width: 28px;
height: 10px;
line-height: 8px;
border-radius: 40px;
vertical-align: middle;
border: 1px solid #B9BCC2;
background: linear-gradient(90deg, #858A94 0%, #B9BCC2 100%);
position: relative;
cursor: pointer;
user-select: none;
transition: all @yy-transition-time @yy-ease-in-out;
&-loading{
opacity: .4;
}
&-inner {
color: #fff;
font-size: @yy-font-size-small;
position: absolute;
left: 23px;
i {
width: 12px;
height: 12px;
text-align: center;
position: relative;
top: -1px;
}
}
&:after {
content: '';
width: 16px;
height: 16px;
margin-top: -8px;
top: 50%;
border-radius: 16px;
// background-color: #AEB8C2;
background-color: white;
position: absolute;
left: -1px;
cursor: pointer;
box-shadow:0px 2px 4px 0px rgba(0,0,0,0.07);
transition: background-color @yy-transition-time @yy-ease-in-out, left @yy-transition-time @yy-ease-in-out, width @yy-transition-time @yy-ease-in-out;
}
// &:active:after {
// width: 26px;
// }
&:before{
content: '';
display: none;
box-sizing: border-box;
width: 14px;
height: 14px;
border-radius: 50%;
background-color: transparent;
position: absolute;
left: 3px;
top: 3px;
z-index: 1;
border: 1px solid @yy-success-color;
border-color: transparent transparent transparent @yy-success-color;
animation: switch-loading 1s linear;
animation-iteration-count: infinite;
}
&-loading:before{
display: block;
}
&:focus {
outline: 0;
}
&-checked {
border-color: #6A98EB;
background: linear-gradient(270deg, #A4C0F3 0%, #6A98EB 100%);
.@{prefixSwitchCls}-inner {
left: 7px;
}
&:after {
left: 11px;
background-color: #fff;
}
&:before{
left: 25px;
}
// &:active:after {
// left: 15px;
// }
}
&-disabled {
.cursor();
opacity: .7;
&:after {
cursor: not-allowed;
}
.@{prefixSwitchCls}-inner {
color: #fff;
}
}
&-disabled&-checked{
border-color: @yy-success-color;
background-color: @yy-success-color;
opacity: .7;
&:after {
background-color: @yy-background-component;
}
.@{prefixSwitchCls}-inner {
color: #fff;
}
}
&-square {
border-radius: 3px;
&:after {
border-radius: 3px;
}
}
}
@keyframes switch-loading {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}