Skip to content

Commit f0516e6

Browse files
feat(checkbox): add helper and error text to the ionic theme (#30278)
- Adds the common stylesheet for the shared styles - Adds design for helper and error text to the checkbox for the ionic theme. - Updates tests to add screenshots for ionic theme --------- Co-authored-by: Brandy Smith <[email protected]>
1 parent e24fcf5 commit f0516e6

File tree

52 files changed

+184
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+184
-270
lines changed

core/api.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,26 +549,40 @@ ion-checkbox,prop,value,any,'on',false,false
549549
ion-checkbox,event,ionBlur,void,true
550550
ion-checkbox,event,ionChange,CheckboxChangeEventDetail<any>,true
551551
ion-checkbox,event,ionFocus,void,true
552+
ion-checkbox,css-prop,--border-color,ionic
552553
ion-checkbox,css-prop,--border-color,ios
553554
ion-checkbox,css-prop,--border-color,md
555+
ion-checkbox,css-prop,--border-color-checked,ionic
554556
ion-checkbox,css-prop,--border-color-checked,ios
555557
ion-checkbox,css-prop,--border-color-checked,md
558+
ion-checkbox,css-prop,--border-radius,ionic
556559
ion-checkbox,css-prop,--border-radius,ios
557560
ion-checkbox,css-prop,--border-radius,md
561+
ion-checkbox,css-prop,--border-style,ionic
558562
ion-checkbox,css-prop,--border-style,ios
559563
ion-checkbox,css-prop,--border-style,md
564+
ion-checkbox,css-prop,--border-width,ionic
560565
ion-checkbox,css-prop,--border-width,ios
561566
ion-checkbox,css-prop,--border-width,md
562567
ion-checkbox,css-prop,--checkbox-background,ios
563568
ion-checkbox,css-prop,--checkbox-background,md
569+
ion-checkbox,css-prop,--checkbox-background-checked,ionic
564570
ion-checkbox,css-prop,--checkbox-background-checked,ios
565571
ion-checkbox,css-prop,--checkbox-background-checked,md
572+
ion-checkbox,css-prop,--checkmark-color,ionic
566573
ion-checkbox,css-prop,--checkmark-color,ios
567574
ion-checkbox,css-prop,--checkmark-color,md
575+
ion-checkbox,css-prop,--checkmark-height,ionic
576+
ion-checkbox,css-prop,--checkmark-width,ionic
568577
ion-checkbox,css-prop,--checkmark-width,ios
569578
ion-checkbox,css-prop,--checkmark-width,md
579+
ion-checkbox,css-prop,--focus-ring-color,ionic
580+
ion-checkbox,css-prop,--focus-ring-offset,ionic
581+
ion-checkbox,css-prop,--focus-ring-width,ionic
582+
ion-checkbox,css-prop,--size,ionic
570583
ion-checkbox,css-prop,--size,ios
571584
ion-checkbox,css-prop,--size,md
585+
ion-checkbox,css-prop,--transition,ionic
572586
ion-checkbox,css-prop,--transition,ios
573587
ion-checkbox,css-prop,--transition,md
574588
ion-checkbox,part,container

core/src/components/checkbox/checkbox.scss renamed to core/src/components/checkbox/checkbox.common.scss

Lines changed: 4 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
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
@@ -22,10 +20,6 @@
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

@@ -34,7 +28,6 @@
3428
cursor: pointer;
3529

3630
user-select: none;
37-
z-index: $z-index-item-input;
3831
}
3932

4033
:host(.in-item) {
@@ -60,12 +53,6 @@
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

@@ -87,21 +74,6 @@
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
@@ -111,62 +83,31 @@
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

Comments
 (0)