Skip to content
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

Merged
merged 108 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
a9d6c3c
chore(floating-label): moved floating-label to new package and integr…
Feb 6, 2018
9b750cd
chore(floating-label): changed all css classes to floating-label
Feb 7, 2018
4b01134
Merge branch 'master' into chore/text-field/decouple-label
Feb 8, 2018
5a4500f
fix(floating-label): fixed all tests
Feb 8, 2018
324a638
chore(floating-label): created test directory
Feb 8, 2018
51f16f6
fix(floating-label): removed label foundation from text-field
Feb 9, 2018
af02b19
Merge branch 'master' into chore/text-field/decouple-label
Feb 10, 2018
6f9abdf
fix(floating-label): tests
Feb 12, 2018
028c00d
Merge branch 'master' into chore/text-field/decouple-label
Feb 12, 2018
024ff39
fix(floating-label): updated readmes to reflect changes to floating-l…
Feb 12, 2018
2f72c61
fix(floating-label): closure annotation
Feb 12, 2018
c2f6b95
Merge branch 'master' into chore/text-field/decouple-label
Feb 12, 2018
f452125
chore(floating-label): moved text-field-placeholder css rule into tex…
Feb 12, 2018
f00ef39
Merge branch 'chore/text-field/decouple-label' of github.com:material…
Feb 12, 2018
4a9846c
chore(text-field): moved invalid label keyframe animation shakes to t…
Feb 13, 2018
1f2cf62
fix(text-field): removed export of floating label
Feb 13, 2018
ab8b035
Merge branch 'master' into chore/text-field/decouple-label
Feb 13, 2018
040f739
fix(text-field): closure annotations
Feb 13, 2018
d3871a3
Merge branch 'chore/text-field/decouple-label' of github.com:material…
Feb 15, 2018
252ffc4
Merge branch 'master' into chore/text-field/decouple-label
Feb 15, 2018
43bd881
fix(floating-label): sass compliation failure
Feb 15, 2018
9b627e2
fix(text-field): updated foundation methods to guard against !hasLabe…
Feb 16, 2018
808b6ff
Merge branch 'master' into chore/text-field/decouple-label
Feb 16, 2018
bed6857
Merge branch 'master' into chore/text-field/decouple-label
Feb 16, 2018
2c1c55e
fix(text-field): changed floating-label ink color mixin and updated t…
Feb 16, 2018
d7e1776
fix(floating-label): updated API for shake and float in component, an…
Feb 17, 2018
8a03462
Merge branch 'master' into chore/text-field/decouple-label
Feb 20, 2018
5973760
fix(floating-label): reorder scss import statements alphabetical
Feb 20, 2018
8385248
Merge branch 'chore/text-field/decouple-label' of github.com:material…
Feb 20, 2018
182b4b1
Merge branch 'master' into chore/text-field/decouple-label
Feb 21, 2018
ce05cda
fix(floating-label): rename from styleShake to shake and styleFloat t…
Feb 21, 2018
1a0aa6c
Merge branch 'master' into chore/text-field/decouple-label
Feb 21, 2018
7f69180
Merge branch 'master' into chore/text-field/decouple-label
Feb 21, 2018
f8ca6f1
fix(floating-label): moved animationend listeners to the init/destroy…
Feb 22, 2018
161e40a
fix(floating-label): fix floating label animation function
Feb 22, 2018
d6a5606
Merge branch 'master' into chore/text-field/decouple-label
Feb 22, 2018
eb3893f
fix(floating-label): fixed rtl for floating-label
Feb 22, 2018
da53da7
fix(floating-label): updated floating label comments
Feb 22, 2018
ead024d
Merge branch 'master' into chore/text-field/decouple-label
Feb 22, 2018
78f5b2d
fix(floating-label): remove empty parens from scss mixins
Feb 22, 2018
8a05219
Merge branch 'master' into chore/text-field/decouple-label
Feb 22, 2018
60467b6
WIP - decouple outline
Feb 23, 2018
466e7e6
fix(notched-outline): mainly working notched-outline
Feb 23, 2018
699da0a
Merge branch 'master' into chore/text-field/decouple-outline
Feb 23, 2018
ca134d9
fix(text-field): decouple outline work on dense
Feb 23, 2018
67c1ab8
fix(floating-label): fixed some typos and empty white space
Feb 23, 2018
d7e6962
Merge branch 'master' into chore/text-field/decouple-label
Feb 23, 2018
d76fedc
Merge branch 'chore/text-field/decouple-label' into chore/text-field/…
Feb 23, 2018
91ad0a9
fix(notched-outline): updated notched-outline readme and scss
Feb 27, 2018
edc898b
fix(text-field): fixed tests and moved notched-outline to its own pac…
Feb 27, 2018
5dbf686
fix(text-field): closure tests
Feb 27, 2018
6fdbafc
Merge branch 'master' into chore/text-field/decouple-label
Feb 27, 2018
30b59cb
Merge branch 'chore/text-field/decouple-label' into chore/text-field/…
Feb 27, 2018
2ae20d1
fix(notched-outline): renamed noched-outline--idle to notched-outline…
Feb 27, 2018
f03ca0e
fix(floating-label): fixed readme
Feb 28, 2018
957fa3c
fix(text-field): reverted sass mixin name change to ...-label-ink-color
Feb 28, 2018
7d3a17c
Merge branch 'master' into chore/text-field/decouple-label
Feb 28, 2018
5247b43
Merge branch 'master' into chore/text-field/decouple-label
Feb 28, 2018
cf75c3b
fix(text-field): renamed shake animation names and updated readme
Feb 28, 2018
fbce528
Merge branch 'chore/text-field/decouple-label' into chore/text-field/…
Feb 28, 2018
4237987
Merge branch 'master' into chore/text-field/decouple-label
Feb 28, 2018
f556712
Merge branch 'chore/text-field/decouple-label' into chore/text-field/…
Feb 28, 2018
f772800
fix(notched-outline): some readme and comment edits
Feb 28, 2018
a14f34a
fix(text-field): updated golden files to pass tests
Feb 28, 2018
0898056
chore(notched-outline): update readme
Mar 1, 2018
c46fa37
Merge branch 'master' into chore/text-field/decouple-outline
Mar 2, 2018
5d19c87
Merge branch 'master' into chore/text-field/decouple-outline
Mar 5, 2018
c2a9737
fix(notched-outline): updated readme and fixed text-field readme
Mar 6, 2018
3bfdcf2
Merge branch 'master' into chore/text-field/decouple-outline
Mar 6, 2018
5efdf4f
fix(notched-outline): added notch() method to toggle active notch class
Mar 6, 2018
4d4c4fe
Merge branch 'master' into chore/text-field/decouple-outline
Mar 6, 2018
b98ae09
fix(notched-outline): removed unused scss rules and renamed mixin for…
Mar 6, 2018
b7b9ce7
fix(text-field): changed mixin name
Mar 6, 2018
39af4be
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 6, 2018
fc35362
fix(text-field): moved textfield outline mixins to appropriate section
Mar 6, 2018
2a30f0d
fix(package): remove duplicate package.json entries
Mar 7, 2018
9b539e0
Merge branch 'master' into chore/text-field/decouple-outline
Mar 9, 2018
db85d16
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 9, 2018
adf5817
Merge branch 'master' into chore/text-field/decouple-outline
Mar 14, 2018
a2ce01b
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 14, 2018
19cc126
fix(notched-outline): updated readme typo
Mar 14, 2018
3f3ca89
fix(notched-outline): added 2 mixins to notched-outline and updated r…
Mar 14, 2018
f351e17
Merge branch 'master' into chore/text-field/decouple-outline
Mar 14, 2018
1a42cd7
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 14, 2018
323552d
fix(notched-outline): removed updateSvgPath from foundation and inclu…
Mar 14, 2018
6606984
fix(notched-outline): updated readme typo
Mar 14, 2018
526a69f
test(notched-outline): added notchedOutline to deps to pass test
Mar 14, 2018
79d67b4
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 14, 2018
67bb0a5
Merge branch 'chore/text-field/decouple-outline' of github.com:materi…
Mar 15, 2018
e9141ea
fix(notched-outline): updated sass mixins to using 2 broder-radius mi…
Mar 15, 2018
0a6294c
Merge branch 'master' into chore/text-field/decouple-outline
Mar 15, 2018
9378b7c
fix(text-field): lint fix
Mar 15, 2018
8157968
Merge branch 'chore/text-field/decouple-outline' of github.com:materi…
Mar 15, 2018
e49a03b
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 15, 2018
142a142
Merge branch 'master' into chore/text-field/decouple-outline
Mar 15, 2018
0ec3a8f
fix(notched-outline): readme update explaining hwo to use mixins
Mar 15, 2018
74fc299
Merge branch 'chore/text-field/decouple-outline' into refactor/notche…
Mar 16, 2018
b32fc7b
Merge branch 'master' into refactor/notched-outline/update-api
Mar 16, 2018
61e3d88
Merge branch 'master' into refactor/notched-outline/update-api
Mar 16, 2018
0656a9e
fix(notched-outline): added more test coverage
Mar 16, 2018
cc391d2
Merge branch 'master' into refactor/notched-outline/update-api
Mar 19, 2018
f2e604b
Merge branch 'master' into refactor/notched-outline/update-api
Mar 20, 2018
4d8dc0e
fix(notched-outline): updated readme
Mar 20, 2018
509e530
Merge branch 'refactor/notched-outline/update-api' of github.com:mate…
Mar 20, 2018
d334297
Merge branch 'master' into refactor/notched-outline/update-api
Mar 20, 2018
a630847
Merge branch 'master' into refactor/notched-outline/update-api
Mar 21, 2018
0634366
feat(notched-outline): added closeOutline method on notchedoutline fo…
Mar 21, 2018
c015302
fix(notched-outline): updated readme and verbiage for open/close notch
Mar 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/mdc-notched-outline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The outline is a border around all sides of either a text field or select compon
CSS Class | Description
--- | ---
`mdc-notched-outline` | Mandatory. Container for the SVG of the notched outline path.
`mdc-notched-outline--notched` | Class to activate notch outline.
`mdc-notched-outline__path` | Mandatory. The path of the SVG of the notched outline.
`mdc-notched-outline__idle` | Mandatory. The full outline when the notch is hidden.

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

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


