1use ratatui::style::{Color, Modifier, Style};
6
7#[derive(Debug, Clone)]
9pub struct Theme {
10 pub primary: Color,
12 #[allow(dead_code)]
14 pub secondary: Color,
15 pub success: Color,
17 pub error: Color,
19 pub warning: Color,
21 pub info: Color,
23 pub progress: Color,
25 #[allow(dead_code)]
27 pub background: Color,
28 pub foreground: Color,
30 pub border: Color,
32 pub border_focused: Color,
34 #[allow(dead_code)]
36 pub selection: Color,
37}
38
39impl Default for Theme {
40 fn default() -> Self {
41 Self {
42 primary: Color::Cyan,
43 secondary: Color::Blue,
44 success: Color::Green,
45 error: Color::Red,
46 warning: Color::Yellow,
47 info: Color::Blue,
48 progress: Color::Cyan,
49 background: Color::Black,
50 foreground: Color::White,
51 border: Color::DarkGray,
52 border_focused: Color::Cyan,
53 selection: Color::DarkGray,
54 }
55 }
56}
57
58impl Theme {
59 #[allow(dead_code)]
61 pub fn light() -> Self {
62 Self {
63 primary: Color::Blue,
64 secondary: Color::Cyan,
65 success: Color::Green,
66 error: Color::Red,
67 warning: Color::Yellow,
68 info: Color::Blue,
69 progress: Color::Cyan,
70 background: Color::White,
71 foreground: Color::Black,
72 border: Color::Gray,
73 border_focused: Color::Blue,
74 selection: Color::LightBlue,
75 }
76 }
77
78 pub fn text(&self) -> Style {
80 Style::default().fg(self.foreground)
81 }
82
83 pub fn text_dim(&self) -> Style {
85 Style::default().fg(Color::DarkGray)
86 }
87
88 pub fn title(&self) -> Style {
90 Style::default()
91 .fg(self.primary)
92 .add_modifier(Modifier::BOLD)
93 }
94
95 pub fn success(&self) -> Style {
97 Style::default().fg(self.success)
98 }
99
100 pub fn error(&self) -> Style {
102 Style::default().fg(self.error).add_modifier(Modifier::BOLD)
103 }
104
105 pub fn warning(&self) -> Style {
107 Style::default().fg(self.warning)
108 }
109
110 pub fn info(&self) -> Style {
112 Style::default().fg(self.info)
113 }
114
115 pub fn progress(&self) -> Style {
117 Style::default().fg(self.progress)
118 }
119
120 pub fn border(&self) -> Style {
122 Style::default().fg(self.border)
123 }
124
125 pub fn border_focused(&self) -> Style {
127 Style::default()
128 .fg(self.border_focused)
129 .add_modifier(Modifier::BOLD)
130 }
131
132 #[allow(dead_code)]
134 pub fn selected(&self) -> Style {
135 Style::default()
136 .bg(self.selection)
137 .add_modifier(Modifier::BOLD)
138 }
139
140 pub fn highlight(&self) -> Style {
142 Style::default()
143 .fg(self.primary)
144 .add_modifier(Modifier::BOLD)
145 }
146
147 pub fn dimmed(&self) -> Style {
149 Style::default()
150 .fg(Color::DarkGray)
151 .add_modifier(Modifier::DIM)
152 }
153}