use ratatui::style::{Color, Modifier, Style};
pub struct Theme;
impl Theme {
pub const BG: Color = Color::Rgb(18, 18, 24);
pub const SURFACE: Color = Color::Rgb(28, 28, 36);
pub const BORDER: Color = Color::Rgb(58, 58, 72);
pub const BORDER_FOCUS: Color = Color::Rgb(120, 170, 255);
pub const TEXT: Color = Color::Rgb(230, 230, 236);
pub const DIM: Color = Color::Rgb(120, 120, 132);
pub const ACCENT: Color = Color::Rgb(120, 170, 255); pub const ACCENT_2: Color = Color::Rgb(130, 210, 170); pub const WARN: Color = Color::Rgb(230, 190, 100); pub const DANGER: Color = Color::Rgb(230, 110, 120); pub const CHIP_CRIT: Color = Color::Rgb(230, 80, 90);
pub const CHIP_HIGH: Color = Color::Rgb(230, 140, 90);
pub const CHIP_MED: Color = Color::Rgb(220, 190, 90);
pub const CHIP_LOW: Color = Color::Rgb(120, 160, 200);
pub fn root() -> Style {
Style::default().fg(Self::TEXT).bg(Self::BG)
}
pub fn surface() -> Style {
Style::default().fg(Self::TEXT).bg(Self::SURFACE)
}
pub fn title() -> Style {
Style::default()
.fg(Self::ACCENT)
.add_modifier(Modifier::BOLD)
}
pub fn section() -> Style {
Style::default().fg(Self::TEXT).add_modifier(Modifier::BOLD)
}
pub fn body() -> Style {
Style::default().fg(Self::TEXT)
}
pub fn dim() -> Style {
Style::default().fg(Self::DIM)
}
pub fn selected() -> Style {
Style::default()
.fg(Self::BG)
.bg(Self::ACCENT)
.add_modifier(Modifier::BOLD)
}
pub fn nav_active() -> Style {
Style::default()
.fg(Self::ACCENT)
.add_modifier(Modifier::BOLD)
}
pub fn ok() -> Style {
Style::default().fg(Self::ACCENT_2)
}
pub fn warn() -> Style {
Style::default().fg(Self::WARN)
}
pub fn danger() -> Style {
Style::default().fg(Self::DANGER)
}
pub fn border(focused: bool) -> Style {
if focused {
Style::default().fg(Self::BORDER_FOCUS)
} else {
Style::default().fg(Self::BORDER)
}
}
pub fn severity(severity: &str) -> Style {
let color = match severity.to_ascii_lowercase().as_str() {
"critical" | "crit" => Self::CHIP_CRIT,
"high" => Self::CHIP_HIGH,
"medium" | "med" => Self::CHIP_MED,
"low" => Self::CHIP_LOW,
_ => Self::DIM,
};
Style::default().fg(color).add_modifier(Modifier::BOLD)
}
pub fn status_chip(status: &str) -> Style {
match status {
"open" | "needs-human" => Self::danger(),
"passed" | "pass/open" | "resolved" | "flag/resolved" => Self::ok(),
"waived" | "flag" => Self::warn(),
_ => Self::dim(),
}
}
}