This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy path_text-field.scss
2692 lines (2341 loc) · 80.8 KB
/
_text-field.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// 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.
//
// stylelint-disable selector-class-pattern --
// Selector '.mdc-*' should only be used in this project.
@use 'sass:math';
@use 'sass:list';
@use 'sass:meta';
@use 'sass:map';
@use '@material/animation/animation';
@use '@material/theme/css';
@use '@material/density/functions' as density-functions;
@use '@material/dom/dom';
@use '@material/floating-label/mixins' as floating-label-mixins;
@use '@material/floating-label/variables' as floating-label-variables;
@use '@material/line-ripple/mixins' as line-ripple-mixins;
@use '@material/notched-outline/mixins' as notched-outline-mixins;
@use '@material/notched-outline/variables' as notched-outline-variables;
@use '@material/ripple/ripple';
@use '@material/ripple/ripple-theme';
@use '@material/theme/custom-properties';
@use '@material/theme/theme';
@use '@material/shape/mixins' as shape-mixins;
@use '@material/shape/functions' as shape-functions;
@use '@material/feature-targeting/feature-targeting';
@use '@material/typography/typography';
@use 'helper-text/mixins' as helper-text-mixins;
@use 'character-counter/mixins' as character-counter-mixins;
@use 'icon/mixins' as icon-mixins;
@use 'icon/variables' as icon-variables;
@use './variables';
@use '@material/rtl/rtl';
$_density-config: map.merge(
variables.$density-config,
(
minimum: math.min(variables.$minimum-height, 36px),
)
);
@mixin core-styles($query: feature-targeting.all()) {
@include ripple($query);
@include static-styles($query);
@include helper-text-mixins.helper-text-core-styles($query);
@include character-counter-mixins.character-counter-core-styles($query);
@include icon-mixins.icon-core-styles($query);
}
/// @deprecated Use static-styles() instead.
@mixin without-ripple($query: feature-targeting.all()) {
@include static-styles($query);
}
@mixin static-styles($query: feature-targeting.all()) {
$feat-structure: feature-targeting.create-target($query, structure);
// Baseline
// postcss-bem-linter: define text-field
.mdc-text-field {
@include _base($query);
}
.mdc-text-field__input {
@include _input($query);
@include placeholder-selector_ {
@include _input-placeholder($query);
}
// Always show placeholder for text fields that has no
// label and show only on focused state when label is present.
.mdc-text-field--no-label &,
.mdc-text-field--focused & {
@include placeholder-selector_ {
@include _input-placeholder-visible($query);
}
}
}
.mdc-text-field__affix {
@include _affix($query: $query);
.mdc-text-field--label-floating &,
.mdc-text-field--no-label & {
@include _affix-visible($query: $query);
}
// Safari only
@supports (-webkit-hyphens: none) {
.mdc-text-field--outlined & {
@include _centered-affix-safari-support($query: $query);
}
}
}
.mdc-text-field__affix--prefix {
@include _prefix($query: $query);
.mdc-text-field--end-aligned & {
@include _prefix-end-aligned($query: $query);
}
}
.mdc-text-field__affix--suffix {
@include _suffix($query: $query);
.mdc-text-field--end-aligned & {
@include _suffix-end-aligned($query: $query);
}
}
// Variants
.mdc-text-field--filled {
@include _filled($query);
&.mdc-text-field--no-label {
@include filled-no-label($query);
}
}
.mdc-text-field--outlined {
@include outlined_($query);
.mdc-notched-outline {
@include _outlined-notched-outline($query);
}
}
// Other Variations
.mdc-text-field--textarea {
@include textarea_($query);
.mdc-text-field__input {
@include _textarea-input($query);
}
&.mdc-text-field--filled {
@include _textarea-filled($query);
.mdc-text-field__input {
@include _textarea-filled-input($query);
}
&.mdc-text-field--no-label {
.mdc-text-field__input {
@include _textarea-filled-no-label-input($query);
}
}
}
&.mdc-text-field--outlined {
@include _textarea-outlined($query);
.mdc-text-field__input {
@include _textarea-outlined-input($query);
}
.mdc-floating-label {
@include _textarea-outlined-floating-label($query);
}
}
&.mdc-text-field--with-internal-counter {
.mdc-text-field__input {
@include _textarea-input-with-internal-counter($query);
}
.mdc-text-field-character-counter {
@include _textarea-internal-counter($query);
}
}
}
// Resizer element does not need to be under mdc-text-field--textarea, that
// just adds specificity
.mdc-text-field__resizer {
@include _textarea-resizer($query);
.mdc-text-field--filled & {
@include _textarea-filled-resizer($query);
.mdc-text-field__input,
.mdc-text-field-character-counter {
@include _textarea-filled-resizer-children($query);
}
}
.mdc-text-field--outlined & {
@include _textarea-outlined-resizer($query);
.mdc-text-field__input,
.mdc-text-field-character-counter {
@include _textarea-outlined-resizer-children($query);
}
}
}
.mdc-text-field--with-leading-icon {
@include _padding-horizontal-with-leading-icon($query);
&.mdc-text-field--filled {
@include with-leading-icon_($query);
}
&.mdc-text-field--outlined {
@include outlined-with-leading-icon_($query);
}
}
.mdc-text-field--with-trailing-icon {
@include _padding-horizontal-with-trailing-icon($query);
&.mdc-text-field--filled {
@include _with-trailing-icon($query);
}
&.mdc-text-field--outlined {
@include _outlined-with-trailing-icon($query);
}
}
.mdc-text-field--with-leading-icon.mdc-text-field--with-trailing-icon {
@include _padding-horizontal-with-both-icons($query);
&.mdc-text-field--filled {
@include _with-leading-and-trailing-icon($query);
}
}
// postcss-bem-linter: define text-field-helper-text
.mdc-text-field-helper-line {
@include feature-targeting.targets($feat-structure) {
display: flex;
justify-content: space-between;
box-sizing: border-box;
}
.mdc-text-field + & {
@include feature-targeting.targets($feat-structure) {
padding-right: variables.$helper-line-padding;
padding-left: variables.$helper-line-padding;
}
}
}
// postcss-bem-linter: end
// mdc-form-field tweaks to align text field label correctly
// stylelint-disable selector-max-type --
// TODO: document why this disable is neccessary
.mdc-form-field > .mdc-text-field + label {
@include feature-targeting.targets($feat-structure) {
align-self: flex-start;
}
}
// stylelint-enable selector-max-type
// States
.mdc-text-field--focused {
@include focused_($query);
&.mdc-text-field--outlined {
@include _focused-outlined($query);
&.mdc-text-field--textarea {
@include _focused-outlined-textarea($query);
}
}
}
.mdc-text-field--invalid {
@include invalid_($query);
}
.mdc-text-field--disabled {
@include disabled_($query);
&.mdc-text-field--filled {
@include _disabled-filled($query);
}
.mdc-text-field__input {
@include _disabled-input($query);
}
}
.mdc-text-field--end-aligned {
@include end-aligned_($query);
}
.mdc-text-field--ltr-text {
@include _ltr-text($query);
&.mdc-text-field--end-aligned {
@include _ltr-text-end-aligned($query);
}
}
}
// This API is intended for use by frameworks that may want to separate the ripple-related styles
// from the other text field styles. It is recommended that most users use `mdc-text-field-core-styles` instead.
@mixin ripple($query: feature-targeting.all()) {
@include ripple.common($query); // COPYBARA_COMMENT_THIS_LINE
.mdc-text-field--filled {
@include ripple.surface(
$query: $query,
$ripple-target: variables.$ripple-target
);
@include ripple.radius-bounded(
$query: $query,
$ripple-target: variables.$ripple-target
);
}
#{variables.$ripple-target} {
@include ripple.target-common($query: $query);
}
}
///
/// Sets density scale for default text field variant.
///
/// @param {Number | String} $density-scale - Density scale value for component. Supported density scale values `-4`,
/// `-3`, `-2`, `-1`, `0`. Default is `0`.
/// @param {Number} $minimum-height-for-filled-label Sets the minimum height for
/// filled textfields at which to allow floating labels.
///
@mixin density(
$density-scale,
$minimum-height-for-filled-label: variables.$minimum-height-for-filled-label,
$query: feature-targeting.all()
) {
$height: density-functions.prop-value(
$density-config: $_density-config,
$density-scale: $density-scale,
$property-name: height,
);
@include height(
$height,
$minimum-height-for-filled-label: $minimum-height-for-filled-label,
$query: $query
);
// TODO(b/151839219): resize icons and adjust label position
// @if $density-scale < 0 {
// @include icon-mixins.size(icon-variables.$dense-icon-size);
// }
}
///
/// Sets density scale for outlined text field (Excluding outlined text field with leading icon).
///
/// @param {Number | String} $density-scale - Density scale value for component. Supported density scale values `-4`,
/// `-3`, `-2`, `-1`, `0`. Default is `0`.
/// @param {Number} $label-font-size - Font-size for the textfield's floating label. If the label size is being customized, it is necessary to specify this value to ensure that the notched outline does not cut-off the label when floated, see b/302340517 for more info. Defaults to 1rem.
///
@mixin outlined-density(
$density-scale,
$label-font-size: 1rem,
$query: feature-targeting.all()
) {
$height: density-functions.prop-value(
$density-config: $_density-config,
$density-scale: $density-scale,
$property-name: height,
);
@include outlined-height(
$height,
$label-font-size: $label-font-size,
$query: $query
);
// TODO(b/151839219): resize icons and adjust label position
// @if $density-scale < 0 {
// @include icon-mixins.size(icon-variables.$dense-icon-size);
// }
}
///
/// Sets density scale for outlined text field with leading icon.
///
/// @param {Number | String} $density-scale - Density scale value for component. Supported density scale values `-4`,
/// `-3`, `-2`, `-1`, `0`. Default is `0`.
/// @param {Number} $label-font-size - Font-size for the textfield's floating label. It is necessary tto specify this value to ensure that the notched outline does not cut-off the label when floated, see b/302340517 for more info.
///
@mixin outlined-with-leading-icon-density(
$density-scale,
$label-font-size: 1rem,
$query: feature-targeting.all()
) {
$height: density-functions.prop-value(
$density-config: $_density-config,
$density-scale: $density-scale,
$property-name: height,
);
@include outlined-with-leading-icon-height(
$height,
$label-font-size: $label-font-size,
$query: $query
);
// TODO(b/151839219): resize icons and adjust label position
// @if $density-scale < 0 {
// @include icon-mixins.size(icon-variables.$dense-icon-size);
// }
}
///
/// Sets density scale for filled textarea.
///
/// @param {Number | String} $density-scale - Density scale value for component. Supported density scale values `-4`,
/// `-3`, `-2`, `-1`, `0`. Default is `0`.
///
@mixin filled-textarea-density(
$density-scale,
$query: feature-targeting.all()
) {
$feat-structure: feature-targeting.create-target($query, structure);
$textfield-height: density-functions.prop-value(
$density-config: $_density-config,
$density-scale: $density-scale,
$property-name: height,
);
$no-label-margin-top: density-functions.prop-value(
$density-config: variables.$textarea-filled-no-label-density-config,
$density-scale: math.div($density-scale, 2),
$property-name: margin-top,
);
$no-label-margin-bottom: density-functions.prop-value(
$density-config: variables.$textarea-filled-no-label-density-config,
$density-scale: math.div($density-scale, 2),
$property-name: margin-bottom,
);
// Textarea mixins require two modifier classes since two are used internally
// for styles (textarea and filled). An extra class is added for the public
// mixin so that only a single public class is needed for specificity.
&.mdc-text-field--filled {
.mdc-text-field__resizer {
@include feature-targeting.targets($feat-structure) {
min-height: $textfield-height;
}
}
@if $density-scale >= -1 {
$keyframe-suffix: text-field-filled-#{$density-scale};
$label-top: density-functions.prop-value(
$density-config: variables.$textarea-filled-label-density-config,
$density-scale: math.div($density-scale, 2),
$property-name: top,
);
// Adjust the floating position and animation/keyframes of the floating
// label by the new position of the resting label
$label-top-difference: variables.$textarea-outlined-label-top -
$label-top;
// Floating label position
@include floating-label-mixins.float-position(
variables.$textarea-filled-label-position-y - $label-top-difference,
$query: $query
);
// Floating label animation
@include floating-label-mixins.shake-animation(
$keyframe-suffix,
$query: $query
);
@at-root {
@include floating-label-mixins.shake-keyframes(
$keyframe-suffix,
variables.$textarea-filled-label-position-y - $label-top-difference,
0%,
$query: $query
);
}
// Resting label position
.mdc-floating-label {
@include feature-targeting.targets($feat-structure) {
top: $label-top;
}
}
$margin-bottom: density-functions.prop-value(
$density-config: variables.$textarea-filled-density-config,
$density-scale: $density-scale,
$property-name: margin-bottom,
);
.mdc-text-field__input {
@include feature-targeting.targets($feat-structure) {
margin-bottom: $margin-bottom;
}
}
} @else {
// The textarea is too dense to show a floating label
.mdc-floating-label {
@include feature-targeting.targets($feat-structure) {
display: none;
}
}
.mdc-text-field__input {
@include feature-targeting.targets($feat-structure) {
margin-top: $no-label-margin-top;
margin-bottom: $no-label-margin-bottom;
}
}
}
&.mdc-text-field--no-label {
.mdc-text-field__input {
@include feature-targeting.targets($feat-structure) {
margin-top: $no-label-margin-top;
margin-bottom: $no-label-margin-bottom;
}
}
}
&.mdc-text-field--with-internal-counter {
.mdc-text-field__input {
// Space between textarea and internal counter should not be affected
@include _textarea-input-with-internal-counter($query);
}
}
}
}
///
/// Sets density scale for outlined textarea.
///
/// @param {Number | String} $density-scale - Density scale value for component. Supported density scale values `-4`,
/// `-3`, `-2`, `-1`, `0`. Default is `0`.
///
@mixin outlined-textarea-density(
$density-scale,
$query: feature-targeting.all()
) {
$feat-structure: feature-targeting.create-target($query, structure);
$keyframe-suffix: text-field-outlined-#{$density-scale};
$label-top: density-functions.prop-value(
$density-config: variables.$textarea-outlined-label-density-config,
$density-scale: math.div($density-scale, 2),
$property-name: top,
);
$textfield-height: density-functions.prop-value(
$density-config: $_density-config,
$density-scale: $density-scale,
$property-name: height,
);
$margin-top: density-functions.prop-value(
$density-config: variables.$textarea-outlined-density-config,
$density-scale: math.div($density-scale, 2),
$property-name: margin-top,
);
$margin-bottom: density-functions.prop-value(
$density-config: variables.$textarea-outlined-density-config,
$density-scale: math.div($density-scale, 2),
$property-name: margin-bottom,
);
// Textarea mixins require two modifier classes since two are used internally
// for styles (textarea and outlined). An extra class is added for the public
// mixin so that only a single public class is needed for specificity.
&.mdc-text-field--outlined {
// Adjust the floating position and animation/keyframes of the floating
// label by the new position of the resting label
$label-top-difference: variables.$textarea-outlined-label-top - $label-top;
// Floating label position
@include notched-outline-mixins.floating-label-float-position-absolute(
variables.$textarea-outlined-label-position-y - $label-top-difference,
$query: $query
);
// Floating label animation
@include floating-label-mixins.shake-animation(
$keyframe-suffix,
$query: $query
);
@at-root {
@include floating-label-mixins.shake-keyframes(
$keyframe-suffix,
variables.$textarea-outlined-label-position-y - $label-top-difference,
0%,
$query: $query
);
}
// Resting label position
.mdc-floating-label {
@include feature-targeting.targets($feat-structure) {
top: $label-top;
}
}
.mdc-text-field__resizer {
@include feature-targeting.targets($feat-structure) {
min-height: $textfield-height;
}
}
.mdc-text-field__input {
@include feature-targeting.targets($feat-structure) {
margin-top: $margin-top;
margin-bottom: $margin-bottom;
}
}
&.mdc-text-field--with-internal-counter {
.mdc-text-field__input {
// Space between textarea and internal counter should not be affected
@include _textarea-input-with-internal-counter($query);
}
}
}
}
///
/// Sets the minimum number of rows for a textarea a textarea may be resized to.
///
/// For IE11 this mixin can be used instead of the rows attribute.
///
/// @param {Number} $rows - The minimum number of rows for a textarea.
/// @param {Number} $line-height - The line-height of the textarea.
///
@mixin textarea-min-rows(
$rows,
$line-height: variables.$textarea-line-height,
$query: feature-targeting.all()
) {
$feat-structure: feature-targeting.create-target($query, structure);
.mdc-text-field__input {
@include feature-targeting.targets($feat-structure) {
min-height: $rows * $line-height;
}
}
}
///
/// Sets height of default text field variant.
///
/// @param {Number} $height
/// @param {Number} $minimum-height-for-filled-label Sets the minimum height for
/// filled textfields at which to allow floating labels.
/// @access public
///
@mixin height(
$height,
$minimum-height-for-filled-label: variables.$minimum-height-for-filled-label,
$query: feature-targeting.all()
) {
$feat-structure: feature-targeting.create-target($query, structure);
@include feature-targeting.targets($feat-structure) {
@include theme.property(height, $height);
}
// We can only hide the label (when there's not enough vertical space for it)
// if we know the container height at compilation time.
// That's not the case when $height is a custom property.
@if not custom-properties.is-custom-prop($height) {
@if $height < $minimum-height-for-filled-label {
@include filled-no-label($query: $query);
}
}
}
///
/// Sets height of outlined text field variant (Excluding outlined text field with leading icon).
///
/// @param {Number} $height
/// @param {String} $keyframe-suffix - Optional suffix to use for generated
/// floating label keyframes
/// @param {Number} label-font-size - font size for the floating label. Defaults to 1rem.
/// @access public
///
@mixin outlined-height(
$height,
$keyframe-suffix: text-field-outlined-#{$height},
$label-font-size: 1rem,
$query: feature-targeting.all()
) {
$feat-structure: feature-targeting.create-target($query, structure);
$positionY: variables.get-outlined-label-position-y($height);
// Floating label position
@include notched-outline-mixins.floating-label-float-position-absolute(
$positionY,
$font-size: $label-font-size,
$query: $query
);
// Floating label animation
@include floating-label-mixins.shake-animation(
$keyframe-suffix,
$query: $query
);
@at-root {
@include floating-label-mixins.shake-keyframes(
$keyframe-suffix,
$positionY,
$query: $query
);
}
@include feature-targeting.targets($feat-structure) {
height: $height;
}
}
///
/// Sets height of outlined text field with leading icon variant.
///
/// @param {Number} $height
/// @param {String} $keyframe-suffix - Optional suffix to use for generated
/// floating label keyframes
/// @param {Number} $label-font-size - Font-size for the textfield's floating label. It is necessary tto specify this value to ensure that the notched outline does not cut-off the label when floated, see b/302340517 for more info.
/// @access public
///
@mixin outlined-with-leading-icon-height(
$height,
$keyframe-suffix: null,
$label-font-size: 1rem,
$query: feature-targeting.all()
) {
$feat-structure: feature-targeting.create-target($query, structure);
// This extra specificity is needed because textfield applies the below mixin
// already to two selectors (outlined + with-leading-icon). To override
// them with a new label position and animation, another selector is needed.
&.mdc-text-field--outlined {
@include _outlined-with-leading-icon-floating-label-position-animation(
$height,
$keyframe-suffix,
$label-font-size,
$query
);
}
@include feature-targeting.targets($feat-structure) {
height: $height;
}
}
// Mixin that sets the floating label position and animations for a given height.
// This mixin is separate to allow outlined-with-leading-icon-height() to
// provide greater specificity over the default mixin that adds styles for
// outlined with leading icons.
@mixin _outlined-with-leading-icon-floating-label-position-animation(
$height,
$keyframe-suffix: text-field-outlined-with-leading-icon-#{$height},
$font-size: 1rem,
$query: feature-targeting.all()
) {
$positionY: variables.get-outlined-label-position-y($height);
// Floating label position
@include notched-outline-mixins.floating-label-float-position-absolute(
$positionY,
variables.$outlined-with-leading-icon-label-position-x,
$font-size: $font-size,
$query: $query
);
// Floating label animation
@include floating-label-mixins.shake-animation(
$keyframe-suffix,
$query: $query
);
@at-root {
@include floating-label-mixins.shake-keyframes(
$keyframe-suffix,
$positionY,
variables.$outlined-with-leading-icon-label-position-x,
$query: $query
);
}
$keyframe-suffix-rtl: #{$keyframe-suffix}-rtl;
@include rtl.rtl {
@include floating-label-mixins.shake-animation(
$keyframe-suffix,
$query: $query
);
}
@at-root {
@include floating-label-mixins.shake-keyframes(
$keyframe-suffix-rtl,
$positionY,
-(variables.$outlined-with-leading-icon-label-position-x),
$query: $query
);
}
}
///
/// Sets shape radius of default text field variant.
///
/// @param {Number} $radius Shape radius value in `px` or in percentage.
/// @param {Number} $text-field-height Height of default text field variant. Required only when `$radius` is in
/// percentage unit and if text field has custom height. Defaults to `variables.$height`.
/// @param {Boolean} $rtl-reflexive Set to true to flip shape radius in RTL context. Defaults to `false`.
///
@mixin shape-radius(
$radius,
$density-scale: variables.$density-scale,
$rtl-reflexive: false,
$query: feature-targeting.all()
) {
@if (meta.type-of($radius) == 'list') and
(list.length($radius) > 2) and
(list.nth($radius, 3) != 0 or list.nth($radius, 4) != 0)
{
@error "mdc-textfield: Invalid radius #{$radius}. Only top-left and top-right corners may be customized.";
}
$height: density-functions.prop-value(
$density-config: $_density-config,
$density-scale: $density-scale,
$property-name: height,
);
$masked-radius: shape-functions.mask-radius($radius, 1 1 0 0);
$fallback: if(
custom-properties.is-custom-prop($radius),
custom-properties.get-fallback($radius),
null
);
@if meta.type-of($fallback) == 'list' {
$fallback: css.unpack-value($fallback);
$first: list.nth($masked-radius, 1);
$second: list.nth($masked-radius, 2);
$third: list.nth($masked-radius, 3);
$fourth: list.nth($masked-radius, 4);
$masked-radius: (
if(
custom-properties.is-custom-prop($first),
custom-properties.set-fallback($first, list.nth($fallback, 1)),
$first
),
if(
custom-properties.is-custom-prop($second),
custom-properties.set-fallback($second, list.nth($fallback, 2)),
$second
),
if(
custom-properties.is-custom-prop($third),
custom-properties.set-fallback($third, list.nth($fallback, 3)),
$third
),
if(
custom-properties.is-custom-prop($fourth),
custom-properties.set-fallback($fourth, list.nth($fallback, 4)),
$fourth
)
);
}
@include shape-mixins.radius(
$masked-radius,
$rtl-reflexive,
$component-height: $height,
$query: $query
);
}
@mixin textarea-shape-radius(
$radius,
$rtl-reflexive: false,
$query: feature-targeting.all()
) {
@include notched-outline-mixins.shape-radius(
$radius,
$rtl-reflexive,
$query: $query
);
}
///
/// Customizes the color of the text entered into an enabled text field.
/// @param {Color} $color - The desired input text color.
///
@mixin ink-color($color, $query: feature-targeting.all()) {
@include if-enabled_ {
@include ink-color_($color, $query: $query);
}
}
///
/// Customizes the color of the entered text in a disabled text field.
/// @param {Color} $color - The desired input text color.
///
@mixin disabled-ink-color($color, $query: feature-targeting.all()) {
@include if-disabled_ {
@include ink-color_($color, $query: $query);
}
}
///
/// Customizes the color of the placeholder in an enabled text field.
/// @param {Color} $color - The desired placeholder text color.
///
@mixin placeholder-color($color, $query: feature-targeting.all()) {
@include if-enabled_ {
@include placeholder-color_($color, $query: $query);
}
}
///
/// Customizes the color of the placeholder in a disabled text field.
/// @param {Color} $color - The desired placeholder text color.
///
@mixin disabled-placeholder-color($color, $query: feature-targeting.all()) {
@include if-disabled_ {
@include placeholder-color_($color, $query: $query);
}
}
///
/// Customizes the background color of the text field or textarea when enabled.
/// @param {Color} $color - The desired background color.
///
@mixin fill-color($color, $query: feature-targeting.all()) {
@include if-enabled_ {
@include fill-color_($color, $query: $query);
}
}
///
/// Customizes the background color of the text field or textarea when disabled.
/// @param {Color} $color - The desired background color.
///
@mixin disabled-fill-color($color, $query: feature-targeting.all()) {
@include if-disabled_ {
@include fill-color_($color, $query: $query);
}
}
///
/// Customizes the text field bottom line color for the filled variant.
/// @param {Color} $color - The desired bottom line color.
///
@mixin bottom-line-color($color, $query: feature-targeting.all()) {
@include if-enabled_ {
@include bottom-line-color_($color, $query: $query);
}
}
///
/// Customizes the disabled text field bottom line color for the filled variant.
/// @param {Color} $color - The desired bottom line color.
///
@mixin disabled-bottom-line-color($color, $query: feature-targeting.all()) {
@include if-disabled_ {
@include bottom-line-color_($color, $query: $query);
}
}
///
/// Customizes the hover text field bottom line color for the filled variant.
/// @param {Color} $color - The desired bottom line color.
///
@mixin hover-bottom-line-color($color, $query: feature-targeting.all()) {
@include if-enabled_ {
@include hover-bottom-line-color_($color, $query: $query);
}
}
///
/// Customizes the color of the default line ripple of the text field.
/// @param {Color} $color - The desired line ripple color.
///
@mixin line-ripple-color($color, $query: feature-targeting.all()) {
@include if-enabled_ {