-
Notifications
You must be signed in to change notification settings - Fork 2.1k
refactor(text-field): Change text-field--box to be the new default #2859
Conversation
Add changes to CSS classes to override necessary styles. Edit README to reflect the new default. Edit JS to match the changes. Edit constants in JS.
packages/mdc-textfield/_mixins.scss
Outdated
@@ -129,17 +129,21 @@ | |||
// Baseline | |||
|
|||
@mixin mdc-text-field-disabled_ { | |||
@include mdc-text-field-bottom-line-color_($mdc-text-field-disabled-border); | |||
@include mdc-text-field-bottom-line-color_($mdc-text-field-outlined-disabled-border); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use $mdc-text-field-disabled-border
here and it should be set to 12% black (I think at least, by eyeballing the spec).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
@mixin mdc-floating-label-width($width) { | ||
.mdc-floating-label { | ||
width: calc(100% - #{$width}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this mixin to just set width: $width
Then the calc(...)
logic can go in the text field CSS, since the text field handles the icon and that's the reason for subtracting part of the width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
packages/mdc-textfield/_mixins.scss
Outdated
@include mdc-text-field-ink-color_($mdc-text-field-disabled-ink-color); | ||
@include mdc-text-field-label-ink-color_($mdc-text-field-disabled-label-color); | ||
@include mdc-text-field-helper-text-color_($mdc-text-field-disabled-helper-text-color); | ||
@include mdc-text-field-icon-color_($mdc-text-field-disabled-icon); | ||
@include mdc-text-field-fullwidth-bottom-line-color_($mdc-text-field-fullwidth-bottom-line-color); | ||
@include mdc-text-field-fill-color_($mdc-text-field-disabled-background); | ||
@include mdc-text-field-label-color($mdc-text-field-disabled-label-color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 139 can be removed, since the label color is set in line 134.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
packages/mdc-textfield/_mixins.scss
Outdated
pointer-events: none; | ||
|
||
.mdc-text-field__input { | ||
border-bottom: 1px dotted; | ||
border-bottom-width: 1px; | ||
border-bottom-style: dotted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can actually remove the dotted
border-bottom-style too because it's no longer in the spec for disabled text fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
packages/mdc-textfield/_mixins.scss
Outdated
|
||
height: 56px; | ||
display: inline-flex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed because it's already set in the default text field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
assert.isNull(component.ripple); | ||
}); | ||
|
||
test('#constructor sets the ripple property to `null` when given a `mdc-text-field--textarea`', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename this test #constructor does not instantiate a ripple when ${cssClasses.TEXTAREA} class is present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -79,6 +79,7 @@ Mixin | Description | |||
`mdc-floating-label-shake-keyframes($modifier, $positionY, $positionX, $scale)` | Generates a CSS `@keyframes` at-rule for an invalid label shake. Used in conjunction with the `mdc-floating-label-shake-animation` mixin. | |||
`mdc-floating-label-shake-animation($modifier)` | Applies shake keyframe animation to label. | |||
`mdc-floating-label-float-position($positionY, $positionX, $scale)` | Sets position of label when floating. | |||
`mdc-floating-label-width($width))` | Sets width of label when floating. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the description to be "Sets the width of the label" since it actually sets the width of the label in both its floating and non-floating position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
packages/mdc-textfield/README.md
Outdated
> | ||
> Other input types (such as `date`) are not currently supported. | ||
> Other input types (such as `number` and `date`) are not currently supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think this is also from the bad sync. I am reverting it back to how it was.
packages/mdc-textfield/README.md
Outdated
`mdc-text-field-box-corner-radius($radius)` | Customizes the border radius for the text field box variant. | ||
`mdc-text-field-box-fill-color($color)` | Customizes the background color of the text field box. | ||
`mdc-text-field-corner-radius($radius)` | Customizes the border radius for the text field. | ||
`mdc-text-field-fill-color($color)` | Customizes the background color of the text field. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consolidate the "Other Mixins" table into the "Mixins for Text Field" table. They don't need to be separate anymore since there's no more Box variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete!
packages/mdc-textfield/README.md
Outdated
@@ -313,8 +305,6 @@ Method Signature | Description | |||
`activateFocus() => void` | Activates the focus state of the Text Field. Normally called in response to the input focus event. | |||
`deactivateFocus() => void` | Deactivates the focus state of the Text Field. Normally called in response to the input blur event. | |||
`setHelperTextContent(content: string) => void` | Sets the content of the helper text. | |||
`setIconAriaLabel(label: string) => void` | Sets the aria label of the icon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed accidentally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never removed this so it must have been a bad sync on my part. I added it back!
Delete unneeded demo JS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I scanned through some of this and left a few comments.
demos/text-field.html
Outdated
); | ||
}); | ||
}); | ||
// demoReady(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, I'm not sure why this was commented out (I assume it's for the demo for the old default text field variant being removed), but it should be removed entirely if it's supposed to be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching that!
@@ -144,19 +152,6 @@ | |||
@include mdc-text-field-dense-with-trailing-icon_; | |||
} | |||
|
|||
.mdc-text-field--upgraded:not(.mdc-text-field--fullwidth):not(.mdc-text-field--box) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused as to why this was entirely removed? AFAICT the --upgraded
modifier is no longer used if we remove this.
Historically we supported text field both CSS-only and with JS, which is why this modifier existed. Support for that was dropped more recently due to all of the work going into the filled and outlined variants. I suppose pursuing support for that again would need to be a separate effort anyway; if we've collapsed these styles into the defaults, we can remove all mention of the upgraded modifier in docs and JS.
I'm particularly wondering why the height: 48px
disappeared though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted all the upgraded CSS code since text-field wont be supporting CSS only.
@@ -186,7 +181,7 @@ | |||
margin-bottom: 4px; | |||
} | |||
|
|||
.mdc-text-field--box + &, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little nervous about changes like this that just remove --box
because whereas --box
only ever applied to one variant, mdc-text-field
applies to every MDC text field (thus making the --outlined
selector after this completely redundant). Are we sure this is what we want, or should there be exceptions to this?
We should check this for anything where --box
specifically was removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only area where --box was removed and the .mdc-text-field part of it was left. This affects specifically the helper text that only the default and outlined variants have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I deleted the outlined line because both the outline and the default variant have the .mdc-text-field class
Remove the outlined css selector because both the outlined version and the default variant (box) will have the .mdc-text-field
packages/mdc-textfield/README.md
Outdated
@@ -207,12 +199,17 @@ apply these mixins with CSS selectors such as `.foo-text-field.mdc-text-field--i | |||
|
|||
> _NOTE_: the `mdc-line-ripple-color` mixin should be applied from the not focused class `foo-text-field:not(.mdc-text-field--focused)`). | |||
|
|||
#### Mixins for Text Field Box | |||
#### Mixins for Text Field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might still want to split this up... IIUC ink/label color are applicable to any text field, while the others are specific to the filled text field (i.e. they wouldn't make sense on an outlined text field).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I separated them into Mixings specific for Filled Text Fields and All text fields
packages/mdc-textfield/_mixins.scss
Outdated
|
||
pointer-events: none; | ||
|
||
.mdc-text-field__input { | ||
border-bottom: 1px dotted; | ||
// border-bottom-width: 1px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this selector entirely if the styles are going away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely right, I forgot to delete the commented code. Got it!
packages/mdc-textfield/_mixins.scss
Outdated
line-height: 1.15; | ||
pointer-events: none; | ||
text-overflow: clip; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why these 4 styles were added - especially pointer-events: auto, didn't we recently intentionally set that to none to avoid the label stealing clicks from the input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to recreate the same effects that the text fields had before and so since more CSS was added in to the default .mdc-text-field I added styles to counteract the changes. However, Pointer-events actually does not counteract anything so i took that one out.
@@ -176,12 +178,16 @@ | |||
} | |||
|
|||
@mixin mdc-text-field-dense_ { | |||
// NOTE: This is an eyeball'd approximation of what's in the mocks. | |||
@include mdc-floating-label-float-position(110%, 0%, $mdc-text-field-dense-label-scale); | |||
@include mdc-floating-label-float-position($mdc-text-field-dense-label-position-y, 0%, $mdc-text-field-dense-label-scale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed from 110% to 70%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
110% was the value for the variant being deprecated and the new default has a value of 70%. The only two variants this affects is the outlined and the "box" however the outlined has its own value in dense.
cursor: text; | ||
overflow: hidden; | ||
// Force the label into its own layer to prevent to prevent visible layer promotion adjustments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to prevent" is repeated
Also, this sounds like something that should be a separate fix, not in this PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can create a PR for that.
packages/mdc-textfield/_mixins.scss
Outdated
@include mdc-rtl-reflexive-position(left, 16px); | ||
|
||
position: absolute; | ||
bottom: 20px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused why this was moved to a common mixin used for both filled and outlined text fields, if it was formerly specific to outlined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was specified in the outlined mixin but actually it was used in both the box variant and the outlined.
&:not(.mdc-text-field--textarea) { | ||
@include mdc-states-base-color(transparent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing states overridden to transparent several places in this file. I would sooner add :not
selectors to our application of states styles than override it everywhere else (which will create far more styles in the output CSS; try npm run build
and see). Is there a reason you didn't do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think per our conversation its better to not have them too specific for the user to be able to customize it?
@@ -473,6 +413,8 @@ | |||
// to position the label within the bounds of the inset padding. | |||
@include mdc-floating-label-float-position($mdc-text-field-textarea-label-position-y, 0%, $mdc-text-field-textarea-label-scale); | |||
@include mdc-floating-label-shake-animation(textarea); | |||
@include mdc-states-base-color(transparent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment RE excluding selectors for states styles rather than overriding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before.
packages/mdc-textfield/_mixins.scss
Outdated
height: auto; | ||
align-self: auto; | ||
box-sizing: content-box; | ||
height: 30px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by why this is changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt seem to show a difference in my comparison with master. Will follow up with you
… and split readme mixins
packages/mdc-textfield/README.md
Outdated
|
||
Mixin | Description | ||
--- | --- | ||
`mdc-text-field-box-corner-radius($radius)` | Customizes the border radius for the text field box variant. | ||
`mdc-text-field-box-fill-color($color)` | Customizes the background color of the text field box. | ||
`mdc-text-field-ink-color($color)` | Customizes the text entered into the text field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Customizes the color of the text..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
packages/mdc-textfield/_mixins.scss
Outdated
border: none; | ||
overflow: visible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what this does in the context of the outlined textfield and why it's necessary to make the content overflow visible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In default, overflow is set to visible. When moving the Box variant to the new default it made overflow to hidden in the mdc-text-field class. It is necessary to set it to visible because when the label floats to the border of the box if it was not visible then the top half of the text would be cut.
Codecov Report
@@ Coverage Diff @@
## master #2859 +/- ##
==========================================
+ Coverage 98.37% 98.39% +0.01%
==========================================
Files 123 123
Lines 5185 5185
Branches 639 639
==========================================
+ Hits 5101 5102 +1
+ Misses 84 83 -1
Continue to review full report at Codecov.
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
Something went wrong the last time this branch was synced. I'm adding the do-not-merge label until that's sorted out. |
…ts/material-components-web into text-field/box-default
Latest screenshot test with known helper text diffs. |
cursor: auto; | ||
} | ||
// stylelint-enable plugin/selector-bem-pattern | ||
} | ||
|
||
.mdc-floating-label { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure all of these styles except for pointer-events: none;
are now redundant with styles in the mdc-floating-label package.
Also, there's lint complaints on this line.
112:1 ✖ Invalid component selector ".mdc-floating-label" plugin/selector-bem-pattern
112:1 ✖ Expected selector ".mdc-floating-label" to come before selector ".mdc-text-field__input:-webkit-autofill + .mdc-floating-label" no-descending-specificity
packages/mdc-textfield/README.md
Outdated
@@ -202,12 +201,23 @@ apply these mixins with CSS selectors such as `.foo-text-field.mdc-text-field--i | |||
|
|||
> _NOTE_: the `mdc-line-ripple-color` mixin should be applied from the not focused class `foo-text-field:not(.mdc-text-field--focused)`). | |||
|
|||
#### Mixins for Text Field Box | |||
#### Mixins for all Text Field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This heading doesn't seem quite accurate... at the very least, the label color mixin is only applicable to filled/outlined, not full-width / textarea (which don't use floating label).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label color mixin applies to fullwidth and textarea.
demos/theme/index.html
Outdated
@@ -800,7 +800,7 @@ <h3 class="mdc-typography--headline5 demo-component-section__heading"> | |||
</p> | |||
</figure> | |||
<figure class="demo-text-field-wrapper"> | |||
<div class="mdc-text-field mdc-text-field--box demo-text-field"> | |||
<div class="mdc-text-field demo-text-field"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input and helper text under this text field still has an id that says box, do we want to update that?
|
||
// Floating Label | ||
@include mdc-text-field-floating-label_; | ||
// The following mixins will be removed after select is updated to default to the box. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment or the shake-animation/keyframes taking text-field-box
as an identifier. The mdc-select package doesn't depend on mdc-text-field at all, so what is this doing? The only reference I see to this within Select's own styles is with text-field-outlined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is stating that this isn't being updated until the floating-label is updated after the select. Updating these requires me to change things in the floating-label package, which is not within the scope of this PR.
No, it wasn't using the correct class for height/width in the golden. |
Stale review
Add changes to CSS classes to override necessary styles. Edit README to reflect the new default. Edit JS to match the changes. Change tests and constants to reflect the new changes.
Fixes #2780