Skip to content

Commit 7f23c60

Browse files
fix(input): remove css variable and update helper text to use valid highlight in ionic theme (#30272)
- Splits the common and native stylesheets - Removes the `--text-color-invalid` variable so the customization across components and themes for helper & error text is consistent. - Sets the color of the helper text when valid to `--highlight-color-valid` to ensure customization works the same as invalid --------- Co-authored-by: Brandy Smith <[email protected]>
1 parent f0516e6 commit 7f23c60

File tree

88 files changed

+205
-133
lines changed

Some content is hidden

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

88 files changed

+205
-133
lines changed

core/api.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,6 @@ ion-input,css-prop,--border-width,md
984984
ion-input,css-prop,--color,ionic
985985
ion-input,css-prop,--color,ios
986986
ion-input,css-prop,--color,md
987-
ion-input,css-prop,--highlight-color-focused,ionic
988987
ion-input,css-prop,--highlight-color-focused,ios
989988
ion-input,css-prop,--highlight-color-focused,md
990989
ion-input,css-prop,--highlight-color-invalid,ionic
@@ -993,7 +992,6 @@ ion-input,css-prop,--highlight-color-invalid,md
993992
ion-input,css-prop,--highlight-color-valid,ionic
994993
ion-input,css-prop,--highlight-color-valid,ios
995994
ion-input,css-prop,--highlight-color-valid,md
996-
ion-input,css-prop,--highlight-height,ionic
997995
ion-input,css-prop,--highlight-height,ios
998996
ion-input,css-prop,--highlight-height,md
999997
ion-input,css-prop,--padding-bottom,ionic
@@ -1020,9 +1018,6 @@ ion-input,css-prop,--placeholder-font-weight,md
10201018
ion-input,css-prop,--placeholder-opacity,ionic
10211019
ion-input,css-prop,--placeholder-opacity,ios
10221020
ion-input,css-prop,--placeholder-opacity,md
1023-
ion-input,css-prop,--text-color-invalid,ionic
1024-
ion-input,css-prop,--text-color-invalid,ios
1025-
ion-input,css-prop,--text-color-invalid,md
10261021

10271022
ion-input-password-toggle,shadow
10281023
ion-input-password-toggle,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true

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

Lines changed: 3 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@import "./input.vars";
1+
@import "../../themes/mixins";
22

3-
// Input
3+
// Input: Common
44
// --------------------------------------------------
55

66
:host {
@@ -19,11 +19,8 @@
1919
* @prop --placeholder-font-weight: Font weight of the input placeholder text
2020
* @prop --placeholder-opacity: Opacity of the input placeholder text
2121
*
22-
* @prop --highlight-height: The height of the highlight on the input. Only applies to md mode.
23-
* @prop --highlight-color-focused: The color of the highlight on the input when focused
2422
* @prop --highlight-color-valid: The color of the highlight on the input when valid
2523
* @prop --highlight-color-invalid: The color of the highlight on the input when invalid
26-
* @prop --text-color-invalid: The color of the error text on the input when invalid. Only applies to ionic theme.
2724
*
2825
* @prop --border-color: Color of the border below the input when using helper text, error text, or counter
2926
* @prop --border-radius: Radius of the input. A large radius may display unevenly when using fill="outline"; if needed, use shape="round" instead or increase --padding-start.
@@ -33,17 +30,11 @@
3330
--placeholder-color: initial;
3431
--placeholder-font-style: initial;
3532
--placeholder-font-weight: initial;
36-
--placeholder-opacity: #{$placeholder-opacity};
3733
--padding-top: 0px;
3834
--padding-end: 0px;
3935
--padding-bottom: 0px;
4036
--padding-start: 0px;
41-
--background: transparent;
42-
--color: initial;
4337
--border-style: solid;
44-
--highlight-color-focused: #{ion-color(primary, base)};
45-
--highlight-color-valid: #{ion-color(success, base)};
46-
--highlight-color-invalid: #{ion-color(danger, base)};
4738

4839
/**
4940
* This is a private API that is used to switch
@@ -59,16 +50,10 @@
5950

6051
width: 100%;
6152

62-
min-height: 44px;
63-
6453
/* stylelint-disable-next-line all */
6554
padding: 0 !important;
6655

6756
color: var(--color);
68-
69-
font-family: $font-family-base;
70-
71-
z-index: $z-index-item-input;
7257
}
7358

7459
:host-context(ion-item)[slot="start"],
@@ -80,19 +65,6 @@
8065
--highlight-color-focused: #{current-color(base)};
8166
}
8267

