Compare commits

...

2 Commits

Author SHA1 Message Date
Nate Butler
1d62f5a58c Theme chaos!
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-07-10 12:51:48 -04:00
Nate Butler
bef7ba8e35 Remove unneded ThemeColorField
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-07-10 11:59:43 -04:00
14 changed files with 1424 additions and 4088 deletions

View File

@@ -6,398 +6,7 @@
{
"name": "One Dark",
"appearance": "dark",
"style": {
"border": "#464b57ff",
"border.variant": "#363c46ff",
"border.focused": "#47679eff",
"border.selected": "#293b5bff",
"border.transparent": "#00000000",
"border.disabled": "#414754ff",
"elevated_surface.background": "#2f343eff",
"surface.background": "#2f343eff",
"background": "#3b414dff",
"element.background": "#2e343eff",
"element.hover": "#363c46ff",
"element.active": "#454a56ff",
"element.selected": "#454a56ff",
"element.disabled": "#2e343eff",
"drop_target.background": "#83899480",
"ghost_element.background": "#00000000",
"ghost_element.hover": "#363c46ff",
"ghost_element.active": "#454a56ff",
"ghost_element.selected": "#454a56ff",
"ghost_element.disabled": "#2e343eff",
"text": "#dce0e5ff",
"text.muted": "#a9afbcff",
"text.placeholder": "#878a98ff",
"text.disabled": "#878a98ff",
"text.accent": "#74ade8ff",
"icon": "#dce0e5ff",
"icon.muted": "#a9afbcff",
"icon.disabled": "#878a98ff",
"icon.placeholder": "#a9afbcff",
"icon.accent": "#74ade8ff",
"status_bar.background": "#3b414dff",
"title_bar.background": "#3b414dff",
"title_bar.inactive_background": "#2e343eff",
"toolbar.background": "#282c33ff",
"tab_bar.background": "#2f343eff",
"tab.inactive_background": "#2f343eff",
"tab.active_background": "#282c33ff",
"search.match_background": "#74ade866",
"panel.background": "#2f343eff",
"panel.focused_border": null,
"pane.focused_border": null,
"scrollbar.thumb.background": "#c8ccd44c",
"scrollbar.thumb.hover_background": "#363c46ff",
"scrollbar.thumb.border": "#363c46ff",
"scrollbar.track.background": "#00000000",
"scrollbar.track.border": "#2e333cff",
"editor.foreground": "#acb2beff",
"editor.background": "#282c33ff",
"editor.gutter.background": "#282c33ff",
"editor.subheader.background": "#2f343eff",
"editor.active_line.background": "#2f343ebf",
"editor.highlighted_line.background": "#2f343eff",
"editor.line_number": "#4e5a5f",
"editor.active_line_number": "#d0d4da",
"editor.hover_line_number": "#acb0b4",
"editor.invisible": "#878a98ff",
"editor.wrap_guide": "#c8ccd40d",
"editor.active_wrap_guide": "#c8ccd41a",
"editor.document_highlight.read_background": "#74ade81a",
"editor.document_highlight.write_background": "#555a6366",
"terminal.background": "#282c33ff",
"terminal.foreground": "#dce0e5ff",
"terminal.bright_foreground": "#dce0e5ff",
"terminal.dim_foreground": "#282c33ff",
"terminal.ansi.black": "#282c33ff",
"terminal.ansi.bright_black": "#525561ff",
"terminal.ansi.dim_black": "#dce0e5ff",
"terminal.ansi.red": "#d07277ff",
"terminal.ansi.bright_red": "#673a3cff",
"terminal.ansi.dim_red": "#eab7b9ff",
"terminal.ansi.green": "#a1c181ff",
"terminal.ansi.bright_green": "#4d6140ff",
"terminal.ansi.dim_green": "#d1e0bfff",
"terminal.ansi.yellow": "#dec184ff",
"terminal.ansi.bright_yellow": "#e5c07bff",
"terminal.ansi.dim_yellow": "#f1dfc1ff",
"terminal.ansi.blue": "#74ade8ff",
"terminal.ansi.bright_blue": "#385378ff",
"terminal.ansi.dim_blue": "#bed5f4ff",
"terminal.ansi.magenta": "#be5046ff",
"terminal.ansi.bright_magenta": "#5e2b26ff",
"terminal.ansi.dim_magenta": "#e6a79eff",
"terminal.ansi.cyan": "#6eb4bfff",
"terminal.ansi.bright_cyan": "#3a565bff",
"terminal.ansi.dim_cyan": "#b9d9dfff",
"terminal.ansi.white": "#dce0e5ff",
"terminal.ansi.bright_white": "#dce0e5ff",
"terminal.ansi.dim_white": "#575d65ff",
"link_text.hover": "#74ade8ff",
"version_control.added": "#27a657ff",
"version_control.modified": "#d3b020ff",
"version_control.deleted": "#e06c76ff",
"version_control.conflict_marker.ours": "#a1c1811a",
"version_control.conflict_marker.theirs": "#74ade81a",
"conflict": "#dec184ff",
"conflict.background": "#dec1841a",
"conflict.border": "#5d4c2fff",
"created": "#a1c181ff",
"created.background": "#a1c1811a",
"created.border": "#38482fff",
"deleted": "#d07277ff",
"deleted.background": "#d072771a",
"deleted.border": "#4c2b2cff",
"error": "#d07277ff",
"error.background": "#d072771a",
"error.border": "#4c2b2cff",
"hidden": "#878a98ff",
"hidden.background": "#696b771a",
"hidden.border": "#414754ff",
"hint": "#788ca6ff",
"hint.background": "#5a6f891a",
"hint.border": "#293b5bff",
"ignored": "#878a98ff",
"ignored.background": "#696b771a",
"ignored.border": "#464b57ff",
"info": "#74ade8ff",
"info.background": "#74ade81a",
"info.border": "#293b5bff",
"modified": "#dec184ff",
"modified.background": "#dec1841a",
"modified.border": "#5d4c2fff",
"predictive": "#5a6a87ff",
"predictive.background": "#5a6a871a",
"predictive.border": "#38482fff",
"renamed": "#74ade8ff",
"renamed.background": "#74ade81a",
"renamed.border": "#293b5bff",
"success": "#a1c181ff",
"success.background": "#a1c1811a",
"success.border": "#38482fff",
"unreachable": "#a9afbcff",
"unreachable.background": "#8389941a",
"unreachable.border": "#464b57ff",
"warning": "#dec184ff",
"warning.background": "#dec1841a",
"warning.border": "#5d4c2fff",
"players": [
{
"cursor": "#74ade8ff",
"background": "#74ade8ff",
"selection": "#74ade83d"
},
{
"cursor": "#be5046ff",
"background": "#be5046ff",
"selection": "#be50463d"
},
{
"cursor": "#bf956aff",
"background": "#bf956aff",
"selection": "#bf956a3d"
},
{
"cursor": "#b477cfff",
"background": "#b477cfff",
"selection": "#b477cf3d"
},
{
"cursor": "#6eb4bfff",
"background": "#6eb4bfff",
"selection": "#6eb4bf3d"
},
{
"cursor": "#d07277ff",
"background": "#d07277ff",
"selection": "#d072773d"
},
{
"cursor": "#dec184ff",
"background": "#dec184ff",
"selection": "#dec1843d"
},
{
"cursor": "#a1c181ff",
"background": "#a1c181ff",
"selection": "#a1c1813d"
}
],
"syntax": {
"attribute": {
"color": "#74ade8ff",
"font_style": null,
"font_weight": null
},
"boolean": {
"color": "#bf956aff",
"font_style": null,
"font_weight": null
},
"comment": {
"color": "#5d636fff",
"font_style": null,
"font_weight": null
},
"comment.doc": {
"color": "#878e98ff",
"font_style": null,
"font_weight": null
},
"constant": {
"color": "#dfc184ff",
"font_style": null,
"font_weight": null
},
"constructor": {
"color": "#73ade9ff",
"font_style": null,
"font_weight": null
},
"embedded": {
"color": "#dce0e5ff",
"font_style": null,
"font_weight": null
},
"emphasis": {
"color": "#74ade8ff",
"font_style": null,
"font_weight": null
},
"emphasis.strong": {
"color": "#bf956aff",
"font_style": null,
"font_weight": 700
},
"enum": {
"color": "#d07277ff",
"font_style": null,
"font_weight": null
},
"function": {
"color": "#73ade9ff",
"font_style": null,
"font_weight": null
},
"hint": {
"color": "#788ca6ff",
"font_style": null,
"font_weight": 700
},
"keyword": {
"color": "#b477cfff",
"font_style": null,
"font_weight": null
},
"label": {
"color": "#74ade8ff",
"font_style": null,
"font_weight": null
},
"link_text": {
"color": "#73ade9ff",
"font_style": "normal",
"font_weight": null
},
"link_uri": {
"color": "#6eb4bfff",
"font_style": null,
"font_weight": null
},
"namespace": {
"color": "#dce0e5ff",
"font_style": null,
"font_weight": null
},
"number": {
"color": "#bf956aff",
"font_style": null,
"font_weight": null
},
"operator": {
"color": "#6eb4bfff",
"font_style": null,
"font_weight": null
},
"predictive": {
"color": "#5a6a87ff",
"font_style": "italic",
"font_weight": null
},
"preproc": {
"color": "#dce0e5ff",
"font_style": null,
"font_weight": null
},
"primary": {
"color": "#acb2beff",
"font_style": null,
"font_weight": null
},
"property": {
"color": "#d07277ff",
"font_style": null,
"font_weight": null
},
"punctuation": {
"color": "#acb2beff",
"font_style": null,
"font_weight": null
},
"punctuation.bracket": {
"color": "#b2b9c6ff",
"font_style": null,
"font_weight": null
},
"punctuation.delimiter": {
"color": "#b2b9c6ff",
"font_style": null,
"font_weight": null
},
"punctuation.list_marker": {
"color": "#d07277ff",
"font_style": null,
"font_weight": null
},
"punctuation.special": {
"color": "#b1574bff",
"font_style": null,
"font_weight": null
},
"selector": {
"color": "#dfc184ff",
"font_style": null,
"font_weight": null
},
"selector.pseudo": {
"color": "#74ade8ff",
"font_style": null,
"font_weight": null
},
"string": {
"color": "#a1c181ff",
"font_style": null,
"font_weight": null
},
"string.escape": {
"color": "#878e98ff",
"font_style": null,
"font_weight": null
},
"string.regex": {
"color": "#bf956aff",
"font_style": null,
"font_weight": null
},
"string.special": {
"color": "#bf956aff",
"font_style": null,
"font_weight": null
},
"string.special.symbol": {
"color": "#bf956aff",
"font_style": null,
"font_weight": null
},
"tag": {
"color": "#74ade8ff",
"font_style": null,
"font_weight": null
},
"text.literal": {
"color": "#a1c181ff",
"font_style": null,
"font_weight": null
},
"title": {
"color": "#d07277ff",
"font_style": null,
"font_weight": 400
},
"type": {
"color": "#6eb4bfff",
"font_style": null,
"font_weight": null
},
"variable": {
"color": "#acb2beff",
"font_style": null,
"font_weight": null
},
"variable.special": {
"color": "#bf956aff",
"font_style": null,
"font_weight": null
},
"variant": {
"color": "#73ade9ff",
"font_style": null,
"font_weight": null
}
}
}
"style": {}
},
{
"name": "One Light",

View File

@@ -571,7 +571,7 @@ impl Default for EditorStyle {
// HACK: Status colors don't have a real default.
// We should look into removing the status colors from the editor
// style and retrieve them directly from the theme.
status: StatusColors::dark(),
status: StatusColors::default(),
inlay_hints_style: HighlightStyle::default(),
inline_completion_styles: InlineCompletionStyles {
insertion: HighlightStyle::default(),

1353
crates/theme/src/default.rs Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,344 +0,0 @@
use std::sync::Arc;
use gpui::{FontStyle, FontWeight, HighlightStyle, Hsla, WindowBackgroundAppearance, hsla};
use crate::{
AccentColors, Appearance, PlayerColors, StatusColors, StatusColorsRefinement, SyntaxTheme,
SystemColors, Theme, ThemeColors, ThemeColorsRefinement, ThemeFamily, ThemeStyles,
default_color_scales,
};
/// The default theme family for Zed.
///
/// This is used to construct the default theme fallback values, as well as to
/// have a theme available at compile time for tests.
pub fn zed_default_themes() -> ThemeFamily {
ThemeFamily {
id: "zed-default".to_string(),
name: "Zed Default".into(),
author: "".into(),
themes: vec![zed_default_dark()],
scales: default_color_scales(),
}
}
// If a theme customizes a foreground version of a status color, but does not
// customize the background color, then use a partly-transparent version of the
// foreground color for the background color.
pub(crate) fn apply_status_color_defaults(status: &mut StatusColorsRefinement) {
for (fg_color, bg_color) in [
(&status.deleted, &mut status.deleted_background),
(&status.created, &mut status.created_background),
(&status.modified, &mut status.modified_background),
(&status.conflict, &mut status.conflict_background),
(&status.error, &mut status.error_background),
(&status.hidden, &mut status.hidden_background),
] {
if bg_color.is_none() {
if let Some(fg_color) = fg_color {
*bg_color = Some(fg_color.opacity(0.25));
}
}
}
}
pub(crate) fn apply_theme_color_defaults(
theme_colors: &mut ThemeColorsRefinement,
player_colors: &PlayerColors,
) {
if theme_colors.element_selection_background.is_none() {
let mut selection = player_colors.local().selection;
if selection.a == 1.0 {
selection.a = 0.25;
}
theme_colors.element_selection_background = Some(selection);
}
}
pub(crate) fn zed_default_dark() -> Theme {
let bg = hsla(215. / 360., 12. / 100., 15. / 100., 1.);
let editor = hsla(220. / 360., 12. / 100., 18. / 100., 1.);
let elevated_surface = hsla(225. / 360., 12. / 100., 17. / 100., 1.);
let blue = hsla(207.8 / 360., 81. / 100., 66. / 100., 1.0);
let gray = hsla(218.8 / 360., 10. / 100., 40. / 100., 1.0);
let green = hsla(95. / 360., 38. / 100., 62. / 100., 1.0);
let orange = hsla(29. / 360., 54. / 100., 61. / 100., 1.0);
let purple = hsla(286. / 360., 51. / 100., 64. / 100., 1.0);
let red = hsla(355. / 360., 65. / 100., 65. / 100., 1.0);
let teal = hsla(187. / 360., 47. / 100., 55. / 100., 1.0);
let yellow = hsla(39. / 360., 67. / 100., 69. / 100., 1.0);
const ADDED_COLOR: Hsla = Hsla {
h: 142. / 360.,
s: 0.68,
l: 0.45,
a: 1.0,
};
const MODIFIED_COLOR: Hsla = Hsla {
h: 48. / 360.,
s: 0.76,
l: 0.47,
a: 1.0,
};
const REMOVED_COLOR: Hsla = Hsla {
h: 355. / 360.,
s: 0.65,
l: 0.65,
a: 1.0,
};
let player = PlayerColors::dark();
Theme {
id: "one_dark".to_string(),
name: "One Dark".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
window_background_appearance: WindowBackgroundAppearance::Opaque,
system: SystemColors::default(),
accents: AccentColors(vec![blue, orange, purple, teal, red, green, yellow]),
colors: ThemeColors {
border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
border_variant: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
border_focused: hsla(223. / 360., 78. / 100., 65. / 100., 1.),
border_selected: hsla(222.6 / 360., 77.5 / 100., 65.1 / 100., 1.0),
border_transparent: SystemColors::default().transparent,
border_disabled: hsla(222.0 / 360., 11.6 / 100., 33.7 / 100., 1.0),
elevated_surface_background: elevated_surface,
surface_background: bg,
background: bg,
element_background: hsla(223.0 / 360., 13. / 100., 21. / 100., 1.0),
element_hover: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
element_disabled: SystemColors::default().transparent,
element_selection_background: player.local().selection.alpha(0.25),
drop_target_background: hsla(220.0 / 360., 8.3 / 100., 21.4 / 100., 1.0),
ghost_element_background: SystemColors::default().transparent,
ghost_element_hover: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
ghost_element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
ghost_element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
ghost_element_disabled: SystemColors::default().transparent,
text: hsla(221. / 360., 11. / 100., 86. / 100., 1.0),
text_muted: hsla(218.0 / 360., 7. / 100., 46. / 100., 1.0),
text_placeholder: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
text_disabled: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
text_accent: hsla(222.6 / 360., 77.5 / 100., 65.1 / 100., 1.0),
icon: hsla(222.9 / 360., 9.9 / 100., 86.1 / 100., 1.0),
icon_muted: hsla(220.0 / 360., 12.1 / 100., 66.1 / 100., 1.0),
icon_disabled: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
icon_placeholder: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
icon_accent: blue,
debugger_accent: red,
status_bar_background: bg,
title_bar_background: bg,
title_bar_inactive_background: bg,
toolbar_background: editor,
tab_bar_background: bg,
tab_inactive_background: bg,
tab_active_background: editor,
search_match_background: bg,
editor_background: editor,
editor_gutter_background: editor,
editor_subheader_background: bg,
editor_active_line_background: hsla(222.9 / 360., 13.5 / 100., 20.4 / 100., 1.0),
editor_highlighted_line_background: hsla(207.8 / 360., 81. / 100., 66. / 100., 0.1),
editor_debugger_active_line_background: hsla(
207.8 / 360.,
81. / 100.,
66. / 100.,
0.2,
),
editor_line_number: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
editor_active_line_number: hsla(216.0 / 360., 5.9 / 100., 49.6 / 100., 1.0),
editor_hover_line_number: hsla(216.0 / 360., 5.9 / 100., 56.7 / 100., 1.0),
editor_invisible: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
editor_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
editor_active_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
editor_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
editor_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
editor_document_highlight_read_background: hsla(
207.8 / 360.,
81. / 100.,
66. / 100.,
0.2,
),
editor_document_highlight_write_background: gpui::red(),
editor_document_highlight_bracket_background: gpui::green(),
terminal_background: bg,
// todo("Use one colors for terminal")
terminal_ansi_background: crate::black().dark().step_12(),
terminal_foreground: crate::white().dark().step_12(),
terminal_bright_foreground: crate::white().dark().step_11(),
terminal_dim_foreground: crate::white().dark().step_10(),
terminal_ansi_black: crate::black().dark().step_12(),
terminal_ansi_red: crate::red().dark().step_11(),
terminal_ansi_green: crate::green().dark().step_11(),
terminal_ansi_yellow: crate::yellow().dark().step_11(),
terminal_ansi_blue: crate::blue().dark().step_11(),
terminal_ansi_magenta: crate::violet().dark().step_11(),
terminal_ansi_cyan: crate::cyan().dark().step_11(),
terminal_ansi_white: crate::neutral().dark().step_12(),
terminal_ansi_bright_black: crate::black().dark().step_11(),
terminal_ansi_bright_red: crate::red().dark().step_10(),
terminal_ansi_bright_green: crate::green().dark().step_10(),
terminal_ansi_bright_yellow: crate::yellow().dark().step_10(),
terminal_ansi_bright_blue: crate::blue().dark().step_10(),
terminal_ansi_bright_magenta: crate::violet().dark().step_10(),
terminal_ansi_bright_cyan: crate::cyan().dark().step_10(),
terminal_ansi_bright_white: crate::neutral().dark().step_11(),
terminal_ansi_dim_black: crate::black().dark().step_10(),
terminal_ansi_dim_red: crate::red().dark().step_9(),
terminal_ansi_dim_green: crate::green().dark().step_9(),
terminal_ansi_dim_yellow: crate::yellow().dark().step_9(),
terminal_ansi_dim_blue: crate::blue().dark().step_9(),
terminal_ansi_dim_magenta: crate::violet().dark().step_9(),
terminal_ansi_dim_cyan: crate::cyan().dark().step_9(),
terminal_ansi_dim_white: crate::neutral().dark().step_10(),
panel_background: bg,
panel_focused_border: blue,
panel_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
panel_indent_guide_hover: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
panel_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
pane_focused_border: blue,
pane_group_border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
scrollbar_thumb_background: gpui::transparent_black(),
scrollbar_thumb_hover_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
scrollbar_thumb_active_background: hsla(
225.0 / 360.,
11.8 / 100.,
26.7 / 100.,
1.0,
),
scrollbar_thumb_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
scrollbar_track_background: gpui::transparent_black(),
scrollbar_track_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
minimap_thumb_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 0.7),
minimap_thumb_hover_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 0.7),
minimap_thumb_active_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 0.7),
minimap_thumb_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
editor_foreground: hsla(218. / 360., 14. / 100., 71. / 100., 1.),
link_text_hover: blue,
version_control_added: ADDED_COLOR,
version_control_deleted: REMOVED_COLOR,
version_control_modified: MODIFIED_COLOR,
version_control_renamed: MODIFIED_COLOR,
version_control_conflict: crate::orange().light().step_12(),
version_control_ignored: crate::gray().light().step_12(),
version_control_conflict_marker_ours: crate::green().light().step_12().alpha(0.5),
version_control_conflict_marker_theirs: crate::blue().light().step_12().alpha(0.5),
},
status: StatusColors {
conflict: yellow,
conflict_background: yellow,
conflict_border: yellow,
created: green,
created_background: green,
created_border: green,
deleted: red,
deleted_background: red,
deleted_border: red,
error: red,
error_background: red,
error_border: red,
hidden: gray,
hidden_background: gray,
hidden_border: gray,
hint: blue,
hint_background: blue,
hint_border: blue,
ignored: gray,
ignored_background: gray,
ignored_border: gray,
info: blue,
info_background: blue,
info_border: blue,
modified: yellow,
modified_background: yellow,
modified_border: yellow,
predictive: gray,
predictive_background: gray,
predictive_border: gray,
renamed: blue,
renamed_background: blue,
renamed_border: blue,
success: green,
success_background: green,
success_border: green,
unreachable: gray,
unreachable_background: gray,
unreachable_border: gray,
warning: yellow,
warning_background: yellow,
warning_border: yellow,
},
player,
syntax: Arc::new(SyntaxTheme {
highlights: vec![
("attribute".into(), purple.into()),
("boolean".into(), orange.into()),
("comment".into(), gray.into()),
("comment.doc".into(), gray.into()),
("constant".into(), yellow.into()),
("constructor".into(), blue.into()),
("embedded".into(), HighlightStyle::default()),
(
"emphasis".into(),
HighlightStyle {
font_style: Some(FontStyle::Italic),
..HighlightStyle::default()
},
),
(
"emphasis.strong".into(),
HighlightStyle {
font_weight: Some(FontWeight::BOLD),
..HighlightStyle::default()
},
),
("enum".into(), HighlightStyle::default()),
("function".into(), blue.into()),
("function.method".into(), blue.into()),
("function.definition".into(), blue.into()),
("hint".into(), blue.into()),
("keyword".into(), purple.into()),
("label".into(), HighlightStyle::default()),
("link_text".into(), blue.into()),
(
"link_uri".into(),
HighlightStyle {
color: Some(teal),
font_style: Some(FontStyle::Italic),
..HighlightStyle::default()
},
),
("number".into(), orange.into()),
("operator".into(), HighlightStyle::default()),
("predictive".into(), HighlightStyle::default()),
("preproc".into(), HighlightStyle::default()),
("primary".into(), HighlightStyle::default()),
("property".into(), red.into()),
("punctuation".into(), HighlightStyle::default()),
("punctuation.bracket".into(), HighlightStyle::default()),
("punctuation.delimiter".into(), HighlightStyle::default()),
("punctuation.list_marker".into(), HighlightStyle::default()),
("punctuation.special".into(), HighlightStyle::default()),
("string".into(), green.into()),
("string.escape".into(), HighlightStyle::default()),
("string.regex".into(), red.into()),
("string.special".into(), HighlightStyle::default()),
("string.special.symbol".into(), HighlightStyle::default()),
("tag".into(), HighlightStyle::default()),
("text.literal".into(), HighlightStyle::default()),
("title".into(), HighlightStyle::default()),
("type".into(), teal.into()),
("variable".into(), HighlightStyle::default()),
("variable.special".into(), red.into()),
("variant".into(), HighlightStyle::default()),
],
}),
},
}
}

