gpui_component/theme/
theme_color.rs

1use std::sync::Arc;
2
3use crate::{theme::DEFAULT_THEME_COLORS, ThemeMode};
4
5use gpui::Hsla;
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, JsonSchema)]
10pub struct ThemeColor {
11    /// Used for accents such as hover background on MenuItem, ListItem, etc.
12    pub accent: Hsla,
13    /// Used for accent text color.
14    pub accent_foreground: Hsla,
15    /// Accordion background color.
16    pub accordion: Hsla,
17    /// Accordion hover background color.
18    pub accordion_hover: Hsla,
19    /// Default background color.
20    pub background: Hsla,
21    /// Default border color
22    pub border: Hsla,
23    /// Background color for GroupBox.
24    pub group_box: Hsla,
25    /// Text color for GroupBox.
26    pub group_box_foreground: Hsla,
27    /// Input caret color (Blinking cursor).
28    pub caret: Hsla,
29    /// Chart 1 color.
30    pub chart_1: Hsla,
31    /// Chart 2 color.
32    pub chart_2: Hsla,
33    /// Chart 3 color.
34    pub chart_3: Hsla,
35    /// Chart 4 color.
36    pub chart_4: Hsla,
37    /// Chart 5 color.
38    pub chart_5: Hsla,
39    /// Danger background color.
40    pub danger: Hsla,
41    /// Danger active background color.
42    pub danger_active: Hsla,
43    /// Danger text color.
44    pub danger_foreground: Hsla,
45    /// Danger hover background color.
46    pub danger_hover: Hsla,
47    /// Description List label background color.
48    pub description_list_label: Hsla,
49    /// Description List label foreground color.
50    pub description_list_label_foreground: Hsla,
51    /// Drag border color.
52    pub drag_border: Hsla,
53    /// Drop target background color.
54    pub drop_target: Hsla,
55    /// Default text color.
56    pub foreground: Hsla,
57    /// Info background color.
58    pub info: Hsla,
59    /// Info active background color.
60    pub info_active: Hsla,
61    /// Info text color.
62    pub info_foreground: Hsla,
63    /// Info hover background color.
64    pub info_hover: Hsla,
65    /// Border color for inputs such as Input, Dropdown, etc.
66    pub input: Hsla,
67    /// Link text color.
68    pub link: Hsla,
69    /// Active link text color.
70    pub link_active: Hsla,
71    /// Hover link text color.
72    pub link_hover: Hsla,
73    /// Background color for List and ListItem.
74    pub list: Hsla,
75    /// Background color for active ListItem.
76    pub list_active: Hsla,
77    /// Border color for active ListItem.
78    pub list_active_border: Hsla,
79    /// Stripe background color for even ListItem.
80    pub list_even: Hsla,
81    /// Background color for List header.
82    pub list_head: Hsla,
83    /// Hover background color for ListItem.
84    pub list_hover: Hsla,
85    /// Muted backgrounds such as Skeleton and Switch.
86    pub muted: Hsla,
87    /// Muted text color, as used in disabled text.
88    pub muted_foreground: Hsla,
89    /// Background color for Popover.
90    pub popover: Hsla,
91    /// Text color for Popover.
92    pub popover_foreground: Hsla,
93    /// Primary background color.
94    pub primary: Hsla,
95    /// Active primary background color.
96    pub primary_active: Hsla,
97    /// Primary text color.
98    pub primary_foreground: Hsla,
99    /// Hover primary background color.
100    pub primary_hover: Hsla,
101    /// Progress bar background color.
102    pub progress_bar: Hsla,
103    /// Used for focus ring.
104    pub ring: Hsla,
105    /// Scrollbar background color.
106    pub scrollbar: Hsla,
107    /// Scrollbar thumb background color.
108    pub scrollbar_thumb: Hsla,
109    /// Scrollbar thumb hover background color.
110    pub scrollbar_thumb_hover: Hsla,
111    /// Secondary background color.
112    pub secondary: Hsla,
113    /// Active secondary background color.
114    pub secondary_active: Hsla,
115    /// Secondary text color, used for secondary Button text color or secondary text.
116    pub secondary_foreground: Hsla,
117    /// Hover secondary background color.
118    pub secondary_hover: Hsla,
119    /// Input selection background color.
120    pub selection: Hsla,
121    /// Sidebar background color.
122    pub sidebar: Hsla,
123    /// Sidebar accent background color.
124    pub sidebar_accent: Hsla,
125    /// Sidebar accent text color.
126    pub sidebar_accent_foreground: Hsla,
127    /// Sidebar border color.
128    pub sidebar_border: Hsla,
129    /// Sidebar text color.
130    pub sidebar_foreground: Hsla,
131    /// Sidebar primary background color.
132    pub sidebar_primary: Hsla,
133    /// Sidebar primary text color.
134    pub sidebar_primary_foreground: Hsla,
135    /// Skeleton background color.
136    pub skeleton: Hsla,
137    /// Slider bar background color.
138    pub slider_bar: Hsla,
139    /// Slider thumb background color.
140    pub slider_thumb: Hsla,
141    /// Success background color.
142    pub success: Hsla,
143    /// Success text color.
144    pub success_foreground: Hsla,
145    /// Success hover background color.
146    pub success_hover: Hsla,
147    /// Success active background color.
148    pub success_active: Hsla,
149    /// Switch background color.
150    pub switch: Hsla,
151    /// Tab background color.
152    pub tab: Hsla,
153    /// Tab active background color.
154    pub tab_active: Hsla,
155    /// Tab active text color.
156    pub tab_active_foreground: Hsla,
157    /// TabBar background color.
158    pub tab_bar: Hsla,
159    /// TabBar segmented background color.
160    pub tab_bar_segmented: Hsla,
161    /// Tab text color.
162    pub tab_foreground: Hsla,
163    /// Table background color.
164    pub table: Hsla,
165    /// Table active item background color.
166    pub table_active: Hsla,
167    /// Table active item border color.
168    pub table_active_border: Hsla,
169    /// Stripe background color for even TableRow.
170    pub table_even: Hsla,
171    /// Table head background color.
172    pub table_head: Hsla,
173    /// Table head text color.
174    pub table_head_foreground: Hsla,
175    /// Table item hover background color.
176    pub table_hover: Hsla,
177    /// Table row border color.
178    pub table_row_border: Hsla,
179    /// TitleBar background color, use for Window title bar.
180    pub title_bar: Hsla,
181    /// TitleBar border color.
182    pub title_bar_border: Hsla,
183    /// Background color for Tiles.
184    pub tiles: Hsla,
185    /// Warning background color.
186    pub warning: Hsla,
187    /// Warning active background color.
188    pub warning_active: Hsla,
189    /// Warning hover background color.
190    pub warning_hover: Hsla,
191    /// Warning foreground color.
192    pub warning_foreground: Hsla,
193    /// Overlay background color.
194    pub overlay: Hsla,
195    /// Window border color.
196    ///
197    /// # Platform specific:
198    ///
199    /// This is only works on Linux, other platforms we can't change the window border color.
200    pub window_border: Hsla,
201
202    pub red: Hsla,
203    pub red_light: Hsla,
204    pub green: Hsla,
205    pub green_light: Hsla,
206    pub blue: Hsla,
207    pub blue_light: Hsla,
208    pub yellow: Hsla,
209    pub yellow_light: Hsla,
210    pub magenta: Hsla,
211    pub magenta_light: Hsla,
212    pub cyan: Hsla,
213    pub cyan_light: Hsla,
214}
215
216impl ThemeColor {
217    pub fn light() -> Arc<Self> {
218        DEFAULT_THEME_COLORS[&ThemeMode::Light].0.clone()
219    }
220
221    pub fn dark() -> Arc<Self> {
222        DEFAULT_THEME_COLORS[&ThemeMode::Dark].0.clone()
223    }
224}