From 989c51611f96da222f904375431fac3526449675 Mon Sep 17 00:00:00 2001
From: Will Ernest <34519388+williamernest@users.noreply.github.com>
Date: Mon, 22 Jan 2018 13:15:08 -0800
Subject: [PATCH] feat(text-field): Move final JS colors to mixins. Update
demos (#2006)
feat(text-field): Move final JS colors to mixins. Update demos
---
demos/text-field.html | 91 ++++++++--
demos/text-field.scss | 92 ++++++++--
packages/mdc-textfield/README.md | 9 +-
packages/mdc-textfield/_mixins.scss | 162 +++++++++---------
.../mdc-textfield/bottom-line/_mixins.scss | 10 +-
.../mdc-textfield/helper-text/_mixins.scss | 2 +-
packages/mdc-textfield/icon/_mixins.scss | 31 ++++
.../icon/mdc-text-field-icon.scss | 4 -
packages/mdc-textfield/label/_mixins.scss | 7 +
packages/mdc-textfield/mdc-text-field.scss | 54 +++---
10 files changed, 322 insertions(+), 140 deletions(-)
create mode 100644 packages/mdc-textfield/icon/_mixins.scss
diff --git a/demos/text-field.html b/demos/text-field.html
index 95b84903e00..41475412813 100644
--- a/demos/text-field.html
+++ b/demos/text-field.html
@@ -119,10 +119,6 @@
Full Functionality JS Component (Floating Label, Validation)
-
-
-
-
@@ -168,8 +164,7 @@
Outlined Text Field
-
+
Must be at least 8 characters
@@ -221,7 +216,7 @@ Outlined Text Field
Text Field box
+
+
+
+
@@ -383,6 +401,10 @@
Textarea
+
+
+
+
@@ -413,6 +435,14 @@
Full-Width Text Field and Textarea
+
+
+
+
+
+
+
+
@@ -447,6 +477,7 @@ Full-Width Text Field and Textarea
var wrapperOutlinedTrailing = document.getElementById('demo-tf-outlined-trailing-wrapper');
var tfIcons = document.querySelectorAll('.mdc-text-field__icon');
+ var tfInputs = tfIconContainer.querySelectorAll('.mdc-text-field__input');
document.getElementById('disable-leading-trailing').addEventListener('change', function(evt) {
tfBoxLeading.disabled = evt.target.checked;
@@ -498,12 +529,26 @@ Full-Width Text Field and Textarea
});
document.getElementById('required-leading-trailing').addEventListener('change', function(evt) {
- tfIconContainer.querySelectorAll('.mdc-text-field__input')
- .forEach(function(input) {
+ [].slice.call(tfInputs).forEach(function(input) {
input.required = evt.target.checked;
input.pattern = evt.target.checked ? '.{8,}' : '.*';
});
});
+
+ document.getElementById('leading-trailing-alternate-colors').addEventListener('change', function(evt) {
+ tfBoxLeadingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-colors');
+ tfBoxLeadingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-error-colors');
+ tfBoxLeading.layout();
+ tfBoxTrailingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-colors');
+ tfBoxTrailingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-error-colors');
+ tfBoxTrailing.layout();
+ tfOutlinedLeadingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-colors');
+ tfOutlinedLeadingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-error-colors');
+ tfOutlinedLeading.layout();
+ tfOutlinedTrailingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-colors');
+ tfOutlinedTrailingEl.classList[evt.target.checked ? 'add' : 'remove']('demo-text-field-custom-error-colors');
+ tfOutlinedTrailing.layout();
+ });
});
demoReady(function() {
@@ -539,9 +584,6 @@ Full-Width Text Field and Textarea
document.getElementById('alternate-colors').addEventListener('change', function (evt) {
var target = evt.target;
tfRoot.classList[target.checked ? 'add' : 'remove']('demo-text-field-custom-colors');
- });
- document.getElementById('alternate-error-colors').addEventListener('change', function (evt) {
- var target = evt.target;
tfRoot.classList[target.checked ? 'add' : 'remove']('demo-text-field-custom-error-colors');
});
document.getElementById('use-helper-text').addEventListener('change', function(evt) {
@@ -584,9 +626,18 @@ Full-Width Text Field and Textarea
var target = evt.target;
section.classList[target.checked ? 'add' : 'remove']('mdc-theme--dark');
});
+
+ document.getElementById('textarea-alternate-colors').addEventListener('change', function (evt) {
+ var target = evt.target;
+ tfRoot.classList[target.checked ? 'add' : 'remove']('demo-textarea');
+ });
+
document.getElementById('textarea-required').addEventListener('change', function(evt) {
var target = evt.target;
- tfRoot.querySelector('.mdc-text-field__input').required = target.checked;
+ [].slice.call(tfRoot.querySelectorAll('.mdc-text-field__input'))
+ .forEach(function(input) {
+ input.required = target.checked;
+ })
});
});
@@ -615,6 +666,20 @@ Full-Width Text Field and Textarea
var target = evt.target;
section.classList[target.checked ? 'add' : 'remove']('mdc-theme--dark');
});
+
+ document.getElementById('fullwidth-required').addEventListener('change', function(evt) {
+ var target = evt.target;
+ [].slice.call(section.querySelectorAll('.mdc-text-field__input'))
+ .forEach(function(input) {
+ input.required = target.checked;
+ })
+ });
+
+ document.getElementById('fullwidth-alternate-colors').addEventListener('change', function (evt) {
+ var target = evt.target;
+ tfRoot.classList[target.checked ? 'add' : 'remove']('demo-fullwidth-input');
+ tfMultiRoot.classList[target.checked ? 'add' : 'remove']('demo-textarea');
+ });
});