Skip to content

Commit

Permalink
fix(material/table): 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.table-theme that are not
emitted by any of: mat.table-color, mat.table-typography,
mat.table-density. If you rely on the partial mixins only and don't
call mat.table-theme, you can add mat.table-base to get the
missing styles.
  • Loading branch information
mmalerba committed Oct 3, 2023
1 parent 2f958ac commit 3750157
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ list-density, list-base;
@forward './stepper/stepper-theme' as stepper-* show stepper-theme, stepper-color,
stepper-typography, stepper-density;
@forward './table/table-theme' as table-* show table-theme, table-color, table-typography,
table-density;
table-density, table-base;
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density;
@forward './toolbar/toolbar-theme' as toolbar-* show toolbar-theme, toolbar-color,
toolbar-typography, toolbar-density;
Expand Down
20 changes: 9 additions & 11 deletions src/material/table/_table-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,39 @@
@use '../core/theming/inspection';
@use '../core/typography/typography';
@use '../core/tokens/token-utils';
@use '../core/style/sass-utils';

@mixin _output-tokens {
@if (&) {
@content;
}
@else {
html {
@content;
}
@mixin base($theme) {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(
tokens-mat-table.$prefix, tokens-mat-table.get-unthemable-tokens());
}
}

@mixin color($theme) {
@include _output-tokens {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-table.$prefix,
tokens-mat-table.get-color-tokens($theme));
}
}

@mixin typography($theme) {
@include _output-tokens {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-table.$prefix,
tokens-mat-table.get-typography-tokens($theme));
}
}

@mixin density($theme) {
@include _output-tokens {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(tokens-mat-table.$prefix,
tokens-mat-table.get-density-tokens($theme));
}
}

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-table') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
Expand Down
3 changes: 0 additions & 3 deletions src/material/table/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
@include table-flex-styles.private-table-flex-styles();

.mat-mdc-table {
@include token-utils.create-token-values(
tokens-mat-table.$prefix, tokens-mat-table.get-unthemable-tokens());

// MDC Table applies `table-layout: fixed`, but this is a backwards incompatible
// change since the table did not previously apply it.
// TODO: Add a mixin to MDC to set the layout instead of including this override,
Expand Down

0 comments on commit 3750157

Please sign in to comment.