From a9d6c3c25b3630a9f35dd9ff23aa2f409d3fa750 Mon Sep 17 00:00:00 2001 From: Matt Goo Date: Tue, 6 Feb 2018 13:55:15 -0800 Subject: [PATCH 01/47] chore(floating-label): moved floating-label to new package and integrate with mdc-text-field --- demos/text-field.scss | 22 +++--- demos/theme/theme-dark.scss | 2 +- package-lock.json | 74 +++++++++---------- package.json | 1 + .../label => mdc-floating-label}/README.md | 25 ++++--- .../label => mdc-floating-label}/_mixins.scss | 30 ++++---- .../_variables.scss | 20 ++--- .../label => mdc-floating-label}/adapter.js | 4 +- .../label => mdc-floating-label}/constants.js | 0 .../foundation.js | 22 +++--- .../label => mdc-floating-label}/index.js | 21 +++--- .../mdc-floating-label.scss} | 4 +- packages/mdc-floating-label/package.json | 25 +++++++ packages/mdc-textfield/README.md | 2 +- packages/mdc-textfield/_mixins.scss | 49 ++++++------ packages/mdc-textfield/adapter.js | 4 +- packages/mdc-textfield/foundation.js | 4 +- packages/mdc-textfield/index.js | 12 +-- packages/mdc-textfield/mdc-text-field.scss | 4 +- packages/mdc-textfield/package.json | 1 + 20 files changed, 179 insertions(+), 147 deletions(-) rename packages/{mdc-textfield/label => mdc-floating-label}/README.md (75%) rename packages/{mdc-textfield/label => mdc-floating-label}/_mixins.scss (57%) rename packages/{mdc-textfield/label => mdc-floating-label}/_variables.scss (58%) rename packages/{mdc-textfield/label => mdc-floating-label}/adapter.js (94%) rename packages/{mdc-textfield/label => mdc-floating-label}/constants.js (100%) rename packages/{mdc-textfield/label => mdc-floating-label}/foundation.js (75%) rename packages/{mdc-textfield/label => mdc-floating-label}/index.js (67%) rename packages/{mdc-textfield/label/mdc-text-field-label.scss => mdc-floating-label/mdc-floating-label.scss} (91%) create mode 100644 packages/mdc-floating-label/package.json diff --git a/demos/text-field.scss b/demos/text-field.scss index b8e506b1f84..7e4a8540643 100644 --- a/demos/text-field.scss +++ b/demos/text-field.scss @@ -28,7 +28,7 @@ @include mdc-text-field-hover-bottom-line-color($hover-border); @include mdc-text-field-line-ripple-color($focused-border); @include mdc-text-field-ink-color(black); - @include mdc-text-field-label-color(rgba(blue, .5)); + @include mdc-floating-label-color(rgba(blue, .5)); @include mdc-text-field-outline-color($idle-border); @include mdc-text-field-hover-outline-color($hover-border); @include mdc-text-field-focused-outline-color($focused-border); @@ -37,7 +37,7 @@ @include mdc-text-field-icon-color($hover-border); &.mdc-text-field--focused { - @include mdc-text-field-label-color(rgba(blue, .87)); + @include mdc-floating-label-color(rgba(blue, .87)); @include mdc-text-field-icon-color($focused-border); } } @@ -48,43 +48,43 @@ $focused-border: rgba(blue, 1); @include mdc-text-field-ink-color(black); - @include mdc-text-field-label-color(rgba(blue, .5)); + @include mdc-floating-label-color(rgba(blue, .5)); @include mdc-text-field-textarea-stroke-color($idle-border); &.mdc-text-field--focused { - @include mdc-text-field-label-color(rgba(blue, .87)); + @include mdc-floating-label-color(rgba(blue, .87)); @include mdc-text-field-textarea-stroke-color($focused-border); } } .demo-textarea.mdc-text-field--invalid { @include mdc-text-field-ink-color(orange); - @include mdc-text-field-label-color(rgba(orange, .5)); + @include mdc-floating-label-color(rgba(orange, .5)); @include mdc-text-field-textarea-stroke-color(orange); &.mdc-text-field--focused { - @include mdc-text-field-label-color(rgba(orange, .87)); + @include mdc-floating-label-color(rgba(orange, .87)); @include mdc-text-field-textarea-stroke-color(orange); } } .demo-fullwidth-input:not(.mdc-text-field--invalid) { @include mdc-text-field-ink-color(black); - @include mdc-text-field-label-color(rgba(blue, .5)); + @include mdc-floating-label-color(rgba(blue, .5)); @include mdc-text-field-line-ripple-color(blue); &.mdc-text-field--focused { - @include mdc-text-field-label-color(rgba(blue, .87)); + @include mdc-floating-label-color(rgba(blue, .87)); } } .demo-fullwidth-input.mdc-text-field--invalid { @include mdc-text-field-ink-color(orange); - @include mdc-text-field-label-color(rgba(orange, .5)); + @include mdc-floating-label-color(rgba(orange, .5)); @include mdc-text-field-line-ripple-color(orange); &.mdc-text-field--focused { - @include mdc-text-field-label-color(rgba(orange, .87)); + @include mdc-floating-label-color(rgba(orange, .87)); @include mdc-text-field-fullwidth-bottom-line-color(orange); } } @@ -98,7 +98,7 @@ @include mdc-text-field-hover-bottom-line-color($hover-border); @include mdc-text-field-line-ripple-color($focused-border); @include mdc-text-field-ink-color(orange); - @include mdc-text-field-label-color(rgba(orange, .87)); + @include mdc-floating-label-color(rgba(orange, .87)); @include mdc-text-field-outline-color($idle-border); @include mdc-text-field-hover-outline-color($hover-border); @include mdc-text-field-focused-outline-color($focused-border); diff --git a/demos/theme/theme-dark.scss b/demos/theme/theme-dark.scss index 804234fae1d..b2b978d92ed 100644 --- a/demos/theme/theme-dark.scss +++ b/demos/theme/theme-dark.scss @@ -38,7 +38,7 @@ $mdc-theme-background: $material-color-grey-900; .demo-text-field { @include mdc-text-field-ink-color(text-primary-on-dark); - @include mdc-text-field-label-color(text-secondary-on-dark); + @include mdc-floating-label-color(text-secondary-on-dark); @include mdc-text-field-line-ripple-color(text-hint-on-dark); } diff --git a/package-lock.json b/package-lock.json index ae50b59aafa..b73924e40da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,6 +2,16 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", @@ -1292,9 +1302,9 @@ "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", "dev": true, "requires": { + "JSONStream": "1.3.1", "combine-source-map": "0.7.2", "defined": "1.0.0", - "JSONStream": "1.3.1", "through2": "2.0.3", "umd": "3.0.1" } @@ -1328,6 +1338,7 @@ "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { + "JSONStream": "1.3.1", "assert": "1.4.1", "browser-pack": "6.0.2", "browser-resolve": "1.11.2", @@ -1349,7 +1360,6 @@ "https-browserify": "1.0.0", "inherits": "2.0.3", "insert-module-globals": "7.0.1", - "JSONStream": "1.3.1", "labeled-stream-splicer": "2.0.0", "module-deps": "4.1.1", "os-browserify": "0.3.0", @@ -2492,8 +2502,8 @@ "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -5148,11 +5158,6 @@ } } }, - "string_decoder": { - "version": "0.10.31", - "bundled": true, - "dev": true - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -5163,6 +5168,11 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "0.10.31", + "bundled": true, + "dev": true + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -6273,10 +6283,10 @@ "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", "dev": true, "requires": { + "JSONStream": "1.3.1", "combine-source-map": "0.7.2", "concat-stream": "1.5.2", "is-buffer": "1.1.5", - "JSONStream": "1.3.1", "lexical-scope": "1.2.0", "process": "0.11.10", "through2": "2.0.3", @@ -6968,16 +6978,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", @@ -8189,6 +8189,7 @@ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { + "JSONStream": "1.3.1", "browser-resolve": "1.11.2", "cached-path-relative": "1.0.1", "concat-stream": "1.5.2", @@ -8196,7 +8197,6 @@ "detective": "4.7.1", "duplexer2": "0.1.4", "inherits": "2.0.3", - "JSONStream": "1.3.1", "parents": "1.0.1", "readable-stream": "2.2.9", "resolve": "1.3.3", @@ -11989,23 +11989,6 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - } - } - }, "string-width": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz", @@ -12027,6 +12010,23 @@ "function-bind": "1.1.0" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + } + } + }, "stringify-entities": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.1.tgz", diff --git a/package.json b/package.json index 6f37e634b60..903a6b1a7a2 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,7 @@ "drawer", "elevation", "fab", + "floating-label", "form-field", "grid-list", "icon-toggle", diff --git a/packages/mdc-textfield/label/README.md b/packages/mdc-floating-label/README.md similarity index 75% rename from packages/mdc-textfield/label/README.md rename to packages/mdc-floating-label/README.md index f79a079378d..6d2955cc0cf 100644 --- a/packages/mdc-textfield/label/README.md +++ b/packages/mdc-floating-label/README.md @@ -1,15 +1,14 @@ -# Text Field Label +# Floating Label -Text field labels display the type of input a field requires. Every text field should have a label. Labels are aligned with the input line and always visible. They can be resting (when a field is inactive and empty) or floating. The label is a text caption or description for the text field. +Floating labels display the type of input a field requires. Every text field and select should have a label. Labels are aligned with the input line and always visible. They can be resting (when a field is inactive and empty) or floating. The label is a text caption or description for the text field. ## Design & API Documentation @@ -37,6 +36,8 @@ Text field labels display the type of input a field requires. Every text field s ``` + + #### Avoid Dynamic ID Generation It's also possible to wrap `mdc-text-field__input` within a `