forked from angular/components
/
_card-theme.scss
86 lines (76 loc) · 2.86 KB
/
_card-theme.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@use '../core/theming/theming';
@use '../core/mdc-helpers/mdc-helpers';
@use '../core/style/private';
@use '../core/typography/typography';
@use '@material/card/elevated-card-theme' as mdc-elevated-card-theme;
@use '@material/card/outlined-card-theme' as mdc-outlined-card-theme;
@use '@material/typography' as mdc-typography;
@use '@material/theme/theme-color' as mdc-theme-color;
@use 'sass:color';
@use 'sass:map';
@use 'sass:meta';
@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
$foreground: map.get($config, foreground);
@include mdc-helpers.using-mdc-theme($config) {
$on-surface: mdc-theme-color.prop-value(on-surface);
$surface: mdc-theme-color.prop-value(surface);
.mat-mdc-card {
// MDC's theme has `container-elevation` and `container-shadow-color` tokens, but we can't
// use them because they output under a `.mdc-card` selector whereas the rest of the theme
// isn't under any selector. Even if the mixin is pulled out of the selector, it throws a
// different error.
@include private.private-theme-elevation(1, $config);
@include mdc-elevated-card-theme.theme((
container-color: $surface,
));
}
.mat-mdc-card-outlined {
@include private.private-theme-elevation(0, $config);
@include mdc-outlined-card-theme.theme((
outline-color: if(
meta.type-of($on-surface) == color and meta.type-of($surface) == color,
color.mix($on-surface, $surface, 12%),
$on-surface
)
));
}
// Card subtitles are an Angular Material construct (not MDC), so we explicitly set their
// color to secondary text here.
.mat-mdc-card-subtitle {
color: theming.get-color-from-palette($foreground, secondary-text);
}
}
}
@mixin typography($config-or-theme) {
$config: typography.private-typography-to-2018-config(
theming.get-typography-config($config-or-theme));
@include mdc-helpers.using-mdc-typography($config) {
// Card subtitles and titles are an Angular Material construct (not MDC), so we explicitly
// set their typographic styles here.
.mat-mdc-card-title {
@include mdc-typography.typography(headline6);
}
.mat-mdc-card-subtitle {
@include mdc-typography.typography(subtitle2);
}
}
}
@mixin density($config-or-theme) {}
@mixin theme($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-card') {
$color: theming.get-color-config($theme);
$density: theming.get-density-config($theme);
$typography: theming.get-typography-config($theme);
@if $color != null {
@include color($color);
}
@if $density != null {
@include density($density);
}
@if $typography != null {
@include typography($typography);
}
}
}