use crate::terminal::ColorSupport;
use ratatui::style::Color;
pub struct Theme {
pub bg: Color,
pub fg: Color,
pub text_dim: Color,
pub accent_primary: Color,
pub accent_secondary: Color,
pub header_bg: Color,
pub selection_bg: Color,
pub selection_fg: Color,
pub surface: Color,
pub bar_empty: Color,
pub success: Color,
pub warning: Color,
pub danger: Color,
pub sleeping: Color,
}
impl Default for Theme {
fn default() -> Self {
Self::new(ColorSupport::TrueColor)
}
}
impl Theme {
pub fn new(support: ColorSupport) -> Self {
if support == ColorSupport::TrueColor {
Self {
bg: Color::Rgb(26, 27, 38), fg: Color::Rgb(192, 202, 245), text_dim: Color::Rgb(86, 95, 137), accent_primary: Color::Rgb(125, 207, 255), accent_secondary: Color::Rgb(187, 154, 247), header_bg: Color::Rgb(36, 40, 59), selection_bg: Color::Rgb(55, 65, 115), selection_fg: Color::Rgb(255, 255, 255), surface: Color::Rgb(30, 32, 48), bar_empty: Color::Rgb(40, 44, 62),
success: Color::Rgb(158, 206, 106), warning: Color::Rgb(224, 175, 104), danger: Color::Rgb(247, 118, 142), sleeping: Color::Rgb(86, 95, 137), }
} else {
Self {
bg: Color::Reset,
fg: Color::White,
text_dim: Color::DarkGray,
accent_primary: Color::Cyan,
accent_secondary: Color::Magenta,
header_bg: Color::DarkGray,
selection_bg: Color::DarkGray,
selection_fg: Color::White,
surface: Color::Reset,
bar_empty: Color::DarkGray,
success: Color::Green,
warning: Color::Yellow,
danger: Color::Red,
sleeping: Color::DarkGray,
}
}
}
pub fn gauge_color(&self, percent: f64) -> Color {
if percent >= 80.0 {
self.danger
} else if percent >= 50.0 {
self.warning
} else {
self.success
}
}
}