element/packages/theme-chalk/src/switch.scss

120 lines
2.4 KiB
SCSS
Raw Normal View History

@import "mixins/mixins";
@import "common/var";
@include b(switch) {
display: inline-block;
position: relative;
font-size: $--switch-font-size;
line-height: $--switch-height;
height: $--switch-height;
vertical-align: middle;
@include when(disabled) {
& .el-switch__core,
& .el-switch__label {
cursor: not-allowed;
}
}
@include e(label) {
transition: .2s;
position: absolute;
width: $--switch-width;
height: $--switch-height;
left: 0;
top: 0;
display: inline-block;
font-size: $--switch-font-size;
cursor: pointer;
@include m(left) {
i {
left: 6px;
}
}
@include m(right) {
i {
right: 6px;
}
}
& * {
line-height: 1;
top: 4px;
position: absolute;
font-size: $--switch-font-size;
display: inline-block;
color: $--color-white;
}
}
@include e(input) {
display: none;
}
@include e(core) {
margin: 0;
display: inline-block;
position: relative;
width: $--switch-width;
height: $--switch-height;
border: 1px solid $--switch-off-color;
outline: none;
border-radius: $--switch-core-border-radius;
box-sizing: border-box;
background: $--switch-off-color;
cursor: pointer;
transition: border-color .3s, background-color .3s;
& .el-switch__button {
position: absolute;
top: 0;
left: 0;
border-radius: $--border-radius-circle;
transition: transform .3s;
width: $--switch-button-size;
height: $--switch-button-size;
background-color: $--color-white;
}
}
@include when(checked) {
.el-switch__core {
border-color: $--switch-on-color;
background-color: $--switch-on-color;
}
}
@include when(disabled) {
.el-switch__core {
border-color: $--switch-disabled-color !important;
background: $--switch-disabled-color !important;
& span {
background-color: $--switch-disabled-text-color !important;
}
& ~ .el-switch__label * {
color: $--switch-disabled-text-color !important;
}
}
}
@include m(wide) {
.el-switch__label {
&.el-switch__label--left {
span {
left: 10px;
}
}
&.el-switch__label--right {
span {
right: 10px;
}
}
}
}
& .label-fade-enter,
& .label-fade-leave-active {
opacity: 0;
}
}