Skip to content

Commit 447f2e6

Browse files
authored
fix(material-experimental/mdc-table): not supporting multiple themes (#18931)
The theming for the MDC table wasn't set up completely which meant that it only works with one theme.
1 parent 68eaaf6 commit 447f2e6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/material-experimental/mdc-table/_table-theme.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
11
@import '../mdc-helpers/mdc-helpers';
2+
@import '@material/theme/functions.import';
3+
@import '@material/data-table/variables.import';
24
@import '@material/data-table/mixins.import';
35

46
@mixin mat-mdc-table-theme($theme) {
7+
// Save original values of MDC global variables. We need to save these so we can restore the
8+
// variables to their original values and prevent unintended side effects from using this mixin.
9+
$orig-mdc-data-table-selected-row-fill-color: $mdc-data-table-selected-row-fill-color;
10+
$orig-mdc-data-table-divider-color: $mdc-data-table-divider-color;
11+
$orig-mdc-data-table-table-divider-color: $mdc-data-table-table-divider-color;
12+
$orig-mdc-data-table-row-hover-fill-color: $mdc-data-table-row-hover-fill-color;
13+
$orig-mdc-data-table-header-row-text-color: $mdc-data-table-header-row-text-color;
14+
$orig-mdc-data-table-row-text-color: $mdc-data-table-row-text-color;
15+
$orig-mdc-data-table-sort-icon-color: $mdc-data-table-sort-icon-color;
16+
$orig-mdc-data-table-sort-icon-active-color: $mdc-data-table-sort-icon-active-color;
17+
$orig-mdc-data-table-stroke-color: $mdc-data-table-stroke-color;
18+
519
@include mat-using-mdc-theme($theme) {
20+
$mdc-data-table-selected-row-fill-color: rgba(mdc-theme-prop-value(primary), 0.04) !global;
21+
$mdc-data-table-divider-color: rgba(mdc-theme-prop-value(on-surface), 0.12) !global;
22+
$mdc-data-table-row-hover-fill-color: rgba(mdc-theme-prop-value(on-surface), 0.04) !global;
23+
$mdc-data-table-header-row-text-color: rgba(mdc-theme-prop-value(on-surface), 0.87) !global;
24+
$mdc-data-table-row-text-color: rgba(mdc-theme-prop-value(on-surface), 0.87) !global;
25+
$mdc-data-table-sort-icon-color: rgba(mdc-theme-prop-value(on-surface), 0.6) !global;
26+
$mdc-data-table-sort-icon-active-color: rgba(mdc-theme-prop-value(on-surface), 0.87) !global;
27+
$mdc-data-table-stroke-color: rgba(mdc-theme-prop-value(on-surface), 0.12) !global;
28+
629
@include mdc-data-table-core-styles($query: $mat-theme-styles-query);
730
}
31+
32+
// Restore original values of MDC global variables.
33+
$mdc-data-table-selected-row-fill-color: $orig-mdc-data-table-selected-row-fill-color !global;
34+
$mdc-data-table-divider-color: $orig-mdc-data-table-divider-color !global;
35+
$mdc-data-table-table-divider-color: $orig-mdc-data-table-table-divider-color !global;
36+
$mdc-data-table-row-hover-fill-color: $orig-mdc-data-table-row-hover-fill-color !global;
37+
$mdc-data-table-header-row-text-color: $orig-mdc-data-table-header-row-text-color !global;
38+
$mdc-data-table-row-text-color: $orig-mdc-data-table-row-text-color !global;
39+
$mdc-data-table-sort-icon-color: $orig-mdc-data-table-sort-icon-color !global;
40+
$mdc-data-table-sort-icon-active-color: $orig-mdc-data-table-sort-icon-active-color !global;
41+
$mdc-data-table-stroke-color: $orig-mdc-data-table-stroke-color !global;
842
}
943

1044
@mixin mat-mdc-table-typography($config) {

0 commit comments

Comments
 (0)