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): Refactor notched outline to use 3 divs #4035

Merged
merged 64 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a17c736
refactor(notched-outline): Refactor notched outline to use 3 divs
williamernest Nov 1, 2018
d5c8b87
refactor(notched-outline): Fix lint errors
williamernest Nov 1, 2018
9f7118e
refactor(notched-outline): Update select label
williamernest Nov 1, 2018
56b5690
refactor(notched-outline): Cleanup
williamernest Nov 1, 2018
ebbb08a
refactor(notched-outline): Fix closure
williamernest Nov 1, 2018
277b0b6
feat(notched-outline): Adjust leading icon and floating label padding
williamernest Nov 2, 2018
448f6db
fix(notched-outline): Update select floating label layout
williamernest Nov 2, 2018
3b39382
feat(notched-outline): Minor layout adjustments
williamernest Nov 2, 2018
46d6eeb
feat(notched-outline): Add FOUC transforms
williamernest Nov 2, 2018
6fe1882
fix(notched-outline): Fix notched state for outline
williamernest Nov 2, 2018
7a0a26b
Merge branch 'master' into refactor/notched-outline
williamernest Nov 2, 2018
eff8812
refactor(notched-outline): Update asterisk for required
williamernest Nov 2, 2018
86c2b8c
Merge branch 'master' into refactor/notched-outline
williamernest Nov 8, 2018
3520d1f
fix(notched-outline): Update textarea styles
williamernest Nov 8, 2018
1b931f6
refactor(select): Update
williamernest Nov 14, 2018
d02b300
refactor(notched-outline): Update
williamernest Nov 14, 2018
bac20d3
Merge branch 'master' into refactor/notched-outline
williamernest Nov 14, 2018
daa35f3
refactor(notched-outline): Add variable
williamernest Nov 14, 2018
fcee88f
refactor(notched-outline): Adjust styles for icons
williamernest Nov 14, 2018
4feda93
refactor(notched-outline): Move label into notched-outline
williamernest Nov 14, 2018
a05f6bd
refactor(notched-outline): Fix tests
williamernest Nov 14, 2018
6ee812a
refactor(notched-outline): Update
williamernest Nov 15, 2018
6547c39
refactor(notched-outline): Update
williamernest Nov 15, 2018
f320482
refactor(notched-outline): Remove extra label
williamernest Nov 15, 2018
e4b0c0d
Merge branch 'master' into refactor/notched-outline
williamernest Nov 15, 2018
59651e8
Merge branch 'master' into refactor/notched-outline
williamernest Nov 20, 2018
a848d3b
Merge branch 'master' into refactor/notched-outline
williamernest Nov 20, 2018
71ea18b
refactor(notched-outline): Update text field outlined shape radius st…
williamernest Nov 20, 2018
28a9375
refactor(notched-outline): Update outlined mixins for padding
williamernest Nov 20, 2018
5455f94
refactor(notched-outline): Detect and add class if no label element
williamernest Nov 21, 2018
333404b
refactor(notched-outline): Add no js screenshots to test for FOUC
williamernest Nov 21, 2018
8cbde9a
Merge branch 'master' into refactor/notched-outline
williamernest Nov 21, 2018
7027f18
refactor(notched-outline): Update goldens
williamernest Nov 21, 2018
63d6800
refactor(notched-outline): Cleanup
williamernest Nov 21, 2018
c5f2fe3
Merge branch 'master' into refactor/notched-outline
williamernest Nov 21, 2018
e95ae74
refactor(notched-outline): Move mixin to notched-outline
williamernest Nov 21, 2018
33f5cb7
refactor(notched-outline): Fix rtl for notched-outline
williamernest Nov 21, 2018
44b594c
refactor(notched-outline): Update text field --dense variants styles …
williamernest Nov 26, 2018
40a8252
refactor(notched-outline): Revert screenshot changes
williamernest Nov 26, 2018
342b98d
refactor(notched-outline): add upgraded to root element
williamernest Nov 26, 2018
2544d6f
refactor(notched-outline): Remove duplicate shape
williamernest Nov 26, 2018
1241ce0
Merge branch 'master' into refactor/notched-outline
williamernest Nov 26, 2018
17095c5
WIP Fix excessive border-radius styles
Nov 27, 2018
bd6009f
WIP Fix lint and closure
Nov 30, 2018
fa6ce6a
WIP Notched Outline readme updates
Nov 30, 2018
e3eaf88
Merge remote-tracking branch 'origin/master' into refactor/notched-ou…
Nov 30, 2018
396c4eb
WIP Update goldens due to sync with master
Nov 30, 2018
18c3f8c
feat(notched-outline): Update for some comments
williamernest Nov 30, 2018
c2b5805
WIP: Update for comments
williamernest Nov 30, 2018
1ef9676
Merge branch 'master' into refactor/notched-outline
williamernest Nov 30, 2018
0cdbf56
WIP: Update tests
williamernest Dec 1, 2018
6779c07
WIP: Add no-js to page
williamernest Dec 1, 2018
e47e319
WIP Add No JS to the other no-js test page
Dec 1, 2018
d04990f
WIP Replace mdc-rtl with equivalent mdc-rtl-reflexive-box for noflip
Dec 1, 2018
438c8bc
WIP Remove remaining stale notched-outline DOM references
Dec 3, 2018
1e04648
WIP Remove obsolete scss comments
Dec 3, 2018
677c83a
WIP Remove obsolete section from README
Dec 3, 2018
013ae74
WIP: Add extra selector to float position mixin
williamernest Dec 4, 2018
f27f8c2
Merge branch 'master' into refactor/notched-outline
williamernest Dec 4, 2018
d10994a
WIP: Fix missed imports
williamernest Dec 4, 2018
06b148a
WIP: Update dense variant for text field
williamernest Dec 4, 2018
7869033
WIP: Update readme with dense deprececation notice
williamernest Dec 4, 2018
e3da3e3
WIP: Remove textarea mixin apply fill color to label
williamernest Dec 4, 2018
955ca04
Merge branch 'master' into refactor/notched-outline
williamernest Dec 4, 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
36 changes: 18 additions & 18 deletions demos/text-field.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ <h2>Outlined Text Field</h2>
<input type="text" id="tf-outlined-input" class="mdc-text-field__input"
aria-controls="name-validation-message"
aria-describedby="name-validation-message">
<label for="tf-outlined-input" class="mdc-floating-label">Your Name</label>
<div class="mdc-notched-outline">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-notched-outline__idle"></div>
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="tf-outlined-input" class="mdc-floating-label">Your Name</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
<p class="mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg"
id="name-validation-message">Helper Text</p>
Expand Down Expand Up @@ -211,27 +211,27 @@ <h2>Text Field - Leading/Trailing icons</h2>
class="mdc-text-field mdc-text-field--outlined mdc-text-field--with-leading-icon" data-demo-no-auto-js>
<i class="material-icons mdc-text-field__icon" tabindex="0" role="button">event</i>
<input type="text" id="tf-outlined-leading" class="mdc-text-field__input">
<label for="tf-outlined-leading" class="mdc-floating-label">Your other name</label>
<div class="mdc-notched-outline">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-notched-outline__idle"></div>
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="tf-outlined-leading" class="mdc-floating-label">Your other name</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
</div>
<div id="demo-tf-outlined-trailing-wrapper" class="demo-text-field-wrapper demo-tf-add-space">
<div id="tf-outlined-trailing-example"
class="mdc-text-field mdc-text-field--outlined mdc-text-field--with-trailing-icon" data-demo-no-auto-js>
<input type="text" id="tf-outlined-trailing" class="mdc-text-field__input">
<label for="tf-outlined-trailing" class="mdc-floating-label">Your other name</label>
<i class="material-icons mdc-text-field__icon" tabindex="0" role="button">delete</i>
<div class="mdc-notched-outline">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-notched-outline__idle"></div>
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="tf-outlined-trailing" class="mdc-floating-label">Your other name</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
</div>
<div>
Expand Down
12 changes: 6 additions & 6 deletions demos/theme/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -784,13 +784,13 @@ <h3 class="mdc-typography--headline5 demo-component-section__heading">
id="demo-text-field"
aria-controls="demo-text-field-helper-text"
aria-describedby="demo-text-field-helper-text">
<label for="demo-text-field" class="mdc-floating-label">Outlined Text Field</label>
<div class="mdc-notched-outline">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-notched-outline__idle"></div>
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="demo-text-field" class="mdc-floating-label">Outlined Text Field</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
<p class="mdc-text-field-helper-text" id="demo-text-field-helper-text"
aria-hidden="true">
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-floating-label/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
// THE SOFTWARE.
//

