Skip to content

Commit

Permalink
fix(material/form-field): move unthemable tokens to theme mixin
Browse files Browse the repository at this point in the history
Though these tokens are not currently affected by the theme, in the
future they will be affected by the design system used for theming (M2
or M3)

BREAKING CHANGE:
There are new styles emitted by mat.form-field-theme that are not
emitted by any of: mat.form-field-color, mat.form-field-typography,
mat.form-field-density. If you rely on the partial mixins only and don't
call mat.form-field-theme, you can add mat.form-field-base to get the
missing styles.
  • Loading branch information
mmalerba committed Oct 3, 2023
1 parent 2f958ac commit d623e47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
@forward './expansion/expansion-theme' as expansion-* show expansion-theme, expansion-color,
expansion-typography, expansion-density;
@forward './form-field/form-field-theme' as form-field-* show form-field-theme,
form-field-color, form-field-typography, form-field-density;
form-field-color, form-field-typography, form-field-density, form-field-base;
@forward './grid-list/grid-list-theme' as grid-list-* show grid-list-theme, grid-list-color,
grid-list-typography, grid-list-density;
@forward './icon/icon-theme' as icon-* show icon-theme, icon-color, icon-typography, icon-density;
Expand Down
15 changes: 15 additions & 0 deletions src/material/form-field/_form-field-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
@use '../core/tokens/token-utils';
@use './form-field-density';

@mixin base($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(
tokens-mdc-filled-text-field.$prefix,
tokens-mdc-filled-text-field.get-unthemable-tokens());
@include token-utils.create-token-values(
tokens-mdc-outlined-text-field.$prefix,
tokens-mdc-outlined-text-field.get-unthemable-tokens());
@include token-utils.create-token-values(
tokens-mat-form-field.$prefix,
tokens-mat-form-field.get-unthemable-tokens());
}
}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include mdc-filled-text-field-theme.theme(
Expand Down Expand Up @@ -57,6 +71,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-form-field') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
12 changes: 0 additions & 12 deletions src/material/form-field/form-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,12 @@
@include mdc-custom-properties.configure(
$emit-fallback-values: false, $emit-fallback-vars: false) {

@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(
tokens-mat-form-field.$prefix,
tokens-mat-form-field.get-unthemable-tokens());
}

.mdc-text-field--filled {
@include token-utils.create-token-values(
tokens-mdc-filled-text-field.$prefix,
tokens-mdc-filled-text-field.get-unthemable-tokens());
@include mdc-filled-text-field-theme.theme-styles(
tokens-mdc-filled-text-field.get-token-slots());
}

.mdc-text-field--outlined {
@include token-utils.create-token-values(
tokens-mdc-outlined-text-field.$prefix,
tokens-mdc-outlined-text-field.get-unthemable-tokens());
@include mdc-outlined-text-field-theme.theme-styles(
tokens-mdc-outlined-text-field.get-token-slots());
}
Expand Down

0 comments on commit d623e47

Please sign in to comment.