-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
Copy path_card-theme.scss
171 lines (163 loc) · 5.5 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@use 'sass:map';
@use '../core/style/sass-utils';
@use '../core/theming/theming';
@use '../core/theming/inspection';
@use '../core/theming/validation';
@use '../core/typography/typography';
@use '../core/tokens/token-utils';
@use '../core/tokens/m2/mat/card' as tokens-mat-card;
@use '../core/tokens/m2/mat/elevated-card' as tokens-mat-elevated-card;
@use '../core/tokens/m2/mat/outlined-card' as tokens-mat-outlined-card;
@use '../core/tokens/m2/mat/filled-card' as tokens-mat-filled-card;
@mixin base($theme) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mat-elevated-card.$prefix,
tokens-mat-elevated-card.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mat-outlined-card.$prefix,
tokens-mat-outlined-card.get-unthemable-tokens()
);
@include token-utils.create-token-values-mixed(
tokens-mat-card.$prefix,
tokens-mat-card.get-unthemable-tokens()
);
}
}
}
@mixin color($theme) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mat-elevated-card.$prefix,
tokens-mat-elevated-card.get-color-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-outlined-card.$prefix,
tokens-mat-outlined-card.get-color-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-card.$prefix,
tokens-mat-card.get-color-tokens($theme)
);
}
}
}
@mixin typography($theme) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mat-elevated-card.$prefix,
tokens-mat-elevated-card.get-typography-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-outlined-card.$prefix,
tokens-mat-outlined-card.get-typography-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-card.$prefix,
tokens-mat-card.get-typography-tokens($theme)
);
}
}
}
@mixin density($theme) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
} @else {
@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values-mixed(
tokens-mat-elevated-card.$prefix,
tokens-mat-elevated-card.get-density-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-outlined-card.$prefix,
tokens-mat-outlined-card.get-density-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-filled-card.$prefix,
tokens-mat-filled-card.get-density-tokens($theme)
);
@include token-utils.create-token-values-mixed(
tokens-mat-card.$prefix,
tokens-mat-card.get-density-tokens($theme)
);
}
}
}
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-card.$prefix,
tokens: tokens-mat-card.get-token-slots(),
),
(
namespace: tokens-mat-elevated-card.$prefix,
tokens: tokens-mat-elevated-card.get-token-slots(),
prefix: 'elevated-',
),
(
namespace: tokens-mat-outlined-card.$prefix,
tokens: tokens-mat-outlined-card.get-token-slots(),
prefix: 'outlined-',
),
(
namespace: tokens-mat-filled-card.$prefix,
tokens: tokens-mat-filled-card.get-token-slots(),
prefix: 'filled-',
)
);
}
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}
@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-card') {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme));
} @else {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
@if inspection.theme-has($theme, density) {
@include density($theme);
}
@if inspection.theme-has($theme, typography) {
@include typography($theme);
}
}
}
}
@mixin _theme-from-tokens($tokens) {
@include validation.selector-defined(
'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector'
);
@if ($tokens != ()) {
@include token-utils.create-token-values(
tokens-mat-elevated-card.$prefix,
map.get($tokens, tokens-mat-elevated-card.$prefix)
);
@include token-utils.create-token-values(
tokens-mat-outlined-card.$prefix,
map.get($tokens, tokens-mat-outlined-card.$prefix)
);
@include token-utils.create-token-values(
tokens-mdc-filled-card.$prefix,
map.get($tokens, tokens-mdc-filled-card.$prefix)
);
@include token-utils.create-token-values(
tokens-mat-card.$prefix,
map.get($tokens, tokens-mat-card.$prefix)
);
}
}