#![allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SemanticColor {
Success,
Warning,
Muted,
Info,
Accent,
Neutral,
}
pub fn status_semantic(status: &str) -> SemanticColor {
match status {
"normative" | "accepted" | "done" | "active" => SemanticColor::Success,
"draft" | "proposed" | "queue" => SemanticColor::Warning,
"deprecated" | "superseded" | "cancelled" => SemanticColor::Muted,
_ => SemanticColor::Neutral,
}
}
pub fn phase_semantic(phase: &str) -> SemanticColor {
match phase {
"stable" => SemanticColor::Success,
"test" => SemanticColor::Info,
"impl" => SemanticColor::Accent,
"spec" => SemanticColor::Warning,
_ => SemanticColor::Neutral,
}
}
pub fn status_icon(status: &str) -> &'static str {
match status {
"normative" | "accepted" | "done" => "●",
"active" => "◉",
"draft" | "proposed" | "queue" => "○",
"deprecated" | "superseded" | "cancelled" => "✗",
_ => "•",
}
}
impl SemanticColor {
pub fn to_owo(self) -> owo_colors::AnsiColors {
match self {
Self::Success => owo_colors::AnsiColors::Green,
Self::Warning => owo_colors::AnsiColors::Yellow,
Self::Muted => owo_colors::AnsiColors::BrightBlack,
Self::Info => owo_colors::AnsiColors::Cyan,
Self::Accent => owo_colors::AnsiColors::Blue,
Self::Neutral => owo_colors::AnsiColors::Default,
}
}
pub fn to_comfy(self) -> comfy_table::Color {
match self {
Self::Success => comfy_table::Color::Green,
Self::Warning => comfy_table::Color::Yellow,
Self::Muted => comfy_table::Color::DarkGrey,
Self::Info => comfy_table::Color::Cyan,
Self::Accent => comfy_table::Color::Blue,
Self::Neutral => comfy_table::Color::White,
}
}
#[cfg(feature = "tui")]
pub fn to_ratatui(self) -> ratatui::style::Color {
match self {
Self::Success => ratatui::style::Color::Green,
Self::Warning => ratatui::style::Color::Yellow,
Self::Muted => ratatui::style::Color::DarkGray,
Self::Info => ratatui::style::Color::Cyan,
Self::Accent => ratatui::style::Color::Blue,
Self::Neutral => ratatui::style::Color::Reset,
}
}
}