History

Refine default colors

Nate Butler committed 3 years ago

Commit 0efd69c1 parent e0cb95b3 files · +131 −92Browse files

Unified · Split

3 files
  1. crates/theme2/src/default_colors.rs +115 −88
  2. crates/theme2/src/theme2.rs +12 −0
  3. crates/ui2/src/elements/label.rs +4 −4
crates/theme2/src/default_colors.rs+115−88
@@ -1,4 +1,4 @@
1−use gpui2::{hsla, Rgba};
1+use gpui2::{hsla, Hsla, Rgba};
22
33 use crate::{
44 colors::{GitStatusColors, PlayerColor, PlayerColors, StatusColors, SystemColors, ThemeColors},
@@ -6,6 +6,10 @@ use crate::{ · 1 unmodified line
66 syntax::SyntaxTheme,
77 };
88
9+fn neutral() -> DefaultColorScaleSet {
10+ slate()
11+}
12+
913 impl Default for SystemColors {
1014 fn default() -> Self {
1115 Self {
@@ -20,17 +24,17 @@ impl Default for SystemColors { · 8 unmodified lines
2024 impl Default for StatusColors {
2125 fn default() -> Self {
2226 Self {
23− conflict: gpui2::black(),
24− created: gpui2::black(),
25− deleted: gpui2::black(),
26− error: gpui2::black(),
27− hidden: gpui2::black(),
28− ignored: gpui2::black(),
29− info: gpui2::black(),
30− modified: gpui2::black(),
31− renamed: gpui2::black(),
32− success: gpui2::black(),
33− warning: gpui2::black(),
27+ conflict: red().dark(11).into(),
28+ created: green().dark(11).into(),
29+ deleted: red().dark(11).into(),
30+ error: red().dark(11).into(),
31+ hidden: neutral().dark(11).into(),
32+ ignored: neutral().dark(11).into(),
33+ info: blue().dark(11).into(),
34+ modified: yellow().dark(11).into(),
35+ renamed: blue().dark(11).into(),
36+ success: green().dark(11).into(),
37+ warning: yellow().dark(11).into(),
3438 }
3539 }
3640 }
@@ -38,12 +42,12 @@ impl Default for StatusColors { · 1 unmodified line
3842 impl Default for GitStatusColors {
3943 fn default() -> Self {
4044 Self {
41− conflict: gpui2::rgba(0xdec184ff).into(),
42− created: gpui2::rgba(0xa1c181ff).into(),
43− deleted: gpui2::rgba(0xd07277ff).into(),
44− ignored: gpui2::rgba(0x555a63ff).into(),
45− modified: gpui2::rgba(0x74ade8ff).into(),
46− renamed: gpui2::rgba(0xdec184ff).into(),
45+ conflict: orange().dark(11),
46+ created: green().dark(11),
47+ deleted: red().dark(11),
48+ ignored: green().dark(11),
49+ modified: yellow().dark(11),
50+ renamed: blue().dark(11),
4751 }
4852 }
4953 }
@@ -189,82 +193,86 @@ impl SyntaxTheme { · 139 unmodified lines
189193
190194 impl ThemeColors {
191195 pub fn default_light() -> Self {
196+ let system = SystemColors::default();
197+
192198 Self {
193− border: gpui2::white(),
194− border_variant: gpui2::white(),
195− border_focused: gpui2::white(),
196− border_transparent: gpui2::white(),
197− elevated_surface: gpui2::white(),
198− surface: gpui2::white(),
199− background: gpui2::white(),
200− element: gpui2::white(),
201− element_hover: gpui2::white(),
202− element_active: gpui2::white(),
203− element_selected: gpui2::white(),
204− element_disabled: gpui2::white(),
205− element_placeholder: gpui2::white(),
206− ghost_element: gpui2::white(),
207− ghost_element_hover: gpui2::white(),
208− ghost_element_active: gpui2::white(),
209− ghost_element_selected: gpui2::white(),
210− ghost_element_disabled: gpui2::white(),
211− text: gpui2::white(),
212− text_muted: gpui2::white(),
213− text_placeholder: gpui2::white(),
214− text_disabled: gpui2::white(),
215− text_accent: gpui2::white(),
216− icon: gpui2::white(),
217− icon_muted: gpui2::white(),
218− icon_disabled: gpui2::white(),
219− icon_placeholder: gpui2::white(),
220− icon_accent: gpui2::white(),
221− status_bar: gpui2::white(),
222− title_bar: gpui2::white(),
223− toolbar: gpui2::white(),
224− tab_bar: gpui2::white(),
225− editor: gpui2::white(),
226− editor_subheader: gpui2::white(),
227− editor_active_line: gpui2::white(),
199+ border: neutral().light(6).into(),
200+ border_variant: neutral().light(5).into(),
201+ border_focused: blue().light(5).into(),
202+ border_transparent: system.transparent,
203+ elevated_surface: neutral().light(2).into(),
204+ surface: neutral().light(2).into(),
205+ background: neutral().light(1).into(),
206+ element: neutral().light(3).into(),
207+ element_hover: neutral().light(4).into(),
208+ element_active: neutral().light(5).into(),
209+ element_selected: neutral().light(5).into(),
210+ element_disabled: neutral().light_alpha(3).into(),
211+ element_placeholder: neutral().light(11).into(),
212+ ghost_element: system.transparent,
213+ ghost_element_hover: neutral().light(4).into(),
214+ ghost_element_active: neutral().light(5).into(),
215+ ghost_element_selected: neutral().light(5).into(),
216+ ghost_element_disabled: neutral().light_alpha(3).into(),
217+ text: neutral().light(12).into(),
218+ text_muted: neutral().light(11).into(),
219+ text_placeholder: neutral().light(11).into(),
220+ text_disabled: neutral().light(10).into(),
221+ text_accent: blue().light(12).into(),
222+ icon: neutral().light(12).into(),
223+ icon_muted: neutral().light(11).into(),
224+ icon_disabled: neutral().light(10).into(),
225+ icon_placeholder: neutral().light(11).into(),
226+ icon_accent: blue().light(12).into(),
227+ status_bar: neutral().light(2).into(),
228+ title_bar: neutral().light(2).into(),
229+ toolbar: neutral().light(2).into(),
230+ tab_bar: neutral().light(2).into(),
231+ editor: neutral().light(1).into(),
232+ editor_subheader: neutral().light(2).into(),
233+ editor_active_line: neutral().light_alpha(3).into(),
228234 }
229235 }
230236
231237 pub fn default_dark() -> Self {
238+ let system = SystemColors::default();
239+
232240 Self {
233− border: gpui2::rgba(0x464b57ff).into(),
234− border_variant: gpui2::rgba(0x464b57ff).into(),
235− border_focused: gpui2::rgba(0x293b5bff).into(),
236− border_transparent: gpui2::rgba(0x00000000).into(),
237− elevated_surface: gpui2::rgba(0x3b414dff).into(),
238− surface: gpui2::rgba(0x2f343eff).into(),
239− background: gpui2::rgba(0x3b414dff).into(),
240− element: gpui2::rgba(0x3b414dff).into(),
241− element_hover: gpui2::rgba(0xffffff1e).into(),
242− element_active: gpui2::rgba(0xffffff28).into(),
243− element_selected: gpui2::rgba(0x18243dff).into(),
244− element_disabled: gpui2::rgba(0x00000000).into(),
245− element_placeholder: gpui2::black(),
246− ghost_element: gpui2::rgba(0x00000000).into(),
247− ghost_element_hover: gpui2::rgba(0xffffff14).into(),
248− ghost_element_active: gpui2::rgba(0xffffff1e).into(),
249− ghost_element_selected: gpui2::rgba(0x18243dff).into(),
250− ghost_element_disabled: gpui2::rgba(0x00000000).into(),
251− text: gpui2::rgba(0xc8ccd4ff).into(),
252− text_muted: gpui2::rgba(0x838994ff).into(),
253− text_placeholder: gpui2::rgba(0xd07277ff).into(),
254− text_disabled: gpui2::rgba(0x555a63ff).into(),
255− text_accent: gpui2::rgba(0x74ade8ff).into(),
256− icon: gpui2::black(),
257− icon_muted: gpui2::rgba(0x838994ff).into(),
258− icon_disabled: gpui2::black(),
259− icon_placeholder: gpui2::black(),
260− icon_accent: gpui2::black(),
261− status_bar: gpui2::rgba(0x3b414dff).into(),
262− title_bar: gpui2::rgba(0x3b414dff).into(),
263− toolbar: gpui2::rgba(0x282c33ff).into(),
264− tab_bar: gpui2::rgba(0x2f343eff).into(),
265− editor: gpui2::rgba(0x282c33ff).into(),
266− editor_subheader: gpui2::rgba(0x2f343eff).into(),
267− editor_active_line: gpui2::rgba(0x2f343eff).into(),
241+ border: neutral().dark(6).into(),
242+ border_variant: neutral().dark(5).into(),
243+ border_focused: blue().dark(5).into(),
244+ border_transparent: system.transparent,
245+ elevated_surface: neutral().dark(2).into(),
246+ surface: neutral().dark(2).into(),
247+ background: neutral().dark(1).into(),
248+ element: neutral().dark(3).into(),
249+ element_hover: neutral().dark(4).into(),
250+ element_active: neutral().dark(5).into(),
251+ element_selected: neutral().dark(5).into(),
252+ element_disabled: neutral().dark_alpha(3).into(),
253+ element_placeholder: neutral().dark(11).into(),
254+ ghost_element: system.transparent,
255+ ghost_element_hover: neutral().dark(4).into(),
256+ ghost_element_active: neutral().dark(5).into(),
257+ ghost_element_selected: neutral().dark(5).into(),
258+ ghost_element_disabled: neutral().dark_alpha(3).into(),
259+ text: neutral().dark(12).into(),
260+ text_muted: neutral().dark(11).into(),
261+ text_placeholder: neutral().dark(11).into(),
262+ text_disabled: neutral().dark(10).into(),
263+ text_accent: blue().dark(12).into(),
264+ icon: neutral().dark(12).into(),
265+ icon_muted: neutral().dark(11).into(),
266+ icon_disabled: neutral().dark(10).into(),
267+ icon_placeholder: neutral().dark(11).into(),
268+ icon_accent: blue().dark(12).into(),
269+ status_bar: neutral().dark(2).into(),
270+ title_bar: neutral().dark(2).into(),
271+ toolbar: neutral().dark(2).into(),
272+ tab_bar: neutral().dark(2).into(),
273+ editor: neutral().dark(1).into(),
274+ editor_subheader: neutral().dark(2).into(),
275+ editor_active_line: neutral().dark_alpha(3).into(),
268276 }
269277 }
270278 }
@@ -277,6 +285,25 @@ struct DefaultColorScaleSet { · 6 unmodified lines
277285 dark_alpha: [&'static str; 12],
278286 }
279287
288+// See [ColorScaleSet] for why we use index-1.
289+impl DefaultColorScaleSet {
290+ pub fn light(&self, index: usize) -> Hsla {
291+ self.light[index - 1].into()
292+ }
293+
294+ pub fn light_alpha(&self, index: usize) -> Hsla {
295+ self.light_alpha[index - 1].into()
296+ }
297+
298+ pub fn dark(&self, index: usize) -> Hsla {
299+ self.dark[index - 1].into()
300+ }
301+
302+ pub fn dark_alpha(&self, index: usize) -> Hsla {
303+ self.dark_alpha[index - 1].into()
304+ }
305+}
306+
280307 impl From<DefaultColorScaleSet> for ColorScaleSet {
281308 fn from(default: DefaultColorScaleSet) -> Self {
282309 Self::new(
crates/theme2/src/theme2.rs+12−0
@@ -70,6 +70,18 @@ impl ThemeVariant { · 69 unmodified lines
7070 &self.styles.syntax
7171 }
7272
73+ /// Returns the [`StatusColors`] for the theme.
74+ #[inline(always)]
75+ pub fn status(&self) -> &StatusColors {
76+ &self.styles.status
77+ }
78+
79+ /// Returns the [`GitStatusColors`] for the theme.
80+ #[inline(always)]
81+ pub fn git(&self) -> &GitStatusColors {
82+ &self.styles.git
83+ }
84+
7385 /// Returns the color for the syntax node with the given name.
7486 #[inline(always)]
7587 pub fn syntax_color(&self, name: &str) -> Hsla {
crates/ui2/src/elements/label.rs+4−4
@@ -21,11 +21,11 @@ impl LabelColor { · 20 unmodified lines
2121 match self {
2222 Self::Default => cx.theme().colors().text,
2323 Self::Muted => cx.theme().colors().text_muted,
24− Self::Created => gpui2::red(),
25− Self::Modified => gpui2::red(),
26− Self::Deleted => gpui2::red(),
24+ Self::Created => cx.theme().status().created,
25+ Self::Modified => cx.theme().status().modified,
26+ Self::Deleted => cx.theme().status().deleted,
2727 Self::Disabled => cx.theme().colors().text_disabled,
28− Self::Hidden => gpui2::red(),
28+ Self::Hidden => cx.theme().status().hidden,
2929 Self::Placeholder => cx.theme().colors().text_placeholder,
3030 Self::Accent => cx.theme().colors().text_accent,
3131 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t