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

chore(notched-outline): separate outline from text-field #2326

Merged
merged 86 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
86 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
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
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
adf5817
Merge branch 'master' into chore/text-field/decouple-outline
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
526a69f
test(notched-outline): added notchedOutline to deps to pass test
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
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
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
80 changes: 40 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/mdc-notched-outline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ Mixin | Description
--- | ---
`mdc-notched-outline-color($color)` | Customizes the border color of the notched outlined.
`mdc-notched-outline-idle-color($color)` | Customizes the border color of the idle outline.
`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:
Copy link
Contributor

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

> 1. Having 2 corner radius mixins is intentional. Combining the mixins into one
> causes the CSS output to be overly specific. The main cause of this is the fact that
> `.mdc-notched-outline__idle` is sibling to `.mdc-notched-outline`. The future fix
> is move `.mdc-notched-outline__idle` as a child to `.mdc-notched-outline`.
> 1. Please be considerate of how you nest the `idle` and `notched` state Sass Mixins.
> You may be overly specific in some cases, which should be avoided.

### `MDCNotchedOutline`

Expand Down
16 changes: 16 additions & 0 deletions packages/mdc-notched-outline/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@
@include mdc-theme-prop(stroke, $color);
}
}

@mixin mdc-notched-outline-stroke-width($width) {
.mdc-notched-outline__path {
stroke-width: $width;
}
}

@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;
}
}
38 changes: 26 additions & 12 deletions packages/mdc-textfield/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
@import "icon/mixins";
@import "icon/variables";

@mixin mdc-text-field-outline-corner-radius($radius) {
border-radius: $radius;
}

@mixin mdc-text-field-box-corner-radius($radius) {
border-radius: $radius $radius 0 0;
}
Expand Down Expand Up @@ -189,6 +185,20 @@
}
}

@mixin mdc-text-field-outline-corner-radius_($radius) {
// NOTE: idle and notched state border radius mixins
// are broken into 2 different mixins, otherwise
// we would be overly specific (big no, no). The cause of
// this is because .mdc-notched-outline and .mdc-notched-outline__idle
// are siblings. .mdc-notched-outline__idle needs to be a child of
// .mdc-notched-outline in order to remedy this issue.
.mdc-notched-outline {
@include mdc-notched-outline-corner-radius($radius);
}

@include mdc-notched-outline-idle-corner-radius($radius);
}

// Outlined

@mixin mdc-text-field-outlined-disabled_ {
Expand All @@ -207,9 +217,7 @@
}

@mixin mdc-text-field-outlined-focused_ {
.mdc-notched-outline__path {
stroke-width: 2px;
}
@include mdc-notched-outline-stroke-width(2px);
}

@mixin mdc-text-field-outlined-dense_ {
Expand Down Expand Up @@ -237,6 +245,7 @@
@include mdc-text-field-focused-outline-color(primary);
@include mdc-floating-label-float-position($mdc-text-field-outlined-label-position-y);
@include mdc-floating-label-shake-animation(text-field-outlined);
@include mdc-text-field-outline-corner-radius_($mdc-text-field-border-radius);

height: 56px;
border: none;
Expand All @@ -261,14 +270,13 @@
.mdc-text-field__icon {
z-index: 2;
}

.mdc-notched-outline,
.mdc-notched-outline__idle {
@include mdc-text-field-outline-corner-radius($mdc-text-field-border-radius);
}
}

@mixin mdc-text-field-outline-color_($color) {
// NOTE: outlined version of text-field wants the "idle" and
// "notched" outline to have the same color. This covers two cases:
// 1) text field renders with NO value in the "idle" state
// 2) text field renders with a value in the "notched" state
@include mdc-notched-outline-idle-color($color);
@include mdc-notched-outline-color($color);
Copy link
Contributor

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

}
Expand All @@ -279,6 +287,12 @@
.mdc-text-field__icon:hover ~ {
@include mdc-notched-outline-idle-color($color);

// tldr; this doesn't break BEM:
// We need to wrap this mixin with the .mdc-notched-outline
// selector, because of the sibling selector '~'. The notched
// outline html structure has .mdc-notched-outline
// and .mdc-notched-outline__idle as siblings, while
// .mdc-notched-outline__path is a child of .mdc-notched-outline
.mdc-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.

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.

@include mdc-notched-outline-color($color);
}
Expand Down
6 changes: 0 additions & 6 deletions packages/mdc-textfield/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
*/

/* eslint-disable no-unused-vars */
import MDCFloatingLabelFoundation from '@material/floating-label/foundation';
import MDCLineRippleFoundation from '@material/line-ripple/foundation';
import MDCNotchedOutlineFoundation from '@material/notched-outline/foundation';
import MDCTextFieldHelperTextFoundation from './helper-text/foundation';
import MDCTextFieldIconFoundation from './icon/foundation';

Expand All @@ -39,11 +36,8 @@ let NativeInputType;

/**
* @typedef {{
* lineRipple: (!MDCLineRippleFoundation|undefined),
* helperText: (!MDCTextFieldHelperTextFoundation|undefined),
* icon: (!MDCTextFieldIconFoundation|undefined),
* label: (!MDCFloatingLabelFoundation|undefined),
* outline: (!MDCNotchedOutlineFoundation|undefined)
* }}
*/
let FoundationMapType;
Expand Down
1 change: 1 addition & 0 deletions scripts/webpack/js-bundle-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class JsBundleFactory {
lineRipple: getAbsolutePath('/packages/mdc-line-ripple/index.js'),
linearProgress: getAbsolutePath('/packages/mdc-linear-progress/index.js'),
menu: getAbsolutePath('/packages/mdc-menu/index.js'),
notchedOutline: getAbsolutePath('/packages/mdc-notched-outline/index.js'),
radio: getAbsolutePath('/packages/mdc-radio/index.js'),
ripple: getAbsolutePath('/packages/mdc-ripple/index.js'),
select: getAbsolutePath('/packages/mdc-select/index.js'),
Expand Down