-
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
refactor(notched-outline): remove text-field notched outline styles and coupling #2401
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
…al-components/material-components-web into chore/text-field/decouple-outline
…d-outline/update-api
…d-outline/update-api
Codecov Report
@@ Coverage Diff @@
## master #2401 +/- ##
==========================================
+ Coverage 98.88% 98.91% +0.02%
==========================================
Files 104 104
Lines 4210 4234 +24
Branches 533 534 +1
==========================================
+ Hits 4163 4188 +25
+ Misses 47 46 -1
Continue to review full report at Codecov.
|
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.
A few minor nits, but LGTM
`setOutlinePathAttr(value: string) => void` | Sets the "d" attribute of the outline element's SVG path. | ||
`getIdleOutlineStyleValue(propertyName: string) => string` | Returns the idle outline element's computed style value of a given css `propertyName`. | ||
|
||
### `MDCNotchedOutlineFoundation` | ||
|
||
Method Signature | Description | ||
--- | --- | ||
`notch(activateNotch: boolean)` | Adds remove the outline notched selector if activateNotch is true. Updates the component to activate/deactivate 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.
I think this description needs to be reworded. Maybe just the second sentence is needed
@@ -50,13 +57,31 @@ class MDCNotchedOutlineFoundation extends MDCFoundation { | |||
super(Object.assign(MDCNotchedOutlineFoundation.defaultAdapter, adapter)); | |||
} | |||
|
|||
/** | |||
* Adds the outline notched selector and updates the notch width | |||
* if activateNotch is true, otherwise it will remove notched |
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 the notched selector"
packages/mdc-textfield/README.md
Outdated
@@ -274,6 +274,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 |
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.
Trailing period.
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 find <needle_in_haystack_emoji>
…rial-components/material-components-web into refactor/notched-outline/update-api
@@ -82,6 +83,7 @@ Mixin | Description | |||
|
|||
Method Signature | Description | |||
--- | --- | |||
`notch(activateNotch: boolean)` | Updates outline to activate/deactivate notch in outline path. | |||
`updateSvgPath(notchWidth: number, isRtl: boolean) => void` | Updates the SVG of the outline element with a notch calculated based off of the notchWidth. The notch will appear left justified, unless isRtl is true. |
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 we change this so there are two methods
notch(notchWidth: number, isRtl: boolean) => void
and
closeNotch() => void
packages/mdc-textfield/README.md
Outdated
@@ -248,7 +248,7 @@ Method Signature | Description | |||
`isFocused() => boolean` | Returns whether the input is focused | |||
`isRtl() => boolean` | Returns whether the direction of the root element is set to RTL | |||
`hasOutline() => boolean` | Returns whether there is an outline element | |||
`updateOutlinePath(labelWidth: number, isRtl: boolean) => void` | Updates the outline path to create a notch for the label element | |||
`notchOutline(labelWidth: number, isRtl: boolean) => void` | Updates the outline path to create a notch for the label element | |||
|
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.
Do you also need a closeOutlineNotch
method in MDCTextFieldAdapter?
packages/mdc-textfield/foundation.js
Outdated
if (activateNotch) { | ||
this.adapter_.notchOutline(labelWidth, isRtl); | ||
} else { | ||
this.adapter_.notchOutline(0); |
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.
setting the labelWidth = 0 in order to simulate "closing the notch" is unintuitive. Just add another method that explicitly closes the notch
packages/mdc-textfield/foundation.js
Outdated
@@ -204,7 +207,11 @@ class MDCTextFieldFoundation extends MDCFoundation { | |||
const labelScale = isDense ? numbers.DENSE_LABEL_SCALE : numbers.LABEL_SCALE; | |||
const labelWidth = this.adapter_.getLabelWidth() * labelScale; | |||
const isRtl = this.adapter_.isRtl(); |
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.
calculate all this labelWidth and isRTL within the if statement for opening the notch.
packages/mdc-textfield/foundation.js
Outdated
@@ -193,9 +195,10 @@ class MDCTextFieldFoundation extends MDCFoundation { | |||
} | |||
|
|||
/** | |||
* Updates the focus outline for outlined text fields. | |||
* Activates/deactivates the notched outline. | |||
* @param {boolean} activateNotch |
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: open notch? instead of activate?
Change as per material-components-web v0.34.1. reference: material-components/material-components-web#2401
fixes #2128
related #1982