Skip to main content

vtcode_ui/design/
constants.rs

1//! Shared design constants: ellipses, layout breakpoints, spacing tokens.
2//!
3//! These constants are the single source of truth for UI values that were
4//! previously scattered across multiple crates.
5
6/// Unicode ellipsis character as a string (`\u{2026}`).
7pub const ELLIPSIS: &str = "\u{2026}";
8
9/// Unicode ellipsis character.
10pub(crate) const ELLIPSIS_CHAR: char = '\u{2026}';
11
12/// Three-dot ASCII fallback ellipsis.
13pub(crate) const ELLIPSIS_ASCII: &str = "...";
14
15/// Alias used by preview contexts. Delegates to [`ELLIPSIS`].
16pub(crate) const INLINE_PREVIEW_ELLIPSIS: &str = ELLIPSIS;
17
18// ── Layout breakpoints ──────────────────────────────────────────────────────
19
20/// Maximum column width for compact layout mode.
21pub(crate) const COMPACT_MAX_COLS: u16 = 80;
22
23/// Maximum row height for compact layout mode.
24pub(crate) const COMPACT_MAX_ROWS: u16 = 20;
25
26/// Minimum column width for wide layout mode.
27pub(crate) const WIDE_MIN_COLS: u16 = 120;
28
29/// Minimum row height for wide layout mode.
30pub(crate) const WIDE_MIN_ROWS: u16 = 24;
31
32// ── Spacing tokens ──────────────────────────────────────────────────────────
33
34/// Tight spacing (1 cell).
35pub const SPACING_TIGHT: u16 = 1;
36
37/// Normal spacing (2 cells).
38pub const SPACING_NORMAL: u16 = 2;
39
40/// Loose spacing (4 cells).
41pub const SPACING_LOOSE: u16 = 4;
42
43/// Target column width before a trailing `value` in list rows (settings,
44/// model capabilities). Shorter titles are padded so values line up.
45pub const VALUE_COL: usize = 28;
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn ellipsis_is_unicode() {
53        assert_eq!(ELLIPSIS, "\u{2026}");
54        assert_eq!(ELLIPSIS.chars().count(), 1);
55        assert_eq!(ELLIPSIS.len(), 3); // UTF-8: 3 bytes
56    }
57
58    #[test]
59    fn ellipsis_char_matches_string() {
60        assert_eq!(ELLIPSIS_CHAR, '\u{2026}');
61        assert_eq!(ELLIPSIS_CHAR.to_string(), ELLIPSIS);
62    }
63
64    #[test]
65    fn ellipsis_ascii_is_three_dots() {
66        assert_eq!(ELLIPSIS_ASCII, "...");
67        assert_eq!(ELLIPSIS_ASCII.len(), 3);
68    }
69
70    #[test]
71    fn preview_ellipsis_delegates() {
72        assert_eq!(INLINE_PREVIEW_ELLIPSIS, ELLIPSIS);
73    }
74
75    #[test]
76    fn layout_breakpoints_are_ordered() {
77        const _: () = assert!(COMPACT_MAX_COLS < WIDE_MIN_COLS);
78        const _: () = assert!(COMPACT_MAX_ROWS < WIDE_MIN_ROWS);
79    }
80
81    #[test]
82    fn spacing_tokens_are_ordered() {
83        const _: () = assert!(SPACING_TIGHT < SPACING_NORMAL);
84        const _: () = assert!(SPACING_NORMAL < SPACING_LOOSE);
85    }
86}