Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(input): add labelPlacement #26206

Merged
merged 68 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
621dc13
feat(input): add new js and css props
liamdebeasi Oct 31, 2022
d24428c
chore(): copy updates
liamdebeasi Oct 31, 2022
0402ae8
test(input): move old tests to legacy directory
liamdebeasi Oct 31, 2022
7643d2d
feat(input): add legacy vs modern template rendering
liamdebeasi Oct 31, 2022
259a3a2
refactor(form): add form controller
liamdebeasi Oct 31, 2022
a989e94
chore(): update comments
liamdebeasi Oct 31, 2022
2a80a5f
chore(): update tests
liamdebeasi Oct 31, 2022
08ea3a0
chore(): add moved screenshots
liamdebeasi Oct 31, 2022
bd80054
chore(): add moved screenshots
liamdebeasi Oct 31, 2022
19f4994
chore(): fix test file
liamdebeasi Oct 31, 2022
d02c144
chore(): prettier
liamdebeasi Oct 31, 2022
cea5615
feat(input): add base functionality and tests
liamdebeasi Oct 31, 2022
8d7f0c4
feat(input): add missing fixed label
liamdebeasi Oct 31, 2022
6eabc11
feat(input): add basic help text rendering
liamdebeasi Oct 31, 2022
0259004
feat(input): add helper and error text
liamdebeasi Oct 31, 2022
5f765a0
chore(): update descriptions for clarity
liamdebeasi Oct 31, 2022
3e4f70c
test(input): make sure correct content is rendered
liamdebeasi Oct 31, 2022
232d868
test(input): make sure error color can be customized
liamdebeasi Oct 31, 2022
2f6019b
chore(): update test
liamdebeasi Oct 31, 2022
5c3bb0c
chore(): add updated snapshots
Ionitron Oct 31, 2022
f8dc97f
refactor(item): deprecate helper and error slots
liamdebeasi Nov 1, 2022
23af9da
Merge branch '2591-helper' of https://github.com/ionic-team/ionic-fra…
liamdebeasi Nov 1, 2022
eeb7124
feat(input): add counter support
liamdebeasi Nov 1, 2022
b9da66c
refactor(item): deprecate counter and counterFormatter
liamdebeasi Nov 1, 2022
516a615
chore(): a few tweaks
liamdebeasi Nov 1, 2022
2d07367
test(input): clean up tests
liamdebeasi Nov 1, 2022
4a4aca7
Merge remote-tracking branch 'origin/2591-helper' into 2591-counter
liamdebeasi Nov 1, 2022
f855134
test(input): add counter tests
liamdebeasi Nov 1, 2022
a7e4426
chore(): update prop description
liamdebeasi Nov 1, 2022
fff8ed1
Merge remote-tracking branch 'origin/FW-2591' into 2591-props
liamdebeasi Nov 1, 2022
563f177
Update core/src/components/input/input.tsx
liamdebeasi Nov 1, 2022
e1696af
chore(): run build
liamdebeasi Nov 1, 2022
a17a9ae
Merge remote-tracking branch 'origin/2591-props' into 2591-template
liamdebeasi Nov 1, 2022
b458fe7
Merge remote-tracking branch 'origin/2591-template' into 2591-base
liamdebeasi Nov 1, 2022
eace2ec
Merge branch '2591-base' into 2591-helper
liamdebeasi Nov 1, 2022
8be3a58
Merge remote-tracking branch 'origin/2591-helper' into 2591-counter
liamdebeasi Nov 1, 2022
f556aee
chore(input): remove justify property
liamdebeasi Nov 1, 2022
f65f289
chore(): add updated snapshots
Ionitron Nov 1, 2022
e93d734
feat(input): add wip placement
liamdebeasi Nov 1, 2022
71cec98
chore(): clean up styles
liamdebeasi Nov 1, 2022
3a2e063
test(input): add label placement to a11y test
liamdebeasi Nov 1, 2022
d3d10db
test(input): add label placement template
liamdebeasi Nov 1, 2022
9ac44c1
fix(input): adjust input sizing for platform specs
liamdebeasi Nov 1, 2022
b2f5879
test(input): add tests for label placement
liamdebeasi Nov 1, 2022
55092f1
Merge remote-tracking branch 'origin/2591-counter' into 2591-placement
liamdebeasi Nov 1, 2022
661be60
chore(): add updated snapshots
Ionitron Nov 1, 2022
6b8131a
Update core/src/components/input/input.tsx
liamdebeasi Nov 2, 2022
e0b5cd6
feat(input): add missing fill property
liamdebeasi Nov 2, 2022
5a0f812
refactor(): explicitly add element type
liamdebeasi Nov 2, 2022
2bf7b10
test(input): mask test uses new syntax
liamdebeasi Nov 2, 2022
1cc337a
refactor(input): access props once
liamdebeasi Nov 2, 2022
9f04dd1
Merge branch '2591-base' into 2591-helper
liamdebeasi Nov 2, 2022
4272366
chore(): fix el type
liamdebeasi Nov 2, 2022
6d09ad6
Merge remote-tracking branch 'origin/2591-props' into 2591-template
liamdebeasi Nov 2, 2022
9632c22
Merge remote-tracking branch 'origin/2591-template' into 2591-base
liamdebeasi Nov 2, 2022
79ff704
Merge remote-tracking branch 'origin/2591-base' into 2591-helper
liamdebeasi Nov 2, 2022
aa7edae
Merge remote-tracking branch 'origin/2591-helper' into 2591-counter
liamdebeasi Nov 2, 2022
15b1ab6
chore(): sync
liamdebeasi Nov 2, 2022
7670a27
chore(): padding is set on wrapper
liamdebeasi Nov 2, 2022
0a66283
chore(): use mixin
liamdebeasi Nov 2, 2022
3408223
fix(input): padding applied to input wrapper
liamdebeasi Nov 2, 2022
10d2af3
fix(input): fixed label does not have end margin
liamdebeasi Nov 2, 2022
0dceaf6
chore(): add updated snapshots
Ionitron Nov 2, 2022
49c7563
refactor(input): move label class to host
liamdebeasi Nov 3, 2022
a85ca3b
Revert "chore(): add updated snapshots"
liamdebeasi Nov 3, 2022
e58033b
fix(input): adjust size and label offset
liamdebeasi Nov 3, 2022
04e17bb
chore(): add updated snapshots
Ionitron Nov 3, 2022
6323b0c
chore(): sync
liamdebeasi Nov 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions core/src/components/input/input.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
@import "./input.ios.vars";

