oxur_cli/table/
themes.rs

1//! Embedded default themes
2
3use super::config::TableStyleConfig;
4
5/// The default Oxur theme with warm orange sunset colors
6pub const OXUR_DEFAULT: &str = r##"[table]
7padding_left = 0
8padding_right = 0
9padding_top = 0
10padding_bottom = 0
11
12[title]
13enabled = true
14bg_color = "#F97316"
15fg_color = "#451A03"
16justification_char = " "
17vertical_fg_color = "#F97316"
18
19[header]
20bg_color = "#D45500"
21fg_color = "#451A03"
22# Ligher shades of the dark brown, useful for web text, etc.:
23# #6c2905
24# #8a3507
25# #a94109
26# Darker shades of the dark brown, useful for web backgrounds, etc.:
27# #280f02ff
28# #361402
29# #261002
30
31justification_char = " "
32vertical_char = "│"
33vertical_bg_color = "#D45500"
34vertical_fg_color = "#D45500"
35
36[rows]
37colors = [
38    { bg = "#451A03", fg = "#FED7AA" },
39    { bg = "#451A03", fg = "#FDBA74" }
40]
41justification_char = " "
42
43[style]
44vertical_bg_color = "#451A03"
45vertical_fg_color = "#803300"
46
47[footer]
48enabled = true
49bg_color = "#803300"
50fg_color = "#D45500"
51vertical_bg_color = "#803300"
52vertical_fg_color = "#803300"
53"##;
54
55impl Default for TableStyleConfig {
56    fn default() -> Self {
57        toml::from_str(OXUR_DEFAULT).expect("Default Oxur theme should be valid TOML")
58    }
59}
60
61#[cfg(test)]
62mod tests {
63    use super::*;
64
65    #[test]
66    fn test_default_theme_is_valid_toml() {
67        // The default theme should parse without panicking
68        let config = TableStyleConfig::default();
69
70        // Verify basic structure
71        assert_eq!(config.table.padding_left, 0);
72        assert_eq!(config.table.padding_right, 0);
73        assert_eq!(config.table.padding_top, 0);
74        assert_eq!(config.table.padding_bottom, 0);
75    }
76
77    #[test]
78    fn test_default_theme_has_title_config() {
79        let config = TableStyleConfig::default();
80
81        assert!(config.title.is_some());
82        let title = config.title.unwrap();
83        assert!(title.enabled);
84        assert_eq!(title.bg_color.as_deref(), Some("#F97316"));
85        assert_eq!(title.fg_color.as_deref(), Some("#451A03"));
86    }
87
88    #[test]
89    fn test_default_theme_has_header_config() {
90        let config = TableStyleConfig::default();
91
92        assert_eq!(config.header.bg_color, "#D45500");
93        assert_eq!(config.header.fg_color, "#451A03");
94        assert_eq!(config.header.justification_char, " ");
95    }
96
97    #[test]
98    fn test_default_theme_has_row_colors() {
99        let config = TableStyleConfig::default();
100
101        assert_eq!(config.rows.colors.len(), 2);
102        assert_eq!(config.rows.colors[0].bg, "#451A03");
103        assert_eq!(config.rows.colors[0].fg, "#FED7AA");
104        assert_eq!(config.rows.colors[1].bg, "#451A03");
105        assert_eq!(config.rows.colors[1].fg, "#FDBA74");
106    }
107
108    #[test]
109    fn test_default_theme_has_footer_config() {
110        let config = TableStyleConfig::default();
111
112        assert!(config.footer.is_some());
113        let footer = config.footer.unwrap();
114        assert!(footer.enabled);
115        assert_eq!(footer.bg_color.as_deref(), Some("#803300"));
116        assert_eq!(footer.fg_color.as_deref(), Some("#D45500"));
117    }
118
119    #[test]
120    fn test_oxur_default_const_parses() {
121        // Ensure the constant string itself is valid TOML
122        let result: Result<TableStyleConfig, _> = toml::from_str(OXUR_DEFAULT);
123        assert!(result.is_ok());
124    }
125}