Skip to content

fix(input): floating label works correctly with long text and notch #26273

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

Merged
merged 202 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
202 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
786e3ea
test(input): add base fill html
liamdebeasi Nov 2, 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
40e2e54
Merge remote-tracking branch 'origin/2591-placement' into 2591-fill
liamdebeasi Nov 2, 2022
fe20efa
feat(input): add base solid + shape implementation
liamdebeasi Nov 2, 2022
7670a27
chore(): padding is set on wrapper
liamdebeasi Nov 2, 2022
0a66283
chore(): use mixin
liamdebeasi Nov 2, 2022
9d13fbe
Merge remote-tracking branch 'origin/2591-placement' into 2591-fill
liamdebeasi Nov 2, 2022
3408223
fix(input): padding applied to input wrapper
liamdebeasi Nov 2, 2022
21f32a1
chore(): sync
liamdebeasi Nov 2, 2022
9d77a37
chore(): border radius is set on native input for legacy
liamdebeasi Nov 2, 2022
bf7d77c
fix(input): bottom is adjusted for padding
liamdebeasi Nov 2, 2022
c87f89b
chore(): add more examples
liamdebeasi Nov 2, 2022
10d2af3
fix(input): fixed label does not have end margin
liamdebeasi Nov 2, 2022
d4ff322
Merge remote-tracking branch 'origin/2591-placement' into 2591-fill
liamdebeasi Nov 2, 2022
056c4f4
chore(): test clean up
liamdebeasi Nov 2, 2022
71a9bdb
chore(): deprecate fill and shape on item
liamdebeasi Nov 2, 2022
9e1ce71
chore(): lint
liamdebeasi Nov 2, 2022
18662d1
test(input): add solid tests
liamdebeasi Nov 2, 2022
db83b9f
chore(): lint
liamdebeasi Nov 2, 2022
0dceaf6
chore(): add updated snapshots
Ionitron Nov 2, 2022
629f189
refactor(input): label container is now rendered in separate fn
liamdebeasi Nov 3, 2022
f3582fa
test(input): add more outline examples
liamdebeasi Nov 3, 2022
cc209d5
feat(input): first pass at outline style
liamdebeasi Nov 3, 2022
4af53c3
fix(input): shaped outline has correct padding
liamdebeasi Nov 3, 2022
5406b62
test(input): add more examples
liamdebeasi Nov 3, 2022
24626dc
chore(): update test file
liamdebeasi Nov 3, 2022
a6149ff
test(input): add outline tests
liamdebeasi Nov 3, 2022
9c52ef7
fix(input): bottom input padding is now correct
liamdebeasi Nov 3, 2022
c7d26e9
test(input): update a11y test
liamdebeasi Nov 3, 2022
b619254
fix(input): resolve a11y issues with outline style
liamdebeasi Nov 3, 2022
3803513
chore(): clean up, comments
liamdebeasi Nov 3, 2022
f1927bb
chore(): add updated snapshots
Ionitron Nov 3, 2022
e676edc
refactor(input): begin work on input taking up full container
liamdebeasi Nov 3, 2022
b167b01
Merge branch '2591-fill' of https://github.com/ionic-team/ionic-frame…
liamdebeasi Nov 3, 2022
21820dd
Revert "chore(): add updated snapshots"
liamdebeasi Nov 3, 2022
49c7563
refactor(input): move label class to host
liamdebeasi Nov 3, 2022
c4ad092
chore(): sync
liamdebeasi Nov 3, 2022
fbfd775
fix(input): inputs now take up full container
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
7e9849a
Merge remote-tracking branch 'origin/2591-placement' into 2591-fill
liamdebeasi Nov 3, 2022
f2c6c42
chore(): add updated snapshots
Ionitron Nov 3, 2022
04e17bb
chore(): add updated snapshots
Ionitron Nov 3, 2022
d825070
refactor(input): split css out into separate files, add comments
liamdebeasi Nov 3, 2022
8bc3bc8
chore(): add empty line
liamdebeasi Nov 3, 2022
ea608fa
Merge branch '2591-fill' of https://github.com/ionic-team/ionic-frame…
liamdebeasi Nov 3, 2022
6de0562
chore(): revert padding fix
liamdebeasi Nov 3, 2022
474366a
Revert "chore(): add updated snapshots"
liamdebeasi Nov 3, 2022
9ded038
Merge remote-tracking branch 'origin/2591-placement' into 2591-fill
liamdebeasi Nov 3, 2022
d5d1947
chore(): add updated snapshots
Ionitron Nov 3, 2022
4e86dea
Revert "chore(): add updated snapshots"
liamdebeasi Nov 4, 2022
26976e8
fix(input): remove bottom border from normal input
liamdebeasi Nov 4, 2022
a14c6b7
chore(): add updated snapshots
Ionitron Nov 4, 2022
1584994
fix(input): outline border thickens on focus
liamdebeasi Nov 4, 2022
ecad98e
Merge branch '2591-fill' of https://github.com/ionic-team/ionic-frame…
liamdebeasi Nov 4, 2022
64b53fc
Revert "chore(): add updated snapshots"
liamdebeasi Nov 4, 2022
8be58c1
chore(): add initial examples
liamdebeasi Nov 4, 2022
9f98f60
chore(): add updated snapshots
Ionitron Nov 4, 2022
6edf8e6
feat(input): add base highlight styles for non outline input
liamdebeasi Nov 4, 2022
74c1b10
fix(input): using color adjusts highlight, add valid/invalid
liamdebeasi Nov 4, 2022
ad86cef
fix(input): add outline styles
liamdebeasi Nov 4, 2022
d553d6b
test(input): add more highlight examples
liamdebeasi Nov 4, 2022
817f3e0
fix(input): highlight and state now shows correctly on all inputs
liamdebeasi Nov 4, 2022
11a64bf
chore(): lint
liamdebeasi Nov 4, 2022
095724a
fix(input): validity only shows up after touch
liamdebeasi Nov 4, 2022
149b980
fix(input): validation colors show up always after touch
liamdebeasi Nov 4, 2022
1897a06
fix(input): account for label too
liamdebeasi Nov 4, 2022
3f548fa
fix(input): move old styles to legacy
liamdebeasi Nov 4, 2022
b1bc5af
fix(input): outline appears on ios, animation is md
liamdebeasi Nov 4, 2022
23bcf45
fix(input): fix highlight height
liamdebeasi Nov 4, 2022
fd6201d
fix(input): highlight only appears on MD
liamdebeasi Nov 4, 2022
98754f1
fix(input): highlight styles moved to MD
liamdebeasi Nov 4, 2022
8a2e998
chore(): fix typo
liamdebeasi Nov 4, 2022
8144701
chore(): remove color for now
liamdebeasi Nov 4, 2022
d3b4eac
test(input): add screenshot tests
liamdebeasi Nov 4, 2022
417a278
chore(): code clean up
liamdebeasi Nov 4, 2022
2e2310c
chore(): add updated snapshots
Ionitron Nov 4, 2022
42a13e7
Merge branch '2591-highlight' of https://github.com/ionic-team/ionic-…
liamdebeasi Nov 4, 2022
aee4c2e
test(input): add color layouts
liamdebeasi Nov 7, 2022
7f5febf
fix(input): add per mode color
liamdebeasi Nov 7, 2022
cfc278f
fix(input): adjust color behavior
liamdebeasi Nov 7, 2022
6d6c282
chore(): code cleanup
liamdebeasi Nov 7, 2022
390bbb9
test(input): add color tests
liamdebeasi Nov 7, 2022
b0a897b
chore(): lint
liamdebeasi Nov 7, 2022
b1fc170
chore(): add updated snapshots
Ionitron Nov 7, 2022
0808278
Merge branch '2591-color' of https://github.com/ionic-team/ionic-fram…
liamdebeasi Nov 7, 2022
c703e21
fix(input): fix clear button alignment
liamdebeasi Nov 7, 2022
5bfd7f5
test(input): add more basic tests
liamdebeasi Nov 7, 2022
b1c015b
fix(input): clear button is rendered correctly
liamdebeasi Nov 7, 2022
7855210
test(input): add bottom tests
liamdebeasi Nov 7, 2022
7962be2
chore(): remove old file
liamdebeasi Nov 7, 2022
e6efffc
chore(): add item tests
liamdebeasi Nov 7, 2022
9ec58f2
chore(item): add modern input class
liamdebeasi Nov 7, 2022
c572604
fix(item): remove end padding and overflow for modern input
liamdebeasi Nov 7, 2022
34477ee
fix(input): adjust MD padding
liamdebeasi Nov 7, 2022
a853d4b
fix(input): fix md styles
liamdebeasi Nov 7, 2022
a3f8d78
chore(): update template
liamdebeasi Nov 7, 2022
eaecb89
test(input): add item tests
liamdebeasi Nov 7, 2022
dd84042
chore(): lint
liamdebeasi Nov 7, 2022
186476c
chore(): add todos
liamdebeasi Nov 7, 2022
2b509b3
chore(): add updated snapshots
Ionitron Nov 7, 2022
d9c606c
Merge branch '2591-tests' of https://github.com/ionic-team/ionic-fram…
liamdebeasi Nov 7, 2022
0c85bb1
test(input): fix shape naming
liamdebeasi Nov 7, 2022
570d4de
Revert "chore(): add updated snapshots"
liamdebeasi Nov 7, 2022
6226556
chore(): add updated snapshots
Ionitron Nov 7, 2022
802063d
chore(): sync
liamdebeasi Nov 8, 2022
eba2d07
Revert "chore(): add updated snapshots"
liamdebeasi Nov 8, 2022
c0d97b2
chore(): sync
liamdebeasi Nov 8, 2022
8c8661a
chore(): add updated snapshots
Ionitron Nov 8, 2022
f6f37eb
Merge remote-tracking branch 'origin/FW-2591' into 2591-fill
liamdebeasi Nov 8, 2022
cb0a03a
Merge remote-tracking branch 'origin/2591-fill' into 2591-highlight
liamdebeasi Nov 8, 2022
5a6fd9e
Merge remote-tracking branch 'origin/2591-highlight' into 2591-color
liamdebeasi Nov 8, 2022
5114151
chore(): sync
liamdebeasi Nov 8, 2022
ae46029
fix(input): use padding on label instead of marge
liamdebeasi Nov 8, 2022
5fdc4a7
fix(input): wrapper is label to avoid dead space
liamdebeasi Nov 8, 2022
6dca13b
chore(): revert old commit
liamdebeasi Nov 8, 2022
2639292
fix(input): label placement is correct
liamdebeasi Nov 8, 2022
07b6608
fix(input): label selection focuses input with narrator
liamdebeasi Nov 8, 2022
e3e1687
test(input): check correct element
liamdebeasi Nov 8, 2022
bc91b37
chore(): add updated snapshots
Ionitron Nov 8, 2022
23935db
fix(input): begin fixing notch adjustment
liamdebeasi Nov 9, 2022
759d14c
Merge branch '2591-padding' of https://github.com/ionic-team/ionic-fr…
liamdebeasi Nov 9, 2022
e163059
Revert "fix(input): begin fixing notch adjustment"
liamdebeasi Nov 9, 2022
bb4288a
fix(input): begin fixing notch adjustment
liamdebeasi Nov 9, 2022
7b4bcc6
chore(): code clean up
liamdebeasi Nov 9, 2022
0323f95
test(input): add customization test
liamdebeasi Nov 9, 2022
6a50edf
fix(input): outline container only shows on md
liamdebeasi Nov 9, 2022
79c7f25
test(input): check floating label with fill
liamdebeasi Nov 9, 2022
f483566
test(input): long label now truncates
liamdebeasi Nov 9, 2022
2ae651c
chore(): remove only
liamdebeasi Nov 9, 2022
bdfa1c5
chore(): add updated snapshots
Ionitron Nov 9, 2022
4bd16ea
chore(): remove extra space
liamdebeasi Nov 9, 2022
c87102c
chore(): update notch comment
liamdebeasi Nov 10, 2022
9ee3472
fix(input): floating label is truncated correctly
liamdebeasi Nov 10, 2022
d538e08
Revert "chore(): add updated snapshots"
liamdebeasi Nov 10, 2022
c60c023
chore(): add updated snapshots
Ionitron Nov 11, 2022
65e2f00
chore(): sync
liamdebeasi Nov 11, 2022
f643f31
chore(): lint
liamdebeasi Nov 11, 2022
952f750
chore(): fix other merges
liamdebeasi Nov 11, 2022
336d809
fix(input): solid stacked label has correct width
liamdebeasi Nov 14, 2022
d566c7c
Revert "chore(): add updated snapshots"
liamdebeasi Nov 14, 2022
d0d89af
chore(): add updated snapshots
Ionitron Nov 14, 2022
56e0c0a
fix(input): long labels render correctly
liamdebeasi Nov 14, 2022
decd683
Revert "chore(): add updated snapshots"
liamdebeasi Nov 14, 2022
38f38b5
chore(): add updated snapshots
Ionitron Nov 14, 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
74 changes: 59 additions & 15 deletions core/src/components/input/input.md.outline.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "./input.vars";

