1
1
@use ' @material/data-table/data-table' as mdc-data-table ;
2
+ @use ' @material/data-table/data-table-cell' as mdc-data-table-cell ;
3
+ @use ' @material/data-table/data-table-header-cell' as mdc-data-table-header-cell ;
4
+ @use ' @material/data-table' as mdc-data-table-theme ;
5
+ @use ' @material/theme/custom-properties' as mdc-custom-properties ;
2
6
@use ' ../core/mdc-helpers/mdc-helpers' ;
7
+ @use ' ../core/tokens/token-utils' ;
8
+ @use ' ../core/tokens/m2/mat/table' as tokens-mat-table ;
3
9
@use ' ./table-flex-styles' ;
4
10
5
- @include mdc-helpers .disable-mdc-fallback-declarations {
6
- @include mdc-data-table .table-styles (
7
- $query : mdc-helpers .$mdc-base-styles-without-animation-query );
8
- @include table-flex-styles .private-table-flex-styles ();
9
- }
10
-
11
11
.mat-mdc-table-sticky {
12
12
// Note that the table can either set this class or an inline style to make something sticky.
13
13
// We set the style as `!important` so that we get an identical specificity in both cases
14
14
// and to avoid cases where user styles have a higher specificity.
15
15
position : sticky !important ;
16
16
}
17
17
18
- .mat-mdc-table {
19
- // MDC Table applies `table-layout: fixed`, but this is a backwards incompatible
20
- // change since the table did not previously apply it.
21
- // TODO: Add a mixin to MDC to set the layout instead of including this override,
22
- // see this issue: https://github.com/material-components/material-components-web/issues/6412
23
- table-layout : auto ;
18
+ @mixin _cell-border {
19
+ @include token-utils .create-token-slot (border-bottom-color , row- item- outline- color);
20
+ @include token-utils .create-token-slot (border-bottom-width , row- item- outline- width);
21
+ border-bottom-style : solid ;
22
+
23
+ .mdc-data-table__row :last-child & {
24
+ border-bottom : none ;
25
+ }
26
+ }
27
+
28
+ @include mdc-custom-properties .configure ($emit-fallback-values : false, $emit-fallback-vars : false) {
29
+ @include mdc-data-table .static-styles ($query : mdc-helpers .$mdc-base-styles-query );
30
+ @include mdc-data-table-cell .static-styles ($query : mdc-helpers .$mdc-base-styles-query );
31
+ @include mdc-data-table-header-cell .static-styles ($query : mdc-helpers .$mdc-base-styles-query );
32
+ @include mdc-data-table-theme .cell-padding (
33
+ $leading-padding : mdc-data-table-theme .$cell-leading-padding ,
34
+ $trailing-padding : mdc-data-table-theme .$cell-trailing-padding ,
35
+ $query : mdc-helpers .$mdc-base-styles-query
36
+ );
37
+ @include table-flex-styles .private-table-flex-styles ();
38
+
39
+ .mat-mdc-table {
40
+ @include token-utils .create-token-values (
41
+ tokens-mat-table .$prefix , tokens-mat-table .get-unthemable-tokens ());
42
+
43
+ // MDC Table applies `table-layout: fixed`, but this is a backwards incompatible
44
+ // change since the table did not previously apply it.
45
+ // TODO: Add a mixin to MDC to set the layout instead of including this override,
46
+ // see this issue: https://github.com/material-components/material-components-web/issues/6412
47
+ table-layout : auto ;
24
48
25
- // The MDC table does not allow text to wrap within the cell. This allows for text to
26
- // wrap when the cell reaches its maximum width.
27
- white-space : normal ;
49
+ // The MDC table does not allow text to wrap within the cell. This allows for text to
50
+ // wrap when the cell reaches its maximum width.
51
+ white-space : normal ;
52
+
53
+ @include token-utils .use-tokens (tokens-mat-table .$prefix , tokens-mat-table .get-token-slots ()) {
54
+ @include token-utils .create-token-slot (background-color , background-color );
55
+ }
56
+ }
57
+
58
+ @include token-utils .use-tokens (tokens-mat-table .$prefix , tokens-mat-table .get-token-slots ()) {
59
+ .mat-mdc-header-row {
60
+ @include token-utils .create-token-slot (height , header- container- height);
61
+ }
62
+
63
+ .mat-mdc-row {
64
+ @include token-utils .create-token-slot (height , row- item- container- height);
65
+ }
66
+
67
+ .mat-mdc-footer-row {
68
+ @include token-utils .create-token-slot (height , footer- container- height);
69
+ }
70
+
71
+ .mat-mdc-header-cell {
72
+ @include _cell-border ;
73
+ @include token-utils .create-token-slot (color , header- headline- color);
74
+ @include token-utils .create-token-slot (font-family , header- headline- font);
75
+ @include token-utils .create-token-slot (line-height , header- headline- line- height);
76
+ @include token-utils .create-token-slot (font-size , header- headline- size);
77
+ @include token-utils .create-token-slot (letter-spacing , header- headline- tracking);
78
+ @include token-utils .create-token-slot (font-weight , header- headline- weight);
79
+ }
80
+
81
+ .mat-mdc-cell {
82
+ @include _cell-border ;
83
+ @include token-utils .create-token-slot (color , row- item- label- text- color);
84
+ @include token-utils .create-token-slot (font-family , row- item- label- text- font);
85
+ @include token-utils .create-token-slot (line-height , row- item- label- text- line- height);
86
+ @include token-utils .create-token-slot (font-size , row- item- label- text- size);
87
+ @include token-utils .create-token-slot (letter-spacing , row- item- label- text- tracking);
88
+ @include token-utils .create-token-slot (font-weight , row- item- label- text- weight);
89
+ }
90
+
91
+ .mat-mdc-footer-cell {
92
+ @include token-utils .create-token-slot (color , row- item- label- text- color);
93
+ @include token-utils .create-token-slot (font-family , footer- supporting- text- font);
94
+ @include token-utils .create-token-slot (line-height , footer- supporting- text- line- height);
95
+ @include token-utils .create-token-slot (font-size , footer- supporting- text- size);
96
+ @include token-utils .create-token-slot (letter-spacing , footer- supporting- text- tracking);
97
+ @include token-utils .create-token-slot (font-weight , footer- supporting- text- weight);
98
+ }
99
+ }
28
100
}
29
101
30
102
// MDC table rows are styled with a top border, whereas our legacy flex table styles rows with
@@ -43,19 +115,14 @@ mat-row.mat-mdc-row, mat-header-row.mat-mdc-header-row, mat-footer-row.mat-mdc-f
43
115
background : inherit ;
44
116
}
45
117
46
- // Disable hover styling while MDC uses an opacity for its color.
47
- // When the hover style is used with sticky cells, the opacity shows the cells overlapping.
48
- .mat-mdc-table .mat-mdc-row :hover ,
49
- .mat-mdc-table .mat-mdc-footer-row :hover {
50
- background-color : inherit ;
51
- }
52
-
53
118
// Flex rows should not set a definite height, but instead stretch to the height of their
54
119
// children. Otherwise, the cells grow larger than the row and the layout breaks.
55
- .mat-mdc-table mat-header-row .mat-mdc-header-row ,
56
- .mat-mdc-table mat-row .mat-mdc-row ,
57
- .mat-mdc-table mat-footer-row .mat-mdc-footer-cell {
58
- height : unset ;
120
+ .mat-mdc-flex-table {
121
+ @include token-utils .create-token-values (tokens-mat-table .$prefix , (
122
+ header- container- height: unset ,
123
+ footer- container- height: unset ,
124
+ row- item- container- height: unset ,
125
+ ));
59
126
}
60
127
61
128
// Flex cells should stretch to the height of their parent. This was okay for the legacy
0 commit comments