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 all 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
18 changes: 9 additions & 9 deletions demos/text-field.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ <h2>Outlined Text Field</h2>
<input type="text" id="tf-outlined-input" class="mdc-text-field__input"
aria-controls="name-validation-message">
<label for="tf-outlined-input" class="mdc-floating-label">Your Name</label>
<div class="mdc-text-field__outline">
<div class="mdc-notched-outline">
<svg>
<path class="mdc-text-field__outline-path"/>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-text-field__idle-outline"></div>
<div class="mdc-notched-outline__idle"></div>
</div>
<p class="mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg"
id="name-validation-message">
Expand Down Expand Up @@ -263,12 +263,12 @@ <h2>Text Field - Leading/Trailing icons</h2>
<i class="material-icons mdc-text-field__icon" tabindex="0">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-text-field__outline">
<div class="mdc-notched-outline">
<svg>
<path class="mdc-text-field__outline-path"/>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-text-field__idle-outline"></div>
<div class="mdc-notched-outline__idle"></div>
</div>
</div>
<div id="demo-tf-outlined-trailing-wrapper">
Expand All @@ -277,12 +277,12 @@ <h2>Text Field - Leading/Trailing icons</h2>
<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">delete</i>
<div class="mdc-text-field__outline">
<div class="mdc-notched-outline">
<svg>
<path class="mdc-text-field__outline-path"/>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-text-field__idle-outline"></div>
<div class="mdc-notched-outline__idle"></div>
</div>
</div>
<div>
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"linear-progress",
"list",
"menu",
"notched-outline",
"radio",
"ripple",
"rtl",
Expand Down Expand Up @@ -175,6 +176,7 @@
"mdc-icon-toggle",
"mdc-line-ripple",
"mdc-menu",
"mdc-notched-outline",
"mdc-radio",
"mdc-ripple",
"mdc-selection-control",
Expand Down
3 changes: 3 additions & 0 deletions packages/material-components-web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as iconToggle from '@material/icon-toggle/index';
import * as linearProgress from '@material/linear-progress/index';
import * as lineRipple from '@material/line-ripple/index';
import * as menu from '@material/menu/index';
import * as notchedOutline from '@material/notched-outline/index';
import * as radio from '@material/radio/index';
import * as ripple from '@material/ripple/index';
import * as select from '@material/select/index';
Expand All @@ -52,6 +53,7 @@ autoInit.register('MDCGridList', gridList.MDCGridList);
autoInit.register('MDCIconToggle', iconToggle.MDCIconToggle);
autoInit.register('MDCLineRipple', lineRipple.MDCLineRipple);
autoInit.register('MDCLinearProgress', linearProgress.MDCLinearProgress);
autoInit.register('MDCNotchedOutline', notchedOutline.MDCNotchedOutline);
autoInit.register('MDCRadio', radio.MDCRadio);
autoInit.register('MDCSnackbar', snackbar.MDCSnackbar);
autoInit.register('MDCTab', tabs.MDCTab);
Expand All @@ -78,6 +80,7 @@ export {
lineRipple,
linearProgress,
menu,
notchedOutline,
radio,
ripple,
select,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@import "@material/linear-progress/mdc-linear-progress";
@import "@material/list/mdc-list";
@import "@material/menu/mdc-menu";
@import "@material/notched-outline/mdc-notched-outline";
@import "@material/radio/mdc-radio";
@import "@material/ripple/mdc-ripple";
@import "@material/select/mdc-select";
Expand Down
1 change: 1 addition & 0 deletions packages/material-components-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@material/linear-progress": "^0.30.0",
"@material/list": "^0.32.0",
"@material/menu": "^0.31.0",
"@material/notched-outline": "0.0.0",
"@material/radio": "^0.32.0",
"@material/ripple": "^0.32.0",
"@material/rtl": "^0.30.0",
Expand Down
103 changes: 103 additions & 0 deletions packages/mdc-notched-outline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!--docs:
title: "Notched Outline"
layout: detail
section: components
excerpt: "The notched outline is a border around either a text field or select element"
iconId: text_field
path: /catalog/input-controls/notched-outline
-->

# Notched Outline

The outline is a border around all sides of either a text field or select component. This is used for the Outlined variant of either a Text Field or Select.

## Design & API Documentation

<ul class="icon-list">
<li class="icon-list-item icon-list-item--spec">
<a href="https://material.io/guidelines/components/text-fields.html#text-fields-field-variations">Material Design guidelines: Text Field Variations</a>
</li>
</ul>

## Usage

### HTML Structure

```html
<div class="mdc-notched-outline">
<svg>
<path class="mdc-notched-outline__path"/>
</svg>
</div>
<div class="mdc-notched-outline__idle"></div>
```

> For usage within a text field see [here](../mdc-textfield/README.md#outlined/).

### CSS Classes

CSS Class | Description
--- | ---
`mdc-notched-outline` | Mandatory. Container for the SVG of the notched outline path.
`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.

### 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-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:
> Because notched-outline has sibling elements, you need to call the "idle" Sass mixins with parent selectors.
> Consider the following example HTML:
>
> ```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:
> ```scss
> .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:
> ```scss
> .foo-line-ripple-parent {
> @include mdc-notched-outline-idle-color($fooColor);
> }
> ```

### `MDCNotchedOutline`

Method Signature | Description
--- | ---
`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.

### `MDCNotchedOutlineAdapter`

Method Signature | Description
--- | ---
`getWidth() => number` | Returns the width of the outline element.
`getHeight() => number` | Returns the height of the 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
--- | ---
`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)
45 changes: 45 additions & 0 deletions packages/mdc-notched-outline/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

@import "@material/theme/mixins";

@mixin mdc-notched-outline-idle-color($color) {
.mdc-notched-outline__idle {
@include mdc-theme-prop(border-color, $color);
}
}

@mixin mdc-notched-outline-color($color) {
.mdc-notched-outline__path {
@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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
/* eslint no-unused-vars: [2, {"args": "none"}] */

/**
* Adapter for MDC Text Field Outline.
* Adapter for MDC Notched Outline.
*
* Defines the shape of the adapter expected by the foundation. Implement this
* adapter to integrate the Text Field outline into your framework. See
* adapter to integrate the Notched Outline into your framework. See
* https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md
* for more information.
*
* @record
*/
class MDCTextFieldOutlineAdapter {
class MDCNotchedOutlineAdapter {
/**
* Returns the width of the root element.
* @return {number}
Expand Down Expand Up @@ -55,4 +55,4 @@ class MDCTextFieldOutlineAdapter {
getIdleOutlineStyleValue(propertyName) {}
}

export default MDCTextFieldOutlineAdapter;
export default MDCNotchedOutlineAdapter;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2016 Google Inc. All Rights Reserved.
* Copyright 2018 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,8 +17,8 @@

/** @enum {string} */
const strings = {
PATH_SELECTOR: '.mdc-text-field__outline-path',
IDLE_OUTLINE_SELECTOR: '.mdc-text-field__idle-outline',
PATH_SELECTOR: '.mdc-notched-outline__path',
IDLE_OUTLINE_SELECTOR: '.mdc-notched-outline__idle',
};

export {strings};
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
*/

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

/**
* @extends {MDCFoundation<!MDCTextFieldOutlineAdapter>}
* @extends {MDCFoundation<!MDCNotchedOutlineAdapter>}
* @final
*/
class MDCTextFieldOutlineFoundation extends MDCFoundation {
class MDCNotchedOutlineFoundation extends MDCFoundation {
/** @return enum {string} */
static get strings() {
return strings;
}

/**
* {@see MDCTextFieldOutlineAdapter} for typing information on parameters and return
* {@see MDCNotchedOutlineAdapter} for typing information on parameters and return
* types.
* @return {!MDCTextFieldOutlineAdapter}
* @return {!MDCNotchedOutlineAdapter}
*/
static get defaultAdapter() {
return /** @type {!MDCTextFieldOutlineAdapter} */ ({
return /** @type {!MDCNotchedOutlineAdapter} */ ({
getWidth: () => {},
getHeight: () => {},
setOutlinePathAttr: () => {},
Expand All @@ -44,19 +44,19 @@ class MDCTextFieldOutlineFoundation extends MDCFoundation {
}

/**
* @param {!MDCTextFieldOutlineAdapter} adapter
* @param {!MDCNotchedOutlineAdapter} adapter
*/
constructor(adapter) {
super(Object.assign(MDCTextFieldOutlineFoundation.defaultAdapter, adapter));
super(Object.assign(MDCNotchedOutlineFoundation.defaultAdapter, adapter));
}

/**
* Updates the SVG path of the focus outline element based on the given width of the
* label element and the RTL context.
* @param {number} labelWidth
* Updates the SVG path of the focus outline element based on the notchWidth
* and the RTL context.
* @param {number} notchWidth
* @param {boolean=} isRtl
*/
updateSvgPath(labelWidth, isRtl = false) {
updateSvgPath(notchWidth, isRtl = false) {
// 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 All @@ -65,7 +65,7 @@ class MDCTextFieldOutlineFoundation extends MDCFoundation {
const height = this.adapter_.getHeight();
const cornerWidth = radius + 1.2;
const leadingStrokeLength = Math.abs(11 - cornerWidth);
const paddedLabelWidth = labelWidth + 8;
const paddedNotchWidth = notchWidth + 8;

// The right, bottom, and left sides of the outline follow the same SVG path.
const pathMiddle = 'a' + radius + ',' + radius + ' 0 0 1 ' + radius + ',' + radius
Expand All @@ -78,19 +78,19 @@ class MDCTextFieldOutlineFoundation extends MDCFoundation {

let path;
if (!isRtl) {
path = 'M' + (cornerWidth + leadingStrokeLength + paddedLabelWidth) + ',' + 1
+ 'h' + (width - (2 * cornerWidth) - paddedLabelWidth - leadingStrokeLength)
path = 'M' + (cornerWidth + leadingStrokeLength + paddedNotchWidth) + ',' + 1
+ 'h' + (width - (2 * cornerWidth) - paddedNotchWidth - leadingStrokeLength)
+ pathMiddle
+ 'h' + leadingStrokeLength;
} else {
path = 'M' + (width - cornerWidth - leadingStrokeLength) + ',' + 1
+ 'h' + leadingStrokeLength
+ pathMiddle
+ 'h' + (width - (2 * cornerWidth) - paddedLabelWidth - leadingStrokeLength);
+ 'h' + (width - (2 * cornerWidth) - paddedNotchWidth - leadingStrokeLength);
}

this.adapter_.setOutlinePathAttr(path);
}
}

export default MDCTextFieldOutlineFoundation;
export default MDCNotchedOutlineFoundation;
Loading