2019-04-30 11:11:25 +08:00
|
|
|
.#{$ns}Switch {
|
2019-12-06 09:58:08 +08:00
|
|
|
cursor: pointer;
|
|
|
|
position: relative;
|
|
|
|
display: inline-block;
|
2020-12-21 10:08:40 +08:00
|
|
|
width: var(--Switch-width);
|
|
|
|
height: var(--Switch-height);
|
2019-12-06 09:58:08 +08:00
|
|
|
overflow: hidden;
|
|
|
|
border-radius: px2rem(30px);
|
2020-12-21 10:08:40 +08:00
|
|
|
background: var(--Switch-onActive-bgColor);
|
2019-12-06 09:58:08 +08:00
|
|
|
margin: 0;
|
|
|
|
vertical-align: middle;
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
&.is-disabled {
|
2020-12-21 10:08:40 +08:00
|
|
|
background: var(--Switch-onDisabled-bgColor);
|
2019-12-06 09:58:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
i {
|
|
|
|
&:before {
|
|
|
|
content: '\5173';
|
2020-12-21 10:08:40 +08:00
|
|
|
color: var(--Switch-valueColor);
|
|
|
|
text-indent: calc(var(--Switch-width) / 2);
|
2019-12-06 09:58:08 +08:00
|
|
|
text-transform: uppercase;
|
2020-12-21 10:08:40 +08:00
|
|
|
font-size: var(--fontSizeSm);
|
|
|
|
line-height: var(--Switch-height);
|
2019-12-06 09:58:08 +08:00
|
|
|
font-style: normal;
|
|
|
|
font-weight: bold;
|
2019-05-15 16:10:20 +08:00
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
position: absolute;
|
|
|
|
top: px2rem(-1px);
|
|
|
|
bottom: px2rem(-1px);
|
|
|
|
left: px2rem(-1px);
|
|
|
|
right: px2rem(-1px);
|
2020-12-21 10:08:40 +08:00
|
|
|
background: var(--Switch-bgColor);
|
|
|
|
border: px2rem(1px) solid var(--Switch-borderColor);
|
2019-12-06 09:58:08 +08:00
|
|
|
border-radius: px2rem(30px);
|
|
|
|
transition: all 0.2s;
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
2020-12-21 10:08:40 +08:00
|
|
|
background: var(--white);
|
|
|
|
width: calc(var(--Switch-height) - #{px2rem(2px)});
|
2019-12-06 09:58:08 +08:00
|
|
|
top: px2rem(1px);
|
|
|
|
bottom: px2rem(1px);
|
|
|
|
left: px2rem(1px);
|
|
|
|
border-radius: 50%;
|
|
|
|
// box-shadow: px2rem(1px) px2rem(1px) px2rem(3px) rgba(0, 0, 0, 0.25);
|
|
|
|
transition: margin-left 0.3s;
|
|
|
|
}
|
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
input {
|
|
|
|
position: absolute;
|
|
|
|
opacity: 0;
|
|
|
|
|
|
|
|
&:disabled,
|
|
|
|
&:disabled:checked {
|
|
|
|
& + i {
|
|
|
|
&:before {
|
2020-12-21 10:08:40 +08:00
|
|
|
color: var(--Switch-onDisabled-color);
|
|
|
|
background: var(--Switch-onDisabled-bgColor);
|
2020-03-31 15:54:31 +08:00
|
|
|
cursor: not-allowed;
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
2019-05-15 16:10:20 +08:00
|
|
|
|
2019-04-30 11:11:25 +08:00
|
|
|
&:after {
|
2020-12-21 10:08:40 +08:00
|
|
|
background: var(--Switch-onDisabled-circle-BackgroundColor);
|
|
|
|
color: var(--Switch-onDisabled-color);
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
2019-12-06 09:58:08 +08:00
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
&:checked {
|
|
|
|
& + i {
|
|
|
|
&:before {
|
|
|
|
left: 100%;
|
|
|
|
border-width: 0;
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
&:after {
|
2020-12-21 10:08:40 +08:00
|
|
|
margin-left: calc(var(--Switch-width) - var(--Switch-height));
|
2019-05-15 16:10:20 +08:00
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
content: '\5f00';
|
2020-12-21 10:08:40 +08:00
|
|
|
color: var(--white);
|
2019-12-06 09:58:08 +08:00
|
|
|
text-indent: px2rem(-18px); // todo
|
|
|
|
text-transform: uppercase;
|
2020-12-21 10:08:40 +08:00
|
|
|
font-size: var(--fontSizeSm);
|
2019-12-06 09:58:08 +08:00
|
|
|
font-weight: bold;
|
|
|
|
font-style: normal;
|
2020-12-21 10:08:40 +08:00
|
|
|
line-height: var(--Switch-height);
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
2019-12-06 09:58:08 +08:00
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
2019-12-06 09:58:08 +08:00
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.#{$ns}Switch-option {
|
2019-12-06 09:58:08 +08:00
|
|
|
vertical-align: middle;
|
2020-12-21 10:08:40 +08:00
|
|
|
margin-left: var(--Switch-gap);
|
2019-04-30 11:11:25 +08:00
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
&:first-child {
|
|
|
|
margin-left: 0;
|
2020-12-21 10:08:40 +08:00
|
|
|
margin-right: var(--Switch-gap);
|
2019-12-06 09:58:08 +08:00
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.#{$ns}SwitchControl {
|
2020-12-21 10:08:40 +08:00
|
|
|
padding-top: calc((var(--Form-input-height) - var(--Switch-height)) / 2);
|
2019-04-30 20:52:23 +08:00
|
|
|
|
2019-12-06 09:58:08 +08:00
|
|
|
&.is-inline {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
}
|