View File

@@ -1,6 +1,7 @@
use std::sync::Arc;
use std::{fmt::Debug, path::Path};
use crate::default::default_theme_family;
use anyhow::{Context as _, Result};
use collections::HashMap;
use derive_more::{Deref, DerefMut};
@@ -91,7 +92,7 @@ impl ThemeRegistry {
// We're loading the Zed default theme, as we need a theme to be loaded
// for tests.
registry.insert_theme_families([crate::fallback_themes::zed_default_themes()]);
registry.insert_theme_families([default_theme_family()]);
let default_icon_theme = crate::default_icon_theme();
registry

View File

@@ -1,298 +0,0 @@
#![allow(missing_docs)]
use gpui::{App, Hsla, SharedString};
use crate::{ActiveTheme, Appearance};
/// A collection of colors that are used to style the UI.
///
/// Each step has a semantic meaning, and is used to style different parts of the UI.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub struct ColorScaleStep(usize);
impl ColorScaleStep {
pub const ONE: Self = Self(1);
pub const TWO: Self = Self(2);
pub const THREE: Self = Self(3);
pub const FOUR: Self = Self(4);
pub const FIVE: Self = Self(5);
pub const SIX: Self = Self(6);
pub const SEVEN: Self = Self(7);
pub const EIGHT: Self = Self(8);
pub const NINE: Self = Self(9);
pub const TEN: Self = Self(10);
pub const ELEVEN: Self = Self(11);
pub const TWELVE: Self = Self(12);
/// All of the steps in a [`ColorScale`].
pub const ALL: [ColorScaleStep; 12] = [
Self::ONE,
Self::TWO,
Self::THREE,
Self::FOUR,
Self::FIVE,
Self::SIX,
Self::SEVEN,
Self::EIGHT,
Self::NINE,
Self::TEN,
Self::ELEVEN,
Self::TWELVE,
];
}
/// A scale of colors for a given [`ColorScaleSet`].
///
/// Each [`ColorScale`] contains exactly 12 colors. Refer to
/// [`ColorScaleStep`] for a reference of what each step is used for.
pub struct ColorScale(Vec<Hsla>);
impl FromIterator<Hsla> for ColorScale {
fn from_iter<T: IntoIterator<Item = Hsla>>(iter: T) -> Self {
Self(Vec::from_iter(iter))
}
}
impl ColorScale {
/// Returns the specified step in the [`ColorScale`].
#[inline]
pub fn step(&self, step: ColorScaleStep) -> Hsla {
// Steps are one-based, so we need convert to the zero-based vec index.
self.0[step.0 - 1]
}
/// `Step 1` - Used for main application backgrounds.
///
/// This step provides a neutral base for any overlaying components, ideal for applications' main backdrop or empty spaces such as canvas areas.
///
#[inline]
pub fn step_1(&self) -> Hsla {
self.step(ColorScaleStep::ONE)
}
/// `Step 2` - Used for both main application backgrounds and subtle component backgrounds.
///
/// Like `Step 1`, this step allows variations in background styles, from striped tables, sidebar backgrounds, to card backgrounds.
#[inline]
pub fn step_2(&self) -> Hsla {
self.step(ColorScaleStep::TWO)
}
/// `Step 3` - Used for UI component backgrounds in their normal states.
///
/// This step maintains accessibility by guaranteeing a contrast ratio of 4.5:1 with steps 11 and 12 for text. It could also suit hover states for transparent components.
#[inline]
pub fn step_3(&self) -> Hsla {
self.step(ColorScaleStep::THREE)
}
/// `Step 4` - Used for UI component backgrounds in their hover states.
///
/// Also suited for pressed or selected states of components with a transparent background.
#[inline]
pub fn step_4(&self) -> Hsla {
self.step(ColorScaleStep::FOUR)
}
/// `Step 5` - Used for UI component backgrounds in their pressed or selected states.
#[inline]
pub fn step_5(&self) -> Hsla {
self.step(ColorScaleStep::FIVE)
}
/// `Step 6` - Used for subtle borders on non-interactive components.
///
/// Its usage spans from sidebars' borders, headers' dividers, cards' outlines, to alerts' edges and separators.
#[inline]
pub fn step_6(&self) -> Hsla {
self.step(ColorScaleStep::SIX)
}
/// `Step 7` - Used for subtle borders on interactive components.
///
/// This step subtly delineates the boundary of elements users interact with.
#[inline]
pub fn step_7(&self) -> Hsla {
self.step(ColorScaleStep::SEVEN)
}
/// `Step 8` - Used for stronger borders on interactive components and focus rings.
///
/// It strengthens the visibility and accessibility of active elements and their focus states.
#[inline]
pub fn step_8(&self) -> Hsla {
self.step(ColorScaleStep::EIGHT)
}
/// `Step 9` - Used for solid backgrounds.
///
/// `Step 9` is the most saturated step, having the least mix of white or black.
///
/// Due to its high chroma, `Step 9` is versatile and particularly useful for semantic colors such as
/// error, warning, and success indicators.
#[inline]
pub fn step_9(&self) -> Hsla {
self.step(ColorScaleStep::NINE)
}
/// `Step 10` - Used for hovered or active solid backgrounds, particularly when `Step 9` is their normal state.
///
/// May also be used for extremely low contrast text. This should be used sparingly, as it may be difficult to read.
#[inline]
pub fn step_10(&self) -> Hsla {
self.step(ColorScaleStep::TEN)
}
/// `Step 11` - Used for text and icons requiring low contrast or less emphasis.
#[inline]
pub fn step_11(&self) -> Hsla {
self.step(ColorScaleStep::ELEVEN)
}
/// `Step 12` - Used for text and icons requiring high contrast or prominence.
#[inline]
pub fn step_12(&self) -> Hsla {
self.step(ColorScaleStep::TWELVE)
}
}
pub struct ColorScales {
pub gray: ColorScaleSet,
pub mauve: ColorScaleSet,
pub slate: ColorScaleSet,
pub sage: ColorScaleSet,
pub olive: ColorScaleSet,
pub sand: ColorScaleSet,
pub gold: ColorScaleSet,
pub bronze: ColorScaleSet,
pub brown: ColorScaleSet,
pub yellow: ColorScaleSet,
pub amber: ColorScaleSet,
pub orange: ColorScaleSet,
pub tomato: ColorScaleSet,
pub red: ColorScaleSet,
pub ruby: ColorScaleSet,
pub crimson: ColorScaleSet,
pub pink: ColorScaleSet,
pub plum: ColorScaleSet,
pub purple: ColorScaleSet,
pub violet: ColorScaleSet,
pub iris: ColorScaleSet,
pub indigo: ColorScaleSet,
pub blue: ColorScaleSet,
pub cyan: ColorScaleSet,
pub teal: ColorScaleSet,
pub jade: ColorScaleSet,
pub green: ColorScaleSet,
pub grass: ColorScaleSet,
pub lime: ColorScaleSet,
pub mint: ColorScaleSet,
pub sky: ColorScaleSet,
pub black: ColorScaleSet,
pub white: ColorScaleSet,
}
impl IntoIterator for ColorScales {
type Item = ColorScaleSet;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
vec![
self.gray,
self.mauve,
self.slate,
self.sage,
self.olive,
self.sand,
self.gold,
self.bronze,
self.brown,
self.yellow,
self.amber,
self.orange,
self.tomato,
self.red,
self.ruby,
self.crimson,
self.pink,
self.plum,
self.purple,
self.violet,
self.iris,
self.indigo,
self.blue,
self.cyan,
self.teal,
self.jade,
self.green,
self.grass,
self.lime,
self.mint,
self.sky,
self.black,
self.white,
]
.into_iter()
}
}
/// Provides groups of [`ColorScale`]s for light and dark themes, as well as transparent versions of each scale.
pub struct ColorScaleSet {
name: SharedString,
light: ColorScale,
dark: ColorScale,
light_alpha: ColorScale,
dark_alpha: ColorScale,
}
impl ColorScaleSet {
pub fn new(
name: impl Into<SharedString>,
light: ColorScale,
light_alpha: ColorScale,
dark: ColorScale,
dark_alpha: ColorScale,
) -> Self {
Self {
name: name.into(),
light,
light_alpha,
dark,
dark_alpha,
}
}
pub fn name(&self) -> &SharedString {
&self.name
}
pub fn light(&self) -> &ColorScale {
&self.light
}
pub fn light_alpha(&self) -> &ColorScale {
&self.light_alpha
}
pub fn dark(&self) -> &ColorScale {
&self.dark
}
pub fn dark_alpha(&self) -> &ColorScale {
&self.dark_alpha
}
pub fn step(&self, cx: &App, step: ColorScaleStep) -> Hsla {
match cx.theme().appearance {
Appearance::Light => self.light().step(step),
Appearance::Dark => self.dark().step(step),
}
}
pub fn step_alpha(&self, cx: &App, step: ColorScaleStep) -> Hsla {
match cx.theme().appearance {
Appearance::Light => self.light_alpha.step(step),
Appearance::Dark => self.dark_alpha.step(step),
}
}
}