:host {
--padding-top: #{$input-ios-padding-top};
--padding-end: #{$input-ios-padding-end};
--padding-bottom: #{$input-ios-padding-bottom};
--padding-start: #{$input-ios-padding-start};
--border-width: #{$hairlines-width};
--border-color: #{$item-ios-border-color};

font-size: $input-ios-font-size;
}

:host(.legacy-input) {
--padding-top: #{$input-ios-padding-top};
--padding-end: #{$input-ios-padding-end};
--padding-bottom: #{$input-ios-padding-bottom};
--padding-start: #{$input-ios-padding-start};
}

:host-context(.item-label-stacked),
:host-context(.item-label-floating) {
--padding-top: 8px;
Expand All @@ -27,3 +30,20 @@

background-size: $input-ios-input-clear-icon-size;
}

// Input Wrapper
// ----------------------------------------------------------------

.input-wrapper {
min-height: 44px;
}

/**
* Since the label sits on top of the element,
* the component needs to be taller otherwise the
* label will appear too close to the input text.
*/
:host(.input-label-placement-floating) .input-wrapper,
:host(.input-label-placement-stacked) .input-wrapper {
min-height: 56px;
}
18 changes: 14 additions & 4 deletions core/src/components/input/input.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
// --------------------------------------------------

:host {
--padding-top: #{$input-md-padding-top};
--padding-end: #{$input-md-padding-end};
--padding-bottom: #{$input-md-padding-bottom};
--padding-start: #{$input-md-padding-start};
--border-width: 1px;
--border-color: #{$item-md-border-color};

font-size: $input-md-font-size;
}

:host(.legacy-input) {
--padding-top: #{$input-md-padding-top};
--padding-end: #{$input-md-padding-end};
--padding-bottom: #{$input-md-padding-bottom};
--padding-start: #{$input-md-padding-start};
}

:host-context(.item-label-stacked),
:host-context(.item-label-floating) {
--padding-top: 8px;
Expand All @@ -37,3 +40,10 @@
.input-bottom .counter {
letter-spacing: .0333333333em;
}

// Input Wrapper
// ----------------------------------------------------------------

.input-wrapper {
min-height: 56px;
}
161 changes: 155 additions & 6 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@
--placeholder-font-style: initial;
--placeholder-font-weight: initial;
--placeholder-opacity: .5;
--padding-top: 0;
--padding-end: 0;
--padding-bottom: 0;
--padding-start: 0;
--padding-top: 0px;
--padding-end: 0px;
--padding-bottom: 0px;
--padding-start: 0px;
--background: transparent;
--color: initial;
--border-style: solid;
--highlight-color-focused: #{ion-color(primary, base)};
--highlight-color-valid: #{ion-color(success, base)};
--highlight-color-invalid: #{ion-color(danger, base)};

display: block;

position: relative;

width: 100%;
Expand All @@ -65,6 +67,10 @@
align-items: center;
}

:host(.legacy-input) .native-input {
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
}

:host-context(ion-item:not(.item-label)) {
--padding-start: 0;
}
Expand All @@ -78,7 +84,7 @@

