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

Commit 9f17ff2

Browse files
patrickrodeecopybara-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: 475872348
1 parent 271aedc commit 9f17ff2

File tree

3 files changed

+37
-76
lines changed

3 files changed

+37
-76
lines changed

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

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

2727
@use 'sass:map';
2828
@use '@material/line-ripple/mixins' as line-ripple-mixins;
29-
@use '@material/ripple/ripple-theme';
3029
@use '@material/theme/theme';
3130
@use '@material/tokens/resolvers';
3231
@use './text-field-theme';
@@ -145,7 +144,7 @@ $_light-theme: (
145144
default: map.get($theme, active-indicator-color),
146145
hover: map.get($theme, hover-active-indicator-color),
147146
focus: map.get($theme, focus-active-indicator-color),
148-
disabled: map.get($theme, disabled-active-indicator-color),
147+
disabled: map.get($theme, disabled-indicator-color),
149148
)
150149
);
151150
@include _error-active-indicator-color(
@@ -156,16 +155,6 @@ $_light-theme: (
156155
)
157156
);
158157
@include _active-indicator-height(map.get($theme, active-indicator-height));
159-
@include _hover-state-layer(
160-
(
161-
error-hover-state-layer-color:
162-
map.get($theme, error-hover-state-layer-color),
163-
error-hover-state-layer-opacity:
164-
map.get($theme, error-hover-state-layer-opacity),
165-
hover-state-layer-color: map.get($theme, hover-state-layer-color),
166-
hover-state-layer-opacity: map.get($theme, hover-state-layer-opacity),
167-
)
168-
);
169158
}
170159

171160
@mixin _container-color($colors) {
@@ -186,7 +175,7 @@ $_light-theme: (
186175
@include text-field-theme.if-enabled {
187176
@include _set-active-indicator-color(map.get($colors, default));
188177

189-
@include text-field-theme.if-hovered {
178+
&:hover {
190179
@include _set-active-indicator-color(map.get($colors, hover));
191180
}
192181

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

packages/mdc-textfield/_mixins.scss

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -658,15 +658,12 @@ $_density-config: map.merge(
658658
$query: feature-targeting.all()
659659
) {
660660
$feat-structure: feature-targeting.create-target($query, structure);
661+
@include feature-targeting.targets($feat-structure) {
662+
height: $height;
663+
}
661664

662-
&:not(.mdc-text-field--textarea) {
663-
@include feature-targeting.targets($feat-structure) {
664-
height: $height;
665-
}
666-
667-
@if $height < $minimum-height-for-filled-label {
668-
@include _filled-no-label($query: $query);
669-
}
665+
@if $height < $minimum-height-for-filled-label {
666+
@include _filled-no-label($query: $query);
670667
}
671668
}
672669

@@ -686,29 +683,27 @@ $_density-config: map.merge(
686683
$feat-structure: feature-targeting.create-target($query, structure);
687684
$positionY: variables.get-outlined-label-position-y($height);
688685

689-
&:not(.mdc-text-field--textarea) {
690-
// Floating label position
691-
@include notched-outline-mixins.floating-label-float-position-absolute(
692-
$positionY,
693-
$query: $query
694-
);
686+
// Floating label position
687+
@include notched-outline-mixins.floating-label-float-position-absolute(
688+
$positionY,
689+
$query: $query
690+
);
695691

696-
// Floating label animation
697-
@include floating-label-mixins.shake-animation(
692+
// Floating label animation
693+
@include floating-label-mixins.shake-animation(
694+
$keyframe-suffix,
695+
$query: $query
696+
);
697+
@at-root {
698+
@include floating-label-mixins.shake-keyframes(
698699
$keyframe-suffix,
700+
$positionY,
699701
$query: $query
700702
);
701-
@at-root {
702-
@include floating-label-mixins.shake-keyframes(
703-
$keyframe-suffix,
704-
$positionY,
705-
$query: $query
706-
);
707-
}
703+
}
708704

709-
@include feature-targeting.targets($feat-structure) {
710-
height: $height;
711-
}
705+
@include feature-targeting.targets($feat-structure) {
706+
height: $height;
712707
}
713708
}
714709

@@ -727,21 +722,19 @@ $_density-config: map.merge(
727722
) {
728723
$feat-structure: feature-targeting.create-target($query, structure);
729724

730-
&:not(.mdc-text-field--textarea) {
731-
// This extra specificity is needed because textfield applies the below mixin
732-
// already to two selectors (outlined + with-leading-icon). To override
733-
// them with a new label position and animation, another selector is needed.
734-
&.mdc-text-field--outlined {
735-
@include _outlined-with-leading-icon-floating-label-position-animation(
736-
$height,
737-
$keyframe-suffix,
738-
$query
739-
);
740-
}
725+
// This extra specificity is needed because textfield applies the below mixin
726+
// already to two selectors (outlined + with-leading-icon). To override
727+
// them with a new label position and animation, another selector is needed.
728+
&.mdc-text-field--outlined {
729+
@include _outlined-with-leading-icon-floating-label-position-animation(
730+
$height,
731+
$keyframe-suffix,
732+
$query
733+
);
734+
}
741735

742-
@include feature-targeting.targets($feat-structure) {
743-
height: $height;
744-
}
736+
@include feature-targeting.targets($feat-structure) {
737+
height: $height;
745738
}
746739
}
747740

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-line .mdc-text-field-helper-text {
442+
& + .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-line .mdc-text-field-helper-text {
466+
& + .mdc-text-field-helper-text {
467467
@include typography.theme-styles($typography-theme);
468468
}
469469
}

0 commit comments

Comments
 (0)