Skip to content

Commit

Permalink
fix(material/button-toggle): 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.button-toggle-theme that are not
emitted by any of: mat.button-toggle-color, mat.button-toggle-typography,
mat.button-toggle-density. If you rely on the partial mixins only and don't
call mat.button-toggle-theme, you can add mat.button-toggle-base to get the
missing styles.
  • Loading branch information
mmalerba committed Oct 5, 2023
1 parent c77ffa0 commit b52c0e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
@forward './button/icon-button-theme' as icon-button-* show icon-button-color,
icon-button-typography, icon-button-density, icon-button-theme;
@forward './button-toggle/button-toggle-theme' as button-toggle-* show button-toggle-theme,
button-toggle-color, button-toggle-typography, button-toggle-density;
button-toggle-color, button-toggle-typography, button-toggle-density, button-toggle-base;
@forward './card/card-theme' as card-* show card-theme, card-color, card-typography, card-density,
card-base;
@forward './checkbox/checkbox-theme' as checkbox-* show checkbox-theme, checkbox-color,
Expand Down
14 changes: 14 additions & 0 deletions src/material/button-toggle/_button-toggle-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
@use '../core/tokens/token-utils';
@use '../core/style/sass-utils';

@mixin base($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(
tokens-mat-legacy-button-toggle.$prefix,
tokens-mat-legacy-button-toggle.get-unthemable-tokens()
);
@include token-utils.create-token-values(
tokens-mat-standard-button-toggle.$prefix,
tokens-mat-standard-button-toggle.get-unthemable-tokens()
);
}
}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-legacy-button-toggle.$prefix,
Expand Down Expand Up @@ -35,6 +48,7 @@

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-button-toggle') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
15 changes: 0 additions & 15 deletions src/material/button-toggle/button-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ $_standard-tokens: (

.mat-button-toggle-standalone,
.mat-button-toggle-group {
@include token-utils.create-token-values(
tokens-mat-legacy-button-toggle.$prefix,
tokens-mat-legacy-button-toggle.get-unthemable-tokens()
);

@include elevation.overridable-elevation(2);
position: relative;
display: inline-flex;
Expand All @@ -54,11 +49,6 @@ $_standard-tokens: (

.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,
.mat-button-toggle-group-appearance-standard {
@include token-utils.create-token-values(
tokens-mat-standard-button-toggle.$prefix,
tokens-mat-standard-button-toggle.get-unthemable-tokens()
);

@include token-utils.use-tokens($_standard-tokens...) {
@include token-utils.create-token-slot(border-radius, shape);
border: solid 1px var(#{token-utils.get-token-variable(divider-color)});
Expand Down Expand Up @@ -122,11 +112,6 @@ $_standard-tokens: (
}

.mat-button-toggle-appearance-standard {
@include token-utils.create-token-values(
tokens-mat-standard-button-toggle.$prefix,
tokens-mat-standard-button-toggle.get-unthemable-tokens()
);

@include token-utils.use-tokens($_standard-tokens...) {
$divider-color: var(#{token-utils.get-token-variable(divider-color)});
@include token-utils.create-token-slot(color, text-color);
Expand Down

0 comments on commit b52c0e3

Please sign in to comment.