.native-input {
@include border-radius(var(--border-radius));
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
@include padding(0, 0, 0, 0);
@include text-inherit();

display: inline-block;
Expand Down Expand Up @@ -211,11 +217,17 @@
// Input Wrapper
// ----------------------------------------------------------------
.input-wrapper {
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));

display: flex;

flex-grow: 1;

align-items: center;
align-items: stretch;

height: 100%;

background: inherit;
}

// Input Bottom Content
Expand Down Expand Up @@ -276,3 +288,140 @@

padding-inline-start: 16px;
}

// Input Label
// ----------------------------------------------------------------

.input-wrapper label {
/**
* The margin between the label and
* the input should be on the end
* when the label sits at the start.
*/
@include margin(0, 8px, 0, 0);
liamdebeasi marked this conversation as resolved.
Show resolved Hide resolved

/**
* This causes the label to take up
* the entire height of its container
* while still keeping the text centered.
*/
display: flex;

align-items: center;

transition: color 150ms cubic-bezier(.4, 0, .2, 1), transform 150ms cubic-bezier(.4, 0, .2, 1);
}

.input-wrapper input {
/**
* When the floating label appears on top of the
* input, we need to fade the input out so that the
* label does not overlap with the placeholder.
*/
transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

// Input Label Placement
// ----------------------------------------------------------------

/**
* Label is on the left of the input in LTR and
* on the right in RTL.
*/
:host(.input-label-placement-start) .input-wrapper {
flex-direction: row;
}

/**
* Label is on the right of the input in LTR and
* on the left in RTL.
*/
:host(.input-label-placement-end) .input-wrapper {
flex-direction: row-reverse;
}

/**
* The margin between the label and
* the input should be on the start
* when the label sits at the end.
*/
:host(.input-label-placement-end) label {
@include margin(0, 0, 0, 8px);
}

/**
* Label is on the left of the input in LTR and
* on the right in RTL. Label also has a fixed width.
*/
:host(.input-label-placement-fixed) label {
@include margin(0, 0, 0, 0);

flex: 0 0 100px;

width: 100px;
min-width: 100px;
max-width: 200px;
}

/**
* Stacked: Label sits above the input and is scaled down.
* Floating: Label sits over the input when the input has no
* value and is blurred. Label sits above the input and is scaled
* down when the input is focused or has a value.
*
*/
:host(.input-label-placement-stacked) .input-wrapper,
:host(.input-label-placement-floating) .input-wrapper {
flex-direction: column;
align-items: start;
}

/**
* Ensures that the label animates
* up and to the left in LTR or
* up and to the right in RTL.
*/
:host(.input-label-placement-stacked) label,
:host(.input-label-placement-floating) label {
@include transform-origin(start, top);
}

/**
* Ensures the input does not
* overlap the label.
*/
:host(.input-label-placement-stacked) input,
:host(.input-label-placement-floating) input {
@include margin(1px, 0, 0, 0);
}

/**
* This makes the label sit over the input
* when the input is blurred and has no value.
*/
:host(.input-label-placement-floating) label {
@include transform(translateY(100%), scale(1));
}

/**
* The input should be hidden when the label
* is on top of the input. This prevents the label
* from overlapping any placeholder value.
*/
:host(.input-label-placement-floating) input {
opacity: 0;
}

:host(.has-focus.input-label-placement-floating) input,
:host(.has-value.input-label-placement-floating) input {
opacity: 1;
}

/**
* This makes the label sit above the input.
*/
:host(.input-label-placement-stacked) label,
:host(.has-focus.input-label-placement-floating) label,
:host(.has-value.input-label-placement-floating) label {
@include transform(translateY(50%), scale(.75));
}
3 changes: 2 additions & 1 deletion core/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ export class Input implements ComponentInterface {
}

private renderInput() {
const { disabled, readonly, inputId } = this;
const { disabled, readonly, inputId, labelPlacement } = this;
const mode = getIonMode(this);
const value = this.getValue();

Expand All @@ -566,6 +566,7 @@ export class Input implements ComponentInterface {
[mode]: true,
'has-value': this.hasValue(),
'has-focus': this.hasFocus,
[`input-label-placement-${labelPlacement}`]: true,
})}
>
<div class="input-wrapper">
Expand Down
2 changes: 2 additions & 0 deletions core/src/components/input/test/a11y/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ <h1>Input - a11y</h1>

<ion-input label="my label"></ion-input>
<ion-input aria-label="my aria label"></ion-input>
<ion-input label="Email" label-placement="stacked" value="[email protected]"></ion-input>
<ion-input label="Email" label-placement="floating"></ion-input>
</main>
</body>
</html>
1 change: 1 addition & 0 deletions core/src/components/input/test/bottom-content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ <h2>Custom Error Color</h2>
error-text="Please enter a valid email"
></ion-input>
</div>

<div class="grid-item">
<h2>Counter</h2>
<ion-input label="Email" counter="true" maxlength="100"></ion-input>
Expand Down
Loading