Skip to main content

max / alloy_tui

1.7 KB · 51 lines History Blame Raw
1 //! Themed span helpers.
2 //!
3 //! sysop-tui's `style.rs` offered the same set (`fg`, `dim`, `bold`, `ok`,
4 //! `warn`, `fault`) against a const palette. Alloy's palette is loaded at
5 //! runtime, so each helper takes the `&Theme` instead. The status-colored
6 //! variants are gone: they collapse into [`Severity`](crate::Severity), which
7 //! already owns the mapping from intent to `status.*` color.
8
9 use ratatui::style::{Modifier, Style};
10 use ratatui::text::Span;
11
12 use crate::theme::Theme;
13
14 /// Body text in the primary content color.
15 pub fn primary(theme: &Theme, s: impl Into<String>) -> Span<'static> {
16 Span::styled(
17 s.into(),
18 Style::default().fg(theme.makeover.content_primary),
19 )
20 }
21
22 /// De-emphasized text — labels, units, inactive rows.
23 pub fn muted(theme: &Theme, s: impl Into<String>) -> Span<'static> {
24 Span::styled(s.into(), Style::default().fg(theme.makeover.content_muted))
25 }
26
27 /// Supporting text: dimmer than primary, louder than muted.
28 pub fn secondary(theme: &Theme, s: impl Into<String>) -> Span<'static> {
29 Span::styled(
30 s.into(),
31 Style::default().fg(theme.makeover.content_secondary),
32 )
33 }
34
35 /// Emphasized body text.
36 pub fn bold(theme: &Theme, s: impl Into<String>) -> Span<'static> {
37 Span::styled(
38 s.into(),
39 Style::default()
40 .fg(theme.makeover.content_primary)
41 .add_modifier(Modifier::BOLD),
42 )
43 }
44
45 /// A key hint or other interactive affordance. The one accent-on-text use that
46 /// is not a `Severity` — DESIGN-LANGUAGE.md allows the action color here
47 /// because a key hint *is* the actionable element, not decoration.
48 pub fn action(theme: &Theme, s: impl Into<String>) -> Span<'static> {
49 Span::styled(s.into(), Style::default().fg(theme.makeover.action_primary))
50 }
51