-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
chore(notched-outline): separate outline from text-field #2326
Conversation
…ate with mdc-text-field
…-components/material-components-web into chore/text-field/decouple-label
…-components/material-components-web into chore/text-field/decouple-label
…ext-field accordingly
…d in respective places
…-components/material-components-web into chore/text-field/decouple-label
packages/mdc-textfield/README.md
Outdated
Mixin | Description | ||
--- | --- | ||
`mdc-text-field-outline-color($color)` | Customizes the border color of the outline text field. | ||
`mdc-text-field-outlined-corner-radius($radius)` | Sets the border radius of of the text field outline 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.
@bonniezhou I think this should be changed to mdc-text-field-outline-corner-radius
what do you think?
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.
Actually I'm going to change mdc-text-field-outline-color
--> mdc-text-field-outlined-color
so it isn't a breaking change.
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.
How is that not a breaking change? AFAICT mdc-text-field-outline-color
is also already a thing that exists.
Plus, it seems like the one "outlined" name is the outlier, and "outline" sounds more natural to me in mixin names, so IMO I'd go with your first suggestion.
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.
True, but that mdc-text-field-outline-color
is in the mdc-text-field__outline package, which is moved to the mdc-notched-outline. I this would cover it:
BREAKING CHANGE: removed mdc-text-field__outline element for mdc-notched-outline
But yes you're right, mdc-text-field-outline-color
and mdc-text-field-outline-corner-radius
are more natural.
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.
Yeah I think initially "Outlined" should refer to the variant of Text Field and "Outline" refers to the actual subcomponent. But changing them both to "Outline" sounds like a good idea, and would cause less confusion.
BREAKING CHANGE: renamed mdc-text-field-outlined-corner-radius to mdc-text-field-outline-corner-radius
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.
LGTM!
@lynnjepsen will take the review from here 😄 |
package-lock.json
Outdated
@@ -2,6 +2,16 @@ | |||
"requires": true, | |||
"lockfileVersion": 1, | |||
"dependencies": { | |||
"JSONStream": { |
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 think package-lock.json should change in this PR. We're only adding new modules.
packages/mdc-textfield/_mixins.scss
Outdated
@include mdc-text-field-outline-color($mdc-text-field-error); | ||
@include mdc-text-field-hover-outline-color($mdc-text-field-error); | ||
@include mdc-text-field-focused-outline-color($mdc-text-field-error); | ||
} | ||
|
||
@mixin mdc-text-field-outlined-focused_ { | ||
.mdc-text-field__outline-path { | ||
.mdc-notched-outline__path { | ||
stroke-width: 2px; |
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 we should make a mixin to support customizing the width of the notched outline. And then call that mixin here.
packages/mdc-textfield/_mixins.scss
Outdated
border: 1px solid; | ||
.mdc-notched-outline, | ||
.mdc-notched-outline__idle { | ||
@include mdc-text-field-outline-corner-radius($mdc-text-field-border-radius); |
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.
calling a text-field mixin within the scope of .mdc-notched-outline
seems backwards. Shouldn't we call a notched outline mixin here?
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.
good catch...that should be a notched-outline mixin
packages/mdc-textfield/_mixins.scss
Outdated
|
||
@mixin mdc-text-field-outline-color_($color) { | ||
@include mdc-notched-outline-idle-color($color); | ||
@include mdc-notched-outline-color($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.
Add a comment that outlined version of text field wants the "idle" and "notched" version to have the same color. This covers two cases: 1) the "idle" state when a text field renders with no value 2) the "notched" state when a text field renders with an initial value
packages/mdc-textfield/_mixins.scss
Outdated
.mdc-text-field__icon:hover ~ { | ||
@include mdc-notched-outline-idle-color($color); | ||
|
||
.mdc-notched-outline { |
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.
Put a bunch of comments here around the ~ and sibling selector, and why thats hella complicated because mdc-notched-outline__path
is a sub-element but mdc-notched-outline__idle
is a sibling element.
And then file a GitHub issue to investigate making mdc-notched-outline__idle
a sub-element of mdc-notched-outline
.
packages/mdc-textfield/adapter.js
Outdated
@@ -43,7 +43,7 @@ let NativeInputType; | |||
* helperText: (!MDCTextFieldHelperTextFoundation|undefined), | |||
* icon: (!MDCTextFieldIconFoundation|undefined), | |||
* label: (!MDCFloatingLabelFoundation|undefined), | |||
* outline: (!MDCTextFieldOutlineFoundation|undefined) | |||
* outline: (!MDCNotchedOutlineFoundation|undefined) |
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.
You dont need lineRipple, label, or outline anymore. MDCTextFieldFoundation
only needs helperText and icon
…al-components/material-components-web into chore/text-field/decouple-outline
…al-components/material-components-web into chore/text-field/decouple-outline
} | ||
|
||
@mixin mdc-notched-outline-corner-radius($radius) { | ||
&, |
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.
Add some comments here about why you have to do this
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 you are looking at an older commit. This is now
@mixin mdc-notched-outline-corner-radius($radius) {
border-radius: $radius;
}
@mixin mdc-notched-outline-idle-corner-radius($radius) {
.mdc-notched-outline__idle {
border-radius: $radius;
}
}
package-lock.json
Outdated
@@ -2,16 +2,6 @@ | |||
"requires": true, | |||
"lockfileVersion": 1, | |||
"dependencies": { | |||
"JSONStream": { |
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 changed again...remove this from 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.
Ah nevermind. Ignore me.
`mdc-notched-outline-stroke-width($width)` | Changes notched outline width to a specified pixel value. | ||
`mdc-notched-outline-corner-radius($radius)` | Sets the corner radius of the notched outline element to the given number. | ||
`mdc-notched-outline-idle-corner-radius($radius)` | Sets the corner radius of the notched outline element in idle state. | ||
> NOTE: |
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.
Change this whole NOTE to
Because notched-outline has sibling elements, you need to call the "idle" Sass mixins with parent selectors.
Consider the following example HTML:
<div class="foo-line-ripple-parent">
<div class="mdc-notched-outline foo-line-ripple">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-notched-outline__idle"></div>
</div>
In order to customize any "non-idle" part of notched-outline, use the .foo-line-ripple
CSS selector:
.foo-line-ripple {
@include mdc-notched-outline-color(fooColor);
}
But in order to customize any "idle" part of the notched-outline, you must use the .foo-line-ripple-parent
CSS selector:
.foo-line-ripple-parent {
@include mdc-notched-outline-idle-color(fooColor);
}
fixes #2128
related #1982
BREAKING CHANGE: removed mdc-text-field__outline element for mdc-notched-outline.
Renamed mdc-text-field-outlined-corner-radius to mdc-text-field-outline-corner-radius.