index.less
3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
@import '../../style/themes/index';
@import '../../style/mixins/index';
@switch-prefix-cls: ~'@{ant-prefix}-switch';
@switch-duration: 0.2s;
@switch-pin-size: @switch-height - 4px;
@switch-sm-pin-size: @switch-sm-height - 4px;
.@{switch-prefix-cls} {
.reset-component;
position: relative;
display: inline-block;
box-sizing: border-box;
min-width: @switch-min-width;
height: @switch-height;
line-height: @switch-height;
vertical-align: middle;
background-color: @disabled-color;
border: 0;
border-radius: 100px;
cursor: pointer;
transition: all @switch-duration;
user-select: none;
&: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 ==========================
&-inner {
display: block;
margin: 0 @switch-inner-margin-min 0 @switch-inner-margin-max;
color: @text-color-inverse;
font-size: @font-size-sm;
transition: margin @switch-duration;
}
&-checked &-inner {
margin: 0 @switch-inner-margin-max 0 @switch-inner-margin-min;
}
// ========================= Handle =========================
&-handle {
position: absolute;
top: @switch-padding;
left: @switch-padding;
width: @switch-pin-size;
height: @switch-pin-size;
transition: all @switch-duration ease-in-out;
&::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: @switch-bg;
border-radius: @switch-pin-size / 2;
box-shadow: 0 2px 4px 0 @switch-shadow-color;
transition: all @switch-duration ease-in-out;
content: '';
}
}
&-checked &-handle {
left: calc(100% - @switch-pin-size - @switch-padding);
}
&: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%;
}
}
}
// ======================== Loading =========================
&-loading-icon {
position: relative;
top: (@switch-pin-size - @font-size-base) / 2;
color: rgba(0, 0, 0, 0.65);
vertical-align: top;
}
&-checked &-loading-icon {
color: @switch-color;
}
// ========================== Size ==========================
&-small {
min-width: @switch-sm-min-width;
height: @switch-sm-height;
line-height: @switch-sm-height;
.@{switch-prefix-cls}-inner {
margin: 0 @switch-sm-inner-margin-min 0 @switch-sm-inner-margin-max;
font-size: @font-size-sm;
}
.@{switch-prefix-cls}-handle {
width: @switch-sm-pin-size;
height: @switch-sm-pin-size;
}
.@{switch-prefix-cls}-loading-icon {
top: (@switch-sm-pin-size - 9px) / 2;
font-size: 9px;
}
&.@{switch-prefix-cls}-checked {
.@{switch-prefix-cls}-inner {
margin: 0 @switch-sm-inner-margin-max 0 @switch-sm-inner-margin-min;
}
.@{switch-prefix-cls}-handle {
left: calc(100% - @switch-sm-pin-size - @switch-padding);
}
}
}
}
@import './rtl';