44@import ' ../core/typography/typography-utils' ;
55
66
7- // Theme styles that only apply to the box appearance of the form-field.
7+ // Theme styles that only apply to the fill appearance of the form-field.
88
9- @mixin mat-form-field-box -theme ($theme ) {
9+ @mixin mat-form-field-fill -theme ($theme ) {
1010 $foreground : map-get ($theme , foreground );
1111 $is-dark-theme : map-get ($theme , is-dark );
1212
13- $box-background : mat-color ($foreground , base , if ($is-dark-theme , 0.1 , 0.06 ));
14- $box-disabled-background : mat-color ($foreground , base , if ($is-dark-theme , 0.05 , 0.03 ));
15- $underline-color : mat-color ($foreground , divider , if ($is-dark-theme , 0.7 , 0.42 ));
13+ $fill-background : mat-color ($foreground , base , if ($is-dark-theme , 0.1 , 0.04 ));
14+ $fill-disabled-background : mat-color ($foreground , base , if ($is-dark-theme , 0.05 , 0.02 ));
15+ $underline-color : mat-color ($foreground , divider , if ($is-dark-theme , 0.5 , 0.42 ));
16+ $label-disabled-color : mat-color ($foreground , disabled-text );
1617
17- .mat-form-field-appearance-box {
18+ .mat-form-field-appearance-fill {
1819 .mat-form-field-flex {
19- background-color : $box -background ;
20+ background-color : $fill -background ;
2021 }
2122
2223 & .mat-form-field-disabled .mat-form-field-flex {
23- background-color : $box -disabled-background ;
24+ background-color : $fill -disabled-background ;
2425 }
2526
2627 .mat-form-field-underline ::before {
2728 background-color : $underline-color ;
2829 }
2930
30- & .mat-form-field-disabled .mat-form-field-underline ::before {
31- background-color : transparent ;
31+ & .mat-form-field-disabled {
32+ .mat-form-field-label {
33+ color : $label-disabled-color ;
34+ }
35+
36+ .mat-form-field-underline ::before {
37+ background-color : transparent ;
38+ }
3239 }
3340 }
3441}
3744// and prevent Google's CSS Optimizer from collapsing the declarations. This is needed because some
3845// of the selectors contain pseudo-classes not recognized in all browsers. If a browser encounters
3946// an unknown pseudo-class it will discard the entire rule set.
40- $mat-form-field-box -dedupe : 0 ;
47+ $mat-form-field-fill -dedupe : 0 ;
4148
4249// Applies a floating label above the form field control itself.
43- @mixin _mat-form-field-box -label-floating ($font-scale , $infix-padding , $infix-margin-top ) {
44- transform : translateY (- $infix-margin-top - $infix-padding + $mat-form-field-box -dedupe )
50+ @mixin _mat-form-field-fill -label-floating ($font-scale , $infix-padding , $infix-margin-top ) {
51+ transform : translateY (- $infix-margin-top - $infix-padding + $mat-form-field-fill -dedupe )
4552 scale ($font-scale );
46- width : 100% / $font-scale + $mat-form-field-box -dedupe ;
53+ width : 100% / $font-scale + $mat-form-field-fill -dedupe ;
4754
48- $mat-form-field-box -dedupe : $mat-form-field-box -dedupe + 0.00001 !global;
55+ $mat-form-field-fill -dedupe : $mat-form-field-fill -dedupe + 0.00001 !global;
4956}
5057
51- @mixin mat-form-field-box -typography ($config ) {
58+ @mixin mat-form-field-fill -typography ($config ) {
5259 // The unit-less line-height from the font config.
5360 $line-height : mat-line-height ($config , input );
5461 // The amount to scale the font for the floating label and subscript.
5562 $subscript-font-scale : 0.75 ;
5663 // The padding on the infix. Mocks show half of the text size.
57- $infix-padding : 0.5em ;
64+ $infix-padding-top : 0.25em ;
65+ $infix-padding-bottom : 0.75em ;
5866 // The margin applied to the form-field-infix to reserve space for the floating label.
5967 $infix-margin-top : 1em * $line-height * $subscript-font-scale ;
60- // The amount we offset the label in the box appearance.
61- $box-appearance-label-offset : -0.5em * $line-height ;
68+ // The amount we offset the label in the fill appearance.
69+ $fill-appearance-label-offset : -0.5em * $line-height ;
70+
71+ .mat-form-field-appearance-fill {
72+ .mat-form-field-infix {
73+ padding : $infix-padding-top 0 $infix-padding-bottom 0 ;
74+ }
75+
76+ .mat-form-field-label {
77+ margin-top : $fill-appearance-label-offset ;
78+ }
6279
63- .mat-form-field-appearance-box {
6480 .mat-form-field-label {
65- margin- top : $box-appearance-label-offset ;
81+ top : $infix-margin-top + $infix-padding-top ;
6682 }
6783
6884 & .mat-form-field-can-float {
6985 & .mat-form-field-should-float .mat-form-field-label ,
7086 .mat-input-server :focus + .mat-form-field-label-wrapper .mat-form-field-label {
7187 @include _mat-form-field-label-floating (
72- $subscript-font-scale , $infix-padding + $box -appearance-label-offset ,
88+ $subscript-font-scale , $infix-padding-top + $fill -appearance-label-offset ,
7389 $infix-margin-top );
7490 }
7591
7692 .mat-form-field-autofill-control :-webkit-autofill + .mat-form-field-label-wrapper
7793 .mat-form-field-label {
7894 @include _mat-form-field-label-floating (
79- $subscript-font-scale , $infix-padding + $box -appearance-label-offset ,
95+ $subscript-font-scale , $infix-padding-top + $fill -appearance-label-offset ,
8096 $infix-margin-top );
8197 }
8298
@@ -85,7 +101,7 @@ $mat-form-field-box-dedupe: 0;
85101 .mat-input-server [label ]:not (:label-shown ) + .mat-form-field-label-wrapper
86102 .mat-form-field-label {
87103 @include _mat-form-field-label-floating (
88- $subscript-font-scale , $infix-padding + $box -appearance-label-offset ,
104+ $subscript-font-scale , $infix-padding-top + $fill -appearance-label-offset ,
89105 $infix-margin-top );
90106 }
91107 }
0 commit comments