ai_code_buddy/
theme.rs

1use ratatui::style::{Color, Modifier, Style};
2
3pub struct Theme {
4    pub primary: Color,
5    pub secondary: Color,
6    pub accent: Color,
7    pub background: Color,
8    pub error: Color,
9    pub warning: Color,
10    pub success: Color,
11    pub info: Color,
12    pub text_primary: Color,
13}
14
15impl Default for Theme {
16    fn default() -> Self {
17        Self {
18            primary: Color::Cyan,
19            secondary: Color::Blue,
20            accent: Color::Magenta,
21            background: Color::Black,
22            error: Color::Red,
23            warning: Color::Yellow,
24            success: Color::Green,
25            info: Color::Blue,
26            text_primary: Color::White,
27        }
28    }
29}
30
31impl Theme {
32    pub fn title_style(&self) -> Style {
33        Style::default()
34            .fg(self.primary)
35            .add_modifier(Modifier::BOLD)
36    }
37
38    pub fn header_style(&self) -> Style {
39        Style::default()
40            .fg(self.secondary)
41            .add_modifier(Modifier::BOLD)
42    }
43
44    pub fn success_style(&self) -> Style {
45        Style::default()
46            .fg(self.success)
47            .add_modifier(Modifier::BOLD)
48    }
49
50    pub fn error_style(&self) -> Style {
51        Style::default().fg(self.error).add_modifier(Modifier::BOLD)
52    }
53
54    pub fn warning_style(&self) -> Style {
55        Style::default()
56            .fg(self.warning)
57            .add_modifier(Modifier::BOLD)
58    }
59
60    pub fn info_style(&self) -> Style {
61        Style::default().fg(self.info)
62    }
63
64    pub fn selected_style(&self) -> Style {
65        Style::default()
66            .bg(self.primary)
67            .fg(self.background)
68            .add_modifier(Modifier::BOLD)
69    }
70
71    pub fn button_style(&self, pressed: bool) -> Style {
72        if pressed {
73            Style::default()
74                .bg(self.accent)
75                .fg(self.background)
76                .add_modifier(Modifier::BOLD)
77        } else {
78            Style::default().fg(self.primary)
79        }
80    }
81
82    pub fn button_hover_style(&self) -> Style {
83        Style::default()
84            .bg(self.secondary)
85            .fg(self.text_primary)
86            .add_modifier(Modifier::BOLD)
87    }
88
89    pub fn button_normal_style(&self) -> Style {
90        Style::default()
91            .fg(self.primary)
92            .add_modifier(Modifier::DIM)
93    }
94
95    pub fn primary_style(&self) -> Style {
96        Style::default().fg(self.primary)
97    }
98}
99
100pub static THEME: Theme = Theme {
101    primary: Color::Cyan,
102    secondary: Color::Blue,
103    accent: Color::Magenta,
104    background: Color::Black,
105    error: Color::Red,
106    warning: Color::Yellow,
107    success: Color::Green,
108    info: Color::Blue,
109    text_primary: Color::White,
110};