@@ -119,10 +119,6 @@ <h2>Full Functionality JS Component (Floating Label, Validation)</h2>
119
119
< input id ="alternate-colors " type ="checkbox ">
120
120
< label for ="alternate-colors "> Alternate Colors</ label >
121
121
</ div >
122
- < div >
123
- < input id ="alternate-error-colors " type ="checkbox ">
124
- < label for ="alternate-error-colors "> Alternate Error Colors</ label >
125
- </ div >
126
122
< div >
127
123
< input id ="use-helper-text " type ="checkbox ">
128
124
< label for ="use-helper-text "> Use Helper Text</ label >
@@ -168,8 +164,7 @@ <h2>Outlined Text Field</h2>
168
164
</ div >
169
165
< div class ="mdc-text-field__idle-outline "> </ div >
170
166
</ div >
171
- < p class ="mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg "
172
- id ="name-validation-msg ">
167
+ < p class ="mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg ">
173
168
Must be at least 8 characters
174
169
</ p >
175
170
</ div >
@@ -221,7 +216,7 @@ <h2>Outlined Text Field</h2>
221
216
< h2 > Text Field box</ h2 >
222
217
< div id ="demo-tf-box-wrapper ">
223
218
< div id ="tf-box-example " class ="mdc-text-field mdc-text-field--box " data-demo-no-auto-js >
224
- < input required pattern =" .{8,} " type ="text " id ="tf-box " class ="mdc-text-field__input "
219
+ < input type ="text " id ="tf-box " class ="mdc-text-field__input "
225
220
aria-controls ="name-validation-message ">
226
221
< label for ="tf-box " class ="mdc-text-field__label "> Your Name</ label >
227
222
< div class ="mdc-text-field__bottom-line "> </ div >
@@ -247,6 +242,14 @@ <h2>Text Field box</h2>
247
242
< input id ="box-dense " type ="checkbox ">
248
243
< label for ="box-dense "> Dense</ label >
249
244
</ div >
245
+ < div >
246
+ < input id ="box-alternate-colors " type ="checkbox ">
247
+ < label for ="box-alternate-colors "> Alternate Colors</ label >
248
+ </ div >
249
+ < div >
250
+ < input id ="box-required " type ="checkbox ">
251
+ < label for ="box-required "> Required</ label >
252
+ </ div >
250
253
< script >
251
254
demoReady ( function ( ) {
252
255
var tfEl = document . getElementById ( 'tf-box-example' ) ;
@@ -274,6 +277,17 @@ <h2>Text Field box</h2>
274
277
tfEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'mdc-text-field--dense' ) ;
275
278
tf . layout ( ) ;
276
279
} ) ;
280
+
281
+ document . getElementById ( 'box-alternate-colors' ) . addEventListener ( 'change' , function ( evt ) {
282
+ var target = evt . target ;
283
+ tfEl . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-colors' ) ;
284
+ tfEl . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-error-colors' ) ;
285
+ } ) ;
286
+
287
+ document . getElementById ( 'box-required' ) . addEventListener ( 'change' , function ( evt ) {
288
+ var target = evt . target ;
289
+ tfEl . querySelector ( '.mdc-text-field__input' ) . required = target . checked ;
290
+ } ) ;
277
291
} ) ;
278
292
</ script >
279
293
</ section >
@@ -346,6 +360,10 @@ <h2>Text Field - Leading/Trailing icons</h2>
346
360
< input id ="unclickable-leading-trailing " type ="checkbox ">
347
361
< label for ="unclickable-leading-trailing "> Unclickable icons</ label >
348
362
</ div >
363
+ < div >
364
+ < input id ="leading-trailing-alternate-colors " type ="checkbox ">
365
+ < label for ="leading-trailing-alternate-colors "> Alternate Colors</ label >
366
+ </ div >
349
367
< div >
350
368
< input id ="required-leading-trailing " type ="checkbox ">
351
369
< label for ="required-leading-trailing "> Required and must be at least 8 characters</ label >
@@ -383,6 +401,10 @@ <h2>Textarea</h2>
383
401
< input id ="textarea-dark-theme " type ="checkbox ">
384
402
< label for ="textarea-dark-theme "> Dark Theme</ label >
385
403
</ div >
404
+ < div >
405
+ < input id ="textarea-alternate-colors " type ="checkbox ">
406
+ < label for ="textarea-alternate-colors "> Alternate Colors</ label >
407
+ </ div >
386
408
< div >
387
409
< input id ="textarea-required " type ="checkbox ">
388
410
< label for ="textarea-required "> Required</ label >
@@ -413,6 +435,14 @@ <h2>Full-Width Text Field and Textarea</h2>
413
435
< input type ="checkbox " id ="fullwidth-dark-theme ">
414
436
< label for ="fullwidth-dark-theme "> Dark Theme</ label >
415
437
</ div >
438
+ < div >
439
+ < input id ="fullwidth-required " type ="checkbox ">
440
+ < label for ="fullwidth-required "> Required</ label >
441
+ </ div >
442
+ < div >
443
+ < input id ="fullwidth-alternate-colors " type ="checkbox ">
444
+ < label for ="fullwidth-alternate-colors "> Alternate Colors</ label >
445
+ </ div >
416
446
</ section >
417
447
</ main >
418
448
@@ -447,6 +477,7 @@ <h2>Full-Width Text Field and Textarea</h2>
447
477
var wrapperOutlinedTrailing = document . getElementById ( 'demo-tf-outlined-trailing-wrapper' ) ;
448
478
449
479
var tfIcons = document . querySelectorAll ( '.mdc-text-field__icon' ) ;
480
+ var tfInputs = tfIconContainer . querySelectorAll ( '.mdc-text-field__input' ) ;
450
481
451
482
document . getElementById ( 'disable-leading-trailing' ) . addEventListener ( 'change' , function ( evt ) {
452
483
tfBoxLeading . disabled = evt . target . checked ;
@@ -498,12 +529,26 @@ <h2>Full-Width Text Field and Textarea</h2>
498
529
} ) ;
499
530
500
531
document . getElementById ( 'required-leading-trailing' ) . addEventListener ( 'change' , function ( evt ) {
501
- tfIconContainer . querySelectorAll ( '.mdc-text-field__input' )
502
- . forEach ( function ( input ) {
532
+ [ ] . slice . call ( tfInputs ) . forEach ( function ( input ) {
503
533
input . required = evt . target . checked ;
504
534
input . pattern = evt . target . checked ? '.{8,}' : '.*' ;
505
535
} ) ;
506
536
} ) ;
537
+
538
+ document . getElementById ( 'leading-trailing-alternate-colors' ) . addEventListener ( 'change' , function ( evt ) {
539
+ tfBoxLeadingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-colors' ) ;
540
+ tfBoxLeadingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-error-colors' ) ;
541
+ tfBoxLeading . layout ( ) ;
542
+ tfBoxTrailingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-colors' ) ;
543
+ tfBoxTrailingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-error-colors' ) ;
544
+ tfBoxTrailing . layout ( ) ;
545
+ tfOutlinedLeadingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-colors' ) ;
546
+ tfOutlinedLeadingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-error-colors' ) ;
547
+ tfOutlinedLeading . layout ( ) ;
548
+ tfOutlinedTrailingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-colors' ) ;
549
+ tfOutlinedTrailingEl . classList [ evt . target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-error-colors' ) ;
550
+ tfOutlinedTrailing . layout ( ) ;
551
+ } ) ;
507
552
} ) ;
508
553
509
554
demoReady ( function ( ) {
@@ -539,9 +584,6 @@ <h2>Full-Width Text Field and Textarea</h2>
539
584
document . getElementById ( 'alternate-colors' ) . addEventListener ( 'change' , function ( evt ) {
540
585
var target = evt . target ;
541
586
tfRoot . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-colors' ) ;
542
- } ) ;
543
- document . getElementById ( 'alternate-error-colors' ) . addEventListener ( 'change' , function ( evt ) {
544
- var target = evt . target ;
545
587
tfRoot . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-text-field-custom-error-colors' ) ;
546
588
} ) ;
547
589
document . getElementById ( 'use-helper-text' ) . addEventListener ( 'change' , function ( evt ) {
@@ -584,9 +626,18 @@ <h2>Full-Width Text Field and Textarea</h2>
584
626
var target = evt . target ;
585
627
section . classList [ target . checked ? 'add' : 'remove' ] ( 'mdc-theme--dark' ) ;
586
628
} ) ;
629
+
630
+ document . getElementById ( 'textarea-alternate-colors' ) . addEventListener ( 'change' , function ( evt ) {
631
+ var target = evt . target ;
632
+ tfRoot . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-textarea' ) ;
633
+ } ) ;
634
+
587
635
document . getElementById ( 'textarea-required' ) . addEventListener ( 'change' , function ( evt ) {
588
636
var target = evt . target ;
589
- tfRoot . querySelector ( '.mdc-text-field__input' ) . required = target . checked ;
637
+ [ ] . slice . call ( tfRoot . querySelectorAll ( '.mdc-text-field__input' ) )
638
+ . forEach ( function ( input ) {
639
+ input . required = target . checked ;
640
+ } )
590
641
} ) ;
591
642
} ) ;
592
643
@@ -615,6 +666,20 @@ <h2>Full-Width Text Field and Textarea</h2>
615
666
var target = evt . target ;
616
667
section . classList [ target . checked ? 'add' : 'remove' ] ( 'mdc-theme--dark' ) ;
617
668
} ) ;
669
+
670
+ document . getElementById ( 'fullwidth-required' ) . addEventListener ( 'change' , function ( evt ) {
671
+ var target = evt . target ;
672
+ [ ] . slice . call ( section . querySelectorAll ( '.mdc-text-field__input' ) )
673
+ . forEach ( function ( input ) {
674
+ input . required = target . checked ;
675
+ } )
676
+ } ) ;
677
+
678
+ document . getElementById ( 'fullwidth-alternate-colors' ) . addEventListener ( 'change' , function ( evt ) {
679
+ var target = evt . target ;
680
+ tfRoot . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-fullwidth-input' ) ;
681
+ tfMultiRoot . classList [ target . checked ? 'add' : 'remove' ] ( 'demo-textarea' ) ;
682
+ } ) ;
618
683
} ) ;
619
684
</ script >
620
685
</ body >
0 commit comments