Skip to content

Commit af18402

Browse files
authored
fix(material/table): move unthemable tokens to theme mixin (#27890)
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.
1 parent 7cd71b6 commit af18402

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/material/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ list-density, list-base;
128128
@forward './stepper/stepper-theme' as stepper-* show stepper-theme, stepper-color,
129129
stepper-typography, stepper-density, stepper-base;
130130
@forward './table/table-theme' as table-* show table-theme, table-color, table-typography,
131-
table-density;
131+
table-density, table-base;
132132
@forward './tabs/tabs-theme' as tabs-* show tabs-theme, tabs-color, tabs-typography, tabs-density;
133133
@forward './toolbar/toolbar-theme' as toolbar-* show toolbar-theme, toolbar-color,
134134
toolbar-typography, toolbar-density, toolbar-base;

src/material/table/_table-theme.scss

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,39 @@
33
@use '../core/theming/inspection';
44
@use '../core/typography/typography';
55
@use '../core/tokens/token-utils';
6+
@use '../core/style/sass-utils';
67

7-
@mixin _output-tokens {
8-
@if (&) {
9-
@content;
10-
}
11-
@else {
12-
html {
13-
@content;
14-
}
8+
@mixin base($theme) {
9+
@include sass-utils.current-selector-or-root() {
10+
@include token-utils.create-token-values(
11+
tokens-mat-table.$prefix, tokens-mat-table.get-unthemable-tokens());
1512
}
1613
}
1714

1815
@mixin color($theme) {
19-
@include _output-tokens {
16+
@include sass-utils.current-selector-or-root() {
2017
@include token-utils.create-token-values(tokens-mat-table.$prefix,
2118
tokens-mat-table.get-color-tokens($theme));
2219
}
2320
}
2421

2522
@mixin typography($theme) {
26-
@include _output-tokens {
23+
@include sass-utils.current-selector-or-root() {
2724
@include token-utils.create-token-values(tokens-mat-table.$prefix,
2825
tokens-mat-table.get-typography-tokens($theme));
2926
}
3027
}
3128

3229
@mixin density($theme) {
33-
@include _output-tokens {
30+
@include sass-utils.current-selector-or-root() {
3431
@include token-utils.create-token-values(tokens-mat-table.$prefix,
3532
tokens-mat-table.get-density-tokens($theme));
3633
}
3734
}
3835

3936
@mixin theme($theme) {
4037
@include theming.private-check-duplicate-theme-styles($theme, 'mat-table') {
38+
@include base($theme);
4139
@if inspection.theme-has($theme, color) {
4240
@include color($theme);
4341
}

src/material/table/table.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
@include table-flex-styles.private-table-flex-styles();
3333

3434
.mat-mdc-table {
35-
@include token-utils.create-token-values(
36-
tokens-mat-table.$prefix, tokens-mat-table.get-unthemable-tokens());
37-
3835
// MDC Table applies `table-layout: fixed`, but this is a backwards incompatible
3936
// change since the table did not previously apply it.
4037
// TODO: Add a mixin to MDC to set the layout instead of including this override,

0 commit comments

Comments
 (0)