$mdc-floating-label-position-y: 100%;
$mdc-floating-label-position-y: 50%;
$mdc-floating-label-transition-duration: 150ms;
1 change: 1 addition & 0 deletions packages/mdc-floating-label/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
const cssClasses = {
LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
LABEL_SHAKE: 'mdc-floating-label--shake',
ROOT: 'mdc-floating-label',
};

export {cssClasses};
1 change: 0 additions & 1 deletion packages/mdc-floating-label/mdc-floating-label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
@include mdc-typography(subtitle1);

position: absolute;
bottom: 8px;
/* @noflip */
left: 0;
/* @noflip */
Expand Down
51 changes: 23 additions & 28 deletions packages/mdc-notched-outline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ npm install @material/notched-outline

```html
<div class="mdc-notched-outline">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label class="mdc-floating-label">Label</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
<div class="mdc-notched-outline__idle"></div>
```

> For usage within a text field see [here](../mdc-textfield/README.md#outlined).
> Note that the [MDC Floating Label](../mdc-floating-label/README.md) component is placed inside the notch element when
> used together with MDC Notched Outline.

> See the [MDC Text Field](../mdc-textfield/README.md#outlined) and
> [MDC Select](../mdc-select/README.md#outlined-select) documentation for
> information on using Notched Outline in the context of those components.

### Styles

Expand All @@ -67,18 +73,18 @@ CSS Class | Description
--- | ---
`mdc-notched-outline` | Mandatory. Container for the SVG of the notched outline path.
Copy link
Contributor

@chaficnajjar chaficnajjar Dec 5, 2018

Choose a reason for hiding this comment

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

@williamernest @kfranqueiro This line in the documentation still mentions SVG despite the notched outline not using SVG anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Man, I knew I was still going to miss something in the README. Thanks for pointing it out.

`mdc-notched-outline--notched` | Class to open 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.
`mdc-notched-outline__leading` | Mandatory. Element representing the leading side of the notched outline (before the notch).
`mdc-notched-outline__notch` | Mandatory. Element representing the notch.
`mdc-notched-outline__trailing` | Mandatory. Element representing the trailing side of the notched outline (after the notch).

### Sass Mixins

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-shape-radius($radius, $rtl-reflexive)` | Sets the rounded shape to notched outline element with given radius size. Set `$rtl-reflexive` to true to flip radius values in RTL context, defaults to false.
`mdc-notched-outline-idle-shape-radius($radius, $rtl-reflexive)` | Sets the rounded shape to notched outline element in idle state with given radius size. Set `$rtl-reflexive` to true to flip radius values in RTL context, defaults to false.
`mdc-notched-outline-floating-label-float-position($positionY, $positionX, $scale)` | Sets the position and scale of the floating label inside the notched outline.


### Sass Functions
Expand All @@ -89,37 +95,30 @@ Function | Description

#### Calling Mixins with Parent Selectors

Because notched-outline has sibling elements, you need to call the "idle" Sass mixins with parent selectors.
Because notched-outline has sibling elements, you need to call the Sass mixins with parent selectors.
Consider the following example HTML:

```html
<div class="foo__parent">
<div class="mdc-notched-outline foo__child">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
<div class="mdc-notched-outline__leading"></div>
kfranqueiro marked this conversation as resolved.
Show resolved Hide resolved
<div class="mdc-notched-outline__notch"></div>
<div class="mdc-notched-outline__trailing"></div>
</div>
<div class="mdc-notched-outline__idle"></div>
</div>
```
In order to customize any "non-idle" part of notched-outline, use the .foo__child CSS selector:
In order to customize the notched-outline, use the .foo__child CSS selector:
```scss
.foo__child {
@include mdc-notched-outline-color($fooColor);
}
```
But in order to customize any "idle" part of the notched-outline, you must use the .foo__parent CSS selector:
```scss
.foo__parent {
@include mdc-notched-outline-idle-color($fooColor);
}
```

## `MDCNotchedOutline` Properties and Methods

Method Signature | Description
--- | ---
`notch(notchWidth: number, isRtl: boolean) => void` | Updates notched outline to open notch in outline path.
`notch(notchWidth: number) => void` | Updates notched outline to open notch in outline path.
`closeNotch() => void` | Updates the notched outline to close notch in outline path.

## Usage Within Frameworks
Expand All @@ -130,17 +129,13 @@ If you are using a JavaScript framework, such as React or Angular, you can creat

Method Signature | Description
--- | ---
`getWidth() => number` | Returns the width of the notched outline element.
`getHeight() => number` | Returns the height of the notched 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 notched outline element's SVG path.
`getIdleOutlineStyleValue(propertyName: string) => string` | Returns the idle outline element's computed style value of a given css `propertyName`.
`setNotchWidthProperty(width: number) => void` | Sets the width of the notch in pixels.

### `MDCNotchedOutlineFoundation`

Method Signature | Description
--- | ---
`notch(notchWidth: number, isRtl: boolean) => void` | Adds the `mdc-notched-outline--notched` selector and updates the notched outline path based off notchWidth and isRtl.
`notch(notchWidth: number) => void` | Adds the `mdc-notched-outline--notched` selector and updates the notched outline path based off notchWidth and isRtl.
`closeNotch() => void` | Removes the outline notched selector.
`updateSvgPath(notchWidth: number, isRtl: boolean) => void` | Updates the SVG path of the focus outline element calculated based off of the notchWidth. The notch will appear left justified, unless isRtl is true.
50 changes: 36 additions & 14 deletions packages/mdc-notched-outline/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,53 @@

@import "@material/theme/mixins";
@import "@material/shape/mixins";

@mixin mdc-notched-outline-idle-color($color) {
.mdc-notched-outline__idle {
@include mdc-theme-prop(border-color, $color);
}
}
@import "@material/rtl/mixins";
@import "./variables";

@mixin mdc-notched-outline-color($color) {
.mdc-notched-outline__path {
@include mdc-theme-prop(stroke, $color);
.mdc-notched-outline__leading,
.mdc-notched-outline__notch,
.mdc-notched-outline__trailing {
@include mdc-theme-prop(border-color, $color);
}
}

@mixin mdc-notched-outline-stroke-width($width) {
.mdc-notched-outline__path {
stroke-width: $width;
.mdc-notched-outline__leading,
.mdc-notched-outline__notch,
.mdc-notched-outline__trailing {
border-width: $width;
}
}

@mixin mdc-notched-outline-shape-radius($radius, $rtl-reflexive: false) {
@include mdc-shape-radius($radius, $rtl-reflexive);
$radius: mdc-shape-prop-value($radius);

.mdc-notched-outline__leading {
@include mdc-shape-radius(mdc-shape-mask-radius($radius, 1 0 0 1), $rtl-reflexive: true);

@if ($radius > $mdc-notched-outline-leading-width) {
width: $radius;
}
}

.mdc-notched-outline__trailing {
@include mdc-shape-radius(mdc-shape-mask-radius($radius, 0 1 1 0), $rtl-reflexive: true);
}
}

@mixin mdc-notched-outline-idle-shape-radius($radius, $rtl-reflexive: false) {
.mdc-notched-outline__idle {
@include mdc-shape-radius($radius, $rtl-reflexive);
@mixin mdc-notched-outline-floating-label-float-position($positionY, $positionX: 0%, $scale: .75) {
@include mdc-floating-label-float-position($positionY + $mdc-notched-outline-label-adjust, $positionX, 1);

.mdc-floating-label--float-above {
font-size: ($scale * 1rem);
}

.mdc-notched-outline--upgraded {
Copy link
Contributor

Choose a reason for hiding this comment

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

I removed the "calling mixins with parent selectors" part of the readme since it was obsolete as written... however, this particular mixin still operates under the assumption that the context is a parent, otherwise this selector won't match.

On the other hand, if we were to revise this to &.mdc-notched-outline--upgraded, you would need to select on the notched outline element (not a parent) in order for it to work, which text field and select currently don't.

We could potentially include both selectors (.mdc-notched-outline--upgraded, &.mdc-notched-outline--upgraded), but that's arguably emitting extra styles, and I'm not sure if there'd be any possible side effects.

Typically we set the expectation that applying a mixin to the root class of its component will work. We do make this sort of assumption in a few other places (I searched for &. in code, though half are in private mixins)... what do you 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'll make a quick commit adding both selectors and see if it changes anything.

@include mdc-floating-label-float-position($positionY, $positionX, $scale);

.mdc-floating-label--float-above {
font-size: 1rem;
}
}
}
5 changes: 5 additions & 0 deletions packages/mdc-notched-outline/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ $mdc-notched-outline-min-leading-stroke-edge-position: 12px;
// The gap between the stroke end and floating label
// Keep this in sync with constants.numbers.NOTCH_GUTTER_SIZE
$mdc-notched-outline-notch-gutter-size: 4px;
$mdc-notched-outline-leading-width: 12px;
$mdc-notched-outline-padding: 4px;
// This variable keeps the before/after JS label centered in the notch when the font-size is changed.
$mdc-notched-outline-label-adjust: 14%;

26 changes: 3 additions & 23 deletions packages/mdc-notched-outline/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@
* @record
*/
class MDCNotchedOutlineAdapter {
/**
* Returns the width of the root element.
* @return {number}
*/
getWidth() {}

/**
* Returns the height of the root element.
* @return {number}
*/
getHeight() {}

/**
* Adds a class to the root element.
* @param {string} className
Expand All @@ -59,18 +47,10 @@ class MDCNotchedOutlineAdapter {
removeClass(className) {}

/**
* Sets the "d" attribute of the outline element's SVG path.
* @param {string} value
*/
setOutlinePathAttr(value) {}

/**
* Returns the idle outline element's computed style value of the given css property `propertyName`.
* We achieve this via `getComputedStyle(...).getPropertyValue(propertyName)`.
* @param {string} propertyName
* @return {string}
* Sets the width style property of the notch element.
* @param {number} width
*/
getIdleOutlineStyleValue(propertyName) {}
setNotchWidthProperty(width) {}
}

export default MDCNotchedOutlineAdapter;
19 changes: 10 additions & 9 deletions packages/mdc-notched-outline/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@

/** @enum {string} */
const strings = {
PATH_SELECTOR: '.mdc-notched-outline__path',
IDLE_OUTLINE_SELECTOR: '.mdc-notched-outline__idle',
NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch',
};

/** @enum {number} */
const numbers = {
// This should stay in sync with $mdc-notched-outline-padding * 2.
NOTCH_ELEMENT_PADDING: 8,
};

/** @enum {string} */
const cssClasses = {
OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded',
NO_LABEL: 'mdc-notched-outline--no-label',
};

/** @enum {number} */
const numbers = {
NOTCH_GUTTER_SIZE: 4,
MIN_LEADING_STROKE_EDGE_POSITION: 12,
};

export {cssClasses, strings, numbers};
export {cssClasses, numbers, strings};
Loading