2020-03-05 12:17:50 +08:00
|
|
|
@import '../../style/themes/index';
|
|
|
|
@import '../../style/mixins/index';
|
|
|
|
|
|
|
|
@switch-prefix-cls: ~'@{ant-prefix}-switch';
|
2020-07-01 21:38:23 +08:00
|
|
|
@switch-duration: 0.2s;
|
2020-03-05 12:17:50 +08:00
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
@switch-pin-size: @switch-height - 4px;
|
|
|
|
@switch-sm-pin-size: @switch-sm-height - 4px;
|
|
|
|
|
2020-03-05 12:17:50 +08:00
|
|
|
.@{switch-prefix-cls} {
|
|
|
|
.reset-component;
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
display: inline-block;
|
|
|
|
box-sizing: border-box;
|
2020-03-08 15:12:21 +08:00
|
|
|
min-width: @switch-min-width;
|
2020-03-05 12:17:50 +08:00
|
|
|
height: @switch-height;
|
2020-05-25 12:38:07 +08:00
|
|
|
line-height: @switch-height;
|
2020-03-05 12:17:50 +08:00
|
|
|
vertical-align: middle;
|
|
|
|
background-color: @disabled-color;
|
2020-05-25 12:38:07 +08:00
|
|
|
border: 0;
|
2020-03-05 12:17:50 +08:00
|
|
|
border-radius: 100px;
|
|
|
|
cursor: pointer;
|
|
|
|
transition: all @switch-duration;
|
|
|
|
user-select: none;
|
2020-03-23 13:51:37 +08:00
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&:focus {
|
|
|
|
outline: 0;
|
|
|
|
box-shadow: 0 0 0 2px fade(@disabled-color, 10%);
|
|
|
|
}
|
|
|
|
|
|
|
|
&-checked:focus {
|
|
|
|
box-shadow: 0 0 0 2px fade(@switch-color, 20%);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:focus:hover {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&-checked {
|
|
|
|
background-color: @switch-color;
|
|
|
|
}
|
|
|
|
|
|
|
|
&-loading,
|
|
|
|
&-disabled {
|
|
|
|
cursor: not-allowed;
|
|
|
|
opacity: @switch-disabled-opacity;
|
|
|
|
* {
|
|
|
|
box-shadow: none;
|
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ========================= Inner ==========================
|
2020-03-05 12:17:50 +08:00
|
|
|
&-inner {
|
|
|
|
display: block;
|
2020-05-25 12:38:07 +08:00
|
|
|
margin: 0 @switch-inner-margin-min 0 @switch-inner-margin-max;
|
2020-03-05 12:17:50 +08:00
|
|
|
color: @text-color-inverse;
|
|
|
|
font-size: @font-size-sm;
|
2020-05-25 12:38:07 +08:00
|
|
|
transition: margin @switch-duration;
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&-checked &-inner {
|
|
|
|
margin: 0 @switch-inner-margin-max 0 @switch-inner-margin-min;
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
// ========================= Handle =========================
|
|
|
|
&-handle {
|
|
|
|
position: absolute;
|
|
|
|
top: @switch-padding;
|
|
|
|
left: @switch-padding;
|
|
|
|
width: @switch-pin-size;
|
|
|
|
height: @switch-pin-size;
|
2020-07-01 21:38:23 +08:00
|
|
|
transition: all @switch-duration ease-in-out;
|
2020-03-05 12:17:50 +08:00
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&::before {
|
2020-03-05 12:17:50 +08:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
2020-05-25 12:38:07 +08:00
|
|
|
background-color: @switch-bg;
|
|
|
|
border-radius: @switch-pin-size / 2;
|
|
|
|
box-shadow: 0 2px 4px 0 @switch-shadow-color;
|
2020-07-01 21:38:23 +08:00
|
|
|
transition: all @switch-duration ease-in-out;
|
2020-05-25 12:38:07 +08:00
|
|
|
content: '';
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&-checked &-handle {
|
|
|
|
left: calc(100% - @switch-pin-size - @switch-padding);
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&:not(&-disabled):active {
|
|
|
|
.@{switch-prefix-cls}-handle::before {
|
|
|
|
right: -30%;
|
|
|
|
left: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.@{switch-prefix-cls}-checked {
|
|
|
|
.@{switch-prefix-cls}-handle::before {
|
|
|
|
right: 0;
|
|
|
|
left: -30%;
|
|
|
|
}
|
|
|
|
}
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
// ======================== Loading =========================
|
|
|
|
&-loading-icon {
|
2020-12-01 11:02:28 +08:00
|
|
|
position: relative;
|
|
|
|
top: (@switch-pin-size - @font-size-base) / 2;
|
2020-05-25 12:38:07 +08:00
|
|
|
color: rgba(0, 0, 0, 0.65);
|
2020-12-01 11:02:28 +08:00
|
|
|
vertical-align: top;
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&-checked &-loading-icon {
|
|
|
|
color: @switch-color;
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
// ========================== Size ==========================
|
2020-03-05 12:17:50 +08:00
|
|
|
&-small {
|
2020-03-08 15:12:21 +08:00
|
|
|
min-width: @switch-sm-min-width;
|
2020-03-05 12:17:50 +08:00
|
|
|
height: @switch-sm-height;
|
2020-05-25 12:38:07 +08:00
|
|
|
line-height: @switch-sm-height;
|
2020-03-05 12:17:50 +08:00
|
|
|
|
|
|
|
.@{switch-prefix-cls}-inner {
|
2020-05-25 12:38:07 +08:00
|
|
|
margin: 0 @switch-sm-inner-margin-min 0 @switch-sm-inner-margin-max;
|
2020-03-05 12:17:50 +08:00
|
|
|
font-size: @font-size-sm;
|
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
.@{switch-prefix-cls}-handle {
|
|
|
|
width: @switch-sm-pin-size;
|
|
|
|
height: @switch-sm-pin-size;
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
.@{switch-prefix-cls}-loading-icon {
|
2020-12-01 11:02:28 +08:00
|
|
|
top: (@switch-sm-pin-size - 9px) / 2;
|
|
|
|
font-size: 9px;
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
&.@{switch-prefix-cls}-checked {
|
|
|
|
.@{switch-prefix-cls}-inner {
|
|
|
|
margin: 0 @switch-sm-inner-margin-max 0 @switch-sm-inner-margin-min;
|
|
|
|
}
|
2020-03-05 12:17:50 +08:00
|
|
|
|
2020-05-25 12:38:07 +08:00
|
|
|
.@{switch-prefix-cls}-handle {
|
|
|
|
left: calc(100% - @switch-sm-pin-size - @switch-padding);
|
|
|
|
}
|
2020-03-05 12:17:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-23 13:51:37 +08:00
|
|
|
|
|
|
|
@import './rtl';
|