Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(text-field): Move bottom-line to separate package #2037

Merged
merged 17 commits into from
Jan 31, 2018

Conversation

williamernest
Copy link
Contributor

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 to mdc-bottom-line.
refs: #1981

@codecov-io
Copy link

codecov-io commented Jan 23, 2018

Codecov Report

Merging #2037 into master will decrease coverage by 0.07%.
The diff coverage is 94.23%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/mdc-textfield/constants.js 100% <ø> (ø) ⬆️
packages/mdc-line-ripple/constants.js 100% <ø> (ø)
packages/mdc-line-ripple/index.js 100% <100%> (ø)
packages/mdc-textfield/foundation.js 98.75% <100%> (-0.04%) ⬇️
packages/mdc-textfield/index.js 96.49% <100%> (+0.06%) ⬆️
packages/mdc-line-ripple/foundation.js 90.32% <76.92%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f4e36b...edde073. Read the comment docs.

@bonniezhou bonniezhou self-assigned this Jan 23, 2018
@@ -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",
Copy link
Contributor

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

Copy link
Contributor

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

@@ -9,7 +9,7 @@ path: /catalog/input-controls/text-field/bottom-line/

# Text Field Bottom Line
Copy link
Contributor

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)


##### `MDCTextFieldBottomLine.foundation`
Copy link
Contributor

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.


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.
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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

@@ -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
Copy link
Contributor

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 {
Copy link
Contributor

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);
Copy link
Contributor

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?

@@ -22,6 +22,7 @@
@import "@material/ripple/common";
@import "@material/ripple/mixins";
@import "@material/rtl/mixins";
@import "@material/list/mixins";
Copy link
Contributor

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

@@ -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);
Copy link
Contributor

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);
  }
}

Copy link
Contributor Author

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.

@williamernest williamernest force-pushed the feat/text-field/move-bottom-line-to-own-package branch from 39936e7 to 78a8286 Compare January 26, 2018 22:59
@@ -12738,32 +12738,6 @@
}
}
},
"stylelint-scss": {
Copy link
Contributor

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

Copy link
Contributor Author

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';
Copy link
Contributor

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

Copy link
Contributor Author

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.

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"
Copy link
Contributor

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?


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.
Copy link
Contributor

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
Copy link
Contributor

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

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, {});
Copy link
Contributor

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.

@@ -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);
Copy link
Contributor

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

@@ -21,7 +21,6 @@
@import "@material/ripple/common";
@import "@material/ripple/mixins";
@import "@material/rtl/mixins";
@import "@material/list/mixins";
Copy link
Contributor

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

Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor

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.
Copy link
Contributor

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.

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, {});
Copy link
Contributor

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.

Copy link
Contributor

@lynnmercier lynnmercier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -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.
Copy link
Contributor

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)


### `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
Copy link
Contributor

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)

@williamernest williamernest merged commit 1dc0e85 into master Jan 31, 2018
@williamernest williamernest deleted the feat/text-field/move-bottom-line-to-own-package branch January 31, 2018 23:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants