naive-ui/styles/Switch.scss

86 lines
2.3 KiB
SCSS
Raw Normal View History

2019-06-14 11:26:46 +08:00
@import './mixins/mixins.scss';
2020-02-11 14:44:29 +08:00
2019-09-29 19:07:16 +08:00
@include themes-mixin{
@include b(switch) {
@include once {
vertical-align: middle;
2019-10-09 17:38:08 +08:00
user-select: none;
2019-09-29 19:07:16 +08:00
display: inline-block;
2019-10-30 18:10:18 +08:00
outline: none;
2019-09-29 18:15:05 +08:00
}
2019-09-29 19:07:16 +08:00
@include e(rail) {
@include once {
cursor: pointer;
position: relative;
height: 14px;
width: 30px;
border-radius: 7px;
margin: 3px;
transition: background-color .3s $--n-ease-in-out-cubic-bezier;
2019-09-29 19:07:16 +08:00
&::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;
background-size: 800% 800%;
2020-02-21 14:59:17 +08:00
transition:
left .3s $--n-ease-in-out-cubic-bezier,
opacity .3s $--n-ease-in-out-cubic-bezier,
max-width .3s $--n-ease-in-out-cubic-bezier,
background-position .3s $--n-ease-in-out-cubic-bezier,
box-shadow .3s $--n-ease-in-out-cubic-bezier;
2019-09-29 19:07:16 +08:00
}
&::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;
}
2019-09-29 18:15:05 +08:00
}
}
2019-10-09 17:38:08 +08:00
&::before {
2019-09-29 19:07:16 +08:00
box-shadow: $--switch-switcher-box-shadow;
background-position: $--switch-background-position;
2020-02-21 14:59:17 +08:00
background-image: map-get($--switch-switcher-background-image, 'inactive');
2019-06-14 11:35:23 +08:00
}
&::after {
2019-12-23 21:40:45 +08:00
background-position: $--switch-background-position;
2020-02-21 14:59:17 +08:00
background-image: map-get($--switch-switcher-background-image, 'active');
2019-09-29 19:07:16 +08:00
}
2020-02-21 14:59:17 +08:00
background-color: map-get($--switch-rail-background-color, 'inactive');
2019-09-29 19:07:16 +08:00
@include m(active) {
2020-02-21 14:59:17 +08:00
background-color: map-get($--switch-rail-background-color, 'active');
2019-09-29 19:07:16 +08:00
}
@include m(disabled) {
cursor: not-allowed;
opacity: .5;
2019-06-14 11:26:46 +08:00
}
}
2019-06-14 11:26:46 +08:00
}
2019-09-29 19:07:16 +08:00
}