use ratatui::style::{Color, Style};
use ratatui::text::Span;
pub const DIM: Style = Style::new().fg(Color::DarkGray);
#[must_use]
pub fn dim_span<'a>(text: impl Into<std::borrow::Cow<'a, str>>) -> Span<'a> {
Span::styled(text, DIM)
}
#[must_use]
pub fn dim_span_trail(text: &str) -> Span<'static> {
Span::styled(format!("{text} "), DIM)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn dim_const_is_dark_gray_fg() {
assert_eq!(DIM.fg, Some(Color::DarkGray));
}
#[test]
fn dim_span_carries_dim_style() {
let s = dim_span("hello");
assert_eq!(s.style.fg, Some(Color::DarkGray));
assert_eq!(s.content, "hello");
}
#[test]
fn dim_span_trail_adds_trailing_space() {
let s = dim_span_trail("uptime");
assert_eq!(s.content, "uptime ");
assert_eq!(s.style.fg, Some(Color::DarkGray));
}
#[test]
fn dim_span_accepts_owned_strings() {
let owned = format!("{}", 42);
let s = dim_span(owned);
assert_eq!(s.content, "42");
}
#[test]
fn dim_span_accepts_static_strs() {
let s = dim_span("static");
assert_eq!(s.content, "static");
}
}