use crossterm::style::Color;
pub const CYAN: Color = Color::Rgb {
r: 118,
g: 217,
b: 224,
};
pub const GREEN: Color = Color::Rgb {
r: 63,
g: 185,
b: 80,
};
pub const YELLOW: Color = Color::Rgb {
r: 210,
g: 153,
b: 34,
};
pub const RED: Color = Color::Rgb {
r: 248,
g: 81,
b: 73,
};
pub const BLUE: Color = Color::Rgb {
r: 88,
g: 166,
b: 255,
};
pub const PURPLE: Color = Color::Rgb {
r: 163,
g: 113,
b: 247,
};
pub const ORANGE: Color = Color::Rgb {
r: 219,
g: 109,
b: 40,
};
pub const FG: Color = Color::Rgb {
r: 230,
g: 237,
b: 243,
};
pub const FG_DIM: Color = Color::Rgb {
r: 139,
g: 148,
b: 158,
};
pub const FG_SUBTLE: Color = Color::Rgb {
r: 88,
g: 96,
b: 105,
};
pub const BG: Color = Color::Rgb {
r: 13,
g: 17,
b: 23,
};
pub const BG_SUBTLE: Color = Color::Rgb {
r: 22,
g: 27,
b: 34,
};
pub const BG_INSET: Color = Color::Rgb { r: 1, g: 4, b: 9 };
pub const BORDER: Color = Color::Rgb {
r: 48,
g: 54,
b: 61,
};
pub const BORDER_MUTED: Color = Color::Rgb {
r: 33,
g: 38,
b: 45,
};
pub const SUCCESS: Color = GREEN;
pub const ERROR: Color = RED;
pub const WARNING: Color = YELLOW;
pub const INFO: Color = BLUE;
pub fn status_color(success: bool) -> Color {
if success {
SUCCESS
} else {
ERROR
}
}
pub fn build_color(building: bool, success: bool) -> Color {
if building {
YELLOW
} else if success {
GREEN
} else {
RED
}
}
pub fn priority_color(level: u8) -> Color {
match level {
0 => RED, 1 => ORANGE, 2 => YELLOW, 3 => BLUE, _ => FG_DIM, }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_status_color() {
assert_eq!(status_color(true), SUCCESS);
assert_eq!(status_color(false), ERROR);
}
#[test]
fn test_build_color() {
assert_eq!(build_color(true, false), YELLOW);
assert_eq!(build_color(false, true), GREEN);
assert_eq!(build_color(false, false), RED);
}
#[test]
fn test_priority_color() {
assert_eq!(priority_color(0), RED);
assert_eq!(priority_color(1), ORANGE);
assert_eq!(priority_color(2), YELLOW);
assert_eq!(priority_color(3), BLUE);
assert_eq!(priority_color(4), FG_DIM);
}
#[test]
fn test_priority_color_high_values() {
assert_eq!(priority_color(5), FG_DIM);
assert_eq!(priority_color(100), FG_DIM);
assert_eq!(priority_color(255), FG_DIM);
}
#[test]
fn test_primary_colors() {
assert!(matches!(CYAN, Color::Rgb { .. }));
assert!(matches!(GREEN, Color::Rgb { .. }));
assert!(matches!(YELLOW, Color::Rgb { .. }));
assert!(matches!(RED, Color::Rgb { .. }));
assert!(matches!(BLUE, Color::Rgb { .. }));
assert!(matches!(PURPLE, Color::Rgb { .. }));
assert!(matches!(ORANGE, Color::Rgb { .. }));
}
#[test]
fn test_foreground_colors() {
assert!(matches!(FG, Color::Rgb { .. }));
assert!(matches!(FG_DIM, Color::Rgb { .. }));
assert!(matches!(FG_SUBTLE, Color::Rgb { .. }));
}
#[test]
fn test_background_colors() {
assert!(matches!(BG, Color::Rgb { .. }));
assert!(matches!(BG_SUBTLE, Color::Rgb { .. }));
assert!(matches!(BG_INSET, Color::Rgb { .. }));
}
#[test]
fn test_border_colors() {
assert!(matches!(BORDER, Color::Rgb { .. }));
assert!(matches!(BORDER_MUTED, Color::Rgb { .. }));
}
#[test]
fn test_semantic_color_aliases() {
assert_eq!(SUCCESS, GREEN);
assert_eq!(ERROR, RED);
assert_eq!(WARNING, YELLOW);
assert_eq!(INFO, BLUE);
}
#[test]
fn test_build_color_building_overrides() {
assert_eq!(build_color(true, true), YELLOW);
assert_eq!(build_color(true, false), YELLOW);
}
}