Skip to main content

hyprstream_compositor/
theme.rs

1//! Color constants and reusable styles for hyprstream TUI applications.
2
3use ratatui::style::{Color, Modifier, Style};
4use ratatui::text::{Line, Span};
5use ratatui::widgets::{Block, BorderType, Borders};
6
7// ── Palette ──
8pub const AMBER: Color = Color::Rgb(236, 201, 75);
9pub const CYAN: Color = Color::Rgb(0, 232, 252);
10pub const DIM: Color = Color::Rgb(112, 128, 160);
11pub const BG: Color = Color::Rgb(10, 10, 20);
12pub const BG_PANEL: Color = Color::Rgb(20, 20, 40);
13/// Floating modal background — slightly lighter than BG for visual separation.
14pub const BG_MODAL: Color = Color::Rgb(16, 16, 34);
15/// Lock icon color in window titlebars.
16pub const LOCK_COLOR: Color = Color::Rgb(136, 170, 255);
17
18// ── Block factories ──
19
20/// Width of the close button " x " rendered in block titlebars (including padding).
21pub const CLOSE_BUTTON_WIDTH: u16 = 3;
22
23fn close_button() -> Line<'static> {
24    Line::from(Span::styled(" x ", Style::default().fg(DIM))).right_aligned()
25}
26
27/// Rounded border block for pane windows, with focus-sensitive border color.
28pub fn window_block(title: Line<'_>, focused: bool) -> Block<'_> {
29    Block::new()
30        .borders(Borders::ALL)
31        .border_type(BorderType::Rounded)
32        .border_style(if focused {
33            border_focused_style()
34        } else {
35            border_style()
36        })
37        .title(title)
38        .title_top(close_button())
39        .style(Style::default().bg(BG))
40}
41
42/// Rounded border block for floating modals.
43pub fn modal_block(title: Line<'_>) -> Block<'_> {
44    Block::new()
45        .borders(Borders::ALL)
46        .border_type(BorderType::Rounded)
47        .border_style(border_focused_style())
48        .title(title)
49        .title_top(close_button())
50        .style(Style::default().bg(BG_MODAL))
51}
52
53/// Rounded border block for the multi-line input box in ChatApp.
54pub fn input_block() -> Block<'static> {
55    Block::new()
56        .borders(Borders::ALL)
57        .border_type(BorderType::Rounded)
58        .border_style(input_border_style())
59        .style(Style::default().bg(BG_PANEL))
60}
61
62pub fn border_focused_style() -> Style {
63    Style::default().fg(CYAN)
64}
65
66pub fn input_border_style() -> Style {
67    Style::default().fg(Color::Rgb(68, 85, 102))
68}
69
70pub fn gutter_style() -> Style {
71    Style::default().fg(DIM)
72}
73
74// ── Reusable styles ──
75
76pub fn title_style() -> Style {
77    Style::default().fg(AMBER).add_modifier(Modifier::BOLD)
78}
79
80pub fn tab_active() -> Style {
81    Style::default()
82        .fg(AMBER)
83        .bg(BG_PANEL)
84        .add_modifier(Modifier::BOLD)
85}
86
87pub fn tab_inactive() -> Style {
88    Style::default().fg(DIM).bg(BG)
89}
90
91pub fn status_style() -> Style {
92    Style::default().fg(DIM)
93}
94
95pub fn progress_filled() -> Style {
96    Style::default().fg(AMBER).bg(BG_PANEL)
97}
98
99pub fn border_style() -> Style {
100    Style::default().fg(DIM)
101}
102
103pub fn titlebar_style() -> Style {
104    Style::default().fg(CYAN).add_modifier(Modifier::BOLD)
105}
106
107pub fn titlebar_dim_style() -> Style {
108    Style::default().fg(DIM)
109}
110
111pub fn help_key() -> Style {
112    Style::default().fg(AMBER).add_modifier(Modifier::BOLD)
113}
114
115pub fn help_text() -> Style {
116    Style::default().fg(DIM)
117}