use ratatui::style::Color;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Theme {
pub fg: Color,
pub fg_dim: Color,
pub fg_muted: Color,
pub accent: Color,
pub border: Color,
pub selected_bg: Option<Color>,
pub marker: &'static str,
pub marker_width: u16,
}
pub const CLAUDE: Theme = Theme {
fg: Color::Rgb(0xaf, 0xd7, 0xff),
fg_dim: Color::Rgb(0xc0, 0xca, 0xf5),
fg_muted: Color::Rgb(0x94, 0x94, 0x94),
accent: Color::Rgb(0xcd, 0x69, 0x4a),
border: Color::Rgb(0xcd, 0x69, 0x4a),
selected_bg: None,
marker: "❯",
marker_width: 1,
};
pub const CODEX: Theme = Theme {
fg: Color::Rgb(0xed, 0xed, 0xed),
fg_dim: Color::Rgb(0xed, 0xed, 0xed),
fg_muted: Color::Rgb(0x7a, 0x7a, 0x7a),
accent: Color::Rgb(0xf6, 0xe2, 0xb7),
border: Color::Rgb(0x7a, 0x7a, 0x7a),
selected_bg: None,
marker: "›",
marker_width: 1,
};
pub const GROK: Theme = Theme {
fg: Color::Rgb(0xe1, 0xe1, 0xe1),
fg_dim: Color::Rgb(0x8b, 0x8b, 0x90),
fg_muted: Color::Rgb(0x6c, 0x6c, 0x6c),
accent: Color::Rgb(0xe1, 0xe1, 0xe1),
border: Color::Rgb(0x80, 0x80, 0x80),
selected_bg: None,
marker: "❯",
marker_width: 2,
};
impl Default for Theme {
fn default() -> Self {
CLAUDE
}
}
#[must_use]
pub fn lookup(name: &str) -> Option<Theme> {
match name.to_ascii_lowercase().as_str() {
"claude" => Some(CLAUDE),
"codex" => Some(CODEX),
"grok" => Some(GROK),
_ => None,
}
}
impl Theme {
#[must_use]
pub fn from_name(name: &str) -> Option<Self> {
lookup(name)
}
#[must_use]
pub fn from_env(var_name: &str) -> Option<Self> {
let raw = std::env::var(var_name).ok()?;
let trimmed = raw.trim();
if trimmed.is_empty() {
return None;
}
Self::from_name(trimmed)
}
#[must_use]
pub fn from_env_or(var_name: &str, default: Self) -> Self {
Self::from_env(var_name).unwrap_or(default)
}
#[must_use]
pub const fn all() -> &'static [Self] {
&[CLAUDE, CODEX, GROK]
}
#[must_use]
pub const fn names() -> &'static [&'static str] {
&["claude", "codex", "grok"]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_is_claude() {
assert_eq!(Theme::default(), CLAUDE);
}
#[test]
fn themes_are_distinct() {
assert_ne!(CLAUDE, CODEX);
assert_ne!(CLAUDE, GROK);
assert_ne!(CODEX, GROK);
}
}