1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//! Color themes and styling for TUI components.
use ratatui::style::{Color, Modifier, Style};
/// Zen minimalist color scheme for debtmap TUI
pub struct Theme {
/// Primary accent color (cyan for active elements)
pub primary: Color,
/// Success color (green for completed elements)
pub success: Color,
/// Muted color (dark gray for pending/inactive elements)
pub muted: Color,
/// Text color (white for normal text)
pub text: Color,
/// Background color (black/default)
pub background: Color,
}
impl Theme {
/// Create the default zen minimalist theme
pub fn default_theme() -> Self {
Self {
primary: Color::Cyan,
success: Color::Green,
muted: Color::DarkGray,
text: Color::White,
background: Color::Reset,
}
}
/// Accent color (alias for primary)
pub fn accent(&self) -> Color {
self.primary
}
/// Secondary color (alias for success)
pub fn secondary(&self) -> Color {
self.success
}
/// Success color (green for positive status messages)
pub fn success(&self) -> Color {
self.success
}
/// Warning color (yellow for warnings and errors)
pub fn warning(&self) -> Color {
Color::Yellow
}
/// Style for completed stage markers (✓)
pub fn completed_style(&self) -> Style {
Style::default().fg(self.success)
}
/// Style for active stage markers (▸)
pub fn active_style(&self) -> Style {
Style::default()
.fg(self.primary)
.add_modifier(Modifier::BOLD)
}
/// Style for pending stage markers (·)
pub fn pending_style(&self) -> Style {
Style::default().fg(self.muted)
}
/// Style for stage names (based on status)
pub fn stage_name_style(&self, is_active: bool) -> Style {
if is_active {
Style::default()
.fg(self.primary)
.add_modifier(Modifier::BOLD)
} else {
Style::default().fg(self.text)
}
}
/// Style for metrics and statistics
pub fn metric_style(&self) -> Style {
Style::default().fg(self.muted)
}
/// Style for progress bars
pub fn progress_bar_style(&self) -> Style {
Style::default().fg(self.primary)
}
/// Style for progress bar background
pub fn progress_bar_bg_style(&self) -> Style {
Style::default().fg(self.muted)
}
/// Style for dotted leaders
pub fn dotted_leader_style(&self) -> Style {
Style::default().fg(self.muted)
}
/// Style for animated arrows
pub fn arrow_style(&self) -> Style {
Style::default().fg(self.primary)
}
/// Style for elapsed time
pub fn time_style(&self) -> Style {
Style::default().fg(self.muted)
}
/// Get primary accent color (Spec 205)
pub fn primary_color(&self) -> Color {
self.primary
}
/// Get muted/dim color (Spec 205)
pub fn muted_color(&self) -> Color {
self.muted
}
/// Color for coupling classification badge (spec 203)
///
/// Returns appropriate color based on classification type:
/// - Stable Core: Green (healthy core module)
/// - Utility Module: Cyan (normal utility)
/// - Leaf Module: Yellow (attention - peripheral)
/// - Isolated: Gray (neutral - low coupling)
/// - Highly Coupled: Red (warning - needs refactoring)
pub fn coupling_classification_color(&self, classification: &str) -> Color {
match classification.to_lowercase().as_str() {
"stable core" => Color::Green,
"utility module" => Color::Cyan,
"leaf module" => Color::Yellow,
"isolated" => Color::DarkGray,
"highly coupled" => Color::Red,
_ => Color::White,
}
}
/// Color for instability gradient (spec 203)
///
/// Returns a color on the green-yellow-red gradient based on instability value:
/// - 0.0 (stable): Green
/// - 0.5 (balanced): Yellow
/// - 1.0 (unstable): Red
pub fn instability_color(&self, instability: f64) -> Color {
if instability < 0.3 {
Color::Green
} else if instability < 0.7 {
Color::Yellow
} else {
Color::Red
}
}
/// Style for coupling classification badge (spec 203)
pub fn coupling_badge_style(&self, classification: &str) -> Style {
Style::default()
.fg(self.coupling_classification_color(classification))
.add_modifier(Modifier::BOLD)
}
}
impl Default for Theme {
fn default() -> Self {
Self::default_theme()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_theme_creation() {
let theme = Theme::default_theme();
assert_eq!(theme.primary, Color::Cyan);
assert_eq!(theme.success, Color::Green);
assert_eq!(theme.muted, Color::DarkGray);
}
#[test]
fn test_style_consistency() {
let theme = Theme::default_theme();
let completed = theme.completed_style();
let active = theme.active_style();
// Verify colors are distinct
assert_ne!(completed.fg, active.fg);
}
// Tests for spec 203: Coupling visualization colors
#[test]
fn test_coupling_classification_colors() {
let theme = Theme::default_theme();
assert_eq!(
theme.coupling_classification_color("stable core"),
Color::Green
);
assert_eq!(
theme.coupling_classification_color("Stable Core"),
Color::Green
);
assert_eq!(
theme.coupling_classification_color("utility module"),
Color::Cyan
);
assert_eq!(
theme.coupling_classification_color("leaf module"),
Color::Yellow
);
assert_eq!(
theme.coupling_classification_color("isolated"),
Color::DarkGray
);
assert_eq!(
theme.coupling_classification_color("highly coupled"),
Color::Red
);
assert_eq!(theme.coupling_classification_color("unknown"), Color::White);
}
#[test]
fn test_instability_color_gradient() {
let theme = Theme::default_theme();
// Stable (low instability) = green
assert_eq!(theme.instability_color(0.0), Color::Green);
assert_eq!(theme.instability_color(0.2), Color::Green);
// Balanced (mid instability) = yellow
assert_eq!(theme.instability_color(0.3), Color::Yellow);
assert_eq!(theme.instability_color(0.5), Color::Yellow);
assert_eq!(theme.instability_color(0.69), Color::Yellow);
// Unstable (high instability) = red
assert_eq!(theme.instability_color(0.7), Color::Red);
assert_eq!(theme.instability_color(1.0), Color::Red);
}
#[test]
fn test_coupling_badge_style_has_bold() {
let theme = Theme::default_theme();
let style = theme.coupling_badge_style("stable core");
assert!(style.add_modifier.contains(Modifier::BOLD));
assert_eq!(style.fg, Some(Color::Green));
}
}