From 35697a579f51a9a76f6638b2faf414be311c1d88 Mon Sep 17 00:00:00 2001 From: Will Ernest <34519388+williamernest@users.noreply.github.com> Date: Fri, 26 Oct 2018 16:53:31 -0400 Subject: [PATCH] feat(select): Add enhanced select variant (#3949) Adds the leading icon variant to the select. Adds the helper text to the select. Adds the rotating dropdown icon to the select. Adds the enhanced menu version of the select. BREAKING CHANGE: Several adapter APIs were added to support the enhanced variant. The drop-down arrow is now its own element. The change event is now MDCSelect:change for all variants. See the README for full details. --- demos/index.html | 8 - demos/select.html | 334 ----- demos/select.scss | 54 - packages/mdc-menu/mdc-menu.scss | 2 +- packages/mdc-notched-outline/_functions.scss | 1 + packages/mdc-select/README.md | 270 +++- packages/mdc-select/_functions.scss | 26 + packages/mdc-select/_mixins.scss | 205 ++- packages/mdc-select/_variables.scss | 26 +- packages/mdc-select/adapter.js | 78 +- packages/mdc-select/constants.js | 13 + packages/mdc-select/foundation.js | 163 ++- packages/mdc-select/helper-text/README.md | 133 ++ packages/mdc-select/helper-text/_mixins.scss | 48 + packages/mdc-select/helper-text/adapter.js | 76 + packages/mdc-select/helper-text/constants.js | 36 + packages/mdc-select/helper-text/foundation.js | 130 ++ packages/mdc-select/helper-text/index.js | 66 + .../helper-text/mdc-select-helper-text.scss | 42 + packages/mdc-select/icon/README.md | 128 ++ packages/mdc-select/icon/_mixins.scss | 75 + packages/mdc-select/icon/_variables.scss | 25 + packages/mdc-select/icon/adapter.js | 83 ++ packages/mdc-select/icon/constants.js | 30 + packages/mdc-select/icon/foundation.js | 119 ++ packages/mdc-select/icon/index.js | 68 + packages/mdc-select/icon/mdc-select-icon.scss | 32 + packages/mdc-select/index.js | 526 ++++++- packages/mdc-select/mdc-select.scss | 146 +- packages/mdc-select/package.json | 2 + packages/mdc-textfield/_mixins.scss | 1 + test/screenshot/golden.json | 288 +++- .../spec/mdc-select/classes/baseline.html | 8 +- .../spec/mdc-select/classes/disabled.html | 12 +- .../mdc-select/classes/enhanced-baseline.html | 164 +++ .../mdc-select/classes/enhanced-disabled.html | 162 +++ .../enhanced-helper-text-persistent.html | 183 +++ .../classes/enhanced-helper-text.html | 182 +++ ...helper-text-persistent-validation-msg.html | 180 +++ ...hanced-invalid-helper-text-persistent.html | 180 +++ .../classes/enhanced-invalid-helper-text.html | 180 +++ .../mdc-select/classes/enhanced-invalid.html | 164 +++ .../classes/enhanced-leading-icon-svg.html | 182 +++ .../classes/enhanced-leading-icon.html | 169 +++ .../classes/helper-text-persistent.html | 157 ++ .../spec/mdc-select/classes/helper-text.html | 157 ++ .../spec/mdc-select/classes/invalid.html | 145 ++ .../mdc-select/classes/leading-icon-svg.html | 161 +++ .../spec/mdc-select/classes/leading-icon.html | 149 ++ .../spec/mdc-select/classes/required.html | 145 ++ test/screenshot/spec/mdc-select/fixture.scss | 6 +- .../spec/mdc-select/issues/3230-3496.html | 3 +- .../mdc-select/mixins/bottom-line-color.html | 6 +- .../mixins/container-fill-color.html | 6 +- .../mixins/enhanced-bottom-line-color.html | 107 ++ .../mixins/enhanced-container-fill-color.html | 107 ++ .../mdc-select/mixins/enhanced-ink-color.html | 111 ++ .../mixins/enhanced-label-color.html | 164 +++ .../mixins/enhanced-outline-color.html | 117 ++ .../mixins/enhanced-shape-radius.html | 163 +++ .../spec/mdc-select/mixins/ink-color.html | 4 +- .../spec/mdc-select/mixins/label-color.html | 8 +- .../spec/mdc-select/mixins/outline-color.html | 2 + .../spec/mdc-select/mixins/shape-radius.html | 8 +- test/unit/mdc-select/foundation.test.js | 282 +++- .../mdc-select/mdc-select-enhanced.test.js | 1260 +++++++++++++++++ .../mdc-select-helper-text-foundation.test.js | 132 ++ .../mdc-select/mdc-select-helper-text.test.js | 83 ++ .../mdc-select-icon-foundation.test.js | 160 +++ test/unit/mdc-select/mdc-select-icon.test.js | 102 ++ test/unit/mdc-select/mdc-select.test.js | 262 +++- 71 files changed, 8297 insertions(+), 710 deletions(-) delete mode 100644 demos/select.html delete mode 100644 demos/select.scss create mode 100644 packages/mdc-select/_functions.scss create mode 100644 packages/mdc-select/helper-text/README.md create mode 100644 packages/mdc-select/helper-text/_mixins.scss create mode 100644 packages/mdc-select/helper-text/adapter.js create mode 100644 packages/mdc-select/helper-text/constants.js create mode 100644 packages/mdc-select/helper-text/foundation.js create mode 100644 packages/mdc-select/helper-text/index.js create mode 100644 packages/mdc-select/helper-text/mdc-select-helper-text.scss create mode 100644 packages/mdc-select/icon/README.md create mode 100644 packages/mdc-select/icon/_mixins.scss create mode 100644 packages/mdc-select/icon/_variables.scss create mode 100644 packages/mdc-select/icon/adapter.js create mode 100644 packages/mdc-select/icon/constants.js create mode 100644 packages/mdc-select/icon/foundation.js create mode 100644 packages/mdc-select/icon/index.js create mode 100644 packages/mdc-select/icon/mdc-select-icon.scss create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-baseline.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-disabled.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-helper-text-persistent.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-helper-text.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-invalid-helper-text-persistent-validation-msg.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-invalid-helper-text-persistent.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-invalid-helper-text.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-invalid.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-leading-icon-svg.html create mode 100644 test/screenshot/spec/mdc-select/classes/enhanced-leading-icon.html create mode 100644 test/screenshot/spec/mdc-select/classes/helper-text-persistent.html create mode 100644 test/screenshot/spec/mdc-select/classes/helper-text.html create mode 100644 test/screenshot/spec/mdc-select/classes/invalid.html create mode 100644 test/screenshot/spec/mdc-select/classes/leading-icon-svg.html create mode 100644 test/screenshot/spec/mdc-select/classes/leading-icon.html create mode 100644 test/screenshot/spec/mdc-select/classes/required.html create mode 100644 test/screenshot/spec/mdc-select/mixins/enhanced-bottom-line-color.html create mode 100644 test/screenshot/spec/mdc-select/mixins/enhanced-container-fill-color.html create mode 100644 test/screenshot/spec/mdc-select/mixins/enhanced-ink-color.html create mode 100644 test/screenshot/spec/mdc-select/mixins/enhanced-label-color.html create mode 100644 test/screenshot/spec/mdc-select/mixins/enhanced-outline-color.html create mode 100644 test/screenshot/spec/mdc-select/mixins/enhanced-shape-radius.html create mode 100644 test/unit/mdc-select/mdc-select-enhanced.test.js create mode 100644 test/unit/mdc-select/mdc-select-helper-text-foundation.test.js create mode 100644 test/unit/mdc-select/mdc-select-helper-text.test.js create mode 100644 test/unit/mdc-select/mdc-select-icon-foundation.test.js create mode 100644 test/unit/mdc-select/mdc-select-icon.test.js diff --git a/demos/index.html b/demos/index.html index 9e9dc199dd9..2439d39af40 100644 --- a/demos/index.html +++ b/demos/index.html @@ -164,14 +164,6 @@ - - - - Select - Popover selection menus - - - diff --git a/demos/select.html b/demos/select.html deleted file mode 100644 index 9c3a013e741..00000000000 --- a/demos/select.html +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - Select Menu - Material Components Catalog - - - - - - - - - - -
-
-
- - Select -
-
-
- -
-
-
-
- - -
-
-
- -
-

Fully-Featured JS Component

-
-
- - -
-
-
-

Currently selected: (none)

-
- - -
-
- - -
-
- - -
-
- -
-
- -
-
- -
-

Outlined Select

-
-
- - -
- - - -
-
-
-
-

Currently selected: (none)

-
- - -
-
- - -
-
- - -
-
- -
-
- -
-
- -
-

Pre-selected option via HTML

-
-
- - -
-
-
-
-
-

MDC Select with optgroups

-
- - -
-
-
-
- - - - - diff --git a/demos/select.scss b/demos/select.scss deleted file mode 100644 index e9cba37de77..00000000000 --- a/demos/select.scss +++ /dev/null @@ -1,54 +0,0 @@ -// -// Copyright 2017 Google Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -@import "./common"; -@import "../packages/mdc-button/mdc-button"; -@import "../packages/mdc-select/mdc-select"; - -// stylelint-disable selector-class-pattern -.demo-select-custom-colors { - @include mdc-select-ink-color(blue); - @include mdc-select-label-color(rgba(blue, .6)); - @include mdc-select-bottom-line-color(rgba(blue, .5)); - - // Focused colors - @include mdc-select-focused-bottom-line-color(green); - @include mdc-select-focused-label-color(green); - - // Hover colors - @include mdc-select-hover-bottom-line-color(rgba(blue, .87)); -} - -.demo-select-custom-colors.mdc-select--box { - @include mdc-select-container-fill-color(rgba(blue, .1)); -} - -.demo-select-custom-colors.mdc-select--outlined { - @include mdc-select-outline-color(rgba(blue, .6)); - @include mdc-select-hover-outline-color(rgba(blue, .87)); - @include mdc-select-focused-outline-color(green); -} - -.button-container { - margin: 8px 0; -} -// stylelint-enable selector-class-pattern diff --git a/packages/mdc-menu/mdc-menu.scss b/packages/mdc-menu/mdc-menu.scss index ec37f8e9b2b..d31f96d8633 100644 --- a/packages/mdc-menu/mdc-menu.scss +++ b/packages/mdc-menu/mdc-menu.scss @@ -46,7 +46,7 @@ .mdc-list-item--disabled { cursor: auto; } - + //stylelint-disable selector-max-type, selector-no-qualifying-type a.mdc-list-item .mdc-list-item__text, a.mdc-list-item .mdc-list-item__graphic { diff --git a/packages/mdc-notched-outline/_functions.scss b/packages/mdc-notched-outline/_functions.scss index 34e298b05e2..8c56af470ab 100644 --- a/packages/mdc-notched-outline/_functions.scss +++ b/packages/mdc-notched-outline/_functions.scss @@ -31,5 +31,6 @@ // @function mdc-notched-outline-get-notch-padded-position($cornerSize) { $leadingStrokeLength: max(0, $mdc-notched-outline-min-leading-stroke-edge-position - $cornerSize - 1.2); + @return $cornerSize + $leadingStrokeLength + $mdc-notched-outline-notch-gutter-size + 1.2; } diff --git a/packages/mdc-select/README.md b/packages/mdc-select/README.md index 7a4221f85b6..b6c3e9b753f 100644 --- a/packages/mdc-select/README.md +++ b/packages/mdc-select/README.md @@ -6,12 +6,6 @@ iconId: menu path: /catalog/input-controls/select-menus/ --> -## Important - Default Style Deprecation Notice - -The existing default select style will be changed in an upcoming release. The Material spec indicates that -the default style will be the filled variant (currently referred to as the box variant). This will become the -default style. Continuing to add the `mdc-select--box` class to the select will result in no change. - # Select Menus -MDC Select provides Material Design single-option select menus. It functions as a wrapper around the -browser's native `` +element, or a MDC Menu. It is fully accessible, and fully RTL-aware. ## Design & API Documentation @@ -43,10 +37,14 @@ npm install @material/select ## Basic Usage +This section documents how to use a MDC Select with a native `