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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
//! Named-color palette and severity helper for `Theme`.
//!
//! This module adds three new public types — [`NamedColor`], [`Palette`],
//! and [`Severity`] — plus three new methods on [`Theme`] (`color`,
//! `severity_color`, `severity_style`). Together they let consumers access
//! palette colors by name and bucket numeric values into a four-band
//! severity gradient without reaching for raw color constants.
//!
//! See the [theme module documentation](super) for an overview.
use ;
use Theme;
// =============================================================================
// Severity
// =============================================================================
/// A four-band severity gradient for value-based coloring (good → mild → bad → critical).
///
/// `Severity` provides a unified vocabulary for "color this number by how bad it is" —
/// the most common visual primitive in monitoring, profiling, and status dashboards.
/// Pair with [`Severity::from_thresholds`] to bucket a numeric value, then pass to
/// [`Theme::severity_color`] or [`Theme::severity_style`] for theme-aware coloring.
///
/// `#[non_exhaustive]` so envision can add severity bands later without breaking
/// downstream `match` arms.
///
/// # Example
///
/// ```rust
/// use envision::theme::{Severity, Theme};
///
/// let theme = Theme::catppuccin_mocha();
/// let ratio = 5.2;
/// let sev = Severity::from_thresholds(ratio, &[
/// (1.0, Severity::Good),
/// (3.0, Severity::Mild),
/// (10.0, Severity::Bad),
/// ]);
/// let style = theme.severity_style(sev);
/// // Use `style` in a Cell or StyledInline for value-coloring.
/// # let _ = style;
/// ```
// =============================================================================
// Named Palette Colors
// =============================================================================
/// A flat enum of 26 palette color names derived from Catppuccin Mocha — the most
/// complete shipped palette.
///
/// Use [`Theme::color`] to look up a named color in the active theme. Every theme
/// returns a sensible color for every variant via its [`Palette`] mapping; for
/// non-Catppuccin themes that lack a native equivalent, the mapping uses the
/// nearest-shade match (documented per theme).
///
/// `#[non_exhaustive]` so envision can add palette names later without breaking
/// downstream `match` arms.
///
/// # Example
///
/// ```rust
/// use envision::theme::{NamedColor, Theme};
///
/// let theme = Theme::catppuccin_mocha();
/// let lavender = theme.color(NamedColor::Lavender);
/// // Use `lavender` in a Style, Cell, or StyledInline span.
/// # let _ = lavender;
/// ```
// =============================================================================
// Palette
// =============================================================================
/// A complete 26-color palette mapping every [`NamedColor`] variant to a `Color`.
///
/// Each shipped theme stores a `Palette` populated at construction time. Custom user
/// themes can construct a `Palette` directly; no envision modification required.
///
/// # Example
///
/// Construct a custom palette for a hand-crafted theme:
///
/// ```rust
/// use envision::theme::Palette;
/// use ratatui::style::Color;
///
/// let palette = Palette {
/// rosewater: Color::Rgb(0xF5, 0xE0, 0xDC),
/// flamingo: Color::Rgb(0xF2, 0xCD, 0xCD),
/// pink: Color::Rgb(0xF5, 0xC2, 0xE7),
/// mauve: Color::Rgb(0xCB, 0xA6, 0xF7),
/// red: Color::Rgb(0xF3, 0x8B, 0xA8),
/// maroon: Color::Rgb(0xEB, 0xA0, 0xAC),
/// peach: Color::Rgb(0xFA, 0xB3, 0x87),
/// yellow: Color::Rgb(0xF9, 0xE2, 0xAF),
/// green: Color::Rgb(0xA6, 0xE3, 0xA1),
/// teal: Color::Rgb(0x94, 0xE2, 0xD5),
/// sky: Color::Rgb(0x89, 0xDC, 0xEB),
/// sapphire: Color::Rgb(0x74, 0xC7, 0xEC),
/// blue: Color::Rgb(0x89, 0xB4, 0xFA),
/// lavender: Color::Rgb(0xB4, 0xBE, 0xFE),
/// text: Color::Rgb(0xCD, 0xD6, 0xF4),
/// subtext1: Color::Rgb(0xBA, 0xC2, 0xDE),
/// subtext0: Color::Rgb(0xA6, 0xAD, 0xC8),
/// overlay2: Color::Rgb(0x93, 0x99, 0xB2),
/// overlay1: Color::Rgb(0x7F, 0x84, 0x9C),
/// overlay0: Color::Rgb(0x6C, 0x70, 0x86),
/// surface2: Color::Rgb(0x58, 0x5B, 0x70),
/// surface1: Color::Rgb(0x45, 0x47, 0x5A),
/// surface0: Color::Rgb(0x31, 0x32, 0x44),
/// base: Color::Rgb(0x1E, 0x1E, 0x2E),
/// mantle: Color::Rgb(0x18, 0x18, 0x25),
/// crust: Color::Rgb(0x11, 0x11, 0x1B),
/// };
/// # let _ = palette;
/// ```
// =============================================================================
// Theme accessors (color, severity_color, severity_style)
// =============================================================================