scrin 0.1.75

A terminal UI toolkit with panes, widgets, overlays, animations, and Aisling-powered effects/loaders.
Documentation
use crate::core::color::Color;

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Theme {
    pub bg: Color,
    pub fg: Color,
    pub accent: Color,
    pub accent_bright: Color,
    pub muted: Color,
    pub surface: Color,
    pub surface_bright: Color,
    pub error: Color,
    pub warning: Color,
    pub success: Color,
    pub info: Color,
    pub border: Color,
    pub border_focus: Color,
    pub text_primary: Color,
    pub text_secondary: Color,
    pub text_dim: Color,
    pub highlight_bg: Color,
    pub highlight_fg: Color,
    pub glow: Color,
}

impl Theme {
    pub const DARK: Theme = Theme {
        bg: Color::rgb(13, 17, 23),
        fg: Color::rgb(201, 209, 217),
        accent: Color::rgb(88, 166, 255),
        accent_bright: Color::rgb(121, 192, 255),
        muted: Color::rgb(110, 118, 129),
        surface: Color::rgb(22, 27, 34),
        surface_bright: Color::rgb(33, 38, 45),
        error: Color::rgb(248, 81, 73),
        warning: Color::rgb(210, 153, 34),
        success: Color::rgb(63, 185, 80),
        info: Color::rgb(56, 139, 253),
        border: Color::rgb(48, 54, 61),
        border_focus: Color::rgb(88, 166, 255),
        text_primary: Color::rgb(201, 209, 217),
        text_secondary: Color::rgb(139, 148, 158),
        text_dim: Color::rgb(110, 118, 129),
        highlight_bg: Color::rgb(31, 111, 235),
        highlight_fg: Color::rgb(255, 255, 255),
        glow: Color::rgb(88, 166, 255),
    };

    pub const CYBERPUNK: Theme = Theme {
        bg: Color::rgb(10, 4, 18),
        fg: Color::rgb(200, 200, 255),
        accent: Color::rgb(255, 0, 128),
        accent_bright: Color::rgb(255, 80, 180),
        muted: Color::rgb(100, 60, 140),
        surface: Color::rgb(20, 10, 35),
        surface_bright: Color::rgb(35, 18, 55),
        error: Color::rgb(255, 30, 30),
        warning: Color::rgb(255, 200, 0),
        success: Color::rgb(0, 255, 128),
        info: Color::rgb(0, 200, 255),
        border: Color::rgb(60, 30, 90),
        border_focus: Color::rgb(255, 0, 128),
        text_primary: Color::rgb(220, 220, 255),
        text_secondary: Color::rgb(150, 130, 180),
        text_dim: Color::rgb(90, 70, 120),
        highlight_bg: Color::rgb(255, 0, 128),
        highlight_fg: Color::rgb(255, 255, 255),
        glow: Color::rgb(255, 0, 128),
    };

    pub const MONOKAI: Theme = Theme {
        bg: Color::rgb(39, 40, 34),
        fg: Color::rgb(248, 248, 242),
        accent: Color::rgb(166, 226, 46),
        accent_bright: Color::rgb(171, 227, 56),
        muted: Color::rgb(117, 113, 94),
        surface: Color::rgb(49, 50, 44),
        surface_bright: Color::rgb(69, 71, 66),
        error: Color::rgb(249, 38, 114),
        warning: Color::rgb(230, 219, 100),
        success: Color::rgb(166, 226, 46),
        info: Color::rgb(102, 217, 239),
        border: Color::rgb(79, 82, 76),
        border_focus: Color::rgb(166, 226, 46),
        text_primary: Color::rgb(248, 248, 242),
        text_secondary: Color::rgb(171, 174, 167),
        text_dim: Color::rgb(117, 113, 94),
        highlight_bg: Color::rgb(73, 72, 62),
        highlight_fg: Color::rgb(255, 255, 255),
        glow: Color::rgb(166, 226, 46),
    };

    pub const SOLARIZED: Theme = Theme {
        bg: Color::rgb(0, 43, 54),
        fg: Color::rgb(131, 148, 150),
        accent: Color::rgb(38, 139, 210),
        accent_bright: Color::rgb(42, 161, 152),
        muted: Color::rgb(88, 110, 117),
        surface: Color::rgb(7, 54, 66),
        surface_bright: Color::rgb(0, 63, 77),
        error: Color::rgb(220, 50, 47),
        warning: Color::rgb(181, 137, 0),
        success: Color::rgb(133, 153, 0),
        info: Color::rgb(42, 161, 152),
        border: Color::rgb(88, 110, 117),
        border_focus: Color::rgb(38, 139, 210),
        text_primary: Color::rgb(147, 161, 161),
        text_secondary: Color::rgb(108, 113, 118),
        text_dim: Color::rgb(88, 110, 117),
        highlight_bg: Color::rgb(0, 63, 77),
        highlight_fg: Color::rgb(253, 246, 227),
        glow: Color::rgb(42, 161, 152),
    };

    pub fn accent_for(&self, index: usize) -> Color {
        let colors = [
            self.accent,
            self.success,
            self.warning,
            self.error,
            self.info,
            Color::rgb(188, 140, 255),
            Color::rgb(255, 160, 180),
            Color::rgb(100, 220, 255),
        ];
        colors[index % colors.len()]
    }
}

impl Default for Theme {
    fn default() -> Self {
        Self::DARK
    }
}