From 1c8531a00e6cfceaf5ad786a7a37db11b37a8947 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 15:45:47 +0000 Subject: [PATCH] Initial upload: GitPulse - Developer Productivity Analyzer CLI tool --- src/ui/theme.rs | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/ui/theme.rs diff --git a/src/ui/theme.rs b/src/ui/theme.rs new file mode 100644 index 0000000..b9a07bb --- /dev/null +++ b/src/ui/theme.rs @@ -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, + } +}