-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(text-field): Move bottom-line to separate package #2037
feat(text-field): Move bottom-line to separate package #2037
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2037 +/- ##
==========================================
- Coverage 99.33% 99.25% -0.08%
==========================================
Files 84 84
Lines 3769 3768 -1
Branches 490 489 -1
==========================================
- Hits 3744 3740 -4
- Misses 25 28 +3
Continue to review full report at Codecov.
|
@@ -16,6 +16,7 @@ | |||
"@material/animation": "^0.25.0", | |||
"@material/auto-init": "^0.29.0", | |||
"@material/base": "^0.29.0", | |||
"@material/bottom-line": "^0.29.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.
I think you might need to create a 0.0.0 version first? And then let lerna upgrade it for you when we release? Check with @kfranqueiro
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.
First commit of selection-control, for reference: da9c7a9
packages/mdc-bottom-line/README.md
Outdated
@@ -9,7 +9,7 @@ path: /catalog/input-controls/text-field/bottom-line/ | |||
|
|||
# Text Field Bottom Line |
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 "Text Field" from this
And you'll want to change the docs comment above to something like
<!--docs:
title: "Bottom Line"
layout: detail
section: components
excerpt: "The bottom line indicates where to enter text, displayed below the label"
path: /catalog/input-controls/bottom-line/
-->
(I think you can just drop the iconId, since we don't have an icon for this)
packages/mdc-bottom-line/README.md
Outdated
|
||
##### `MDCTextFieldBottomLine.foundation` |
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, since we are making this a public component, we should not make the foundation a field of MDCBottomLine
anymore. I think we should create proxy methods on MDCBottomLine
which proxy to MDCBottomLineFoundation
's activate
, deactivate
and setTransformOrigin
When it was internal only to text-field, it was easier not to create proxy methods. But I think with this becoming a public component we should protect access to the foundation class.
Of course, you'll also have to change the adapter for Text Field. I think Select has a good example of this here:
https://github.com/material-components/material-components-web/blob/master/packages/mdc-select/index.js#L112
It shows how the Select foundation interacts with a Menu through the Select adapter. I think we need to add methods like activateBottomLine
to the Text Field adapter.
packages/mdc-bottom-line/README.md
Outdated
|
||
Method Signature | Description | ||
--- | --- | ||
`activate() => void` | Activates the bottom line | ||
`deactivate => void` | Deactivates the bottom line | ||
`deactivate() => void` | Immediately deactivates the bottom line | ||
`deactivateFocus() => void` | Sets `isActive_` flag to false, allowing the animation to finish before deactivating. |
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 description is an internal implementation detail. Be more general about what deactivateFocus
is trying to accomplish. Do we still need deactivate
? Shouldn't we always wait for the animation to finish before deactivating?
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 could remove the deactivateFocus
field and combine it's functionality into deactivate
// limitations under the License. | ||
// | ||
|
||
@function mdc-bottom-line-transition($property) { |
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.
transition-value...based of what we did for mdc-elevation
packages/mdc-bottom-line/adapter.js
Outdated
@@ -21,13 +21,13 @@ | |||
* Adapter for MDC TextField Bottom Line. | |||
* | |||
* Defines the shape of the adapter expected by the foundation. Implement this | |||
* adapter to integrate the TextField bottom line into your framework. See | |||
* adapter to integrate the TextField or Select bottom line into your framework. See |
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.
drop "the TextField or Select" and just go with bottom line
|
||
&__bottom-line--active { | ||
&--active { |
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.
drop the & syntax here
width: 100%; | ||
height: 2px; | ||
transform: scaleX(0); | ||
transition: mdc-text-field-transition(transform), mdc-text-field-transition(opacity); |
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 shouldnt have any references to text-field in this file. Why is mdc-text-field-transition
here?
packages/mdc-select/mdc-select.scss
Outdated
@@ -22,6 +22,7 @@ | |||
@import "@material/ripple/common"; | |||
@import "@material/ripple/mixins"; | |||
@import "@material/rtl/mixins"; | |||
@import "@material/list/mixins"; |
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 should not be in this PR
packages/mdc-textfield/_mixins.scss
Outdated
@@ -156,7 +167,7 @@ | |||
@mixin mdc-text-field-invalid_ { | |||
@include mdc-text-field-bottom-line-color($mdc-text-field-error-on-light); | |||
@include mdc-text-field-hover-bottom-line-color($mdc-text-field-error-on-light); | |||
@include mdc-text-field-focused-bottom-line-color($mdc-text-field-error-on-light); | |||
@include mdc-bottom-line-color($mdc-text-field-error-on-light); |
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're calling both mdc-text-field-bottom-line-color
and mdc-bottom-line-color
...Can you change mdc-text-field-bottom-line-color
to call mdc-bottom-line-color
internally?
@mixin mdc-text-field-bottom-line-color_($color) {
@include mdc-bottom-line-color($color);
.mdc-text-field__input {
@include mdc-theme-prop(border-bottom-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.
No, mdc-bottom-line-color
and mdc-text-field-bottom-line-color
are two different colors. The latter is referring to the idle state of the input bottom-border-color
property.
We should probably change mdc-text-field-bottom-line-color
to be more along the lines of mdc-text-field-bottom-border-color
to help differentiate between the two.
39936e7
to
78a8286
Compare
package-lock.json
Outdated
@@ -12738,32 +12738,6 @@ | |||
} | |||
} | |||
}, | |||
"stylelint-scss": { |
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 does not belong 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.
This is from my merge with master.
@@ -14,29 +14,29 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
import autoInit from '@material/auto-init'; |
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 looks like a broken change 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.
This is from my merge with master.
packages/mdc-line-ripple/README.md
Outdated
excerpt: "The bottom line indicates where to enter text, displayed below the label" | ||
iconId: text_field | ||
path: /catalog/input-controls/text-field/bottom-line/ | ||
excerpt: "The line ripple is used to indicate certain information, such as a line of text or a selected 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.
The user specified text is highlighted above the line ripple.
How about that?
packages/mdc-line-ripple/README.md
Outdated
|
||
The bottom line indicates the selected element or text, displayed below the label. When a text field/select is active, the line’s color and thickness vary. | ||
The line ripple is used to indicate the selected element or text. When a the line ripple is active, the line’s color and thickness vary. |
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 description too.
} | ||
|
||
/** | ||
* Sets the transform origin given a user's click location. | ||
* @param {!Event} evt | ||
* @param {!number} normalizedX |
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.
maybe add some more description here about what "normalized" means
packages/mdc-line-ripple/index.js
Outdated
setAttr: (attr, value) => this.root_.setAttribute(attr, value), | ||
registerEventHandler: (evtType, handler) => this.root_.addEventListener(evtType, handler), | ||
deregisterEventHandler: (evtType, handler) => this.root_.removeEventListener(evtType, handler), | ||
notifyAnimationEnd: () => { | ||
this.emit(MDCBottomLineFoundation.strings.ANIMATION_END_EVENT, {}); | ||
this.emit(MDCLineRippleFoundation.strings.ANIMATION_END_EVENT, {}); |
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.
Dont think we need this anymore, since Text Field isn't listening to it. So lets remove it.
packages/mdc-select/foundation.js
Outdated
@@ -251,7 +251,7 @@ export default class MDCSelectFoundation extends MDCFoundation { | |||
close_() { | |||
const {OPEN} = MDCSelectFoundation.cssClasses; | |||
this.adapter_.removeClass(OPEN); | |||
this.adapter_.removeClassFromBottomLine(cssClasses.BOTTOM_LINE_ACTIVE); | |||
this.adapter_.removeClassFromBottomLine(cssClasses.LINE_RIPPLE_ACTIVE); |
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 snuck into this PR I think
packages/mdc-select/mdc-select.scss
Outdated
@@ -21,7 +21,6 @@ | |||
@import "@material/ripple/common"; | |||
@import "@material/ripple/mixins"; | |||
@import "@material/rtl/mixins"; | |||
@import "@material/list/mixins"; |
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 snuck into this PR I 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.
I deleted this, because I accidentally added it in one of my previous commits.
packages/mdc-textfield/README.md
Outdated
@@ -224,8 +224,8 @@ Method Signature | Description | |||
`deregisterTextFieldInteractionHandler(evtType: string, handler: EventListener)` => void | Deregisters an event handler on the root element for a given event | |||
`registerInputInteractionHandler(evtType: string, handler: EventListener)` => void | Registers an event listener on the native input element for a given event | |||
`deregisterInputInteractionHandler(evtType: string, handler: EventListener)` => void | Deregisters an event listener on the native input element for a given event | |||
`registerBottomLineEventHandler(evtType: string, handler: EventListener)` => void | Registers an event listener on the bottom line element for a given event | |||
`deregisterBottomLineEventHandler(evtType: string, handler: EventListener)` => void | Deregisters an event listener on the bottom line element for a given event | |||
`registerLineRippleEventHandler(evtType: string, handler: EventListener)` => void | Proxies to MDCLineRipple to register an event listener on the line ripple element for a given event |
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 can remove this too
@@ -80,11 +80,11 @@ class MDCLineRippleFoundation extends MDCFoundation { | |||
|
|||
/** | |||
* Sets the transform origin given a user's click location. |
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 should be: setRippleCenter(xCoordinate)
Because really "transform-origin" is an internal implementation detail to line-ripple CSS.
And the description should be: "Sets the center of the ripple animation to the given X coordinate"
...or something in that direction anyway.
packages/mdc-line-ripple/index.js
Outdated
setAttr: (attr, value) => this.root_.setAttribute(attr, value), | ||
registerEventHandler: (evtType, handler) => this.root_.addEventListener(evtType, handler), | ||
deregisterEventHandler: (evtType, handler) => this.root_.removeEventListener(evtType, handler), | ||
notifyAnimationEnd: () => { | ||
this.emit(MDCTextFieldBottomLineFoundation.strings.ANIMATION_END_EVENT, {}); | ||
this.emit(MDCLineRippleFoundation.strings.ANIMATION_END_EVENT, {}); |
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 thought you were going to remove this ANIMATION_END_EVENT? It doesn't seem necessary.
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
packages/mdc-line-ripple/README.md
Outdated
@@ -50,7 +50,7 @@ CSS Class | Description | |||
|
|||
`activate() => void` | Proxies to the foundations `activate()` method. | |||
`deactivate() => void` | Proxies to the foundations `deactivate()` method. | |||
`setTransformOrigin(evt: Event) => void` | Proxies to the foundations `setTransformOrigin(evt: Event)` method. | |||
`setRippleCenter(evt: Event) => void` | Proxies to the foundations `setRippleCenter(evt: Event)` method. |
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.
number: xCoordinate (not evt:Event)
packages/mdc-line-ripple/README.md
Outdated
|
||
### `MDCLineRippleFoundation` | ||
|
||
Method Signature | Description | ||
--- | --- | ||
`activate() => void` | Activates the line ripple | ||
`deactivate() => void` | Deactivates the line ripple | ||
`setTransformOrigin(evt: Event) => void` | Sets the transform origin given a user's click location | ||
`setRippleCenter(evt: Event) => void` | Sets the transform origin given a user's click location |
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.
number: xCoordinate (not evt:Event)
BREAKING CHANGE: Moves the text-field bottom-line element to a new package, so we can reuse it in other components. The HTML class name for the bottom-line element has changed from
mdc-text-field__bottom-line
tomdc-bottom-line
.refs: #1981