83-
// Input Wrapper
84-
// ----------------------------------------------------------------
85-
86-
/**
87-
* Since the label sits on top of the element,
88-
* the component needs to be taller otherwise the
89-
* label will appear too close to the input text.
90-
*/
91-
:host(.input-label-placement-floating),
92-
:host(.input-label-placement-stacked) {
93-
min-height: 56px;
94-
}
95-
9668
// Native Text Input
9769
// --------------------------------------------------
9870

@@ -191,18 +163,13 @@
191163
align-items: center;
192164
justify-content: center;
193165

194-
width: 30px;
195-
height: 30px;
196-
197166
border: 0;
198167

199168
outline: none;
200169

201170
background-color: transparent;
202171
background-repeat: no-repeat;
203172

204-
color: $text-color-step-400;
205-
206173
visibility: hidden;
207174
appearance: none;
208175
}
@@ -211,17 +178,6 @@
211178
color: inherit;
212179
}
213180

214-
/**
215-
* Normally, we would not want to use :focus
216-
* here because that would mean tapping the button
217-
* on mobile would focus it (and keep it focused).
218-
* However, the clear button always disappears after
219-
* being activated, so we never get to that state.
220-
*/
221-
.input-clear-icon:focus {
222-
opacity: 0.5;
223-
}
224-
225181
:host(.has-value) .input-clear-icon {
226182
visibility: visible;
227183
}
@@ -293,21 +249,12 @@
293249
// ----------------------------------------------------------------
294250

295251
.input-bottom {
296-
/**
297-
* The bottom content should take on the start and end
298-
* padding so it is always aligned with either the label
299-
* or the start of the text input.
300-
*/
301-
@include padding(5px, var(--padding-end), 0, var(--padding-start));
302-
303252
display: flex;
304253

305254
justify-content: space-between;
306255

307256
border-top: var(--border-width) var(--border-style) var(--border-color);
308257

309-
font-size: dynamic-font(12px);
310-
311258
white-space: normal;
312259
}
313260

@@ -342,8 +289,6 @@
342289

343290
.input-bottom .helper-text {
344291
display: block;
345-
346-
color: $text-color-step-300;
347292
}
348293

349294
:host(.ion-touched.ion-invalid) .input-bottom .error-text {
@@ -365,11 +310,7 @@
365310
*/
366311
@include margin-horizontal(auto, null);
367312

368-
color: $text-color-step-300;
369-
370313
white-space: nowrap;
371-
372-
padding-inline-start: 16px;
373314
}
374315

375316
// Input Native
@@ -464,15 +405,6 @@
464405
flex-direction: row;
465406
}
466407

467-
:host(.input-label-placement-start) .label-text-wrapper {
468-
/**
469-
* The margin between the label and
470-
* the input should be on the end
471-
* when the label sits at the start.
472-
*/
473-
@include margin(0, $form-control-label-margin, 0, 0);
474-
}
475-
476408
// Input Label Placement - End
477409
// ----------------------------------------------------------------
478410

@@ -484,27 +416,9 @@
484416
flex-direction: row-reverse;
485417
}
486418

487-
/**
488-
* The margin between the label and
489-
* the input should be on the start
490-
* when the label sits at the end.
491-
*/
492-
:host(.input-label-placement-end) .label-text-wrapper {
493-
@include margin(0, 0, 0, $form-control-label-margin);
494-
}
495-
496419
// Input Label Placement - Fixed
497420
// ----------------------------------------------------------------
498421

