/
_chip.scss
313 lines (305 loc) · 10.3 KB
/
_chip.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
@use 'sass:map';
@use '../../token-utils';
@use '../../../mdc-helpers/mdc-helpers';
@use '../../../style/sass-utils';
@use '../../../theming/theming';
@use '../../../typography/typography-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mdc, chip);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
// The shape & radius of the chip.
container-shape:
(
family: 'rounded',
radius: (
16px 16px 16px 16px,
)
),
// The shape & radius of the avatar.
with-avatar-avatar-shape:
(
family: 'rounded',
radius: (
14px 14px 14px 14px,
)
),
// The width & height of the chip avatar.
with-avatar-avatar-size: 28px,
// The width & height of the chip icon.
with-icon-icon-size: 18px,
// Not used by MDC.
disabled-label-text-opacity: null,
// Not used by MDC.
disabled-outline-opacity: null,
// Not used by MDC.
elevated-disabled-container-opacity: null,
// Not used by MDC.
flat-disabled-outline-opacity: null,
// Not used by MDC.
flat-disabled-unselected-outline-opacity: null,
// Our chips do not have a border.
flat-outline-width: null,
// Our chips do not have a border.
flat-selected-outline-width: null,
// Our chips do not have a border.
flat-unselected-outline-width: null,
// Our chips do not have a border.
outline-width: null,
// Not used by MDC.
with-avatar-disabled-avatar-opacity: null,
// Not used by MDC.
with-icon-disabled-icon-opacity: null,
// Not used by MDC.
with-leading-icon-disabled-leading-icon-opacity: null,
// Not used by MDC.
with-leading-icon-leading-icon-size: null,
// Not used by MDC.
with-trailing-icon-disabled-trailing-icon-opacity: null,
// Not used by MDC.
with-trailing-icon-trailing-icon-size: null,
// Elevated chips not implemented.
container-elevation: null,
// Elevated chips not implemented.
container-shadow-color: null,
// Our chips do not have a border.
disabled-outline-color: null,
// Elevated chips not implemented.
elevated-container-elevation: null,
// Elevated chips not implemented.
elevated-container-shadow-color: null,
// Elevated chips not implemented.
container-surface-tint-layer-color: null,
// Elevated chips not implemented.
elevated-disabled-container-elevation: null,
// Elevated chips not implemented.
elevated-focus-container-elevation: null,
// Elevated chips not implemented.
elevated-hover-container-elevation: null,
// Elevated chips not implemented.
elevated-pressed-container-elevation: null,
// Elevated chips not implemented.
elevated-selected-container-color: null,
// Elevated chips not implemented.
elevated-selected-container-elevation: null,
// Elevated chips not implemented.
elevated-unselected-container-color: null,
// Elevated chips not implemented.
flat-container-elevation: null,
// Our chips do not have a border.
flat-disabled-outline-color: null,
// Not providing this uses
flat-disabled-selected-container-color: null,
// Not used by MDC.
flat-disabled-selected-container-opacity: null,
// Unused.
flat-disabled-selected-outline-color: null,
// Unused.
flat-disabled-selected-outline-opacity: null,
// Unused.
flat-disabled-unselected-outline-color: null,
// Unused.
flat-focus-outline-color: null,
// Unused.
flat-outline-color: null,
// Unused.
flat-selected-container-color: null,
// Unused.
flat-selected-focus-container-elevation: null,
// Unused.
flat-selected-hover-container-elevation: null,
// Unused.
flat-selected-outline-color: null,
// Unused.
flat-selected-pressed-container-elevation: null,
// Unused.
flat-unselected-focus-container-elevation: null,
// Unused.
flat-unselected-focus-outline-color: null,
// Unused.
flat-unselected-hover-container-elevation: null,
// Unused.
flat-unselected-outline-color: null,
// Unused.
flat-unselected-pressed-container-elevation: null,
// Unused.
focus-label-text-color: null,
// Unused.
focus-outline-color: null,
// Unused.
focus-state-layer-color: null,
// Unused.
focus-state-layer-opacity: null,
// Unused.
hover-label-text-color: null,
// Unused.
hover-state-layer-color: null,
// Unused.
hover-state-layer-opacity: null,
// Unused.
outline-color: null,
// Unused.
pressed-label-text-color: null,
// Unused.
pressed-state-layer-color: null,
// Unused.
pressed-state-layer-opacity: null,
// Unused.
selected-focus-label-text-color: null,
// Unused.
selected-focus-state-layer-color: null,
// Unused.
selected-focus-state-layer-opacity: null,
// Unused.
selected-hover-label-text-color: null,
// Unused.
selected-hover-state-layer-color: null,
// Unused.
selected-hover-state-layer-opacity: null,
// Unused.
selected-label-text-color: null,
// Unused.
selected-pressed-label-text-color: null,
// Unused.
selected-pressed-state-layer-color: null,
// Unused.
selected-pressed-state-layer-opacity: null,
// Unused.
unselected-focus-label-text-color: null,
// Unused.
unselected-focus-state-layer-color: null,
// Unused.
unselected-focus-state-layer-opacity: null,
// Unused.
unselected-hover-label-text-color: null,
// Unused.
unselected-hover-state-layer-color: null,
// Unused.
unselected-hover-state-layer-opacity: null,
// Unused.
unselected-label-text-color: null,
// Unused.
unselected-pressed-label-text-color: null,
// Unused.
unselected-pressed-state-layer-color: null,
// Unused.
unselected-pressed-state-layer-opacity: null,
// Unused.
with-icon-focus-icon-color: null,
// Unused.
with-icon-hover-icon-color: null,
// Unused.
with-icon-pressed-icon-color: null,
// Unused.
with-icon-selected-focus-icon-color: null,
// Unused.
with-icon-selected-hover-icon-color: null,
// Unused.
with-icon-selected-pressed-icon-color: null,
// Unused.
with-icon-unselected-focus-icon-color: null,
// Unused.
with-icon-unselected-hover-icon-color: null,
// Unused.
with-icon-unselected-icon-color: null,
// Unused.
with-icon-unselected-pressed-icon-color: null,
// Unused.
with-leading-icon-disabled-leading-icon-color: null,
// Unused.
with-leading-icon-focus-leading-icon-color: null,
// Unused.
with-leading-icon-hover-leading-icon-color: null,
// Unused.
with-leading-icon-leading-icon-color: null,
// Unused.
with-leading-icon-pressed-leading-icon-color: null,
// Unused.
with-trailing-icon-focus-trailing-icon-color: null,
// Unused.
with-trailing-icon-hover-trailing-icon-color: null,
// Unused.
with-trailing-icon-pressed-trailing-icon-color: null
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($config) {
$palette: map.get($config, primary);
$background: theming.get-color-from-palette($palette);
$foreground: theming.get-color-from-palette($palette, default-contrast);
@return (
// The text color of a disabled chip.
disabled-label-text-color: $foreground,
// The background-color of the chip.
elevated-container-color: $background,
// The background-color of a disabled chip.
elevated-disabled-container-color: $background,
// The chip text color.
label-text-color: $foreground,
// The icon color of a chip.
with-icon-icon-color: $foreground,
// The color of the icon of a disabled chip.
with-icon-disabled-icon-color: $foreground,
// The color of the icon of a selected chip.
with-icon-selected-icon-color: $foreground,
// The color of the icon at the end of a disabled chip.
with-trailing-icon-disabled-trailing-icon-color: $foreground,
// The color of the icon at the end of the chip.
with-trailing-icon-trailing-icon-color: $foreground
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($config) {
// TODO(wagnermaciel): The earlier implementation of the chip used MDC's APIs to create the
// typography tokens. As a result, we unintentionally allowed `null` typography configs to be
// passed in. Since there a lot of apps that now depend on this pattern, we need this temporary
// fallback.
@if ($config == null) {
$config: mdc-helpers.private-fallback-typography-from-mdc();
}
@return (
// The font family of the chip text.
label-text-font: typography-utils.font-family($config, body-2) or
typography-utils.font-family($config),
// The line height of the chip text.
label-text-line-height: typography-utils.line-height($config, body-2),
// The font size of the chip text.
label-text-size: typography-utils.font-size($config, body-2),
// The letter spacing of the chip label.
label-text-tracking: typography-utils.letter-spacing($config, body-2),
// The font weight of the chip text.
label-text-weight: typography-utils.font-weight($config, body-2)
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($config) {
$scale: theming.clamp-density($config, -2);
@return (
// The height of the chip.
container-height:
map.get(
(
0: 32px,
-1: 28px,
-2: 24px,
),
$scale
)
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-utils.$placeholder-color-config),
get-typography-tokens(token-utils.$placeholder-typography-config),
get-density-tokens(token-utils.$placeholder-density-config)
);
}