Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit d3344c1

Browse files
Yavanostacopybara-github
authored andcommitted
fix(textfield): Fix several tokens in theming API
1. Correctly apply `disabled-active-indicator-color` token 2. Apply `hover-state-layer` related tokens 3. Fix active indicator (underline) token 4. Do not apply heigh customisations for textarea 5. Fix selector for supporting text color and font tokens PiperOrigin-RevId: 476041470
1 parent 9f17ff2 commit d3344c1

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

packages/mdc-textfield/_filled-text-field-theme.scss

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
@use 'sass:map';
2828
@use '@material/line-ripple/mixins' as line-ripple-mixins;
29+
@use '@material/ripple/ripple-theme';
2930
@use '@material/theme/theme';
3031
@use '@material/tokens/resolvers';
3132
@use './text-field-theme';
@@ -126,8 +127,10 @@ $_light-theme: (
126127
@include theme.validate-theme($_light-theme, $theme);
127128
@include text-field-theme.theme-styles($theme, $resolvers: $resolvers);
128129

129-
@if map.get($theme, container-height) {
130-
@include mixins.height(map.get($theme, container-height));
130+
&:not(.mdc-text-field--textarea) {
131+
@if map.get($theme, container-height) {
132+
@include mixins.height(map.get($theme, container-height));
133+
}
131134
}
132135
@if map.get($theme, container-shape) {
133136
@include mixins.shape-radius(map.get($theme, container-shape));
@@ -144,7 +147,7 @@ $_light-theme: (
144147
default: map.get($theme, active-indicator-color),
145148
hover: map.get($theme, hover-active-indicator-color),
146149
focus: map.get($theme, focus-active-indicator-color),
147-
disabled: map.get($theme, disabled-indicator-color),
150+
disabled: map.get($theme, disabled-active-indicator-color),
148151
)
149152
);
150153
@include _error-active-indicator-color(
@@ -155,6 +158,16 @@ $_light-theme: (
155158
)
156159
);
157160
@include _active-indicator-height(map.get($theme, active-indicator-height));
161+
@include _hover-state-layer(
162+
(
163+
error-hover-state-layer-color:
164+
map.get($theme, error-hover-state-layer-color),
165+
error-hover-state-layer-opacity:
166+
map.get($theme, error-hover-state-layer-opacity),
167+
hover-state-layer-color: map.get($theme, hover-state-layer-color),
168+
hover-state-layer-opacity: map.get($theme, hover-state-layer-opacity),
169+
)
170+
);
158171
}
159172

160173
@mixin _container-color($colors) {
@@ -175,7 +188,7 @@ $_light-theme: (
175188
@include text-field-theme.if-enabled {
176189
@include _set-active-indicator-color(map.get($colors, default));
177190

178-
&:hover {
191+
@include text-field-theme.if-hovered {
179192
@include _set-active-indicator-color(map.get($colors, hover));
180193
}
181194

@@ -210,3 +223,24 @@ $_light-theme: (
210223
@include line-ripple-mixins.height($height);
211224
}
212225
}
226+
227+
@mixin _hover-state-layer($colors) {
228+
@include ripple-theme.theme-styles(
229+
(
230+
hover-state-layer-color: map.get($colors, hover-state-layer-color),
231+
hover-state-layer-opacity: map.get($colors, hover-state-layer-opacity),
232+
),
233+
$ripple-target: '.mdc-text-field__ripple'
234+
);
235+
236+
&.mdc-text-field--invalid {
237+
@include ripple-theme.theme-styles(
238+
(
239+
hover-state-layer-color: map.get($colors, error-hover-state-layer-color),
240+
hover-state-layer-opacity:
241+
map.get($colors, error-hover-state-layer-opacity),
242+
),
243+
$ripple-target: '.mdc-text-field__ripple'
244+
);
245+
}
246+
}

packages/mdc-textfield/_outlined-text-field-theme.scss

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,15 @@ $_light-theme: (
120120
@include theme.validate-theme($_light-theme, $theme);
121121
@include text-field-theme.theme-styles($theme, $resolvers: $resolvers);
122122

123-
@if map.get($theme, container-height) {
124-
@include mixins.outlined-height(map.get($theme, container-height));
125-
126-
&.mdc-text-field--with-leading-icon {
127-
@include mixins.outlined-with-leading-icon-height(
128-
map.get($theme, container-height)
129-
);
123+
&:not(.mdc-text-field--textarea) {
124+
@if map.get($theme, container-height) {
125+
@include mixins.outlined-height(map.get($theme, container-height));
126+
127+
&.mdc-text-field--with-leading-icon {
128+
@include mixins.outlined-with-leading-icon-height(
129+
map.get($theme, container-height)
130+
);
131+
}
130132
}
131133
}
132134
@if map.get($theme, container-shape) {

packages/mdc-textfield/_text-field-theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ $_light-theme: (
439439
}
440440

441441
@mixin _set-supporting-text-color($color) {
442-
& + .mdc-text-field-helper-text {
442+
& + .mdc-text-field-helper-line .mdc-text-field-helper-text {
443443
@include theme.property(color, $color);
444444
}
445445
}
@@ -463,7 +463,7 @@ $_light-theme: (
463463
}
464464

465465
@mixin _supporting-text-typography($typography-theme) {
466-
& + .mdc-text-field-helper-text {
466+
& + .mdc-text-field-helper-line .mdc-text-field-helper-text {
467467
@include typography.theme-styles($typography-theme);
468468
}
469469
}

0 commit comments

Comments
 (0)