// Input Fill: Outline
// ----------------------------------------------------------------

Expand All @@ -9,7 +11,7 @@
}

:host(.input-fill-outline.input-shape-round) {
--border-radius: 9999px;
--border-radius: 28px;
--padding-start: 32px;
--padding-end: 32px;
}
Expand Down Expand Up @@ -62,7 +64,15 @@

:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper,
:host(.input-fill-outline.input-label-placement-floating) .label-text-wrapper {
@include transform-origin(center, top);
@include transform-origin(start, top);

position: absolute;

/**
* Label text should not extend
* beyond the bounds of the input.
*/
max-width: calc(100% - var(--padding-start) - var(--padding-end));
}

/**
Expand All @@ -81,10 +91,15 @@
*/
:host(.has-focus.input-fill-outline.input-label-placement-floating) .label-text-wrapper,
:host(.has-value.input-fill-outline.input-label-placement-floating) .label-text-wrapper,
:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper,
:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper {
@include transform(translateY(-32%), scale(.75));
@include transform(translateY(-32%), scale(#{$input-floating-label-scale}));
@include margin(0);

/**
* Label text should not extend
* beyond the bounds of the input.
*/
max-width: calc((100% - var(--padding-start) - var(--padding-end) - #{$input-md-floating-label-padding * 2}) / #{$input-floating-label-scale});
}

/**
Expand Down Expand Up @@ -128,20 +143,50 @@
border-bottom: var(--border-width) var(--border-style) var(--border-color);
}

:host(.input-fill-outline) .input-outline-start {
@include border-radius(var(--border-radius), 0px, 0px, var(--border-radius));
@include border(null, null, null, var(--border-width) var(--border-style) var(--border-color));

width: 12px;
/**
* Ensures long labels do not cause the notch to flow
* out of bounds.
*/
:host(.input-fill-outline) .input-outline-notch {
max-width: calc(100% - var(--padding-start) - var(--padding-end));
}

/**
* When shape="round", the starting outline fragment
* should appear with a pill shape.
* This element ensures that the notch used
* the size of the scaled text so that the
* border cut out is the correct width.
* The text in this element should not
* be interactive.
*/
:host(.input-fill-outline.input-shape-round) .input-outline-start {
@include border-radius(28px, 0px, 0px, 28px);
width: 28px;
:host(.input-fill-outline) .notch-spacer {
/**
* We need $input-md-floating-label-padding of padding on the right.
* However, we also subtracted $input-md-floating-label-padding from
* the width of .input-outline-start
* to create space, so we need to take
* that into consideration here.
*/
@include padding(null, #{$input-md-floating-label-padding * 2}, null, null);

font-size: calc(1em * #{$input-floating-label-scale});

opacity: 0;
pointer-events: none;
}

:host(.input-fill-outline) .input-outline-start {
@include border-radius(var(--border-radius), 0px, 0px, var(--border-radius));
@include border(null, null, null, var(--border-width) var(--border-style) var(--border-color));

/**
* There should be spacing between the translated text
* and .input-outline-start. However, we can't add this
* spacing onto the notch because it would cause the
* label to look like it is not aligned with the
* text input. Instead, we subtract a few pixels from
* this element.
*/
width: calc(var(--padding-start) - #{$input-md-floating-label-padding});
}

:host(.input-fill-outline) .input-outline-end {
Expand All @@ -163,7 +208,6 @@
*/
:host(.has-focus.input-fill-outline.input-label-placement-floating) .input-outline-notch,
:host(.has-value.input-fill-outline.input-label-placement-floating) .input-outline-notch,
:host(.input-fill-outline.input-label-placement-stacked) .input-outline-notch,
:host(.input-fill-outline.input-label-placement-stacked) .input-outline-notch {
border-top: none;
}
15 changes: 15 additions & 0 deletions core/src/components/input/input.md.solid.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "./input.vars";

// Input Fill: Solid
// ----------------------------------------------------------------

Expand Down Expand Up @@ -59,3 +61,16 @@
*/
@include border-radius(var(--border-radius), var(--border-radius), 0px, 0px);
}

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

:host(.input-fill-solid.input-label-placement-stacked) .label-text-wrapper,
:host(.has-focus.input-fill-solid.input-label-placement-floating) .label-text-wrapper,
:host(.has-value.input-fill-solid.input-label-placement-floating) .label-text-wrapper {
/**
* Label text should not extend
* beyond the bounds of the input.
*/
max-width: calc(100% / #{$input-floating-label-scale});
}
3 changes: 3 additions & 0 deletions core/src/components/input/input.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ $input-md-inset-margin-bottom: ($item-md-padding-bottom * 0.5) !defau

/// @prop - Margin start of the inset input
$input-md-inset-margin-start: $item-md-padding-start !default;

/// @prop - The amount of whitespace to display on either side of the floating label
$input-md-floating-label-padding: 4px !default;
43 changes: 36 additions & 7 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,6 @@
// ----------------------------------------------------------------

.label-text-wrapper {
/**
* 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);

/**
* This causes the label to take up
* the entire height of its container
Expand All @@ -409,6 +402,16 @@

align-items: center;

/**
* Label text should not extend
* beyond the bounds of the input.
* However, we do not set the max
* width to 100% because then
* only the label would show and users
* would not be able to see what they are typing.
*/
max-width: 200px;

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

/**
Expand Down Expand Up @@ -460,6 +463,15 @@
flex-direction: row;
}

:host(.input-label-placement-start) .label-text-wrapper {
/**
* 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);
}

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

Expand All @@ -483,6 +495,15 @@
// Input Label Placement - Fixed
// ----------------------------------------------------------------

:host(.input-label-placement-fixed) .label-text-wrapper {
/**
* 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);
}

/**
* Label is on the left of the input in LTR and
* on the right in RTL. Label also has a fixed width.
Expand Down Expand Up @@ -519,6 +540,8 @@
:host(.input-label-placement-stacked) .label-text-wrapper,
:host(.input-label-placement-floating) .label-text-wrapper {
@include transform-origin(start, top);

max-width: 100%;
}

/**
Expand Down Expand Up @@ -559,4 +582,10 @@
:host(.has-focus.input-label-placement-floating) .label-text-wrapper,
:host(.has-value.input-label-placement-floating) .label-text-wrapper {
@include transform(translateY(50%), scale(.75));

/**
* Label text should not extend
* beyond the bounds of the input.
*/
max-width: calc(100% / #{$input-floating-label-scale});
}
20 changes: 10 additions & 10 deletions core/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -572,28 +572,28 @@ export class Input implements ComponentInterface {
* when fill="outline".
*/
private renderLabelContainer() {
const { labelPlacement } = this;
const hasOutlineFill = this.fill === 'outline';
const needsNotch = labelPlacement === 'floating' || labelPlacement === 'stacked';
const mode = getIonMode(this);
const hasOutlineFill = mode === 'md' && this.fill === 'outline';

if (hasOutlineFill) {
/**
* The outline fill has a special outline
* that appears around the input and the label.
* Certain label placements cause the
* Certain stacked and floating label placements cause the
* label to translate up and create a "cut out"
* inside of that border. When this happens, we need
* to render the label inside of the input-outline-notch
* element. Otherwise, we can render it as a sibling
* of the outline container.
* inside of that border by using the notch-spacer element.
*/
return [
<div class="input-outline-container">
<div class="input-outline-start"></div>
<div class="input-outline-notch">{needsNotch && this.renderLabel()}</div>
<div class="input-outline-notch">
<div class="notch-spacer" aria-hidden="true">
{this.label}
</div>
</div>
<div class="input-outline-end"></div>
</div>,
!needsNotch && this.renderLabel(),
this.renderLabel(),
];
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/components/input/input.vars.scss
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
@import "../../themes/ionic.globals";

/// @prop - How much to scale the floating label by
$input-floating-label-scale: 0.75 !default;
90 changes: 90 additions & 0 deletions core/src/components/input/test/fill/input.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ test.describe('input: fill', () => {
const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(`input-fill-solid-${page.getSnapshotSettings()}.png`);
});
test('should render correctly with floating label', async ({ page }) => {
await page.setContent(`
<ion-input
fill="solid"
label="Email"
label-placement="floating"
value="hi@ionic.io"
helper-text="Enter your email"
maxlength="20"
counter="true"
></ion-input>
`);

const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(
`input-fill-solid-label-floating-${page.getSnapshotSettings()}.png`
);
});
test('should not have visual regressions with shaped solid', async ({ page }) => {
await page.setContent(`
<ion-input
Expand All @@ -38,6 +56,33 @@ test.describe('input: fill', () => {
const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(`input-fill-shaped-solid-${page.getSnapshotSettings()}.png`);
});
test('padding and border radius should be customizable', async ({ page }) => {
await page.setContent(`
<style>
ion-input {
--border-radius: 10px !important;
--padding-start: 50px !important;
--padding-end: 50px !important;
}
</style>

<ion-input
shape="round"
fill="solid"
label="Email"
label-placement="floating"
value="hi@ionic.io"
helper-text="Enter your email"
maxlength="20"
counter="true"
></ion-input>
`);

const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(
`input-fill-shaped-solid-custom-${page.getSnapshotSettings()}.png`
);
});
});
test.describe('input: fill outline', () => {
test('should not have visual regressions', async ({ page }) => {
Expand All @@ -55,6 +100,24 @@ test.describe('input: fill', () => {
const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(`input-fill-outline-${page.getSnapshotSettings()}.png`);
});
test('should render correctly with floating label', async ({ page }) => {
await page.setContent(`
<ion-input
fill="outline"
label="Email"
label-placement="floating"
value="hi@ionic.io"
helper-text="Enter your email"
maxlength="20"
counter="true"
></ion-input>
`);

const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(
`input-fill-outline-label-floating-${page.getSnapshotSettings()}.png`
);
});
test('should not have visual regressions with shaped outline', async ({ page }) => {
await page.setContent(`
<ion-input
Expand All @@ -71,5 +134,32 @@ test.describe('input: fill', () => {
const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(`input-fill-shaped-outline-${page.getSnapshotSettings()}.png`);
});
test('padding and border radius should be customizable', async ({ page }) => {
await page.setContent(`
<style>
ion-input {
--border-radius: 10px !important;
--padding-start: 50px !important;
--padding-end: 50px !important;
}
</style>

<ion-input
shape="round"
fill="outline"
label="Email"
label-placement="floating"
value="hi@ionic.io"
helper-text="Enter your email"
maxlength="20"
counter="true"
></ion-input>
`);

const input = page.locator('ion-input');
expect(await input.screenshot()).toMatchSnapshot(
`input-fill-shaped-outline-custom-${page.getSnapshotSettings()}.png`
);
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading