11@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/typography/typography' as mdc-typography ;
26@use ' ../core/mdc-helpers/mdc-helpers' ;
7+ @use ' ../core/tokens/token-utils' ;
8+ @use ' ../core/tokens/m2/mat/table' as tokens-mat-table ;
39@use ' ./table-flex-styles' ;
410
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-
1111.mat-mdc-table-sticky {
1212 // Note that the table can either set this class or an inline style to make something sticky.
1313 // We set the style as `!important` so that we get an identical specificity in both cases
1414 // and to avoid cases where user styles have a higher specificity.
1515 position : sticky !important ;
1616}
1717
18+ @mixin _cell-border {
19+ @include token-utils .create-token-slot (border-bottom-color , row- item- outline- color, true);
20+ @include token-utils .create-token-slot (border-bottom-width , row- item- outline- width, true);
21+ border-bottom-style : solid ;
22+ }
23+
24+ @include mdc-data-table .static-styles ($query : mdc-helpers .$mdc-base-styles-query );
25+ @include mdc-data-table-cell .static-styles ($query : mdc-helpers .$mdc-base-styles-query );
26+ @include mdc-data-table-header-cell .static-styles ($query : mdc-helpers .$mdc-base-styles-query );
27+ @include mdc-data-table-theme .cell-padding (
28+ $leading-padding : mdc-data-table-theme .$cell-leading-padding ,
29+ $trailing-padding : mdc-data-table-theme .$cell-trailing-padding ,
30+ $query : mdc-helpers .$mdc-base-styles-query
31+ );
32+ @include table-flex-styles .private-table-flex-styles ();
33+
1834.mat-mdc-table {
35+ @include token-utils .create-token-values (
36+ tokens-mat-table .$prefix , tokens-mat-table .get-unthemable-tokens ());
37+
1938 // MDC Table applies `table-layout: fixed`, but this is a backwards incompatible
2039 // change since the table did not previously apply it.
2140 // TODO: Add a mixin to MDC to set the layout instead of including this override,
2544 // The MDC table does not allow text to wrap within the cell. This allows for text to
2645 // wrap when the cell reaches its maximum width.
2746 white-space : normal ;
47+
48+ @include token-utils .use-tokens (tokens-mat-table .$prefix , tokens-mat-table .get-token-slots ()) {
49+ @include token-utils .create-token-slot (background-color , background-color );
50+ }
51+ }
52+
53+ @include mdc-helpers .disable-mdc-fallback-declarations {
54+ @include token-utils .use-tokens (tokens-mat-table .$prefix , tokens-mat-table .get-token-slots ()) {
55+ // TODO(crisbeto): these tokens have default values in order to make the initial token
56+ // work easier to land in g3. Eventually we should remove them.
57+ .mat-mdc-header-row {
58+ @include mdc-typography .smooth-font ();
59+ @include token-utils .create-token-slot (height , header- container- height, 56px );
60+ @include token-utils .create-token-slot (color , header- headline- color, true);
61+ @include token-utils .create-token-slot (font-family , header- headline- font, true);
62+ @include token-utils .create-token-slot (line-height , header- headline- line- height);
63+ @include token-utils .create-token-slot (font-size , header- headline- size, 14px );
64+ @include token-utils .create-token-slot (font-weight , header- headline- weight, 500 );
65+ }
66+
67+ .mat-mdc-row {
68+ @include token-utils .create-token-slot (height , row- item- container- height, 52px );
69+ @include token-utils .create-token-slot (color , row- item- label- text- color, true);
70+ }
71+
72+ // Note that while it's redundant to apply the typography both to the row
73+ // and the content element since the cell inherit from both of them,
74+ // applying it only to one results in sub-pixel differences in the
75+ // letter spacing which leads to a lot of internal screenshot diffs.
76+ .mat-mdc-row ,
77+ .mdc-data-table__content {
78+ @include mdc-typography .smooth-font ();
79+ @include token-utils .create-token-slot (font-family , row- item- label- text- font, true);
80+ @include token-utils .create-token-slot (line-height , row- item- label- text- line- height);
81+ @include token-utils .create-token-slot (font-size , row- item- label- text- size, 14px );
82+ @include token-utils .create-token-slot (font-weight , row- item- label- text- weight);
83+ }
84+
85+ .mat-mdc-footer-row {
86+ @include mdc-typography .smooth-font ();
87+ @include token-utils .create-token-slot (height , footer- container- height, 52px );
88+ @include token-utils .create-token-slot (color , row- item- label- text- color, true);
89+ @include token-utils .create-token-slot (font-family , footer- supporting- text- font, true);
90+ @include token-utils .create-token-slot (line-height , footer- supporting- text- line- height);
91+ @include token-utils .create-token-slot (font-size , footer- supporting- text- size, 14px );
92+ @include token-utils .create-token-slot (font-weight , footer- supporting- text- weight);
93+ @include token-utils .create-token-slot (letter-spacing , footer- supporting- text- tracking);
94+ }
95+
96+ .mat-mdc-header-cell {
97+ @include _cell-border ;
98+ @include token-utils .create-token-slot (letter-spacing , header- headline- tracking);
99+ font-weight : inherit ;
100+ line-height : inherit ;
101+ }
102+
103+ .mat-mdc-cell {
104+ @include _cell-border ;
105+ @include token-utils .create-token-slot (letter-spacing , row- item- label- text- tracking);
106+ line-height : inherit ;
107+
108+ .mdc-data-table__row :last-child & {
109+ border-bottom : none ;
110+ }
111+ }
112+
113+ .mat-mdc-footer-cell {
114+ @include token-utils .create-token-slot (letter-spacing , row- item- label- text- tracking);
115+ }
116+ }
28117}
29118
30119// MDC table rows are styled with a top border, whereas our legacy flex table styles rows with
@@ -43,13 +132,6 @@ mat-row.mat-mdc-row, mat-header-row.mat-mdc-header-row, mat-footer-row.mat-mdc-f
43132 background : inherit ;
44133}
45134
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-
53135// Flex rows should not set a definite height, but instead stretch to the height of their
54136// children. Otherwise, the cells grow larger than the row and the layout breaks.
55137.mat-mdc-table mat-header-row .mat-mdc-header-row ,
0 commit comments