maycoon_theme/theme/
celeste.rs

1use peniko::{color::palette, Color};
2
3use crate::globals::Globals;
4use crate::id::WidgetId;
5use crate::style::{
6    DefaultContainerStyles, DefaultInteractiveStyles, DefaultStyles, DefaultTextStyles, Style,
7    StyleVal,
8};
9use crate::theme::Theme;
10
11/// A smooth and minimalistic theme with a cold blue and purple touch.
12#[derive(Debug, Clone)]
13pub enum CelesteTheme {
14    /// Use [`CelesteTheme::light`] to use the light Celeste theme.
15    Light(Globals),
16}
17
18impl CelesteTheme {
19    /// The Light Celeste Theme.
20    pub fn light() -> Self {
21        Self::Light(Globals::default())
22    }
23}
24
25impl Theme for CelesteTheme {
26    fn of(&self, id: WidgetId) -> Option<Style> {
27        match id.namespace() {
28            "maycoon-widgets" => match id.id() {
29                "Text" => Some(Style::from_values([
30                    ("color".to_string(), StyleVal::Color(palette::css::BLACK)),
31                    (
32                        "color_invert".to_string(),
33                        StyleVal::Color(palette::css::WHITE),
34                    ),
35                ])),
36
37                "Button" => Some(Style::from_values([
38                    (
39                        "color_idle".to_string(),
40                        StyleVal::Color(Color::from_rgb8(150, 170, 250)),
41                    ),
42                    (
43                        "color_pressed".to_string(),
44                        StyleVal::Color(Color::from_rgb8(130, 150, 230)),
45                    ),
46                    (
47                        "color_hovered".to_string(),
48                        StyleVal::Color(Color::from_rgb8(140, 160, 240)),
49                    ),
50                ])),
51
52                "Checkbox" => Some(Style::from_values([
53                    (
54                        "color_checked".to_string(),
55                        StyleVal::Color(Color::from_rgb8(130, 130, 230)),
56                    ),
57                    (
58                        "color_unchecked".to_string(),
59                        StyleVal::Color(Color::from_rgb8(170, 170, 250)),
60                    ),
61                ])),
62
63                "Slider" => Some(Style::from_values([
64                    (
65                        "color".to_string(),
66                        StyleVal::Color(Color::from_rgb8(130, 130, 230)),
67                    ),
68                    (
69                        "color_ball".to_string(),
70                        StyleVal::Color(Color::from_rgb8(170, 170, 250)),
71                    ),
72                ])),
73
74                _ => None,
75            },
76            _ => None,
77        }
78    }
79
80    fn defaults(&self) -> DefaultStyles {
81        DefaultStyles::new(
82            DefaultTextStyles::new(palette::css::BLACK, palette::css::WHITE_SMOKE),
83            DefaultContainerStyles::new(palette::css::ANTIQUE_WHITE, palette::css::WHITE),
84            DefaultInteractiveStyles::new(
85                Color::from_rgb8(130, 150, 230),
86                Color::from_rgb8(150, 170, 250),
87                Color::from_rgb8(140, 160, 240),
88                Color::from_rgb8(110, 110, 110),
89            ),
90        )
91    }
92
93    fn window_background(&self) -> Color {
94        Color::WHITE
95    }
96
97    fn globals(&self) -> &Globals {
98        match &self {
99            CelesteTheme::Light(globals) => globals,
100        }
101    }
102
103    fn globals_mut(&mut self) -> &mut Globals {
104        match self {
105            CelesteTheme::Light(globals) => globals,
106        }
107    }
108}