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 ) {
6053 width : auto ;
6154}
6255
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- }
68-
6956.checkbox-wrapper {
7057 display : flex ;
7158
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
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 {
@@ -206,15 +143,6 @@ input {
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
@@ -228,27 +156,9 @@ input {
228156 justify-content : start ;
229157}
230158
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 );
238- }
239-
240159// Label Placement - Fixed
241160// ----------------------------------------------------------------
242161
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-
252162/* *
253163 * Label is on the left of the checkbox in LTR and
254164 * on the right in RTL. Label also has a fixed width.
@@ -273,29 +183,12 @@ input {
273183 text-align : center ;
274184}
275185
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-
293186:host (.checkbox-label-placement-stacked.checkbox-alignment-start ) .label-text-wrapper {
294- @include transform-origin (start , top );
187+ @include mixins . transform-origin (start , top );
295188}
296189
297190:host (.checkbox-label-placement-stacked.checkbox-alignment-center ) .label-text-wrapper {
298- @include transform-origin (center , top );
191+ @include mixins . transform-origin (center , top );
299192}
300193
301194// Justify Content
@@ -355,7 +248,6 @@ input {
355248
356249// Disabled Checkbox
357250// ---------------------------------------------
358-
359251:host (.checkbox-disabled ) {
360252 pointer-events : none ;
361253}
0 commit comments