Skip to main content

diffler_graph/
theme.rs

1//! The colors the graph renderer needs, supplied by the host so the component
2//! stays independent of any particular app's theme.
3
4use ratatui::style::Color;
5
6#[derive(Debug, Clone, Copy)]
7pub struct GraphTheme {
8    /// Default background and node text/foreground.
9    pub bg: Color,
10    pub fg: Color,
11    pub dim: Color,
12    /// Status colors for node borders/labels.
13    pub ok: Color,
14    pub failed: Color,
15    pub running: Color,
16    pub queued: Color,
17    /// Bottom-bar / panel background.
18    pub panel: Color,
19}
20
21impl GraphTheme {
22    /// The color for a node status.
23    pub(crate) fn status(&self, status: crate::model::NodeStatus) -> Color {
24        use crate::model::NodeStatus;
25        match status {
26            NodeStatus::Ok => self.ok,
27            NodeStatus::Failed => self.failed,
28            NodeStatus::Running => self.running,
29            NodeStatus::Queued | NodeStatus::Skipped => self.queued,
30            NodeStatus::Neutral => self.fg,
31        }
32    }
33}