Skip to content

Commit 1c89846

Browse files
committed
refactor(input): split common and native styles
1 parent a2d2cd6 commit 1c89846

File tree

5 files changed

+196
-125
lines changed

5 files changed

+196
-125
lines changed

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

Lines changed: 12 additions & 120 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,8 +19,6 @@
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
2624
*
@@ -32,17 +30,11 @@
3230
--placeholder-color: initial;
3331
--placeholder-font-style: initial;
3432
--placeholder-font-weight: initial;
35-
--placeholder-opacity: #{$placeholder-opacity};
3633
--padding-top: 0px;
3734
--padding-end: 0px;
3835
--padding-bottom: 0px;
3936
--padding-start: 0px;
40-
--background: transparent;
41-
--color: initial;
4237
--border-style: solid;
43-
--highlight-color-focused: #{ion-color(primary, base)};
44-
--highlight-color-valid: #{ion-color(success, base)};
45-
--highlight-color-invalid: #{ion-color(danger, base)};
4638

4739
/**
4840
* This is a private API that is used to switch
@@ -58,16 +50,10 @@
5850

5951
width: 100%;
6052

61-
min-height: 44px;
62-
6353
/* stylelint-disable-next-line all */
6454
padding: 0 !important;
6555

6656
color: var(--color);
67-
68-
font-family: $font-family-base;
69-
70-
z-index: $z-index-item-input;
7157
}
7258

7359
:host-context(ion-item)[slot="start"],
@@ -79,19 +65,6 @@
7965
--highlight-color-focused: #{current-color(base)};
8066
}
8167

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

@@ -190,18 +163,13 @@
190163
align-items: center;
191164
justify-content: center;
192165

193-
width: 30px;
194-
height: 30px;
195-
196166
border: 0;
197167

198168
outline: none;
199169

200170
background-color: transparent;
201171
background-repeat: no-repeat;
202172

203-
color: $text-color-step-400;
204-
205173
visibility: hidden;
206174
appearance: none;
207175
}
@@ -210,17 +178,6 @@
210178
color: inherit;
211179
}
212180

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

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

304254
justify-content: space-between;
305255

306256
border-top: var(--border-width) var(--border-style) var(--border-color);
307257

308-
font-size: dynamic-font(12px);
309-
310258
white-space: normal;
311259
}
312260

@@ -341,8 +289,6 @@
341289

342290
.input-bottom .helper-text {
343291
display: block;
344-
345-
color: $text-color-step-300;
346292
}
347293

348294
:host(.ion-touched.ion-invalid) .input-bottom .error-text {
@@ -364,11 +310,7 @@
364310
*/
365311
@include margin-horizontal(auto, null);
366312

367-
color: $text-color-step-300;
368-
369313
white-space: nowrap;
370-
371-
padding-inline-start: 16px;
372314
}
373315

374316
// Input Native
@@ -463,15 +405,6 @@
463405
flex-direction: row;
464406
}
465407

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

@@ -483,27 +416,9 @@
483416
flex-direction: row-reverse;
484417
}
485418

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

498-
:host(.input-label-placement-fixed) .label-text-wrapper {
499-
/**
500-
* The margin between the label and
501-
* the input should be on the end
502-
* when the label sits at the start.
503-
*/
504-
@include margin(0, $form-control-label-margin, 0, 0);
505-
}
506-
507422
/**
508423
* Label is on the left of the input in LTR and
509424
* on the right in RTL. Label also has a fixed width.
@@ -551,15 +466,6 @@
551466
z-index: 2;
552467
}
553468

554-
/**
555-
* Ensures the input does not
556-
* overlap the label.
557-
*/
558-
:host(.input-label-placement-stacked) input,
559-
:host(.input-label-placement-floating) input {
560-
@include margin(1px, 0, 0, 0);
561-
}
562-
563469
/**
564470
* This makes the label sit over the input
565471
* when the input is blurred and has no value.
@@ -568,6 +474,15 @@
568474
@include transform(translateY(100%), scale(1));
569475
}
570476

477+
/**
478+
* Ensures the input does not
479+
* overlap the label.
480+
*/
481+
:host(.input-label-placement-stacked) input,
482+
:host(.input-label-placement-floating) input {
483+
@include margin(1px, 0, 0, 0);
484+
}
485+
571486
/**
572487
* The input should be hidden when the label
573488
* is on top of the input. This prevents the label
@@ -582,32 +497,9 @@
582497
opacity: 1;
583498
}
584499

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

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

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

Lines changed: 2 additions & 3 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
@@ -139,8 +139,7 @@
139139

140140
.input-bottom {
141141
@include padding(globals.$ion-space-100, 0, 0, 0);
142-
143-
font-weight: globals.$ion-font-weight-medium;
142+
@include globals.typography(globals.$ion-body-sm-medium);
144143
}
145144

146145
.input-bottom .helper-text,

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)