naive-ui/styles/Switch.scss
2019-10-30 18:10:18 +08:00

85 lines
2.2 KiB
SCSS

@import './mixins/mixins.scss';
@import './themes/vars.scss';
@include themes-mixin{
@include b(switch) {
@include once {
vertical-align: middle;
user-select: none;
display: inline-block;
outline: none;
}
@include e(rail) {
@include once {
cursor: pointer;
position: relative;
height: 14px;
width: 30px;
border-radius: 7px;
margin: 3px;
transition: background-color .2s $default-cubic-bezier;
&::before, &::after {
box-sizing: border-box;
cursor: inherit;
content: "";
position: absolute;
height: 20px;
width: 24px;
max-width: 20px;
border-radius: 10px;
top: -3px;
left: -3px;
// transition: left .2s $default-cubic-bezier, opacity .2s $default-cubic-bezier, max-width .2s $default-cubic-bezier;
}
&::before {
opacity: 1;
}
&::after {
opacity: 0;
}
@include not-m(disabled) {
&:active::before, &:active::after {
max-width: 24px;
}
@include m(active) {
&:active::before, &:active::after {
left: 9px;
}
}
}
@include m(active) {
&::before {
left: 13px;
opacity: 1;
}
&::after {
left: 13px;
opacity: 1;
}
}
}
&::before {
box-shadow: $--switch-switcher-box-shadow;
transition: $--switch-switcher-transition;
}
&::after {
transition: $--switch-switcher-transition;
}
background-color: map-get($map: $--switch-rail-background-color, $key: 'inactive');
&::before {
background-image: map-get($map: $--switch-switcher-color, $key: 'inactive');
}
&::after {
background-image: map-get($map: $--switch-switcher-color, $key: 'active');
}
@include m(active) {
background-color: map-get($map: $--switch-rail-background-color, $key: 'active');
}
@include m(disabled) {
cursor: not-allowed;
opacity: .5;
}
}
}
}