View File

@@ -1,4 +1,4 @@
use crate::fallback_themes::zed_default_dark;
use crate::default::{DEFAULT_DARK_THEME_NAME, default_dark_theme};
use crate::{
Appearance, DEFAULT_ICON_THEME_NAME, IconTheme, IconThemeNotFoundError, SyntaxTheme, Theme,
ThemeNotFoundError, ThemeRegistry, ThemeStyleContent,
@@ -846,7 +846,7 @@ impl settings::Settings for ThemeSettings {
theme_selection: defaults.theme.clone(),
active_theme: themes
.get(defaults.theme.as_ref().unwrap().theme(*system_appearance))
.or(themes.get(&zed_default_dark().name))
.or(themes.get(&DEFAULT_DARK_THEME_NAME))
.unwrap(),
theme_overrides: None,
icon_theme_selection: defaults.icon_theme.clone(),

View File

@@ -1,10 +1,7 @@
use gpui::Hsla;
use serde_derive::Deserialize;
use crate::{
AccentContent, amber, blue, cyan, gold, grass, indigo, iris, jade, lime, orange, pink, purple,
tomato, try_parse_color,
};
use crate::{AccentContent, default::default_dark_theme, try_parse_color};
/// A collection of colors that are used to color indent aware lines in the editor.
#[derive(Clone, Debug, Deserialize, PartialEq)]
@@ -15,47 +12,7 @@ impl Default for AccentColors {
/// We have to have a default to be `[refineable::Refinable]`.
/// TODO "Find a way to not need this for Refinable"
fn default() -> Self {
Self::dark()
}
}
impl AccentColors {
/// Returns the set of dark accent colors.
pub fn dark() -> Self {
Self(vec![
blue().dark().step_9(),
orange().dark().step_9(),
pink().dark().step_9(),
lime().dark().step_9(),
purple().dark().step_9(),
amber().dark().step_9(),
jade().dark().step_9(),
tomato().dark().step_9(),
cyan().dark().step_9(),
gold().dark().step_9(),
grass().dark().step_9(),
indigo().dark().step_9(),
iris().dark().step_9(),
])
}
/// Returns the set of light accent colors.
pub fn light() -> Self {
Self(vec![
blue().light().step_9(),
orange().light().step_9(),
pink().light().step_9(),
lime().light().step_9(),
purple().light().step_9(),
amber().light().step_9(),
jade().light().step_9(),
tomato().light().step_9(),
cyan().light().step_9(),
gold().light().step_9(),
grass().light().step_9(),
indigo().light().step_9(),
iris().light().step_9(),
])
default_dark_theme().accents().clone()
}
}

View File

@@ -1,14 +1,10 @@
#![allow(missing_docs)]
use gpui::{App, Hsla, SharedString, WindowBackgroundAppearance};
use crate::StatusColorsRefinement;
use gpui::{Hsla, WindowBackgroundAppearance};
use refineable::Refineable;
use std::sync::Arc;
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
use crate::{
AccentColors, ActiveTheme, PlayerColors, StatusColors, StatusColorsRefinement, SyntaxTheme,
SystemColors,
};
use crate::{AccentColors, PlayerColors, StatusColors, SyntaxTheme, SystemColors};
#[derive(Refineable, Clone, Debug, PartialEq)]
#[refineable(Debug, serde::Deserialize)]
@@ -280,261 +276,6 @@ pub struct ThemeColors {
pub version_control_conflict_marker_theirs: Hsla,
}
#[derive(EnumIter, Debug, Clone, Copy, AsRefStr)]
#[strum(serialize_all = "snake_case")]
pub enum ThemeColorField {
Border,
BorderVariant,
BorderFocused,
BorderSelected,
BorderTransparent,
BorderDisabled,
ElevatedSurfaceBackground,
SurfaceBackground,
Background,
ElementBackground,
ElementHover,
ElementActive,
ElementSelected,
ElementDisabled,
DropTargetBackground,
GhostElementBackground,
GhostElementHover,
GhostElementActive,
GhostElementSelected,
GhostElementDisabled,
Text,
TextMuted,
TextPlaceholder,
TextDisabled,
TextAccent,
Icon,
IconMuted,
IconDisabled,
IconPlaceholder,
IconAccent,
StatusBarBackground,
TitleBarBackground,
TitleBarInactiveBackground,
ToolbarBackground,
TabBarBackground,
TabInactiveBackground,
TabActiveBackground,
SearchMatchBackground,
PanelBackground,
PanelFocusedBorder,
PanelIndentGuide,
PanelIndentGuideHover,
PanelIndentGuideActive,
PaneFocusedBorder,
PaneGroupBorder,
ScrollbarThumbBackground,
ScrollbarThumbHoverBackground,
ScrollbarThumbActiveBackground,
ScrollbarThumbBorder,
ScrollbarTrackBackground,
ScrollbarTrackBorder,
MinimapThumbBackground,
MinimapThumbHoverBackground,
MinimapThumbActiveBackground,
MinimapThumbBorder,
EditorForeground,
EditorBackground,
EditorGutterBackground,
EditorSubheaderBackground,
EditorActiveLineBackground,
EditorHighlightedLineBackground,
EditorLineNumber,
EditorActiveLineNumber,
EditorInvisible,
EditorWrapGuide,
EditorActiveWrapGuide,
EditorIndentGuide,
EditorIndentGuideActive,
EditorDocumentHighlightReadBackground,
EditorDocumentHighlightWriteBackground,
EditorDocumentHighlightBracketBackground,
TerminalBackground,
TerminalForeground,
TerminalBrightForeground,
TerminalDimForeground,
TerminalAnsiBackground,
TerminalAnsiBlack,
TerminalAnsiBrightBlack,
TerminalAnsiDimBlack,
TerminalAnsiRed,
TerminalAnsiBrightRed,
TerminalAnsiDimRed,
TerminalAnsiGreen,
TerminalAnsiBrightGreen,
TerminalAnsiDimGreen,
TerminalAnsiYellow,
TerminalAnsiBrightYellow,
TerminalAnsiDimYellow,
TerminalAnsiBlue,
TerminalAnsiBrightBlue,
TerminalAnsiDimBlue,
TerminalAnsiMagenta,
TerminalAnsiBrightMagenta,
TerminalAnsiDimMagenta,
TerminalAnsiCyan,
TerminalAnsiBrightCyan,
TerminalAnsiDimCyan,
TerminalAnsiWhite,
TerminalAnsiBrightWhite,
TerminalAnsiDimWhite,
LinkTextHover,
VersionControlAdded,
VersionControlDeleted,
VersionControlModified,
VersionControlRenamed,
VersionControlConflict,
VersionControlIgnored,
}
impl ThemeColors {
pub fn color(&self, field: ThemeColorField) -> Hsla {
match field {
ThemeColorField::Border => self.border,
ThemeColorField::BorderVariant => self.border_variant,
ThemeColorField::BorderFocused => self.border_focused,
ThemeColorField::BorderSelected => self.border_selected,
ThemeColorField::BorderTransparent => self.border_transparent,
ThemeColorField::BorderDisabled => self.border_disabled,
ThemeColorField::ElevatedSurfaceBackground => self.elevated_surface_background,
ThemeColorField::SurfaceBackground => self.surface_background,
ThemeColorField::Background => self.background,
ThemeColorField::ElementBackground => self.element_background,
ThemeColorField::ElementHover => self.element_hover,
ThemeColorField::ElementActive => self.element_active,
ThemeColorField::ElementSelected => self.element_selected,
ThemeColorField::ElementDisabled => self.element_disabled,
ThemeColorField::DropTargetBackground => self.drop_target_background,
ThemeColorField::GhostElementBackground => self.ghost_element_background,
ThemeColorField::GhostElementHover => self.ghost_element_hover,
ThemeColorField::GhostElementActive => self.ghost_element_active,
ThemeColorField::GhostElementSelected => self.ghost_element_selected,
ThemeColorField::GhostElementDisabled => self.ghost_element_disabled,
ThemeColorField::Text => self.text,
ThemeColorField::TextMuted => self.text_muted,
ThemeColorField::TextPlaceholder => self.text_placeholder,
ThemeColorField::TextDisabled => self.text_disabled,
ThemeColorField::TextAccent => self.text_accent,
ThemeColorField::Icon => self.icon,
ThemeColorField::IconMuted => self.icon_muted,
ThemeColorField::IconDisabled => self.icon_disabled,
ThemeColorField::IconPlaceholder => self.icon_placeholder,
ThemeColorField::IconAccent => self.icon_accent,
ThemeColorField::StatusBarBackground => self.status_bar_background,
ThemeColorField::TitleBarBackground => self.title_bar_background,
ThemeColorField::TitleBarInactiveBackground => self.title_bar_inactive_background,
ThemeColorField::ToolbarBackground => self.toolbar_background,
ThemeColorField::TabBarBackground => self.tab_bar_background,
ThemeColorField::TabInactiveBackground => self.tab_inactive_background,
ThemeColorField::TabActiveBackground => self.tab_active_background,
ThemeColorField::SearchMatchBackground => self.search_match_background,
ThemeColorField::PanelBackground => self.panel_background,
ThemeColorField::PanelFocusedBorder => self.panel_focused_border,
ThemeColorField::PanelIndentGuide => self.panel_indent_guide,
ThemeColorField::PanelIndentGuideHover => self.panel_indent_guide_hover,
ThemeColorField::PanelIndentGuideActive => self.panel_indent_guide_active,
ThemeColorField::PaneFocusedBorder => self.pane_focused_border,
ThemeColorField::PaneGroupBorder => self.pane_group_border,
ThemeColorField::ScrollbarThumbBackground => self.scrollbar_thumb_background,
ThemeColorField::ScrollbarThumbHoverBackground => self.scrollbar_thumb_hover_background,
ThemeColorField::ScrollbarThumbActiveBackground => {
self.scrollbar_thumb_active_background
}
ThemeColorField::ScrollbarThumbBorder => self.scrollbar_thumb_border,
ThemeColorField::ScrollbarTrackBackground => self.scrollbar_track_background,
ThemeColorField::ScrollbarTrackBorder => self.scrollbar_track_border,
ThemeColorField::MinimapThumbBackground => self.minimap_thumb_background,
ThemeColorField::MinimapThumbHoverBackground => self.minimap_thumb_hover_background,
ThemeColorField::MinimapThumbActiveBackground => self.minimap_thumb_active_background,
ThemeColorField::MinimapThumbBorder => self.minimap_thumb_border,
ThemeColorField::EditorForeground => self.editor_foreground,
ThemeColorField::EditorBackground => self.editor_background,
ThemeColorField::EditorGutterBackground => self.editor_gutter_background,
ThemeColorField::EditorSubheaderBackground => self.editor_subheader_background,
ThemeColorField::EditorActiveLineBackground => self.editor_active_line_background,
ThemeColorField::EditorHighlightedLineBackground => {
self.editor_highlighted_line_background
}
ThemeColorField::EditorLineNumber => self.editor_line_number,
ThemeColorField::EditorActiveLineNumber => self.editor_active_line_number,
ThemeColorField::EditorInvisible => self.editor_invisible,
ThemeColorField::EditorWrapGuide => self.editor_wrap_guide,
ThemeColorField::EditorActiveWrapGuide => self.editor_active_wrap_guide,
ThemeColorField::EditorIndentGuide => self.editor_indent_guide,
ThemeColorField::EditorIndentGuideActive => self.editor_indent_guide_active,
ThemeColorField::EditorDocumentHighlightReadBackground => {
self.editor_document_highlight_read_background
}
ThemeColorField::EditorDocumentHighlightWriteBackground => {
self.editor_document_highlight_write_background
}
ThemeColorField::EditorDocumentHighlightBracketBackground => {
self.editor_document_highlight_bracket_background
}
ThemeColorField::TerminalBackground => self.terminal_background,
ThemeColorField::TerminalForeground => self.terminal_foreground,
ThemeColorField::TerminalBrightForeground => self.terminal_bright_foreground,
ThemeColorField::TerminalDimForeground => self.terminal_dim_foreground,
ThemeColorField::TerminalAnsiBackground => self.terminal_ansi_background,
ThemeColorField::TerminalAnsiBlack => self.terminal_ansi_black,
ThemeColorField::TerminalAnsiBrightBlack => self.terminal_ansi_bright_black,
ThemeColorField::TerminalAnsiDimBlack => self.terminal_ansi_dim_black,
ThemeColorField::TerminalAnsiRed => self.terminal_ansi_red,
ThemeColorField::TerminalAnsiBrightRed => self.terminal_ansi_bright_red,
ThemeColorField::TerminalAnsiDimRed => self.terminal_ansi_dim_red,
ThemeColorField::TerminalAnsiGreen => self.terminal_ansi_green,
ThemeColorField::TerminalAnsiBrightGreen => self.terminal_ansi_bright_green,
ThemeColorField::TerminalAnsiDimGreen => self.terminal_ansi_dim_green,
ThemeColorField::TerminalAnsiYellow => self.terminal_ansi_yellow,
ThemeColorField::TerminalAnsiBrightYellow => self.terminal_ansi_bright_yellow,
ThemeColorField::TerminalAnsiDimYellow => self.terminal_ansi_dim_yellow,
ThemeColorField::TerminalAnsiBlue => self.terminal_ansi_blue,
ThemeColorField::TerminalAnsiBrightBlue => self.terminal_ansi_bright_blue,
ThemeColorField::TerminalAnsiDimBlue => self.terminal_ansi_dim_blue,
ThemeColorField::TerminalAnsiMagenta => self.terminal_ansi_magenta,
ThemeColorField::TerminalAnsiBrightMagenta => self.terminal_ansi_bright_magenta,
ThemeColorField::TerminalAnsiDimMagenta => self.terminal_ansi_dim_magenta,
ThemeColorField::TerminalAnsiCyan => self.terminal_ansi_cyan,
ThemeColorField::TerminalAnsiBrightCyan => self.terminal_ansi_bright_cyan,
ThemeColorField::TerminalAnsiDimCyan => self.terminal_ansi_dim_cyan,
ThemeColorField::TerminalAnsiWhite => self.terminal_ansi_white,
ThemeColorField::TerminalAnsiBrightWhite => self.terminal_ansi_bright_white,
ThemeColorField::TerminalAnsiDimWhite => self.terminal_ansi_dim_white,
ThemeColorField::LinkTextHover => self.link_text_hover,
ThemeColorField::VersionControlAdded => self.version_control_added,
ThemeColorField::VersionControlDeleted => self.version_control_deleted,
ThemeColorField::VersionControlModified => self.version_control_modified,
ThemeColorField::VersionControlRenamed => self.version_control_renamed,
ThemeColorField::VersionControlConflict => self.version_control_conflict,
ThemeColorField::VersionControlIgnored => self.version_control_ignored,
}
}
pub fn iter(&self) -> impl Iterator<Item = (ThemeColorField, Hsla)> + '_ {
ThemeColorField::iter().map(move |field| (field, self.color(field)))
}
pub fn to_vec(&self) -> Vec<(ThemeColorField, Hsla)> {
self.iter().collect()
}
}
pub fn all_theme_colors(cx: &mut App) -> Vec<(Hsla, SharedString)> {
let theme = cx.theme();
ThemeColorField::iter()
.map(|field| {
let color = theme.colors().color(field);
let name = field.as_ref().to_string();
(color, SharedString::from(name))
})
.collect()
}
#[derive(Refineable, Clone, Debug, PartialEq)]
pub struct ThemeStyles {
/// The background appearance of the window.
@@ -560,11 +301,13 @@ pub struct ThemeStyles {
mod tests {
use serde_json::json;
use crate::default::default_dark_theme;
use super::*;
#[test]
fn override_a_single_theme_color() {
let mut colors = ThemeColors::light();
let mut colors = default_dark_theme().colors().clone();
let magenta: Hsla = gpui::rgb(0xff00ff).into();
@@ -582,7 +325,7 @@ mod tests {
#[test]
fn override_multiple_theme_colors() {
let mut colors = ThemeColors::light();
let mut colors = default_dark_theme().colors().clone();
let magenta: Hsla = gpui::rgb(0xff00ff).into();
let green: Hsla = gpui::rgb(0x00ff00).into();

View File

@@ -3,9 +3,7 @@
use gpui::Hsla;
use serde_derive::Deserialize;
use crate::{
PlayerColorContent, amber, blue, jade, lime, orange, pink, purple, red, try_parse_color,
};
use crate::{PlayerColorContent, default::default_dark_theme, try_parse_color};
#[derive(Debug, Clone, Copy, Deserialize, Default, PartialEq)]
pub struct PlayerColor {
@@ -28,99 +26,7 @@ impl Default for PlayerColors {
/// We have to have a default to be `[refineable::Refinable]`.
/// TODO "Find a way to not need this for Refinable"
fn default() -> Self {
Self::dark()
}
}
impl PlayerColors {
pub fn dark() -> Self {
Self(vec![
PlayerColor {
cursor: blue().dark().step_9(),
background: blue().dark().step_5(),
selection: blue().dark().step_3(),
},
PlayerColor {
cursor: orange().dark().step_9(),
background: orange().dark().step_5(),
selection: orange().dark().step_3(),
},
PlayerColor {
cursor: pink().dark().step_9(),
background: pink().dark().step_5(),
selection: pink().dark().step_3(),
},
PlayerColor {
cursor: lime().dark().step_9(),
background: lime().dark().step_5(),
selection: lime().dark().step_3(),
},
PlayerColor {
cursor: purple().dark().step_9(),
background: purple().dark().step_5(),
selection: purple().dark().step_3(),
},
PlayerColor {
cursor: amber().dark().step_9(),
background: amber().dark().step_5(),
selection: amber().dark().step_3(),
},
PlayerColor {
cursor: jade().dark().step_9(),
background: jade().dark().step_5(),
selection: jade().dark().step_3(),
},
PlayerColor {
cursor: red().dark().step_9(),
background: red().dark().step_5(),
selection: red().dark().step_3(),
},
])
}
pub fn light() -> Self {
Self(vec![
PlayerColor {
cursor: blue().light().step_9(),
background: blue().light().step_4(),
selection: blue().light().step_3(),
},
PlayerColor {
cursor: orange().light().step_9(),
background: orange().light().step_4(),
selection: orange().light().step_3(),
},
PlayerColor {
cursor: pink().light().step_9(),
background: pink().light().step_4(),
selection: pink().light().step_3(),
},
PlayerColor {
cursor: lime().light().step_9(),
background: lime().light().step_4(),
selection: lime().light().step_3(),
},
PlayerColor {
cursor: purple().light().step_9(),
background: purple().light().step_4(),
selection: purple().light().step_3(),
},
PlayerColor {
cursor: amber().light().step_9(),
background: amber().light().step_4(),
selection: amber().light().step_3(),
},
PlayerColor {
cursor: jade().light().step_9(),
background: jade().light().step_4(),
selection: jade().light().step_3(),
},
PlayerColor {
cursor: red().light().step_9(),
background: red().light().step_4(),
selection: red().light().step_3(),
},
])
default_dark_theme().players().clone()
}
}

View File

@@ -3,7 +3,7 @@
use gpui::Hsla;
use refineable::Refineable;
use crate::{blue, grass, neutral, red, yellow};
use crate::default::default_dark_theme;
#[derive(Refineable, Clone, Debug, PartialEq)]
#[refineable(Debug, serde::Deserialize)]
@@ -80,112 +80,14 @@ pub struct StatusColors {
pub warning_border: Hsla,
}
impl Default for StatusColors {
fn default() -> Self {
default_dark_theme().status().clone()
}
}
pub struct DiagnosticColors {
pub error: Hsla,
pub warning: Hsla,
pub info: Hsla,
}
impl StatusColors {
pub fn dark() -> Self {
Self {
conflict: red().dark().step_9(),
conflict_background: red().dark().step_9(),
conflict_border: red().dark().step_9(),
created: grass().dark().step_9(),
created_background: grass().dark().step_9().opacity(0.25),
created_border: grass().dark().step_9(),
deleted: red().dark().step_9(),
deleted_background: red().dark().step_9().opacity(0.25),
deleted_border: red().dark().step_9(),
error: red().dark().step_9(),
error_background: red().dark().step_9(),
error_border: red().dark().step_9(),
hidden: neutral().dark().step_9(),
hidden_background: neutral().dark().step_9(),
hidden_border: neutral().dark().step_9(),
hint: blue().dark().step_9(),
hint_background: blue().dark().step_9(),
hint_border: blue().dark().step_9(),
ignored: neutral().dark().step_9(),
ignored_background: neutral().dark().step_9(),
ignored_border: neutral().dark().step_9(),
info: blue().dark().step_9(),
info_background: blue().dark().step_9(),
info_border: blue().dark().step_9(),
modified: yellow().dark().step_9(),
modified_background: yellow().dark().step_9().opacity(0.25),
modified_border: yellow().dark().step_9(),
predictive: neutral().dark_alpha().step_9(),
predictive_background: neutral().dark_alpha().step_9(),
predictive_border: neutral().dark_alpha().step_9(),
renamed: blue().dark().step_9(),
renamed_background: blue().dark().step_9(),
renamed_border: blue().dark().step_9(),
success: grass().dark().step_9(),
success_background: grass().dark().step_9(),
success_border: grass().dark().step_9(),
unreachable: neutral().dark().step_10(),
unreachable_background: neutral().dark().step_10(),
unreachable_border: neutral().dark().step_10(),
warning: yellow().dark().step_9(),
warning_background: yellow().dark().step_9(),
warning_border: yellow().dark().step_9(),
}
}
pub fn light() -> Self {
Self {
conflict: red().light().step_9(),
conflict_background: red().light().step_9(),
conflict_border: red().light().step_9(),
created: grass().light().step_9(),
created_background: grass().light().step_9(),
created_border: grass().light().step_9(),
deleted: red().light().step_9(),
deleted_background: red().light().step_9(),
deleted_border: red().light().step_9(),
error: red().light().step_9(),
error_background: red().light().step_9(),
error_border: red().light().step_9(),
hidden: neutral().light().step_9(),
hidden_background: neutral().light().step_9(),
hidden_border: neutral().light().step_9(),
hint: blue().light().step_9(),
hint_background: blue().light().step_9(),
hint_border: blue().light().step_9(),
ignored: neutral().light().step_9(),
ignored_background: neutral().light().step_9(),
ignored_border: neutral().light().step_9(),
info: blue().light().step_9(),
info_background: blue().light().step_9(),
info_border: blue().light().step_9(),
modified: yellow().light().step_9(),
modified_background: yellow().light().step_9(),
modified_border: yellow().light().step_9(),
predictive: neutral().light_alpha().step_9(),
predictive_background: neutral().light_alpha().step_9(),
predictive_border: neutral().light_alpha().step_9(),
renamed: blue().light().step_9(),
renamed_background: blue().light().step_9(),
renamed_border: blue().light().step_9(),
success: grass().light().step_9(),
success_background: grass().light().step_9(),
success_border: grass().light().step_9(),
unreachable: neutral().light().step_10(),
unreachable_background: neutral().light().step_10(),
unreachable_border: neutral().light().step_10(),
warning: yellow().light().step_9(),
warning_background: yellow().light().step_9(),
warning_border: yellow().light().step_9(),
}
}
pub fn diagnostic(&self) -> DiagnosticColors {
DiagnosticColors {
error: self.error,
warning: self.warning,
info: self.info,
}
}
}

View File

@@ -8,13 +8,11 @@
//!
//! A theme is a collection of colors used to build a consistent appearance for UI components across the application.
mod default_colors;
mod fallback_themes;
mod default;
mod font_family_cache;
mod icon_theme;
mod icon_theme_schema;
mod registry;
mod scale;
mod schema;
mod settings;
mod styles;
@@ -25,7 +23,6 @@ use std::sync::Arc;
use ::settings::Settings;
use ::settings::SettingsStore;
use anyhow::Result;
use fallback_themes::apply_status_color_defaults;
use fs::Fs;
use gpui::{
App, AssetSource, HighlightStyle, Hsla, Pixels, Refineable, SharedString, WindowAppearance,
@@ -34,13 +31,12 @@ use gpui::{
use serde::Deserialize;
use uuid::Uuid;
pub use crate::default_colors::*;
use crate::fallback_themes::apply_theme_color_defaults;
use crate::default::default_dark_theme;
use crate::default::default_light_theme;
pub use crate::font_family_cache::*;
pub use crate::icon_theme::*;
pub use crate::icon_theme_schema::*;
pub use crate::registry::*;
pub use crate::scale::*;
pub use crate::schema::*;
pub use crate::settings::*;
pub use crate::styles::*;
@@ -135,6 +131,39 @@ impl ActiveTheme for App {
}
}
// If a theme customizes a foreground version of a status color, but does not
// customize the background color, then use a partly-transparent version of the
// foreground color for the background color.
pub(crate) fn apply_status_color_defaults(status: &mut StatusColorsRefinement) {
for (fg_color, bg_color) in [
(&status.deleted, &mut status.deleted_background),
(&status.created, &mut status.created_background),
(&status.modified, &mut status.modified_background),
(&status.conflict, &mut status.conflict_background),
(&status.error, &mut status.error_background),
(&status.hidden, &mut status.hidden_background),
] {
if bg_color.is_none() {
if let Some(fg_color) = fg_color {
*bg_color = Some(fg_color.opacity(0.25));
}
}
}
}
pub(crate) fn apply_theme_color_defaults(
theme_colors: &mut ThemeColorsRefinement,
player_colors: &PlayerColors,
) {
if theme_colors.element_selection_background.is_none() {
let mut selection = player_colors.local().selection;
if selection.a == 1.0 {
selection.a = 0.25;
}
theme_colors.element_selection_background = Some(selection);
}
}
/// A theme family is a grouping of themes under a single name.
///
/// For example, the "One" theme family contains the "One Light" and "One Dark" themes.
@@ -151,9 +180,6 @@ pub struct ThemeFamily {
pub author: SharedString,
/// The [Theme]s in the family.
pub themes: Vec<Theme>,
/// The color scales used by the themes in the family.
/// Note: This will be removed in the future.
pub scales: ColorScales,
}
impl ThemeFamily {
@@ -166,32 +192,28 @@ impl ThemeFamily {
AppearanceContent::Dark => Appearance::Dark,
};
let mut refined_status_colors = match theme.appearance {
AppearanceContent::Light => StatusColors::light(),
AppearanceContent::Dark => StatusColors::dark(),
let default_theme = match appearance {
Appearance::Light => default_light_theme(),
Appearance::Dark => default_dark_theme(),
};
let mut refined_status_colors = default_theme.status().clone();
let mut status_colors_refinement = theme.style.status_colors_refinement();
apply_status_color_defaults(&mut status_colors_refinement);
refined_status_colors.refine(&status_colors_refinement);
let mut refined_player_colors = match theme.appearance {
AppearanceContent::Light => PlayerColors::light(),
AppearanceContent::Dark => PlayerColors::dark(),
};
let mut refined_player_colors = default_theme.players().clone();
refined_player_colors.merge(&theme.style.players);
let mut refined_theme_colors = match theme.appearance {
AppearanceContent::Light => ThemeColors::light(),
AppearanceContent::Dark => ThemeColors::dark(),
};
// TODO:
let mut refined_theme_colors = default_theme.colors().clone();
let mut theme_colors_refinement = theme.style.theme_colors_refinement();
apply_theme_color_defaults(&mut theme_colors_refinement, &refined_player_colors);
refined_theme_colors.refine(&theme_colors_refinement);
let mut refined_accent_colors = match theme.appearance {
AppearanceContent::Light => AccentColors::light(),
AppearanceContent::Dark => AccentColors::dark(),
};
let mut refined_accent_colors = default_theme.accents().clone();
refined_accent_colors.merge(&theme.style.accents);
let syntax_highlights = theme
@@ -253,7 +275,6 @@ pub fn refine_theme_family(theme_family_content: ThemeFamilyContent) -> ThemeFam
name: name.clone().into(),
author: author.clone().into(),
themes: vec![],
scales: default_color_scales(),
};
let refined_themes = theme_family_content

View File

@@ -1,7 +1,6 @@
#![allow(unused, dead_code)]
use gpui::{AnyElement, App, Entity, EventEmitter, FocusHandle, Focusable, Hsla, actions, hsla};
use strum::IntoEnumIterator;
use theme::all_theme_colors;
use ui::{
AudioStatus, Avatar, AvatarAudioStatusIndicator, AvatarAvailabilityIndicator, ButtonLike,
Checkbox, CheckboxWithLabel, CollaboratorAvailability, ContentGroup, DecoratedIcon,
@@ -281,56 +280,6 @@ impl ThemePreview {
)
}
fn render_colors(
&self,
layer: ElevationIndex,
window: &mut Window,
cx: &mut Context<Self>,
) -> impl IntoElement {
let bg = layer.bg(cx);
let all_colors = all_theme_colors(cx);
v_flex()
.gap_1()
.child(
Headline::new("Colors")
.size(HeadlineSize::Small)
.color(Color::Muted),
)
.child(
h_flex()
.flex_wrap()
.gap_1()
.children(all_colors.into_iter().map(|(color, name)| {
let id = ElementId::Name(format!("{:?}-preview", color).into());
let name = name.clone();
div().size_8().flex_none().child(
ButtonLike::new(id)
.child(
div()
.size_8()
.bg(color)
.border_1()
.border_color(cx.theme().colors().border)
.overflow_hidden(),
)
.size(ButtonSize::None)
.style(ButtonStyle::Transparent)
.tooltip(move |window, cx| {
let name = name.clone();
Tooltip::with_meta(
name,
None,
format!("{:?}", color),
window,
cx,
)
}),
)
})),
)
}
fn render_theme_layer(
&self,
layer: ElevationIndex,
@@ -344,7 +293,6 @@ impl ThemePreview {
.gap_2()
.child(Headline::new(layer.clone().to_string()).size(HeadlineSize::Medium))
.child(self.render_text(layer, window, cx))
.child(self.render_colors(layer, window, cx))
}
fn render_overview_page(