Initial upload: GitPulse - Developer Productivity Analyzer CLI tool
This commit is contained in:
75
src/ui/theme.rs
Normal file
75
src/ui/theme.rs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ThemeColors {
|
||||||
|
pub background: String,
|
||||||
|
pub foreground: String,
|
||||||
|
pub primary: String,
|
||||||
|
pub secondary: String,
|
||||||
|
pub accent: String,
|
||||||
|
pub error: String,
|
||||||
|
pub success: String,
|
||||||
|
pub warning: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ThemeColors {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
background: "#1a1b26".to_string(),
|
||||||
|
foreground: "#a9b1d6".to_string(),
|
||||||
|
primary: "#7aa2f7".to_string(),
|
||||||
|
secondary: "#9ece6a".to_string(),
|
||||||
|
accent: "#e0af68".to_string(),
|
||||||
|
error: "#f7768e".to_string(),
|
||||||
|
success: "#9ece6a".to_string(),
|
||||||
|
warning: "#ff9e64".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub enum Theme {
|
||||||
|
Dark,
|
||||||
|
Light,
|
||||||
|
Custom(ThemeColors),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Theme {
|
||||||
|
pub fn colors(&self) -> &ThemeColors {
|
||||||
|
match self {
|
||||||
|
Theme::Dark => &DARK_THEME,
|
||||||
|
Theme::Light => &LIGHT_THEME,
|
||||||
|
Theme::Custom(colors) => colors,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub static DARK_THEME: ThemeColors = ThemeColors {
|
||||||
|
background: "#1a1b26",
|
||||||
|
foreground: "#a9b1d6",
|
||||||
|
primary: "#7aa2f7",
|
||||||
|
secondary: "#9ece6a",
|
||||||
|
accent: "#e0af68",
|
||||||
|
error: "#f7768e",
|
||||||
|
success: "#9ece6a",
|
||||||
|
warning: "#ff9e64",
|
||||||
|
};
|
||||||
|
|
||||||
|
pub static LIGHT_THEME: ThemeColors = ThemeColors {
|
||||||
|
background: "#ffffff",
|
||||||
|
foreground: "#1a1a2e",
|
||||||
|
primary: "#0066cc",
|
||||||
|
secondary: "#28a745",
|
||||||
|
accent: "#ffc107",
|
||||||
|
error: "#dc3545",
|
||||||
|
success: "#28a745",
|
||||||
|
warning: "#fd7e14",
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn get_theme_from_string(s: &str) -> Theme {
|
||||||
|
match s.to_lowercase().as_str() {
|
||||||
|
"dark" => Theme::Dark,
|
||||||
|
"light" => Theme::Light,
|
||||||
|
_ => Theme::Dark,
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user