1use std::sync::Once;
2
3use mecomp_core::OnceLockDefault;
4
5pub static APP_BORDER: OnceLockDefault<material::HexColor> =
7 OnceLockDefault::new(material::PINK_900);
8pub static APP_BORDER_TEXT: OnceLockDefault<material::HexColor> =
9 OnceLockDefault::new(material::PINK_300);
10
11pub static BORDER_UNFOCUSED: OnceLockDefault<material::HexColor> =
13 OnceLockDefault::new(material::RED_900);
14pub static BORDER_FOCUSED: OnceLockDefault<material::HexColor> =
15 OnceLockDefault::new(material::RED_200);
16
17pub static POPUP_BORDER: OnceLockDefault<material::HexColor> =
19 OnceLockDefault::new(material::LIGHT_BLUE_500);
20
21pub static TEXT_NORMAL: OnceLockDefault<material::HexColor> = OnceLockDefault::new(material::WHITE);
23pub static TEXT_HIGHLIGHT: OnceLockDefault<material::HexColor> =
24 OnceLockDefault::new(material::RED_600);
25pub static TEXT_HIGHLIGHT_ALT: OnceLockDefault<material::HexColor> =
26 OnceLockDefault::new(material::RED_200);
27
28pub static GAUGE_FILLED: OnceLockDefault<material::HexColor> =
30 OnceLockDefault::new(material::WHITE);
31pub static GAUGE_UNFILLED: OnceLockDefault<material::HexColor> =
32 OnceLockDefault::new(material::BLACK);
33
34pub static COLORS_INITIALIZED: Once = Once::new();
35
36pub fn initialize_colors(theme: mecomp_core::config::TuiColorScheme) {
44 macro_rules! set_color {
45 ($color:ident, $value:expr) => {
46 if let Some(color) =
47 $value.and_then(|c| material::HexColor::parse(Box::leak(c.into_boxed_str())))
48 {
49 $color.set(color).ok();
50 }
51 };
52 }
53
54 COLORS_INITIALIZED.call_once(|| {
56 set_color!(APP_BORDER, theme.app_border);
58 set_color!(APP_BORDER_TEXT, theme.app_border_text);
59 set_color!(BORDER_UNFOCUSED, theme.border_unfocused);
60 set_color!(BORDER_FOCUSED, theme.border_focused);
61 set_color!(POPUP_BORDER, theme.popup_border);
62 set_color!(TEXT_NORMAL, theme.text_normal);
63 set_color!(TEXT_HIGHLIGHT, theme.text_highlight);
64 set_color!(TEXT_HIGHLIGHT_ALT, theme.text_highlight_alt);
65 set_color!(GAUGE_FILLED, theme.gauge_filled);
66 set_color!(GAUGE_UNFILLED, theme.gauge_unfilled);
67 });
68}
69
70#[must_use]
71pub fn border_color(is_focused: bool) -> material::HexColor {
72 if is_focused {
73 *BORDER_FOCUSED
74 } else {
75 *BORDER_UNFOCUSED
76 }
77}
78
79#[cfg(test)]
80mod tests {
81 use super::*;
82 use mecomp_core::config::TuiColorScheme;
83 use pretty_assertions::assert_eq;
84
85 #[test]
86 fn test_border_color() {
87 let focused = border_color(true);
88 let unfocused = border_color(false);
89 assert_eq!(focused, *BORDER_FOCUSED);
90 assert_eq!(unfocused, *BORDER_UNFOCUSED);
91 }
92
93 #[test]
94 fn test_colors() {
95 assert_eq!(*APP_BORDER, material::PINK_900);
97 assert_eq!(*APP_BORDER_TEXT, material::PINK_300);
98 assert_eq!(*BORDER_UNFOCUSED, material::RED_900);
99 assert_eq!(*BORDER_FOCUSED, material::RED_200);
100 assert_eq!(*POPUP_BORDER, material::LIGHT_BLUE_500);
101 assert_eq!(*TEXT_NORMAL, material::WHITE);
102 assert_eq!(*TEXT_HIGHLIGHT, material::RED_600);
103 assert_eq!(*TEXT_HIGHLIGHT_ALT, material::RED_200);
104 assert_eq!(*GAUGE_FILLED, material::WHITE);
105 assert_eq!(*GAUGE_UNFILLED, material::BLACK);
106
107 let theme = TuiColorScheme {
109 app_border: Some(material::PINK_900.to_string()),
110 app_border_text: Some(material::PINK_300.to_string()),
111 border_unfocused: Some(material::RED_900.to_string()),
112 border_focused: Some(material::RED_200.to_string()),
113 popup_border: Some(material::LIGHT_BLUE_500.to_string()),
114 text_normal: Some(material::WHITE.to_string()),
115 text_highlight: Some(material::RED_600.to_string()),
116 text_highlight_alt: Some(material::RED_200.to_string()),
117 gauge_filled: Some(material::WHITE.to_string()),
118 gauge_unfilled: Some(material::BLACK.to_string()),
119 };
120
121 initialize_colors(theme);
123
124 assert!(APP_BORDER.is_initialized());
126 assert!(APP_BORDER_TEXT.is_initialized());
127 assert!(BORDER_UNFOCUSED.is_initialized());
128 assert!(BORDER_FOCUSED.is_initialized());
129 assert!(POPUP_BORDER.is_initialized());
130 assert!(TEXT_NORMAL.is_initialized());
131 assert!(TEXT_HIGHLIGHT.is_initialized());
132 assert!(TEXT_HIGHLIGHT_ALT.is_initialized());
133 assert!(GAUGE_FILLED.is_initialized());
134 assert!(GAUGE_UNFILLED.is_initialized());
135 }
136}
137
138pub mod material {
139 #![allow(dead_code)]
148
149 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
150 pub struct HexColor(&'static str);
151
152 impl HexColor {
153 #[must_use]
157 pub fn parse(s: &'static str) -> Option<Self> {
158 let candidate = if s.len() == 7 && s.starts_with('#') {
160 Self(s)
161 } else if let Some((_, hex)) = MATERIAL_COLORS
162 .iter()
163 .find(|(name, _)| *name == s.to_ascii_lowercase())
164 {
165 *hex
166 } else {
167 return None;
168 };
169
170 if candidate.0.len() == 7
172 && candidate.0.starts_with('#')
173 && candidate.0[1..].chars().all(|c| c.is_ascii_hexdigit())
174 {
175 Some(candidate)
176 } else {
177 None
178 }
179 }
180 }
181
182 impl From<HexColor> for ratatui::style::Color {
183 fn from(hex_color: HexColor) -> Self {
185 let s = hex_color.0;
186 let (r, g, b) = (
187 u8::from_str_radix(&s[1..3], 16).unwrap_or_default(),
188 u8::from_str_radix(&s[3..5], 16).unwrap_or_default(),
189 u8::from_str_radix(&s[5..7], 16).unwrap_or_default(),
190 );
191
192 Self::Rgb(r, g, b)
193 }
194 }
195
196 impl std::fmt::Display for HexColor {
197 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
198 write!(f, "{}", self.0)
199 }
200 }
201
202 static MATERIAL_COLORS: &[(&str, HexColor)] = &[
204 ("red_50", RED_50),
206 ("red_100", RED_100),
207 ("red_200", RED_200),
208 ("red_300", RED_300),
209 ("red_400", RED_400),
210 ("red_500", RED_500),
211 ("red_600", RED_600),
212 ("red_700", RED_700),
213 ("red_800", RED_800),
214 ("red_900", RED_900),
215 ("red_a100", RED_A100),
216 ("red_a200", RED_A200),
217 ("red_a400", RED_A400),
218 ("red_a700", RED_A700),
219 ("pink_50", PINK_50),
221 ("pink_100", PINK_100),
222 ("pink_200", PINK_200),
223 ("pink_300", PINK_300),
224 ("pink_400", PINK_400),
225 ("pink_500", PINK_500),
226 ("pink_600", PINK_600),
227 ("pink_700", PINK_700),
228 ("pink_800", PINK_800),
229 ("pink_900", PINK_900),
230 ("pink_a100", PINK_A100),
231 ("pink_a200", PINK_A200),
232 ("pink_a400", PINK_A400),
233 ("pink_a700", PINK_A700),
234 ("purple_50", PURPLE_50),
236 ("purple_100", PURPLE_100),
237 ("purple_200", PURPLE_200),
238 ("purple_300", PURPLE_300),
239 ("purple_400", PURPLE_400),
240 ("purple_500", PURPLE_500),
241 ("purple_600", PURPLE_600),
242 ("purple_700", PURPLE_700),
243 ("purple_800", PURPLE_800),
244 ("purple_900", PURPLE_900),
245 ("purple_a100", PURPLE_A100),
246 ("purple_a200", PURPLE_A200),
247 ("purple_a400", PURPLE_A400),
248 ("purple_a700", PURPLE_A700),
249 ("deep_purple_50", DEEP_PURPLE_50),
251 ("deep_purple_100", DEEP_PURPLE_100),
252 ("deep_purple_200", DEEP_PURPLE_200),
253 ("deep_purple_300", DEEP_PURPLE_300),
254 ("deep_purple_400", DEEP_PURPLE_400),
255 ("deep_purple_500", DEEP_PURPLE_500),
256 ("deep_purple_600", DEEP_PURPLE_600),
257 ("deep_purple_700", DEEP_PURPLE_700),
258 ("deep_purple_800", DEEP_PURPLE_800),
259 ("deep_purple_900", DEEP_PURPLE_900),
260 ("deep_purple_a100", DEEP_PURPLE_A100),
261 ("deep_purple_a200", DEEP_PURPLE_A200),
262 ("deep_purple_a400", DEEP_PURPLE_A400),
263 ("deep_purple_a700", DEEP_PURPLE_A700),
264 ("indigo_50", INDIGO_50),
266 ("indigo_100", INDIGO_100),
267 ("indigo_200", INDIGO_200),
268 ("indigo_300", INDIGO_300),
269 ("indigo_400", INDIGO_400),
270 ("indigo_500", INDIGO_500),
271 ("indigo_600", INDIGO_600),
272 ("indigo_700", INDIGO_700),
273 ("indigo_800", INDIGO_800),
274 ("indigo_900", INDIGO_900),
275 ("indigo_a100", INDIGO_A100),
276 ("indigo_a200", INDIGO_A200),
277 ("indigo_a400", INDIGO_A400),
278 ("indigo_a700", INDIGO_A700),
279 ("blue_50", BLUE_50),
281 ("blue_100", BLUE_100),
282 ("blue_200", BLUE_200),
283 ("blue_300", BLUE_300),
284 ("blue_400", BLUE_400),
285 ("blue_500", BLUE_500),
286 ("blue_600", BLUE_600),
287 ("blue_700", BLUE_700),
288 ("blue_800", BLUE_800),
289 ("blue_900", BLUE_900),
290 ("blue_a100", BLUE_A100),
291 ("blue_a200", BLUE_A200),
292 ("blue_a400", BLUE_A400),
293 ("blue_a700", BLUE_A700),
294 ("light_blue_50", LIGHT_BLUE_50),
296 ("light_blue_100", LIGHT_BLUE_100),
297 ("light_blue_200", LIGHT_BLUE_200),
298 ("light_blue_300", LIGHT_BLUE_300),
299 ("light_blue_400", LIGHT_BLUE_400),
300 ("light_blue_500", LIGHT_BLUE_500),
301 ("light_blue_600", LIGHT_BLUE_600),
302 ("light_blue_700", LIGHT_BLUE_700),
303 ("light_blue_800", LIGHT_BLUE_800),
304 ("light_blue_900", LIGHT_BLUE_900),
305 ("light_blue_a100", LIGHT_BLUE_A100),
306 ("light_blue_a200", LIGHT_BLUE_A200),
307 ("light_blue_a400", LIGHT_BLUE_A400),
308 ("light_blue_a700", LIGHT_BLUE_A700),
309 ("cyan_50", CYAN_50),
311 ("cyan_100", CYAN_100),
312 ("cyan_200", CYAN_200),
313 ("cyan_300", CYAN_300),
314 ("cyan_400", CYAN_400),
315 ("cyan_500", CYAN_500),
316 ("cyan_600", CYAN_600),
317 ("cyan_700", CYAN_700),
318 ("cyan_800", CYAN_800),
319 ("cyan_900", CYAN_900),
320 ("cyan_a100", CYAN_A100),
321 ("cyan_a200", CYAN_A200),
322 ("cyan_a400", CYAN_A400),
323 ("cyan_a700", CYAN_A700),
324 ("teal_50", TEAL_50),
326 ("teal_100", TEAL_100),
327 ("teal_200", TEAL_200),
328 ("teal_300", TEAL_300),
329 ("teal_400", TEAL_400),
330 ("teal_500", TEAL_500),
331 ("teal_600", TEAL_600),
332 ("teal_700", TEAL_700),
333 ("teal_800", TEAL_800),
334 ("teal_900", TEAL_900),
335 ("teal_a100", TEAL_A100),
336 ("teal_a200", TEAL_A200),
337 ("teal_a400", TEAL_A400),
338 ("teal_a700", TEAL_A700),
339 ("green_50", GREEN_50),
341 ("green_100", GREEN_100),
342 ("green_200", GREEN_200),
343 ("green_300", GREEN_300),
344 ("green_400", GREEN_400),
345 ("green_500", GREEN_500),
346 ("green_600", GREEN_600),
347 ("green_700", GREEN_700),
348 ("green_800", GREEN_800),
349 ("green_900", GREEN_900),
350 ("green_a100", GREEN_A100),
351 ("green_a200", GREEN_A200),
352 ("green_a400", GREEN_A400),
353 ("green_a700", GREEN_A700),
354 ("light_green_50", LIGHT_GREEN_50),
356 ("light_green_100", LIGHT_GREEN_100),
357 ("light_green_200", LIGHT_GREEN_200),
358 ("light_green_300", LIGHT_GREEN_300),
359 ("light_green_400", LIGHT_GREEN_400),
360 ("light_green_500", LIGHT_GREEN_500),
361 ("light_green_600", LIGHT_GREEN_600),
362 ("light_green_700", LIGHT_GREEN_700),
363 ("light_green_800", LIGHT_GREEN_800),
364 ("light_green_900", LIGHT_GREEN_900),
365 ("light_green_a100", LIGHT_GREEN_A100),
366 ("light_green_a200", LIGHT_GREEN_A200),
367 ("light_green_a400", LIGHT_GREEN_A400),
368 ("light_green_a700", LIGHT_GREEN_A700),
369 ("lime_50", LIME_50),
371 ("lime_100", LIME_100),
372 ("lime_200", LIME_200),
373 ("lime_300", LIME_300),
374 ("lime_400", LIME_400),
375 ("lime_500", LIME_500),
376 ("lime_600", LIME_600),
377 ("lime_700", LIME_700),
378 ("lime_800", LIME_800),
379 ("lime_900", LIME_900),
380 ("lime_a100", LIME_A100),
381 ("lime_a200", LIME_A200),
382 ("lime_a400", LIME_A400),
383 ("lime_a700", LIME_A700),
384 ("yellow_50", YELLOW_50),
386 ("yellow_100", YELLOW_100),
387 ("yellow_200", YELLOW_200),
388 ("yellow_300", YELLOW_300),
389 ("yellow_400", YELLOW_400),
390 ("yellow_500", YELLOW_500),
391 ("yellow_600", YELLOW_600),
392 ("yellow_700", YELLOW_700),
393 ("yellow_800", YELLOW_800),
394 ("yellow_900", YELLOW_900),
395 ("yellow_a100", YELLOW_A100),
396 ("yellow_a200", YELLOW_A200),
397 ("yellow_a400", YELLOW_A400),
398 ("yellow_a700", YELLOW_A700),
399 ("amber_50", AMBER_50),
401 ("amber_100", AMBER_100),
402 ("amber_200", AMBER_200),
403 ("amber_300", AMBER_300),
404 ("amber_400", AMBER_400),
405 ("amber_500", AMBER_500),
406 ("amber_600", AMBER_600),
407 ("amber_700", AMBER_700),
408 ("amber_800", AMBER_800),
409 ("amber_900", AMBER_900),
410 ("amber_a100", AMBER_A100),
411 ("amber_a200", AMBER_A200),
412 ("amber_a400", AMBER_A400),
413 ("amber_a700", AMBER_A700),
414 ("orange_50", ORANGE_50),
416 ("orange_100", ORANGE_100),
417 ("orange_200", ORANGE_200),
418 ("orange_300", ORANGE_300),
419 ("orange_400", ORANGE_400),
420 ("orange_500", ORANGE_500),
421 ("orange_600", ORANGE_600),
422 ("orange_700", ORANGE_700),
423 ("orange_800", ORANGE_800),
424 ("orange_900", ORANGE_900),
425 ("orange_a100", ORANGE_A100),
426 ("orange_a200", ORANGE_A200),
427 ("orange_a400", ORANGE_A400),
428 ("orange_a700", ORANGE_A700),
429 ("deep_orange_50", DEEP_ORANGE_50),
431 ("deep_orange_100", DEEP_ORANGE_100),
432 ("deep_orange_200", DEEP_ORANGE_200),
433 ("deep_orange_300", DEEP_ORANGE_300),
434 ("deep_orange_400", DEEP_ORANGE_400),
435 ("deep_orange_500", DEEP_ORANGE_500),
436 ("deep_orange_600", DEEP_ORANGE_600),
437 ("deep_orange_700", DEEP_ORANGE_700),
438 ("deep_orange_800", DEEP_ORANGE_800),
439 ("deep_orange_900", DEEP_ORANGE_900),
440 ("deep_orange_a100", DEEP_ORANGE_A100),
441 ("deep_orange_a200", DEEP_ORANGE_A200),
442 ("deep_orange_a400", DEEP_ORANGE_A400),
443 ("deep_orange_a700", DEEP_ORANGE_A700),
444 ("brown_50", BROWN_50),
446 ("brown_100", BROWN_100),
447 ("brown_200", BROWN_200),
448 ("brown_300", BROWN_300),
449 ("brown_400", BROWN_400),
450 ("brown_500", BROWN_500),
451 ("brown_600", BROWN_600),
452 ("brown_700", BROWN_700),
453 ("brown_800", BROWN_800),
454 ("brown_900", BROWN_900),
455 ("grey_50", GREY_50),
457 ("grey_100", GREY_100),
458 ("grey_200", GREY_200),
459 ("grey_300", GREY_300),
460 ("grey_400", GREY_400),
461 ("grey_500", GREY_500),
462 ("grey_600", GREY_600),
463 ("grey_700", GREY_700),
464 ("grey_800", GREY_800),
465 ("grey_900", GREY_900),
466 ("blue_grey_50", BLUE_GREY_50),
468 ("blue_grey_100", BLUE_GREY_100),
469 ("blue_grey_200", BLUE_GREY_200),
470 ("blue_grey_300", BLUE_GREY_300),
471 ("blue_grey_400", BLUE_GREY_400),
472 ("blue_grey_500", BLUE_GREY_500),
473 ("blue_grey_600", BLUE_GREY_600),
474 ("blue_grey_700", BLUE_GREY_700),
475 ("blue_grey_800", BLUE_GREY_800),
476 ("blue_grey_900", BLUE_GREY_900),
477 ("white", WHITE),
479 ("black", BLACK),
480 ];
481
482 pub const RED_50: HexColor = HexColor("#ffebee");
484 pub const RED_100: HexColor = HexColor("#ffcdd2");
486 pub const RED_200: HexColor = HexColor("#ef9a9a");
488 pub const RED_300: HexColor = HexColor("#e57373");
490 pub const RED_400: HexColor = HexColor("#ef5350");
492 pub const RED_500: HexColor = HexColor("#f44336");
494 pub const RED_600: HexColor = HexColor("#e53935");
496 pub const RED_700: HexColor = HexColor("#d32f2f");
498 pub const RED_800: HexColor = HexColor("#c62828");
500 pub const RED_900: HexColor = HexColor("#b71c1c");
502 pub const RED_A100: HexColor = HexColor("#ff8a80");
504 pub const RED_A200: HexColor = HexColor("#ff5252");
506 pub const RED_A400: HexColor = HexColor("#ff1744");
508 pub const RED_A700: HexColor = HexColor("#d50000");
510
511 pub const PINK_50: HexColor = HexColor("#fce4ec");
513 pub const PINK_100: HexColor = HexColor("#f8bbd0");
515 pub const PINK_200: HexColor = HexColor("#f48fb1");
517 pub const PINK_300: HexColor = HexColor("#f06292");
519 pub const PINK_400: HexColor = HexColor("#ec407a");
521 pub const PINK_500: HexColor = HexColor("#e91e63");
523 pub const PINK_600: HexColor = HexColor("#d81b60");
525 pub const PINK_700: HexColor = HexColor("#c2185b");
527 pub const PINK_800: HexColor = HexColor("#ad1457");
529 pub const PINK_900: HexColor = HexColor("#880e4f");
531 pub const PINK_A100: HexColor = HexColor("#ff80ab");
533 pub const PINK_A200: HexColor = HexColor("#ff4081");
535 pub const PINK_A400: HexColor = HexColor("#f50057");
537 pub const PINK_A700: HexColor = HexColor("#c51162");
539
540 pub const PURPLE_50: HexColor = HexColor("#f3e5f5");
542 pub const PURPLE_100: HexColor = HexColor("#e1bee7");
544 pub const PURPLE_200: HexColor = HexColor("#ce93d8");
546 pub const PURPLE_300: HexColor = HexColor("#ba68c8");
548 pub const PURPLE_400: HexColor = HexColor("#ab47bc");
550 pub const PURPLE_500: HexColor = HexColor("#9c27b0");
552 pub const PURPLE_600: HexColor = HexColor("#8e24aa");
554 pub const PURPLE_700: HexColor = HexColor("#7b1fa2");
556 pub const PURPLE_800: HexColor = HexColor("#6a1b9a");
558 pub const PURPLE_900: HexColor = HexColor("#4a148c");
560 pub const PURPLE_A100: HexColor = HexColor("#ea80fc");
562 pub const PURPLE_A200: HexColor = HexColor("#e040fb");
564 pub const PURPLE_A400: HexColor = HexColor("#d500f9");
566 pub const PURPLE_A700: HexColor = HexColor("#aa00ff");
568
569 pub const DEEP_PURPLE_50: HexColor = HexColor("#ede7f6");
571 pub const DEEP_PURPLE_100: HexColor = HexColor("#d1c4e9");
573 pub const DEEP_PURPLE_200: HexColor = HexColor("#b39ddb");
575 pub const DEEP_PURPLE_300: HexColor = HexColor("#9575cd");
577 pub const DEEP_PURPLE_400: HexColor = HexColor("#7e57c2");
579 pub const DEEP_PURPLE_500: HexColor = HexColor("#673ab7");
581 pub const DEEP_PURPLE_600: HexColor = HexColor("#5e35b1");
583 pub const DEEP_PURPLE_700: HexColor = HexColor("#512da8");
585 pub const DEEP_PURPLE_800: HexColor = HexColor("#4527a0");
587 pub const DEEP_PURPLE_900: HexColor = HexColor("#311b92");
589 pub const DEEP_PURPLE_A100: HexColor = HexColor("#b388ff");
591 pub const DEEP_PURPLE_A200: HexColor = HexColor("#7c4dff");
593 pub const DEEP_PURPLE_A400: HexColor = HexColor("#651fff");
595 pub const DEEP_PURPLE_A700: HexColor = HexColor("#6200ea");
597
598 pub const INDIGO_50: HexColor = HexColor("#e8eaf6");
600 pub const INDIGO_100: HexColor = HexColor("#c5cae9");
602 pub const INDIGO_200: HexColor = HexColor("#9fa8da");
604 pub const INDIGO_300: HexColor = HexColor("#7986cb");
606 pub const INDIGO_400: HexColor = HexColor("#5c6bc0");
608 pub const INDIGO_500: HexColor = HexColor("#3f51b5");
610 pub const INDIGO_600: HexColor = HexColor("#3949ab");
612 pub const INDIGO_700: HexColor = HexColor("#303f9f");
614 pub const INDIGO_800: HexColor = HexColor("#283593");
616 pub const INDIGO_900: HexColor = HexColor("#1a237e");
618 pub const INDIGO_A100: HexColor = HexColor("#8c9eff");
620 pub const INDIGO_A200: HexColor = HexColor("#536dfe");
622 pub const INDIGO_A400: HexColor = HexColor("#3d5afe");
624 pub const INDIGO_A700: HexColor = HexColor("#304ffe");
626
627 pub const BLUE_50: HexColor = HexColor("#e3f2fd");
629 pub const BLUE_100: HexColor = HexColor("#bbdefb");
631 pub const BLUE_200: HexColor = HexColor("#90caf9");
633 pub const BLUE_300: HexColor = HexColor("#64b5f6");
635 pub const BLUE_400: HexColor = HexColor("#42a5f5");
637 pub const BLUE_500: HexColor = HexColor("#2196f3");
639 pub const BLUE_600: HexColor = HexColor("#1e88e5");
641 pub const BLUE_700: HexColor = HexColor("#1976d2");
643 pub const BLUE_800: HexColor = HexColor("#1565c0");
645 pub const BLUE_900: HexColor = HexColor("#0d47a1");
647 pub const BLUE_A100: HexColor = HexColor("#82b1ff");
649 pub const BLUE_A200: HexColor = HexColor("#448aff");
651 pub const BLUE_A400: HexColor = HexColor("#2979ff");
653 pub const BLUE_A700: HexColor = HexColor("#2962ff");
655
656 pub const LIGHT_BLUE_50: HexColor = HexColor("#e1f5fe");
658 pub const LIGHT_BLUE_100: HexColor = HexColor("#b3e5fc");
660 pub const LIGHT_BLUE_200: HexColor = HexColor("#81d4fa");
662 pub const LIGHT_BLUE_300: HexColor = HexColor("#4fc3f7");
664 pub const LIGHT_BLUE_400: HexColor = HexColor("#29b6f6");
666 pub const LIGHT_BLUE_500: HexColor = HexColor("#03a9f4");
668 pub const LIGHT_BLUE_600: HexColor = HexColor("#039be5");
670 pub const LIGHT_BLUE_700: HexColor = HexColor("#0288d1");
672 pub const LIGHT_BLUE_800: HexColor = HexColor("#0277bd");
674 pub const LIGHT_BLUE_900: HexColor = HexColor("#01579b");
676 pub const LIGHT_BLUE_A100: HexColor = HexColor("#80d8ff");
678 pub const LIGHT_BLUE_A200: HexColor = HexColor("#40c4ff");
680 pub const LIGHT_BLUE_A400: HexColor = HexColor("#00b0ff");
682 pub const LIGHT_BLUE_A700: HexColor = HexColor("#0091ea");
684
685 pub const CYAN_50: HexColor = HexColor("#e0f7fa");
687 pub const CYAN_100: HexColor = HexColor("#b2ebf2");
689 pub const CYAN_200: HexColor = HexColor("#80deea");
691 pub const CYAN_300: HexColor = HexColor("#4dd0e1");
693 pub const CYAN_400: HexColor = HexColor("#26c6da");
695 pub const CYAN_500: HexColor = HexColor("#00bcd4");
697 pub const CYAN_600: HexColor = HexColor("#00acc1");
699 pub const CYAN_700: HexColor = HexColor("#0097a7");
701 pub const CYAN_800: HexColor = HexColor("#00838f");
703 pub const CYAN_900: HexColor = HexColor("#006064");
705 pub const CYAN_A100: HexColor = HexColor("#84ffff");
707 pub const CYAN_A200: HexColor = HexColor("#18ffff");
709 pub const CYAN_A400: HexColor = HexColor("#00e5ff");
711 pub const CYAN_A700: HexColor = HexColor("#00b8d4");
713
714 pub const TEAL_50: HexColor = HexColor("#e0f2f1");
716 pub const TEAL_100: HexColor = HexColor("#b2dfdb");
718 pub const TEAL_200: HexColor = HexColor("#80cbc4");
720 pub const TEAL_300: HexColor = HexColor("#4db6ac");
722 pub const TEAL_400: HexColor = HexColor("#26a69a");
724 pub const TEAL_500: HexColor = HexColor("#009688");
726 pub const TEAL_600: HexColor = HexColor("#00897b");
728 pub const TEAL_700: HexColor = HexColor("#00796b");
730 pub const TEAL_800: HexColor = HexColor("#00695c");
732 pub const TEAL_900: HexColor = HexColor("#004d40");
734 pub const TEAL_A100: HexColor = HexColor("#a7ffeb");
736 pub const TEAL_A200: HexColor = HexColor("#64ffda");
738 pub const TEAL_A400: HexColor = HexColor("#1de9b6");
740 pub const TEAL_A700: HexColor = HexColor("#00bfa5");
742
743 pub const GREEN_50: HexColor = HexColor("#e8f5e9");
745 pub const GREEN_100: HexColor = HexColor("#c8e6c9");
747 pub const GREEN_200: HexColor = HexColor("#a5d6a7");
749 pub const GREEN_300: HexColor = HexColor("#81c784");
751 pub const GREEN_400: HexColor = HexColor("#66bb6a");
753 pub const GREEN_500: HexColor = HexColor("#4caf50");
755 pub const GREEN_600: HexColor = HexColor("#43a047");
757 pub const GREEN_700: HexColor = HexColor("#388e3c");
759 pub const GREEN_800: HexColor = HexColor("#2e7d32");
761 pub const GREEN_900: HexColor = HexColor("#1b5e20");
763 pub const GREEN_A100: HexColor = HexColor("#b9f6ca");
765 pub const GREEN_A200: HexColor = HexColor("#69f0ae");
767 pub const GREEN_A400: HexColor = HexColor("#00e676");
769 pub const GREEN_A700: HexColor = HexColor("#00c853");
771
772 pub const LIGHT_GREEN_50: HexColor = HexColor("#f1f8e9");
774 pub const LIGHT_GREEN_100: HexColor = HexColor("#dcedc8");
776 pub const LIGHT_GREEN_200: HexColor = HexColor("#c5e1a5");
778 pub const LIGHT_GREEN_300: HexColor = HexColor("#aed581");
780 pub const LIGHT_GREEN_400: HexColor = HexColor("#9ccc65");
782 pub const LIGHT_GREEN_500: HexColor = HexColor("#8bc34a");
784 pub const LIGHT_GREEN_600: HexColor = HexColor("#7cb342");
786 pub const LIGHT_GREEN_700: HexColor = HexColor("#689f38");
788 pub const LIGHT_GREEN_800: HexColor = HexColor("#558b2f");
790 pub const LIGHT_GREEN_900: HexColor = HexColor("#33691e");
792 pub const LIGHT_GREEN_A100: HexColor = HexColor("#ccff90");
794 pub const LIGHT_GREEN_A200: HexColor = HexColor("#b2ff59");
796 pub const LIGHT_GREEN_A400: HexColor = HexColor("#76ff03");
798 pub const LIGHT_GREEN_A700: HexColor = HexColor("#64dd17");
800
801 pub const LIME_50: HexColor = HexColor("#f9fbe7");
803 pub const LIME_100: HexColor = HexColor("#f0f4c3");
805 pub const LIME_200: HexColor = HexColor("#e6ee9c");
807 pub const LIME_300: HexColor = HexColor("#dce775");
809 pub const LIME_400: HexColor = HexColor("#d4e157");
811 pub const LIME_500: HexColor = HexColor("#cddc39");
813 pub const LIME_600: HexColor = HexColor("#c0ca33");
815 pub const LIME_700: HexColor = HexColor("#afb42b");
817 pub const LIME_800: HexColor = HexColor("#9e9d24");
819 pub const LIME_900: HexColor = HexColor("#827717");
821 pub const LIME_A100: HexColor = HexColor("#f4ff81");
823 pub const LIME_A200: HexColor = HexColor("#eeff41");
825 pub const LIME_A400: HexColor = HexColor("#c6ff00");
827 pub const LIME_A700: HexColor = HexColor("#aeea00");
829
830 pub const YELLOW_50: HexColor = HexColor("#fffde7");
832 pub const YELLOW_100: HexColor = HexColor("#fff9c4");
834 pub const YELLOW_200: HexColor = HexColor("#fff59d");
836 pub const YELLOW_300: HexColor = HexColor("#fff176");
838 pub const YELLOW_400: HexColor = HexColor("#ffee58");
840 pub const YELLOW_500: HexColor = HexColor("#ffeb3b");
842 pub const YELLOW_600: HexColor = HexColor("#fdd835");
844 pub const YELLOW_700: HexColor = HexColor("#fbc02d");
846 pub const YELLOW_800: HexColor = HexColor("#f9a825");
848 pub const YELLOW_900: HexColor = HexColor("#f57f17");
850 pub const YELLOW_A100: HexColor = HexColor("#ffff8d");
852 pub const YELLOW_A200: HexColor = HexColor("#ffff00");
854 pub const YELLOW_A400: HexColor = HexColor("#ffea00");
856 pub const YELLOW_A700: HexColor = HexColor("#ffd600");
858
859 pub const AMBER_50: HexColor = HexColor("#fff8e1");
861 pub const AMBER_100: HexColor = HexColor("#ffecb3");
863 pub const AMBER_200: HexColor = HexColor("#ffe082");
865 pub const AMBER_300: HexColor = HexColor("#ffd54f");
867 pub const AMBER_400: HexColor = HexColor("#ffca28");
869 pub const AMBER_500: HexColor = HexColor("#ffc107");
871 pub const AMBER_600: HexColor = HexColor("#ffb300");
873 pub const AMBER_700: HexColor = HexColor("#ffa000");
875 pub const AMBER_800: HexColor = HexColor("#ff8f00");
877 pub const AMBER_900: HexColor = HexColor("#ff6f00");
879 pub const AMBER_A100: HexColor = HexColor("#ffe57f");
881 pub const AMBER_A200: HexColor = HexColor("#ffd740");
883 pub const AMBER_A400: HexColor = HexColor("#ffc400");
885 pub const AMBER_A700: HexColor = HexColor("#ffab00");
887
888 pub const ORANGE_50: HexColor = HexColor("#fff3e0");
890 pub const ORANGE_100: HexColor = HexColor("#ffe0b2");
892 pub const ORANGE_200: HexColor = HexColor("#ffcc80");
894 pub const ORANGE_300: HexColor = HexColor("#ffb74d");
896 pub const ORANGE_400: HexColor = HexColor("#ffa726");
898 pub const ORANGE_500: HexColor = HexColor("#ff9800");
900 pub const ORANGE_600: HexColor = HexColor("#fb8c00");
902 pub const ORANGE_700: HexColor = HexColor("#f57c00");
904 pub const ORANGE_800: HexColor = HexColor("#ef6c00");
906 pub const ORANGE_900: HexColor = HexColor("#e65100");
908 pub const ORANGE_A100: HexColor = HexColor("#ffd180");
910 pub const ORANGE_A200: HexColor = HexColor("#ffab40");
912 pub const ORANGE_A400: HexColor = HexColor("#ff9100");
914 pub const ORANGE_A700: HexColor = HexColor("#ff6d00");
916
917 pub const DEEP_ORANGE_50: HexColor = HexColor("#fbe9e7");
919 pub const DEEP_ORANGE_100: HexColor = HexColor("#ffccbc");
921 pub const DEEP_ORANGE_200: HexColor = HexColor("#ffab91");
923 pub const DEEP_ORANGE_300: HexColor = HexColor("#ff8a65");
925 pub const DEEP_ORANGE_400: HexColor = HexColor("#ff7043");
927 pub const DEEP_ORANGE_500: HexColor = HexColor("#ff5722");
929 pub const DEEP_ORANGE_600: HexColor = HexColor("#f4511e");
931 pub const DEEP_ORANGE_700: HexColor = HexColor("#e64a19");
933 pub const DEEP_ORANGE_800: HexColor = HexColor("#d84315");
935 pub const DEEP_ORANGE_900: HexColor = HexColor("#bf360c");
937 pub const DEEP_ORANGE_A100: HexColor = HexColor("#ff9e80");
939 pub const DEEP_ORANGE_A200: HexColor = HexColor("#ff6e40");
941 pub const DEEP_ORANGE_A400: HexColor = HexColor("#ff3d00");
943 pub const DEEP_ORANGE_A700: HexColor = HexColor("#dd2c00");
945
946 pub const BROWN_50: HexColor = HexColor("#efebe9");
948 pub const BROWN_100: HexColor = HexColor("#d7ccc8");
950 pub const BROWN_200: HexColor = HexColor("#bcaaa4");
952 pub const BROWN_300: HexColor = HexColor("#a1887f");
954 pub const BROWN_400: HexColor = HexColor("#8d6e63");
956 pub const BROWN_500: HexColor = HexColor("#795548");
958 pub const BROWN_600: HexColor = HexColor("#6d4c41");
960 pub const BROWN_700: HexColor = HexColor("#5d4037");
962 pub const BROWN_800: HexColor = HexColor("#4e342e");
964 pub const BROWN_900: HexColor = HexColor("#3e2723");
966
967 pub const GREY_50: HexColor = HexColor("#fafafa");
969 pub const GREY_100: HexColor = HexColor("#f5f5f5");
971 pub const GREY_200: HexColor = HexColor("#eeeeee");
973 pub const GREY_300: HexColor = HexColor("#e0e0e0");
975 pub const GREY_400: HexColor = HexColor("#bdbdbd");
977 pub const GREY_500: HexColor = HexColor("#9e9e9e");
979 pub const GREY_600: HexColor = HexColor("#757575");
981 pub const GREY_700: HexColor = HexColor("#616161");
983 pub const GREY_800: HexColor = HexColor("#424242");
985 pub const GREY_900: HexColor = HexColor("#212121");
987
988 pub const BLUE_GREY_50: HexColor = HexColor("#eceff1");
990 pub const BLUE_GREY_100: HexColor = HexColor("#cfd8dc");
992 pub const BLUE_GREY_200: HexColor = HexColor("#b0bec5");
994 pub const BLUE_GREY_300: HexColor = HexColor("#90a4ae");
996 pub const BLUE_GREY_400: HexColor = HexColor("#78909c");
998 pub const BLUE_GREY_500: HexColor = HexColor("#607d8b");
1000 pub const BLUE_GREY_600: HexColor = HexColor("#546e7a");
1002 pub const BLUE_GREY_700: HexColor = HexColor("#455a64");
1004 pub const BLUE_GREY_800: HexColor = HexColor("#37474f");
1006 pub const BLUE_GREY_900: HexColor = HexColor("#263238");
1008
1009 pub const BLACK: HexColor = HexColor("#000000");
1011 pub const WHITE: HexColor = HexColor("#ffffff");
1013
1014 #[cfg(test)]
1015 mod tests {
1016 use super::*;
1017 use pretty_assertions::assert_eq;
1018 use rstest::rstest;
1019
1020 #[rstest]
1021 #[case::valid_hex(Some(HexColor("#ff0000")), "#ff0000")]
1022 #[case::valid_name(Some(RED_500), "red_500")]
1023 #[case::invalid_name(None, "red_5")]
1024 #[case::invalid_hex(None, "#ff00g0")]
1025 #[case::invalid_hex_no_hash(None, "ff0000")]
1026 #[case::invalid_hex_too_short(None, "#ff00")]
1027 #[case::invalid_hex_too_long(None, "#ff00000")]
1028 #[case::invalid_hex_no_hash_too_short(None, "ff00")]
1029 #[case::invalid_hex_no_hash_too_long(None, "ff00000")]
1030 fn test_parse(#[case] expected: Option<HexColor>, #[case] input: &'static str) {
1031 let actual = HexColor::parse(input);
1032 assert_eq!(actual, expected);
1033 }
1034 }
1035}