Skip to main content

velox_engine/
theme.rs

1//! 全局主题配色令牌 `Theme` / `CoreTheme`(现代 Shadcn Zinc 中性暗/亮色板)。
2
3use crate::style::Color;
4
5/// 核心主题配色令牌(供 `cx.theme()` 直接访问,包含亮色/暗色双模式)。
6///
7/// 色板采用现代 Shadcn / Zinc 中性桌面风格,提供完整的表面层级、交互状态、
8/// 语义警示(`danger` / `success` / `warning` / `info`)、输入框边框(`input`)、
9/// 键盘焦点环(`ring`)与侧边栏/列表高亮令牌。
10#[derive(Copy, Clone, PartialEq, Eq, Debug)]
11pub struct CoreTheme {
12    pub background: Color,
13    pub foreground: Color,
14    pub card: Color,
15    pub card_foreground: Color,
16    pub popover: Color,
17    pub popover_foreground: Color,
18    pub primary: Color,
19    pub primary_foreground: Color,
20    pub secondary: Color,
21    pub secondary_foreground: Color,
22    pub muted: Color,
23    pub muted_foreground: Color,
24    pub accent: Color,
25    pub accent_foreground: Color,
26    pub danger: Color,
27    pub danger_foreground: Color,
28    pub success: Color,
29    pub success_foreground: Color,
30    pub warning: Color,
31    pub warning_foreground: Color,
32    pub info: Color,
33    pub info_foreground: Color,
34    pub border: Color,
35    pub input: Color,
36    pub ring: Color,
37    pub sidebar: Color,
38    pub sidebar_foreground: Color,
39    pub list_hover: Color,
40    pub list_active: Color,
41}
42
43/// `CoreTheme` 的标准别名。
44pub type Theme = CoreTheme;
45
46impl CoreTheme {
47    /// 默认暗色主题(Shadcn Zinc Dark 现代中性暗色色板)。
48    pub const fn dark() -> Self {
49        Self {
50            background: Color::rgb(9, 9, 11),           // Zinc 950 (#09090B)
51            foreground: Color::rgb(250, 250, 250),      // Zinc 50  (#FAFAFA)
52            card: Color::rgb(20, 20, 23),               // Zinc 925 (#141417)
53            card_foreground: Color::rgb(250, 250, 250), // Zinc 50
54            popover: Color::rgb(24, 24, 27),            // Zinc 900 (#18181B)
55            popover_foreground: Color::rgb(250, 250, 250),
56            primary: Color::rgb(59, 130, 246),          // Blue 500 (#3B82F6)
57            primary_foreground: Color::rgb(255, 255, 255),
58            secondary: Color::rgb(39, 39, 42),          // Zinc 800 (#27272A)
59            secondary_foreground: Color::rgb(244, 244, 245), // Zinc 100
60            muted: Color::rgb(28, 28, 32),              // Zinc 875 (#1C1C20)
61            muted_foreground: Color::rgb(161, 161, 170), // Zinc 400 (#A1A1AA)
62            accent: Color::rgb(39, 39, 42),             // Zinc 800 (#27272A)
63            accent_foreground: Color::rgb(250, 250, 250),
64            danger: Color::rgb(239, 68, 68),            // Red 500  (#EF4444)
65            danger_foreground: Color::rgb(255, 255, 255),
66            success: Color::rgb(34, 197, 94),           // Green 500 (#22C55E)
67            success_foreground: Color::rgb(255, 255, 255),
68            warning: Color::rgb(245, 158, 11),          // Amber 500 (#F59E0B)
69            warning_foreground: Color::rgb(24, 24, 27),
70            info: Color::rgb(59, 130, 246),             // Blue 500 (#3B82F6)
71            info_foreground: Color::rgb(255, 255, 255),
72            border: Color::rgb(39, 39, 42),             // Zinc 800 (#27272A)
73            input: Color::rgb(63, 63, 70),              // Zinc 700 (#3F3F46)
74            ring: Color::rgb(91, 139, 217),             // 柔和低饱和钢蓝焦环(与暗色 Zinc 表面自然融合)
75            sidebar: Color::rgb(15, 15, 18),            // Zinc 940 (#0F0F12)
76            sidebar_foreground: Color::rgb(228, 228, 231), // Zinc 200
77            list_hover: Color::rgb(34, 34, 38),         // Zinc 825
78            list_active: Color::rgb(46, 46, 52),        // Zinc 775
79        }
80    }
81
82    /// 明亮日间主题(Shadcn Zinc Light 清爽日间色板)。
83    pub const fn light() -> Self {
84        Self {
85            background: Color::rgb(255, 255, 255),      // Pure White (#FFFFFF)
86            foreground: Color::rgb(9, 9, 11),           // Zinc 950 (#09090B)
87            card: Color::rgb(255, 255, 255),            // Pure White
88            card_foreground: Color::rgb(9, 9, 11),      // Zinc 950
89            popover: Color::rgb(255, 255, 255),         // Pure White
90            popover_foreground: Color::rgb(9, 9, 11),
91            primary: Color::rgb(37, 99, 235),           // Blue 600 (#2563EB)
92            primary_foreground: Color::rgb(255, 255, 255),
93            secondary: Color::rgb(244, 244, 245),       // Zinc 100 (#F4F4F5)
94            secondary_foreground: Color::rgb(24, 24, 27), // Zinc 900
95            muted: Color::rgb(244, 244, 245),           // Zinc 100 (#F4F4F5)
96            muted_foreground: Color::rgb(113, 113, 122), // Zinc 500 (#71717A)
97            accent: Color::rgb(244, 244, 245),          // Zinc 100
98            accent_foreground: Color::rgb(24, 24, 27),
99            danger: Color::rgb(220, 38, 38),            // Red 600  (#DC2626)
100            danger_foreground: Color::rgb(255, 255, 255),
101            success: Color::rgb(22, 163, 74),           // Green 600 (#16A34A)
102            success_foreground: Color::rgb(255, 255, 255),
103            warning: Color::rgb(217, 119, 6),           // Amber 600 (#D97706)
104            warning_foreground: Color::rgb(255, 255, 255),
105            info: Color::rgb(37, 99, 235),              // Blue 600 (#2563EB)
106            info_foreground: Color::rgb(255, 255, 255),
107            border: Color::rgb(228, 228, 231),          // Zinc 200 (#E4E4E7)
108            input: Color::rgb(212, 212, 216),           // Zinc 300 (#D4D4D8)
109            ring: Color::rgb(96, 145, 232),             // 柔和清爽天蓝焦环(与亮色 Zinc 表面自然融合)
110            sidebar: Color::rgb(250, 250, 250),         // Zinc 50  (#FAFAFA)
111            sidebar_foreground: Color::rgb(39, 39, 42), // Zinc 800
112            list_hover: Color::rgb(244, 244, 245),      // Zinc 100
113            list_active: Color::rgb(228, 228, 231),     // Zinc 200
114        }
115    }
116}
117
118impl Default for CoreTheme {
119    fn default() -> Self {
120        Self::dark()
121    }
122}