1use ratatui::style::{
4 Color,
5 Modifier,
6 Style,
7};
8
9#[derive(Debug, Clone, Copy, PartialEq, Default)]
11pub enum Theme {
12 #[default]
13 Dark,
14 Light,
15}
16
17impl Theme {
18 pub fn toggle(&self) -> Self {
20 match self {
21 Theme::Dark => Theme::Light,
22 Theme::Light => Theme::Dark,
23 }
24 }
25
26 pub fn background(&self) -> Color {
27 match self {
28 Theme::Dark => Color::Black,
29 Theme::Light => Color::White,
30 }
31 }
32
33 pub fn foreground(&self) -> Color {
34 match self {
35 Theme::Dark => Color::White,
36 Theme::Light => Color::Black,
37 }
38 }
39
40 pub fn border(&self) -> Color {
41 match self {
42 Theme::Dark => Color::Cyan,
43 Theme::Light => Color::Blue,
44 }
45 }
46
47 pub fn border_active(&self) -> Color {
48 match self {
49 Theme::Dark => Color::Green,
50 Theme::Light => Color::Green,
51 }
52 }
53
54 pub fn title(&self) -> Color {
55 match self {
56 Theme::Dark => Color::Yellow,
57 Theme::Light => Color::Blue,
58 }
59 }
60
61 pub fn success(&self) -> Color {
62 Color::Green
63 }
64
65 pub fn error(&self) -> Color {
66 Color::Red
67 }
68
69 pub fn warning(&self) -> Color {
70 Color::Yellow
71 }
72
73 pub fn info(&self) -> Color {
74 Color::Cyan
75 }
76
77 pub fn highlight(&self) -> Color {
78 match self {
79 Theme::Dark => Color::Blue,
80 Theme::Light => Color::LightBlue,
81 }
82 }
83
84 pub fn selection(&self) -> Color {
85 match self {
86 Theme::Dark => Color::DarkGray,
87 Theme::Light => Color::LightYellow,
88 }
89 }
90
91 pub fn line_number(&self) -> Color {
92 match self {
93 Theme::Dark => Color::DarkGray,
94 Theme::Light => Color::Gray,
95 }
96 }
97
98 pub fn normal_style(&self) -> Style {
99 Style::default().fg(self.foreground()).bg(self.background())
100 }
101
102 pub fn border_style(&self, active: bool) -> Style {
104 Style::default().fg(if active {
105 self.border_active()
106 } else {
107 self.border()
108 })
109 }
110
111 pub fn title_style(&self) -> Style {
112 Style::default()
113 .fg(self.title())
114 .add_modifier(Modifier::BOLD)
115 }
116
117 pub fn highlight_style(&self) -> Style {
118 Style::default().fg(self.foreground()).bg(self.highlight())
119 }
120
121 pub fn selection_style(&self) -> Style {
122 Style::default()
123 .fg(self.foreground())
124 .bg(self.selection())
125 .add_modifier(Modifier::BOLD)
126 }
127
128 pub fn error_style(&self) -> Style {
129 Style::default()
130 .fg(self.error())
131 .add_modifier(Modifier::BOLD)
132 }
133
134 pub fn success_style(&self) -> Style {
135 Style::default()
136 .fg(self.success())
137 .add_modifier(Modifier::BOLD)
138 }
139
140 pub fn warning_style(&self) -> Style {
141 Style::default()
142 .fg(self.warning())
143 .add_modifier(Modifier::BOLD)
144 }
145
146 pub fn info_style(&self) -> Style {
147 Style::default().fg(self.info())
148 }
149
150 pub fn line_number_style(&self) -> Style {
151 Style::default().fg(self.line_number())
152 }
153}