Skip to content

Commit 1f63014

Browse files
authored
Revert "refactor(material/card): switch to new theming API" (#25464)
This reverts commit 3738a24.
1 parent 938802f commit 1f63014

File tree

3 files changed

+18
-45
lines changed

3 files changed

+18
-45
lines changed

src/material/card/_card-theme.scss

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
@use '../core/theming/theming';
22
@use '../core/mdc-helpers/mdc-helpers';
33
@use '../core/typography/typography';
4-
@use '@material/card/elevated-card-theme' as mdc-elevated-card-theme;
5-
@use '@material/card/outlined-card-theme' as mdc-outlined-card-theme;
4+
@use '@material/card' as mdc-card;
65
@use '@material/typography' as mdc-typography;
76
@use '@material/theme/theme-color' as mdc-theme-color;
87
@use 'sass:color';
@@ -11,31 +10,36 @@
1110
@mixin color($config-or-theme) {
1211
$config: theming.get-color-config($config-or-theme);
1312
$foreground: map.get($config, foreground);
13+
$is-dark-theme: map.get($config, is-dark);
14+
15+
$orig-mdc-card-action-icon-color: mdc-card.$action-icon-color;
16+
$orig-mdc-card-outline-color: mdc-card.$outline-color;
1417

1518
@include mdc-helpers.using-mdc-theme($config) {
16-
.mat-mdc-card {
17-
@include mdc-elevated-card-theme.theme((
18-
container-color: mdc-theme-color.prop-value(surface),
19-
));
19+
mdc-card.$action-icon-color: rgba(mdc-theme-color.prop-value(on-surface),
20+
mdc-theme-color.text-emphasis(medium));
21+
mdc-card.$outline-color: color.mix(mdc-theme-color.prop-value(on-surface),
22+
mdc-theme-color.prop-value(surface), 12%);
2023

21-
@include mdc-outlined-card-theme.theme((
22-
outline-color: color.mix(mdc-theme-color.prop-value(on-surface),
23-
mdc-theme-color.prop-value(surface), 12%)
24-
));
25-
}
24+
@include mdc-card.without-ripple($query: mdc-helpers.$mdc-theme-styles-query);
2625

2726
// Card subtitles are an Angular Material construct (not MDC), so we explicitly set their
2827
// color to secondary text here.
2928
.mat-mdc-card-subtitle {
3029
color: theming.get-color-from-palette($foreground, secondary-text);
3130
}
3231
}
32+
33+
mdc-card.$action-icon-color: $orig-mdc-card-action-icon-color;
34+
mdc-card.$outline-color: $orig-mdc-card-outline-color;
3335
}
3436

3537
@mixin typography($config-or-theme) {
3638
$config: typography.private-typography-to-2018-config(
3739
theming.get-typography-config($config-or-theme));
3840
@include mdc-helpers.using-mdc-typography($config) {
41+
@include mdc-card.without-ripple($query: mdc-helpers.$mdc-typography-styles-query);
42+
3943
// Card subtitles and titles are an Angular Material construct (not MDC), so we explicitly
4044
// set their typographic styles here.
4145
.mat-mdc-card-title {

src/material/card/card.scss

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
@use '@material/card' as mdc-card;
2-
@use '@material/card/variables' as mdc-card-variables;
3-
@use '@material/card/elevated-card-theme' as mdc-elevated-card-theme;
4-
@use '@material/card/outlined-card-theme' as mdc-outlined-card-theme;
51
@use '../core/mdc-helpers/mdc-helpers';
6-
@use '../core/style/elevation';
2+
@use '@material/card' as mdc-card;
73

84
// TODO(jelbourn): move header and title-group styles to their own files.
95

@@ -15,33 +11,7 @@ $mat-card-default-padding: 16px !default;
1511

1612
@include mdc-helpers.disable-mdc-fallback-declarations {
1713
// Include all MDC card styles except for color and typography.
18-
@include mdc-card.static-styles($query: mdc-helpers.$mdc-base-styles-query);
19-
}
20-
21-
.mat-mdc-card {
22-
position: relative;
23-
24-
@include mdc-helpers.disable-mdc-fallback-declarations {
25-
// MDC's theme has `container-elevation` and `container-shadow-color` tokens, but we can't
26-
// use them because they output under a `.mdc-card` selector whereas the rest of the theme
27-
// isn't under any selector. Even if the mixin is pulled out of the selector, it throws a
28-
// different error.
29-
@include elevation.elevation(1);
30-
@include mdc-elevated-card-theme.theme-styles((
31-
container-color: transparent,
32-
container-shape: mdc-card-variables.$shape-radius,
33-
));
34-
}
35-
}
36-
37-
.mat-mdc-card-outlined {
38-
@include mdc-helpers.disable-mdc-fallback-declarations {
39-
@include elevation.elevation(0);
40-
@include mdc-outlined-card-theme.theme-styles((
41-
outline-color: transparent,
42-
outline-width: 1px,
43-
));
44-
}
14+
@include mdc-card.without-ripple($query: mdc-helpers.$mdc-base-styles-query);
4515
}
4616

4717
// Title text and subtitles text within a card. MDC doesn't have pre-made title sections for cards.

src/material/card/card.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ export const MAT_CARD_CONFIG = new InjectionToken<MatCardConfig>('MAT_CARD_CONFI
4040
styleUrls: ['card.css'],
4141
host: {
4242
'class': 'mat-mdc-card mdc-card',
43-
'[class.mat-mdc-card-outlined]': 'appearance === "outlined"',
44-
'[class.mdc-card--outlined]': 'appearance === "outlined"',
43+
'[class.mdc-card--outlined]': 'appearance == "outlined"',
4544
},
4645
exportAs: 'matCard',
4746
encapsulation: ViewEncapsulation.None,

0 commit comments

Comments
 (0)