1- @import " ../../themes/native/native.globals" ;
2- @import " ./checkbox.vars.scss" ;
1+ @use " ../../themes/mixins" as mixins ;
32
4- // Checkbox
3+ // Checkbox: Common
54// --------------------------------------------------
65
76:host {
87 /* *
98 * @prop --size: Size of the checkbox icon
109 *
11- * @prop --checkbox-background: Background of the checkbox icon
1210 * @prop --checkbox-background-checked: Background of the checkbox icon when checked
1311 *
1412 * @prop --border-color: Border color of the checkbox icon
2220 * @prop --checkmark-color: Color of the checkbox checkmark when checked
2321 * @prop --checkmark-width: Stroke width of the checkbox checkmark
2422 */
25- --checkbox-background-checked : #{ion-color (primary , base )} ;
26- --border-color-checked : #{ion-color (primary , base )} ;
27- --checkmark-color : #{ion-color (primary , contrast )} ;
28- --transition : none ;
2923
3024 display : inline-block ;
3125
3428 cursor : pointer ;
3529
3630 user-select : none ;
37- z-index : $z-index-item-input ;
3831}
3932
4033:host (.in-item ) {
5043 * toolbar which is why we do not
5144 * limit the below behavior to just ion-item.
5245 */
53- :host ([slot = " start" ]),
54- :host ([slot = " end" ]) {
55- // Reset the flex property when the checkbox
56- // is slotted to avoid growing the element larger
57- // than its content.
58- flex : initial ;
59-
60- width : auto ;
61- }
46+ :host ([slot = " start" ]),
47+ :host ([slot = " end" ]) {
48+ // Reset the flex property when the checkbox
49+ // is slotted to avoid growing the element larger
50+ // than its content.
51+ flex : initial ;
6252
63- :host (.ion-color ) {
64- --checkbox-background-checked : #{current-color (base )} ;
65- --border-color-checked : #{current-color (base )} ;
66- --checkmark-color : #{current-color (contrast )} ;
67- }
53+ width : auto ;
54+ }
6855
69- .checkbox-wrapper {
56+ .checkbox-wrapper {
7057 display : flex ;
7158
7259 flex-grow : 1 ;
8774 overflow : hidden ;
8875}
8976
90- // Checkboxes that are not slotted inside an item and are not used with a
91- // stacked label should have margins equal to those of the label.
92- :host (.in-item ) .label-text-wrapper ,
93- :host (.in-item :not (.checkbox-label-placement-stacked ):not ([slot ])) .native-wrapper {
94- @include margin ($checkbox-item-label-margin-top , null, $checkbox-item-label-margin-bottom , null);
95- }
96-
97- :host (.in-item.checkbox-label-placement-stacked ) .label-text-wrapper {
98- @include margin ($checkbox-item-label-margin-top , null, $form-control-label-margin , null);
99- }
100-
101- :host (.in-item.checkbox-label-placement-stacked ) .native-wrapper {
102- @include margin (null, null, $checkbox-item-label-margin-bottom , null);
103- }
104-
10577/* *
10678 * If no label text is placed into the slot
10779 * then the element should be hidden otherwise
10880 * there will be additional margins added.
10981 */
110- .label-text-wrapper-hidden {
82+ .label-text-wrapper-hidden {
11183 display : none ;
11284}
11385
114- input {
115- @include visually-hidden ();
116- }
117-
11886.native-wrapper {
11987 display : flex ;
12088
12189 align-items : center ;
12290}
12391
12492.checkbox-icon {
125- @include border-radius (var (--border-radius ));
126-
12793 position : relative ;
128-
129- width : var (--size );
130- height : var (--size );
131-
132- transition : var (--transition );
133-
134- border-width : var (--border-width );
135- border-style : var (--border-style );
136- border-color : var (--border-color );
137-
138- background : var (--checkbox-background );
139-
140- box-sizing : border-box ;
14194}
14295
14396.checkbox-icon path {
144- fill : none ;
145- stroke : var (--checkmark-color );
146- stroke-width : var (--checkmark-width );
147-
14897 opacity : 0 ;
14998}
15099
151100// Checkbox Bottom Content
152101// ----------------------------------------------------------------
153102
154103.checkbox-bottom {
155- @include padding (4px , null, null, null);
156-
157104 display : flex ;
158105
159106 justify-content : space-between ;
160107
161- font-size : dynamic-font (12px );
162-
163108 white-space : normal ;
164109}
165110
166- :host (.checkbox-label-placement-stacked ) .checkbox-bottom {
167- font-size : dynamic-font (16px );
168- }
169-
170111// Checkbox Hint Text
171112// ----------------------------------------------------------------
172113
@@ -177,14 +118,10 @@ input {
177118 */
178119.checkbox-bottom .error-text {
179120 display : none ;
180-
181- color : ion-color (danger , base );
182121}
183122
184123.checkbox-bottom .helper-text {
185124 display : block ;
186-
187- color : $text-color-step-300 ;
188125}
189126
190127:host (.ion-touched.ion-invalid ) .checkbox-bottom .error-text {
@@ -202,53 +139,24 @@ input {
202139 * Label is on the left of the checkbox in LTR and
203140 * on the right in RTL.
204141 */
205- :host (.checkbox-label-placement-start ) .checkbox-wrapper {
142+ :host (.checkbox-label-placement-start ) .checkbox-wrapper {
206143 flex-direction : row ;
207144}
208145
209- :host (.checkbox-label-placement-start ) .label-text-wrapper {
210- /* *
211- * The margin between the label and
212- * the checkbox should be on the end
213- * when the label sits at the start.
214- */
215- @include margin (null, $form-control-label-margin , null, 0 );
216- }
217-
218146// Label Placement - End
219147// ----------------------------------------------------------------
220148
221149/* *
222150 * Label is on the right of the checkbox in LTR and
223151 * on the left in RTL.
224152 */
225- :host (.checkbox-label-placement-end ) .checkbox-wrapper {
153+ :host (.checkbox-label-placement-end ) .checkbox-wrapper {
226154 flex-direction : row-reverse ;
227-
228- justify-content : start ;
229- }
230-
231- /* *
232- * The margin between the label and
233- * the checkbox should be on the start
234- * when the label sits at the end.
235- */
236- :host (.checkbox-label-placement-end ) .label-text-wrapper {
237- @include margin (null, 0 , null, $form-control-label-margin );
238155}
239156
240157// Label Placement - Fixed
241158// ----------------------------------------------------------------
242159
243- :host (.checkbox-label-placement-fixed ) .label-text-wrapper {
244- /* *
245- * The margin between the label and
246- * the checkbox should be on the end
247- * when the label sits at the start.
248- */
249- @include margin (null, $form-control-label-margin , null, 0 );
250- }
251-
252160/* *
253161 * Label is on the left of the checkbox in LTR and
254162 * on the right in RTL. Label also has a fixed width.
@@ -267,35 +175,18 @@ input {
267175/* *
268176 * Label is on top of the checkbox.
269177 */
270- :host (.checkbox-label-placement-stacked ) .checkbox-wrapper {
178+ :host (.checkbox-label-placement-stacked ) .checkbox-wrapper {
271179 flex-direction : column ;
272180
273181 text-align : center ;
274182}
275183
276- :host (.checkbox-label-placement-stacked ) .label-text-wrapper {
277- @include transform (scale (#{$form-control-label-stacked-scale } ));
278-
279- /* *
280- * The margin between the label and
281- * the checkbox should be on the bottom
282- * when the label sits at the top.
283- */
284- @include margin (null, 0 , $form-control-label-margin , 0 );
285-
286- /* *
287- * Label text should not extend
288- * beyond the bounds of the checkbox.
289- */
290- max-width : calc (100% / #{$form-control-label-stacked-scale } );
291- }
292-
293184:host (.checkbox-label-placement-stacked.checkbox-alignment-start ) .label-text-wrapper {
294- @include transform-origin (start , top );
185+ @include mixins . transform-origin (start , top );
295186}
296187
297188:host (.checkbox-label-placement-stacked.checkbox-alignment-center ) .label-text-wrapper {
298- @include transform-origin (center , top );
189+ @include mixins . transform-origin (center , top );
299190}
300191
301192// Justify Content
@@ -353,9 +244,8 @@ input {
353244 opacity : 1 ;
354245}
355246
356- // Disabled Checkbox
357- // ---------------------------------------------
358-
247+ // Checkbox Disabled
248+ // --------------------------------------------------
359249:host (.checkbox-disabled ) {
360250 pointer-events : none ;
361251}
0 commit comments