Skip to content

Commit 097dcf1

Browse files
committed
fix(material-experimental/mdc-table): not supporting multiple themes
The theming for the MDC table wasn't set up completely which meant that it only works with one theme.
1 parent 8a71288 commit 097dcf1

File tree

3 files changed

+561
-514
lines changed

3 files changed

+561
-514
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@types/youtube": "^0.0.38",
5959
"@webcomponents/custom-elements": "^1.1.0",
6060
"core-js": "^2.6.9",
61-
"material-components-web": "6.0.0-canary.d5808057f.0",
61+
"material-components-web": "6.0.0-canary.e33c49e.0",
6262
"rxjs": "^6.5.3",
6363
"systemjs": "0.19.43",
6464
"tslib": "^1.10.0",

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)