1use termimad::crossterm::style::Color;
4use termimad::{Alignment, CompoundStyle, MadSkin};
5
6#[derive(Debug, Clone)]
8pub struct HelpTheme {
9 pub accent: Color,
10 pub skin: MadSkin,
11}
12
13impl HelpTheme {
14 pub fn new(mut skin: MadSkin, accent: Color) -> Self {
16 apply_accent(&mut skin, accent);
17 Self { accent, skin }
18 }
19
20 pub fn light(accent: Color) -> Self {
22 Self::new(MadSkin::default_light(), accent)
23 }
24
25 pub fn dark(accent: Color) -> Self {
27 Self::new(MadSkin::default_dark(), accent)
28 }
29
30 pub fn default(accent: Color) -> Self {
32 if terminal_light::luma().map_or(false, |luma| luma > 0.6) {
33 Self::light(accent)
34 } else {
35 Self::dark(accent)
36 }
37 }
38}
39
40pub fn apply_accent(skin: &mut MadSkin, accent: Color) {
42 skin.set_headers_fg(accent);
43 skin.headers[0].align = Alignment::Center;
44 skin.bold.set_fg(accent);
45 skin.italic.set_fg(Color::DarkGrey);
46 skin.strikeout = CompoundStyle::with_fg(accent);
47 skin.scrollbar.thumb.set_fg(accent);
48 skin.table_border_chars = termimad::ROUNDED_TABLE_BORDER_CHARS;
49}