UNPKG

6.13 kBSCSSView Raw
1@charset "UTF-8";
2
3@import '../core/index-noreset';
4@import 'scss/variable';
5@import './rtl.scss';
6
7/* stylelint-disable max-nesting-depth */
8
9#{$checkbox-prefix}-wrapper {
10 @include box-sizing;
11 display: inline-block;
12
13 #{$checkbox-prefix} {
14 display: inline-block;
15 position: relative;
16 line-height: 1;
17 vertical-align: middle;
18 }
19
20 input[type="checkbox"] {
21 opacity: 0;
22 position: absolute;
23 top: 0;
24 left: 0;
25 width: $checkbox-size;
26 height: $checkbox-size;
27 margin: 0;
28 cursor: pointer;
29 }
30
31 #{$checkbox-prefix}-inner {
32 display: block;
33 width: $checkbox-size;
34 height: $checkbox-size;
35 background: $checkbox-bg-color;
36 border-radius: $checkbox-border-radius;
37 border: $checkbox-border-width solid $checkbox-border-color;
38 transition: all $motion-duration-immediately $motion-linear;
39 text-align: left; /* 防止继承父级 */
40 box-shadow: $checkbox-shadow;
41
42 > .#{$css-prefix}icon {
43 transform: scale(0);
44 position: absolute;
45 top: 0;
46 opacity: 0;
47 line-height: $checkbox-size;
48 transition: all $motion-duration-immediately $motion-linear;
49 color: $checkbox-checked-circle-color;
50 left: calc((#{$checkbox-size} - #{$checkbox-circle-size}) / 2);
51 @if (get-compiling-value($checkbox-circle-size) == 12) {
52 margin-top: 1px;
53 }
54 @include icon-size($checkbox-circle-size, 0px);
55 }
56 > .#{$css-prefix}icon::before {
57 vertical-align: top;
58 margin-top: 0;
59 }
60 > .#{$css-prefix}checkbox-select-icon::before {
61 content: $checkbox-select-icon-content;
62 }
63 > .#{$css-prefix}checkbox-semi-select-icon::before {
64 content: $checkbox-semi-select-icon-content;
65 }
66 }
67
68 &.checked,
69 &.checked.focused {
70 > #{$checkbox-prefix} {
71 > #{$checkbox-prefix}-inner {
72 border-color: $checkbox-checked-border-color;
73 background-color: $checkbox-checked-bg-color;
74
75 &:hover,
76 &.hovered {
77 border-color: $checkbox-checked-border-color;
78 }
79 > .#{$css-prefix}icon {
80 opacity: 1;
81 transform: scale(1);
82 @include icon-size($checkbox-circle-size, 0px); /* font-size < 12px的时候进行覆盖。 */
83 }
84 }
85 }
86 }
87
88 &.indeterminate,
89 &.indeterminate.focused {
90 > #{$checkbox-prefix} {
91 > #{$checkbox-prefix}-inner {
92 border-color: $checkbox-checked-border-color;
93 background-color: $checkbox-checked-bg-color;
94
95 &:hover,
96 &.hovered {
97 border-color: $checkbox-checked-border-color;
98 }
99 > .#{$css-prefix}icon {
100 opacity: 1;
101 transform: scale3d(1, 1, 1);
102 @include icon-size($checkbox-circle-size, 0px); /* font-size < 12px的时候进行覆盖。 */
103 }
104 }
105 }
106 }
107
108 &:not(.disabled):hover,
109 &.hovered,
110 &.focused {
111 > #{$checkbox-prefix} {
112 > #{$checkbox-prefix}-inner {
113 border-color: $checkbox-hovered-border-color;
114 background-color: $checkbox-hovered-bg-color;
115 }
116 }
117 #{$checkbox-prefix}-label {
118 cursor: pointer;
119 }
120 }
121
122 &.indeterminate:not(.disabled):hover,
123 &.indeterminate:not(.disabled).hovered,
124 &.checked:not(.disabled):hover,
125 &.checked:not(.disabled).hovered {
126 > #{$checkbox-prefix} {
127 #{$checkbox-prefix}-inner {
128 border-color: $checkbox-checked-hovered-border-color;
129 background-color: $checkbox-checked-hovered-bg-color;
130
131 > .#{$css-prefix}icon {
132 color: $checkbox-checked-hovered-circle-color;
133 opacity: 1;
134 }
135 }
136 }
137 }
138
139 &.disabled {
140 input[type="checkbox"] {
141 cursor: not-allowed;
142 }
143 #{$checkbox-prefix}-inner {
144 border-color: $checkbox-disabled-border-color;
145 background: $checkbox-disabled-bg-color;
146 }
147 &.checked,
148 &.indeterminate {
149 #{$checkbox-prefix}-inner {
150 border-color: $checkbox-disabled-border-color;
151 background: $checkbox-disabled-bg-color;
152
153 &:hover, &.hovered {
154 border-color: $checkbox-disabled-border-color;
155 }
156
157 > .#{$css-prefix}icon {
158 color: $checkbox-disabled-circle-color;
159 opacity: 1;
160 }
161 }
162 }
163 &.checked.focused {
164 #{$checkbox-prefix}-inner {
165 border-color: $checkbox-disabled-border-color;
166 background: $checkbox-disabled-bg-color;
167
168 > .#{$css-prefix}icon {
169 color: $checkbox-disabled-circle-color;
170 opacity: 1;
171 }
172 }
173 }
174 #{$checkbox-prefix}-label {
175 color: $checkbox-disabled-label-color;
176 cursor: not-allowed;
177 }
178 }
179}
180
181#{$checkbox-prefix}-group {
182 #{$checkbox-prefix}-wrapper {
183 display: inline-block;
184 margin-right: 12px;
185 &:last-child {
186 margin-right: 0;
187 }
188 }
189
190 &-ver {
191 #{$checkbox-prefix}-wrapper {
192 display: block;
193 margin-left: 0;
194 margin-right: 0;
195 margin-bottom: 8px;
196 }
197 }
198}
199
200#{$checkbox-prefix}-label {
201 font-size: $checkbox-font-size;
202 color: $checkbox-label-color;
203 vertical-align: middle;
204 margin: 0;
205 margin-left: $checkbox-margin-left;
206 /* 使用已存margin-left变量 */
207 margin-right: $checkbox-margin-left;
208 line-height: 1;
209}