leetcode_tui_config/
theme.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
pub mod color;
pub mod style;

use crate::theme::style::Style;
use serde::{Deserialize, Serialize};

use self::color::Color;

#[derive(Serialize, Debug, Deserialize)]
pub struct Difficulty {
    pub easy: Style,
    pub medium: Style,
    pub hard: Style,
}

#[derive(Serialize, Debug, Deserialize)]
pub struct Question {
    pub normal: Difficulty,
    pub hovered: Difficulty,
}

#[derive(Serialize, Debug, Deserialize)]
pub struct Topic {
    pub normal: Style,
    pub hovered: Style,
}

#[derive(Serialize, Debug, Deserialize)]
pub struct Border {
    pub normal: Style,
    pub hovered: Style,
}

#[derive(Serialize, Debug, Deserialize)]
pub struct Defaults {
    pub bg_dark: Color,
    pub bg: Color,
    pub bg_highlight: Color,
    pub terminal_black: Color,
    pub fg: Color,
    pub fg_dark: Color,
    pub fg_gutter: Color,
    pub dark3: Color,
    pub comment: Color,
    pub dark5: Color,
    pub info: Color,
}

#[derive(Serialize, Debug, Deserialize)]
pub struct Theme {
    pub question: Question,
    pub topic: Topic,
    pub border: Border,
    pub defaults: Defaults,
}

impl Default for Theme {
    fn default() -> Self {
        toml::from_str(
            r#"
            [question.normal]
            easy = { fg = '#9ece6a' }
            medium = { fg = '#e0af68' }
            hard = { fg = '#f7768e' }

            [question.hovered]
            easy = { fg = '#9ece6a', bg = '#292e42', bold = true }
            medium = { fg = '#e0af68', bg = '#292e42', bold = true }
            hard = { fg = '#f7768e', bg = '#292e42', bold = true }

            [topic]
            normal = { fg = '#a9b1d6' }
            hovered = { fg = '#c0caf5', bg = '#292e42', bold = true }

            [border]
            hovered = { fg = '#7dcfff', bold = true }
            normal = { fg = '#a9b1d6' }

            [defaults]
            bg_dark = '#1f2335'
            bg = '#24283b'
            bg_highlight = '#292e42'
            terminal_black = '#414868'
            fg = '#c0caf5'
            fg_dark = '#a9b1d6'
            fg_gutter = '#3b4261'
            dark3 = '#545c7e'
            comment = '#565f89'
            dark5 = '#737aa2'
            info = '#7dcfff'
        "#,
        )
        .unwrap()
    }
}