### `MDCNotchedOutlineAdapter`
Expand All @@ -90,14 +92,14 @@ Method Signature | Description
--- | ---
`getWidth() => number` | Returns the width of the outline element.
`getHeight() => number` | Returns the height of the outline element.
`addClass(className: string) => void` | Adds a class to the notched outline element.
`removeClass(className: string) => void` | Removes a class from the notched outline element.
`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.
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 description needs to be reworded. Maybe just the second sentence is needed

`updateSvgPath(notchWidth: number, isRtl: boolean) => void` | Updates the SVG path of the focus outline element based on the given notchWidth and the RTL context.


[//]: <> (TODO(mattgoo): add how to hide/show notch in outline)
12 changes: 12 additions & 0 deletions packages/mdc-notched-outline/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ class MDCNotchedOutlineAdapter {
*/
getHeight() {}

/**
* Adds a class to the root element.
* @param {string} className
*/
addClass(className) {}

/**
* Removes a class from the root element.
* @param {string} className
*/
removeClass(className) {}

/**
* Sets the "d" attribute of the outline element's SVG path.
* @param {string} value
Expand Down
7 changes: 6 additions & 1 deletion packages/mdc-notched-outline/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ const strings = {
IDLE_OUTLINE_SELECTOR: '.mdc-notched-outline__idle',
};

export {strings};
/** @enum {string} */
const cssClasses = {
OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
};

export {cssClasses, strings};
29 changes: 27 additions & 2 deletions packages/mdc-notched-outline/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import MDCFoundation from '@material/base/foundation';
import MDCNotchedOutlineAdapter from './adapter';
import {strings} from './constants';
import {cssClasses, strings} from './constants';

/**
* @extends {MDCFoundation<!MDCNotchedOutlineAdapter>}
Expand All @@ -29,6 +29,11 @@ class MDCNotchedOutlineFoundation extends MDCFoundation {
return strings;
}

/** @return enum {string} */
static get cssClasses() {
return cssClasses;
}

/**
* {@see MDCNotchedOutlineAdapter} for typing information on parameters and return
* types.
Expand All @@ -38,6 +43,8 @@ class MDCNotchedOutlineFoundation extends MDCFoundation {
return /** @type {!MDCNotchedOutlineAdapter} */ ({
getWidth: () => {},
getHeight: () => {},
addClass: () => {},
removeClass: () => {},
setOutlinePathAttr: () => {},
getIdleOutlineStyleValue: () => {},
});
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

"remove the notched selector"

* selector.
* @param {number} notchWidth
* @param {boolean=} isRtl
*/
notch(notchWidth, isRtl = false) {
const {OUTLINE_NOTCHED} = MDCNotchedOutlineFoundation.cssClasses;
if (notchWidth > 0) {
this.adapter_.addClass(OUTLINE_NOTCHED);
this.updateSvgPath_(notchWidth, isRtl);
} else {
this.adapter_.removeClass(OUTLINE_NOTCHED);
}
}

/**
* Updates the SVG path of the focus outline element based on the notchWidth
* and the RTL context.
* @param {number} notchWidth
* @param {boolean=} isRtl
* @private
*/
updateSvgPath(notchWidth, isRtl = false) {
updateSvgPath_(notchWidth, isRtl) {
// Fall back to reading a specific corner's style because Firefox doesn't report the style on border-radius.
const radiusStyleValue = this.adapter_.getIdleOutlineStyleValue('border-radius') ||
this.adapter_.getIdleOutlineStyleValue('border-top-left-radius');
Expand Down
12 changes: 7 additions & 5 deletions packages/mdc-notched-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class MDCNotchedOutline extends MDCComponent {
}

/**
* Updates the SVG path of the outline element based on the
* notch element width and the RTL context.
* @param {number} notchWidth The notch width in the outline.
* Updates outline selectors and SVG path to activate/deactivate notch.
* @param {number} notchWidth The notch width in the outline. If set to 0,
* the component will return to the idle state.
* @param {boolean=} isRtl Determines if outline is rtl. If rtl is true, notch
* will be right justified in outline path, otherwise left justified.
*/
updateSvgPath(notchWidth, isRtl) {
this.foundation_.updateSvgPath(notchWidth, isRtl);
notch(notchWidth, isRtl) {
this.foundation_.notch(notchWidth, isRtl);
}

/**
Expand All @@ -52,6 +52,8 @@ class MDCNotchedOutline extends MDCComponent {
return new MDCNotchedOutlineFoundation({
getWidth: () => this.root_.offsetWidth,
getHeight: () => this.root_.offsetHeight,
addClass: (className) => this.root_.classList.add(className),
removeClass: (className) => this.root_.classList.remove(className),
setOutlinePathAttr: (value) => {
const path = this.root_.querySelector(strings.PATH_SELECTOR);
path.setAttribute('d', value);
Expand Down
8 changes: 8 additions & 0 deletions packages/mdc-notched-outline/mdc-notched-outline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@
mdc-text-field-transition(opacity);
fill: transparent;
}

.mdc-notched-outline--notched {
opacity: 1;
}

.mdc-notched-outline--notched ~ .mdc-notched-outline__idle {
opacity: 0;
}
4 changes: 2 additions & 2 deletions packages/mdc-textfield/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Contributor

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?

#### `MDCTextFieldAdapter.getNativeInput()`

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

Choose a reason for hiding this comment

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

Trailing period.

Copy link
Contributor Author

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>

`updateOutline() => void` | Updates the focus outline for outlined text fields
`notchOutline(activateNotch: boolean) => void` | Activates/deactivates the notched outline.

`MDCTextFieldFoundation` supports multiple optional sub-elements: helper text and icon. The foundations of these sub-elements must be passed in as constructor arguments to `MDCTextFieldFoundation`.
10 changes: 6 additions & 4 deletions packages/mdc-textfield/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ class MDCTextFieldAdapter {

/**
* Only implement if outline element exists.
* Updates SVG Path on outline element based on the
* label element width and RTL context.
* Updates SVG Path and outline element based on the
* label element width and RTL context. Will notch the
* element if labelWidth is greater than 0, otherwise
* will return to idle state.
* @param {number} labelWidth
* @param {boolean} isRtl
* @param {boolean=} isRtl
*/
updateOutlinePath(labelWidth, isRtl) {}
notchOutline(labelWidth, isRtl) {}
}

export {MDCTextFieldAdapter, NativeInputType, FoundationMapType};
18 changes: 13 additions & 5 deletions packages/mdc-textfield/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class MDCTextFieldFoundation extends MDCFoundation {
hasLabel: () => {},
getLabelWidth: () => {},
hasOutline: () => {},
updateOutlinePath: () => {},
notchOutline: () => {},
});
}

Expand Down Expand Up @@ -135,6 +135,7 @@ class MDCTextFieldFoundation extends MDCFoundation {
// Ensure label does not collide with any pre-filled value.
if (this.adapter_.hasLabel() && this.getValue()) {
this.adapter_.floatLabel(this.shouldFloat);
this.notchOutline(this.shouldFloat);
}

if (this.adapter_.isFocused()) {
Expand Down Expand Up @@ -193,9 +194,10 @@ class MDCTextFieldFoundation extends MDCFoundation {
}

/**
* Updates the focus outline for outlined text fields.
* Activates/deactivates the notched outline.
* @param {boolean} activateNotch
Copy link
Contributor

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?

*/
updateOutline() {
notchOutline(activateNotch) {
if (!this.adapter_.hasOutline() || !this.adapter_.hasLabel()) {
return;
}
Expand All @@ -204,7 +206,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();
Copy link
Contributor

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.

this.adapter_.updateOutlinePath(labelWidth, isRtl);
if (activateNotch) {
this.adapter_.notchOutline(labelWidth, isRtl);
} else {
this.adapter_.notchOutline(0);
Copy link
Contributor

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

}
}

/**
Expand All @@ -214,7 +220,7 @@ class MDCTextFieldFoundation extends MDCFoundation {
this.isFocused_ = true;
this.styleFocused_(this.isFocused_);
this.adapter_.activateLineRipple();
this.updateOutline();
this.notchOutline(this.shouldFloat);
if (this.adapter_.hasLabel()) {
this.adapter_.shakeLabel(this.shouldShake);
this.adapter_.floatLabel(this.shouldFloat);
Expand Down Expand Up @@ -260,6 +266,7 @@ class MDCTextFieldFoundation extends MDCFoundation {
if (this.adapter_.hasLabel()) {
this.adapter_.shakeLabel(this.shouldShake);
this.adapter_.floatLabel(this.shouldFloat);
this.notchOutline(this.shouldFloat);
}
if (shouldRemoveLabelFloat) {
this.receivedUserInput_ = false;
Expand All @@ -283,6 +290,7 @@ class MDCTextFieldFoundation extends MDCFoundation {
if (this.adapter_.hasLabel()) {
this.adapter_.shakeLabel(this.shouldShake);
this.adapter_.floatLabel(this.shouldFloat);
this.notchOutline(this.shouldFloat);
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/mdc-textfield/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ class MDCTextField extends MDCComponent {
* all dimensions and positions for the ripple element.
*/
layout() {
this.foundation_.updateOutline();
const activateNotch = this.foundation_.shouldFloat;
this.foundation_.notchOutline(activateNotch);
if (this.ripple) {
this.ripple.layout();
}
Expand Down Expand Up @@ -401,14 +402,14 @@ class MDCTextField extends MDCComponent {

/**
* @return {!{
* notchOutline: function(number, boolean): undefined,
* hasOutline: function(): boolean,
* updateOutlinePath: function(number, boolean): undefined,
* }}
*/
getOutlineAdapterMethods_() {
return {
notchOutline: (labelWidth, isRtl) => this.outline_.notch(labelWidth, isRtl),
hasOutline: () => !!this.outline_,
updateOutlinePath: (labelWidth, isRtl) => this.outline_.updateSvgPath(labelWidth, isRtl),
};
}

Expand Down
12 changes: 0 additions & 12 deletions packages/mdc-textfield/mdc-text-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,6 @@
@include mdc-text-field-textarea-disabled_;
}

// Never show the idle outline when the label is floating, otherwise the label
// will collide with the idle outline.
.mdc-floating-label--float-above ~ .mdc-notched-outline__idle {
opacity: 0;
}

// Show the outline when the label is floating, since the outline has a
// notch for the label to fit into.
.mdc-floating-label--float-above ~ .mdc-notched-outline {
opacity: 1;
}

@include mdc-floating-label-shake-keyframes(text-field-box, $mdc-text-field-box-label-position-y);
@include mdc-floating-label-shake-keyframes(text-field-box-dense, $mdc-text-field-box-dense-label-position-y, 0%, $mdc-text-field-dense-label-scale);
@include mdc-floating-label-shake-keyframes(text-field-outlined, $mdc-text-field-outlined-label-position-y);
Expand Down
42 changes: 37 additions & 5 deletions test/unit/mdc-notched-outline/foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,56 @@ import {verifyDefaultAdapter} from '../helpers/foundation';
import {setupFoundationTest} from '../helpers/setup';
import MDCNotchedOutlineFoundation from '../../../packages/mdc-notched-outline/foundation';

const {cssClasses, strings} = MDCNotchedOutlineFoundation;

suite('MDCNotchedOutlineFoundation');


test('exports cssClasses', () => {
assert.deepEqual(MDCNotchedOutlineFoundation.cssClasses, cssClasses);
});

test('exports strings', () => {
assert.isOk('strings' in MDCNotchedOutlineFoundation);
assert.deepEqual(MDCNotchedOutlineFoundation.strings, strings);
});

test('defaultAdapter returns a complete adapter implementation', () => {
verifyDefaultAdapter(MDCNotchedOutlineFoundation, [
'getWidth', 'getHeight', 'setOutlinePathAttr', 'getIdleOutlineStyleValue',
'addClass', 'removeClass', 'getWidth', 'getHeight',
'setOutlinePathAttr', 'getIdleOutlineStyleValue',
]);
});

const setupTest = () => setupFoundationTest(MDCNotchedOutlineFoundation);

test('#updateSvgPath sets the path of the outline element', () => {
test('#notch sets the path of the outline element if notchWidth > 0', () => {
const {foundation, mockAdapter} = setupTest();
const notchWidth = 30;
foundation.notch(notchWidth);
td.verify(mockAdapter.addClass(MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED));
td.verify(mockAdapter.setOutlinePathAttr(td.matchers.anything()));
});

test('#notch sets the path of the outline element if notchWidth <= 0', () => {
const {foundation, mockAdapter} = setupTest();
const labelWidth = 30;
const notchWidth = 0;
foundation.notch(notchWidth);
td.verify(mockAdapter.removeClass(MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED));
td.verify(mockAdapter.setOutlinePathAttr(td.matchers.anything()), {times: 0});
});

test('#updateSvgPath_ sets the path of the outline element', () => {
const {foundation, mockAdapter} = setupTest();
const notchWidth = 30;
const isRtl = true;
foundation.updateSvgPath(labelWidth, isRtl);
foundation.updateSvgPath_(notchWidth, isRtl);
td.verify(mockAdapter.setOutlinePathAttr(td.matchers.anything()));
});

test('#updateSvgPath_ sets the path of the outline element if not isRtl', () => {
const {foundation, mockAdapter} = setupTest();
const notchWidth = 30;
const isRtl = false;
foundation.updateSvgPath_(notchWidth, isRtl);
td.verify(mockAdapter.setOutlinePathAttr(td.matchers.anything()));
});
Loading