Skip to content

Commit d26a51e

Browse files
authored
fix(material-experimental/theming): set up internal form field in M3 (#28414)
Fixes that the tokens for the internal form field weren't being provided in M3. Also includes the tokens in the components where the internal form field is used.
1 parent 339905c commit d26a51e

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

src/material-experimental/theming/_m3-tokens.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,22 @@
384384
));
385385
}
386386

387+
/// Gets the token values for the MDC form field.
388+
/// @param {Map} $systems The MDC system tokens.
389+
/// @return {Map} The form field tokens.
390+
@function _get-form-field-tokens($systems) {
391+
@return (
392+
// TODO: MDC currently doesn't provide tokens for the form field so we need to
393+
// define them ourselves. Clean this up once b/284340076 is resolved.
394+
label-text-color: map.get($systems, 'md-sys-color', 'on-surface'),
395+
label-text-font: map.get($systems, 'md-sys-typescale', 'body-medium-font'),
396+
label-text-line-height: map.get($systems, 'md-sys-typescale', 'body-medium-line-height'),
397+
label-text-size: map.get($systems, 'md-sys-typescale', 'body-medium-size'),
398+
label-text-tracking: map.get($systems, 'md-sys-typescale', 'body-medium-tracking'),
399+
label-text-weight: map.get($systems, 'md-sys-typescale', 'body-medium-weight'),
400+
);
401+
}
402+
387403
/// Generates a set of namespaced tokens for all components.
388404
/// @param {Map} $systems The MDC system tokens
389405
/// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens
@@ -466,6 +482,11 @@
466482
),
467483
$token-slots
468484
),
485+
_namespace-tokens(
486+
(mdc, form-field),
487+
_get-form-field-tokens($systems),
488+
$token-slots
489+
),
469490
_namespace-tokens(
470491
(mdc, icon-button),
471492
mdc-tokens.md-comp-icon-button-values($systems, $exclude-hardcoded),

src/material/checkbox/_checkbox-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@
107107
// TODO(mmalerba): Some of the theme styles above are not represented in terms of tokens,
108108
// so this mixin is currently incomplete.
109109
@include mdc-checkbox-theme.theme(map.get($tokens, tokens-mdc-checkbox.$prefix));
110+
@include mdc-form-field-theme.theme(map.get($tokens, tokens-mdc-form-field.$prefix));
110111
}
111112
}

src/material/core/tokens/m2/_index.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
@use './mdc/elevated-card' as tokens-mdc-elevated-card;
4949
@use './mdc/extended-fab' as tokens-mdc-extended-fab;
5050
@use './mdc/fab' as tokens-mdc-fab;
51+
@use './mdc/form-field' as tokens-mdc-form-field;
5152
@use './mdc/filled-text-field' as tokens-mdc-filled-text-field;
5253
@use './mdc/icon-button' as tokens-mdc-icon-button;
5354
@use './mdc/linear-progress' as tokens-mdc-linear-progress;
@@ -149,7 +150,8 @@
149150
_get-tokens-for-module($theme, tokens-mdc-extended-fab),
150151
_get-tokens-for-module($theme, tokens-mdc-fab),
151152
_get-tokens-for-module($theme, tokens-mdc-filled-button),
152-
_get-tokens-for-module($theme, tokens-mdc-filled-text-field),
153+
_get-tokens-for-module($theme, tokens-mdc-filled-button),
154+
_get-tokens-for-module($theme, tokens-mdc-form-field),
153155
_get-tokens-for-module($theme, tokens-mdc-icon-button),
154156
_get-tokens-for-module($theme, tokens-mdc-linear-progress),
155157
_get-tokens-for-module($theme, tokens-mdc-list),

src/material/radio/_radio-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
@mixin _theme-from-tokens($tokens) {
111111
@if ($tokens != ()) {
112112
@include mdc-radio-theme.theme(map.get($tokens, tokens-mdc-radio.$prefix));
113+
@include mdc-form-field-theme.theme(map.get($tokens, tokens-mdc-form-field.$prefix));
113114
@include token-utils.create-token-values(
114115
tokens-mat-radio.$prefix, map.get($tokens, tokens-mat-radio.$prefix));
115116
}

src/material/slide-toggle/_slide-toggle-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@
101101
@mixin _theme-from-tokens($tokens) {
102102
@if ($tokens != ()) {
103103
@include mdc-switch-theme.theme(map.get($tokens, tokens-mdc-switch.$prefix));
104+
@include mdc-form-field-theme.theme(map.get($tokens, tokens-mdc-form-field.$prefix));
104105
}
105106
}

0 commit comments

Comments
 (0)