1use super::{ColorTheme, CommonTheme};
4
5fn emit_orb(css_vars: &mut String, orb: &str, value: &str) {
6 css_vars.push_str(&format!("{orb}: {value};"));
7}
8
9impl CommonTheme {
10 pub fn write_orb_common_css_vars(&self, css_vars: &mut String) {
12 emit_orb(css_vars, "--orb-type-family-sans", self.font_family_base());
13 emit_orb(
14 css_vars,
15 "--orb-type-family-mono",
16 self.font_family_monospace(),
17 );
18 emit_orb(
19 css_vars,
20 "--orb-type-family-numeric",
21 self.font_family_numeric(),
22 );
23 emit_orb(
24 css_vars,
25 "--orb-type-family-display",
26 self.font_family_display(),
27 );
28
29 let font_sizes = [
30 ("--orb-type-size-2xs", self.font_size_base_100()),
31 ("--orb-type-size-xs", self.font_size_base_200()),
32 ("--orb-type-size-sm", self.font_size_base_300()),
33 ("--orb-type-size-md", self.font_size_base_400()),
34 ("--orb-type-size-lg", self.font_size_base_500()),
35 ("--orb-type-size-xl", self.font_size_base_600()),
36 ("--orb-type-size-2xl", self.font_size_base_700()),
37 ("--orb-type-size-3xl", self.font_size_base_800()),
38 ("--orb-type-size-4xl", self.font_size_base_900()),
39 ("--orb-type-size-5xl", self.font_size_base_1000()),
40 ];
41 for (orb, value) in font_sizes {
42 emit_orb(css_vars, orb, value);
43 }
44
45 let spacing_inline = [
46 ("--orb-space-inline-none", self.spacing_horizontal_none()),
47 ("--orb-space-inline-2xs", self.spacing_horizontal_x_x_s()),
48 ("--orb-space-inline-xs", self.spacing_horizontal_x_s()),
49 ("--orb-space-inline-sm", self.spacing_horizontal_s()),
50 ("--orb-space-inline-md", self.spacing_horizontal_m()),
51 ("--orb-space-inline-lg", self.spacing_horizontal_l()),
52 ("--orb-space-inline-xl", self.spacing_horizontal_x_l()),
53 ("--orb-space-inline-2xl", self.spacing_horizontal_x_x_l()),
54 ("--orb-space-inline-3xl", self.spacing_horizontal_x_x_x_l()),
55 ];
56 for (orb, value) in spacing_inline {
57 emit_orb(css_vars, orb, value);
58 }
59
60 let spacing_block = [
61 ("--orb-space-block-none", self.spacing_vertical_none()),
62 ("--orb-space-block-2xs", self.spacing_vertical_x_x_s()),
63 ("--orb-space-block-xs", self.spacing_vertical_x_s()),
64 ("--orb-space-block-sm", self.spacing_vertical_s()),
65 ("--orb-space-block-md", self.spacing_vertical_m()),
66 ("--orb-space-block-lg", self.spacing_vertical_l()),
67 ("--orb-space-block-xl", self.spacing_vertical_x_l()),
68 ("--orb-space-block-2xl", self.spacing_vertical_x_x_l()),
69 ("--orb-space-block-3xl", self.spacing_vertical_x_x_x_l()),
70 ];
71 for (orb, value) in spacing_block {
72 emit_orb(css_vars, orb, value);
73 }
74
75 let radii = [
76 ("--orb-radius-none", self.border_radius_none()),
77 ("--orb-radius-sm", self.border_radius_small()),
78 ("--orb-radius-md", self.border_radius_medium()),
79 ("--orb-radius-lg", self.border_radius_large()),
80 ("--orb-radius-xl", self.border_radius_x_large()),
81 ("--orb-radius-floating", self.border_radius_floating()),
82 ("--orb-radius-circular", self.border_radius_circular()),
83 ];
84 for (orb, value) in radii {
85 emit_orb(css_vars, orb, value);
86 }
87
88 let strokes = [
89 ("--orb-stroke-thin", self.stroke_width_thin()),
90 ("--orb-stroke-thick", self.stroke_width_thick()),
91 ("--orb-stroke-thicker", self.stroke_width_thicker()),
92 ("--orb-stroke-thickest", self.stroke_width_thickest()),
93 ];
94 for (orb, value) in strokes {
95 emit_orb(css_vars, orb, value);
96 }
97
98 emit_orb(css_vars, "--orb-type-line-sm", self.line_height_base_200());
99 emit_orb(css_vars, "--orb-type-line-md", self.line_height_base_300());
100 emit_orb(css_vars, "--orb-type-line-lg", self.line_height_base_400());
101 emit_orb(css_vars, "--orb-type-line-xl", self.line_height_base_500());
102 emit_orb(
103 css_vars,
104 "--orb-type-weight-regular",
105 self.font_weight_regular(),
106 );
107 emit_orb(
108 css_vars,
109 "--orb-type-weight-semibold",
110 self.font_weight_semibold(),
111 );
112 emit_orb(css_vars, "--orb-type-weight-bold", self.font_weight_bold());
113 emit_orb(
114 css_vars,
115 "--orb-space-inline-snudge",
116 self.spacing_horizontal_s_nudge(),
117 );
118 emit_orb(
119 css_vars,
120 "--orb-space-inline-mnudge",
121 self.spacing_horizontal_m_nudge(),
122 );
123 emit_orb(
124 css_vars,
125 "--orb-space-block-snudge",
126 self.spacing_vertical_s_nudge(),
127 );
128 emit_orb(
129 css_vars,
130 "--orb-space-block-mnudge",
131 self.spacing_vertical_m_nudge(),
132 );
133 }
134}
135
136impl ColorTheme {
137 pub fn write_orb_color_css_vars(&self, css_vars: &mut String) {
139 emit_orb(css_vars, "--orb-color-scheme", self.color_scheme());
140
141 let brand = [
142 ("--orb-color-brand-bg", self.color_brand_background()),
143 (
144 "--orb-color-brand-bg-hover",
145 self.color_brand_background_hover(),
146 ),
147 (
148 "--orb-color-brand-bg-pressed",
149 self.color_brand_background_pressed(),
150 ),
151 (
152 "--orb-color-brand-bg-subtle",
153 self.color_brand_background_2(),
154 ),
155 ("--orb-color-brand-fg", self.color_brand_foreground_1()),
156 (
157 "--orb-color-brand-fg-secondary",
158 self.color_brand_foreground_2(),
159 ),
160 ("--orb-color-brand-stroke", self.color_brand_stroke_1()),
161 (
162 "--orb-color-brand-stroke-subtle",
163 self.color_brand_stroke_2(),
164 ),
165 (
166 "--orb-color-brand-compound-bg",
167 self.color_compound_brand_background(),
168 ),
169 ];
170 for (orb, value) in brand {
171 emit_orb(css_vars, orb, value);
172 }
173
174 let surfaces = [
175 (
176 "--orb-color-surface-canvas",
177 self.color_neutral_background_1(),
178 ),
179 (
180 "--orb-color-surface-canvas-hover",
181 self.color_neutral_background_1_hover(),
182 ),
183 (
184 "--orb-color-surface-canvas-pressed",
185 self.color_neutral_background_1_pressed(),
186 ),
187 (
188 "--orb-color-surface-shell",
189 self.color_neutral_background_2(),
190 ),
191 (
192 "--orb-color-surface-subtle",
193 self.color_neutral_background_3(),
194 ),
195 (
196 "--orb-color-text-primary",
197 self.color_neutral_foreground_1(),
198 ),
199 (
200 "--orb-color-text-secondary",
201 self.color_neutral_foreground_2(),
202 ),
203 ("--orb-color-border-default", self.color_neutral_stroke_1()),
204 ("--orb-color-border-subtle", self.color_neutral_stroke_2()),
205 ];
206 for (orb, value) in surfaces {
207 emit_orb(css_vars, orb, value);
208 }
209
210 let status = [
211 (
212 "--orb-color-status-danger-fg",
213 self.color_status_danger_foreground_1(),
214 ),
215 (
216 "--orb-color-status-success-fg",
217 self.color_status_success_foreground_1(),
218 ),
219 (
220 "--orb-color-status-warning-fg",
221 self.color_status_warning_foreground_3(),
222 ),
223 ];
224 for (orb, value) in status {
225 emit_orb(css_vars, orb, value);
226 }
227
228 let elevation = [
229 ("--orb-elev-raised-xs", self.shadow2()),
230 ("--orb-elev-raised-sm", self.shadow4()),
231 ("--orb-elev-raised-md", self.shadow8()),
232 ("--orb-elev-floating", self.shadow16()),
233 ("--orb-elev-overlay", self.shadow28()),
234 ("--orb-elev-modal", self.shadow64()),
235 ];
236 for (orb, value) in elevation {
237 emit_orb(css_vars, orb, value);
238 }
239
240 emit_orb(
242 css_vars,
243 "--orb-color-surface-canvas-selected",
244 self.color_neutral_background_1_hover(),
245 );
246 emit_orb(
247 css_vars,
248 "--orb-color-border-muted",
249 self.color_neutral_stroke_2(),
250 );
251
252 self.write_orb_extended_color_css_vars(css_vars);
253 }
254
255 pub fn write_orb_extended_color_css_vars(&self, css_vars: &mut String) {
257 let extended = [
258 (
259 "--orb-color-brand-bg-hover",
260 self.color_brand_background_hover(),
261 ),
262 (
263 "--orb-color-brand-bg-pressed",
264 self.color_brand_background_pressed(),
265 ),
266 (
267 "--orb-color-brand-stroke-contrast",
268 self.color_brand_stroke_2_contrast(),
269 ),
270 ("--orb-color-brand-link", self.color_brand_foreground_link()),
271 (
272 "--orb-color-brand-link-hover",
273 self.color_brand_foreground_link_hover(),
274 ),
275 (
276 "--orb-color-brand-link-pressed",
277 self.color_brand_foreground_link_pressed(),
278 ),
279 (
280 "--orb-color-brand-compound-bg-hover",
281 self.color_compound_brand_background_hover(),
282 ),
283 (
284 "--orb-color-brand-compound-bg-pressed",
285 self.color_compound_brand_background_pressed(),
286 ),
287 (
288 "--orb-color-brand-compound-fg",
289 self.color_compound_brand_foreground_1(),
290 ),
291 (
292 "--orb-color-brand-compound-fg-hover",
293 self.color_compound_brand_foreground_1_hover(),
294 ),
295 (
296 "--orb-color-brand-compound-fg-pressed",
297 self.color_compound_brand_foreground_1_pressed(),
298 ),
299 (
300 "--orb-color-brand-compound-stroke",
301 self.color_compound_brand_stroke(),
302 ),
303 (
304 "--orb-color-brand-compound-stroke-pressed",
305 self.color_compound_brand_stroke_pressed(),
306 ),
307 (
308 "--orb-color-surface-static",
309 self.color_neutral_background_static(),
310 ),
311 (
312 "--orb-color-surface-inverted",
313 self.color_neutral_background_inverted(),
314 ),
315 (
316 "--orb-color-surface-disabled",
317 self.color_neutral_background_disabled(),
318 ),
319 (
320 "--orb-color-surface-subtle-hover",
321 self.color_neutral_background_3_hover(),
322 ),
323 (
324 "--orb-color-surface-subtle-pressed",
325 self.color_neutral_background_3_pressed(),
326 ),
327 (
328 "--orb-color-surface-overlay",
329 self.color_neutral_background_4(),
330 ),
331 (
332 "--orb-color-surface-overlay-hover",
333 self.color_neutral_background_4_hover(),
334 ),
335 (
336 "--orb-color-surface-overlay-pressed",
337 self.color_neutral_background_4_pressed(),
338 ),
339 (
340 "--orb-color-surface-raised",
341 self.color_neutral_background_5(),
342 ),
343 (
344 "--orb-color-surface-sunken",
345 self.color_neutral_background_6(),
346 ),
347 (
348 "--orb-color-text-on-static",
349 self.color_neutral_foreground_static_inverted(),
350 ),
351 (
352 "--orb-color-text-disabled",
353 self.color_neutral_foreground_disabled(),
354 ),
355 (
356 "--orb-color-text-primary-hover",
357 self.color_neutral_foreground_1_hover(),
358 ),
359 (
360 "--orb-color-text-primary-pressed",
361 self.color_neutral_foreground_1_pressed(),
362 ),
363 (
364 "--orb-color-text-secondary-hover",
365 self.color_neutral_foreground_2_hover(),
366 ),
367 (
368 "--orb-color-text-secondary-pressed",
369 self.color_neutral_foreground_2_pressed(),
370 ),
371 (
372 "--orb-color-text-secondary-brand-hover",
373 self.color_neutral_foreground_2_brand_hover(),
374 ),
375 (
376 "--orb-color-text-secondary-brand-pressed",
377 self.color_neutral_foreground_2_brand_pressed(),
378 ),
379 (
380 "--orb-color-text-secondary-brand-selected",
381 self.color_neutral_foreground_2_brand_selected(),
382 ),
383 (
384 "--orb-color-text-tertiary",
385 self.color_neutral_foreground_3(),
386 ),
387 (
388 "--orb-color-text-quaternary",
389 self.color_neutral_foreground_4(),
390 ),
391 (
392 "--orb-color-text-on-brand",
393 self.color_neutral_foreground_on_brand(),
394 ),
395 (
396 "--orb-color-text-inverted",
397 self.color_neutral_foreground_inverted(),
398 ),
399 (
400 "--orb-color-border-disabled",
401 self.color_neutral_stroke_disabled(),
402 ),
403 (
404 "--orb-color-border-default-hover",
405 self.color_neutral_stroke_1_hover(),
406 ),
407 (
408 "--orb-color-border-default-pressed",
409 self.color_neutral_stroke_1_pressed(),
410 ),
411 (
412 "--orb-color-border-accessible",
413 self.color_neutral_stroke_accessible(),
414 ),
415 (
416 "--orb-color-border-accessible-hover",
417 self.color_neutral_stroke_accessible_hover(),
418 ),
419 (
420 "--orb-color-border-accessible-pressed",
421 self.color_neutral_stroke_accessible_pressed(),
422 ),
423 ("--orb-color-border-focus", self.color_stroke_focus_2()),
424 (
425 "--orb-color-border-transparent",
426 self.color_transparent_stroke(),
427 ),
428 (
429 "--orb-color-shadow-ambient",
430 self.color_neutral_shadow_ambient(),
431 ),
432 ("--orb-color-shadow-key", self.color_neutral_shadow_key()),
433 (
434 "--orb-color-stencil-primary",
435 self.color_neutral_stencil_1(),
436 ),
437 (
438 "--orb-color-stencil-secondary",
439 self.color_neutral_stencil_2(),
440 ),
441 ("--orb-color-subtle-bg", self.color_subtle_background()),
442 (
443 "--orb-color-subtle-bg-hover",
444 self.color_subtle_background_hover(),
445 ),
446 (
447 "--orb-color-subtle-bg-pressed",
448 self.color_subtle_background_pressed(),
449 ),
450 (
451 "--orb-color-transparent-bg",
452 self.color_transparent_background(),
453 ),
454 (
455 "--orb-color-transparent-bg-hover",
456 self.color_transparent_background_hover(),
457 ),
458 (
459 "--orb-color-transparent-bg-pressed",
460 self.color_transparent_background_pressed(),
461 ),
462 ("--orb-color-code-bg", self.color_code_background()),
463 ("--orb-color-code-fg", self.color_code_foreground()),
464 (
465 "--orb-color-status-success-bg",
466 self.color_status_success_background_1(),
467 ),
468 (
469 "--orb-color-status-success-border",
470 self.color_status_success_border_1(),
471 ),
472 (
473 "--orb-color-status-warning-bg",
474 self.color_status_warning_background_1(),
475 ),
476 (
477 "--orb-color-status-warning-border",
478 self.color_status_warning_border_1(),
479 ),
480 (
481 "--orb-color-status-danger-bg",
482 self.color_status_danger_background_1(),
483 ),
484 (
485 "--orb-color-status-danger-border",
486 self.color_status_danger_border_1(),
487 ),
488 (
489 "--orb-color-palette-red-bg-subtle",
490 self.color_palette_red_background_1(),
491 ),
492 (
493 "--orb-color-palette-red-bg",
494 self.color_palette_red_background_3(),
495 ),
496 (
497 "--orb-color-palette-red-fg",
498 self.color_palette_red_foreground_1(),
499 ),
500 (
501 "--orb-color-palette-red-fg-strong",
502 self.color_palette_red_foreground_3(),
503 ),
504 (
505 "--orb-color-palette-red-border",
506 self.color_palette_red_border_1(),
507 ),
508 (
509 "--orb-color-palette-red-border-strong",
510 self.color_palette_red_border_2(),
511 ),
512 (
513 "--orb-color-palette-green-bg-subtle",
514 self.color_palette_green_background_1(),
515 ),
516 (
517 "--orb-color-palette-green-bg",
518 self.color_palette_green_background_3(),
519 ),
520 (
521 "--orb-color-palette-green-fg",
522 self.color_palette_green_foreground_1(),
523 ),
524 (
525 "--orb-color-palette-green-fg-strong",
526 self.color_palette_green_foreground_3(),
527 ),
528 (
529 "--orb-color-palette-green-border",
530 self.color_palette_green_border_1(),
531 ),
532 (
533 "--orb-color-palette-green-border-strong",
534 self.color_palette_green_border_2(),
535 ),
536 (
537 "--orb-color-palette-yellow-bg-subtle",
538 self.color_palette_yellow_background_1(),
539 ),
540 (
541 "--orb-color-palette-yellow-bg",
542 self.color_palette_yellow_background_3(),
543 ),
544 (
545 "--orb-color-palette-yellow-fg",
546 self.color_palette_yellow_foreground_1(),
547 ),
548 (
549 "--orb-color-palette-yellow-fg-muted",
550 self.color_palette_yellow_foreground_2(),
551 ),
552 (
553 "--orb-color-palette-yellow-border",
554 self.color_palette_yellow_border_1(),
555 ),
556 (
557 "--orb-color-palette-orange-bg-subtle",
558 self.color_palette_dark_orange_background_1(),
559 ),
560 (
561 "--orb-color-palette-orange-bg",
562 self.color_palette_dark_orange_background_3(),
563 ),
564 (
565 "--orb-color-palette-orange-fg",
566 self.color_palette_dark_orange_foreground_1(),
567 ),
568 (
569 "--orb-color-palette-orange-fg-strong",
570 self.color_palette_dark_orange_foreground_3(),
571 ),
572 (
573 "--orb-color-palette-orange-border",
574 self.color_palette_dark_orange_border_1(),
575 ),
576 ];
577 for (orb, value) in extended {
578 emit_orb(css_vars, orb, value);
579 }
580 }
581}