499-
:host(.input-label-placement-fixed) .label-text-wrapper {
500-
/**
501-
* The margin between the label and
502-
* the input should be on the end
503-
* when the label sits at the start.
504-
*/
505-
@include margin(0, $form-control-label-margin, 0, 0);
506-
}
507-
508422
/**
509423
* Label is on the left of the input in LTR and
510424
* on the right in RTL. Label also has a fixed width.
@@ -583,32 +497,9 @@
583497
opacity: 1;
584498
}
585499

586-
/**
587-
* This makes the label sit above the input.
588-
*/
589-
:host(.label-floating) .label-text-wrapper {
590-
@include transform(translateY(50%), scale(#{$form-control-label-stacked-scale}));
591-
592-
/**
593-
* Label text should not extend
594-
* beyond the bounds of the input.
595-
*/
596-
max-width: calc(100% / #{$form-control-label-stacked-scale});
597-
}
598-
599-
// Start/End Slots
500+
// Input Password Toggle
600501
// ----------------------------------------------------------------
601502

602-
::slotted([slot="start"]:last-of-type) {
603-
margin-inline-end: $form-control-label-margin;
604-
margin-inline-start: 0;
605-
}
606-
607-
::slotted([slot="end"]:first-of-type) {
608-
margin-inline-start: $form-control-label-margin;
609-
margin-inline-end: 0;
610-
}
611-
612503
/**
613504
* The input password toggle component should be hidden when the input is readonly/disabled
614505
* because it is not possible to edit a password.

core/src/components/input/input.ionic.scss

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@use "../../themes/ionic/ionic.globals.scss" as globals;
2-
@import "./input";
2+
@import "./input.common";
33
@import "./input.ionic.outline.scss";
44

55
// Ionic Input
@@ -13,7 +13,6 @@
1313
--highlight-color-invalid: #{globals.$ion-semantics-danger-800};
1414
--placeholder-color: #{globals.$ion-primitives-neutral-800};
1515
--placeholder-opacity: 1;
16-
--text-color-invalid: #{globals.$ion-semantics-danger-800};
1716
--background: #{globals.$ion-primitives-base-white};
1817

1918
font-size: globals.$ion-font-size-350;
@@ -138,8 +137,7 @@
138137

139138
.input-bottom {
140139
@include padding(globals.$ion-space-100, 0, 0, 0);
141-
142-
font-weight: globals.$ion-font-weight-medium;
140+
@include globals.typography(globals.$ion-body-sm-medium);
143141
}
144142

145143
.input-bottom .helper-text,
@@ -148,11 +146,7 @@
148146
}
149147

150148
:host(.has-focus.ion-valid) .helper-text {
151-
color: globals.$ion-semantics-success-900;
152-
}
153-
154-
:host(.ion-touched.ion-invalid) .error-text {
155-
color: var(--text-color-invalid);
149+
color: var(--highlight-color-valid);
156150
}
157151

158152
:host(.has-focus.ion-valid),
@@ -173,7 +167,6 @@
173167
// ----------------------------------------------------------------
174168

175169
:host(.input-disabled) {
176-
// color for the text within the input
177170
--color: #{globals.$ion-primitives-neutral-500};
178171
--background: #{globals.$ion-primitives-neutral-100};
179172
--border-color: #{globals.$ion-primitives-neutral-300};
@@ -185,7 +178,7 @@
185178
:host(.input-disabled:not(.ion-valid)) .input-bottom .helper-text,
186179
:host(.input-disabled) .input-bottom .counter,
187180
:host(.input-disabled) .label-text-wrapper {
188-
color: globals.$ion-primitives-neutral-500;
181+
color: globals.$ion-text-disabled;
189182
}
190183

191184
:host(.input-disabled.has-focus.ion-valid) {
@@ -201,9 +194,7 @@
201194
}
202195

203196
:host(.input-disabled.has-focus.ion-valid) .input-bottom .helper-text,
204-
:host(.input-disabled.ion-touched.ion-invalid) .error-text,
205-
:host(.input-disabled.ion-color) .input-bottom .helper-text,
206-
:host(.input-disabled.ion-color) .helper-text {
197+
:host(.input-disabled.ion-touched.ion-invalid) .error-text {
207198
opacity: 0.6;
208199
}
209200

core/src/components/input/input.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./input";
1+
@import "./input.native";
22
@import "./input.ios.vars";
33

44
:host {

core/src/components/input/input.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./input";
1+
@import "./input.native";
22
@import "./input.md.vars";
33
@import "./input.md.solid.scss";
44
@import "./input.md.outline.scss";

0 commit comments

Comments
 (0)