Start using base theme in zed1 theme importer
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
parent
30624b9899
commit
7ea9725125
12 changed files with 894 additions and 123 deletions
|
@ -1,5 +1,5 @@
|
|||
use anyhow::Result;
|
||||
use gpui::{Hsla, Rgba};
|
||||
use anyhow::{Context, Result};
|
||||
use gpui::{serde_json, Hsla, Rgba};
|
||||
use gpui1::color::Color as Zed1Color;
|
||||
use gpui1::fonts::HighlightStyle as Zed1HighlightStyle;
|
||||
use theme::{
|
||||
|
@ -7,7 +7,7 @@ use theme::{
|
|||
UserFontStyle, UserFontWeight, UserHighlightStyle, UserSyntaxTheme, UserTheme,
|
||||
UserThemeStylesRefinement,
|
||||
};
|
||||
use theme1::Theme as Zed1Theme;
|
||||
use theme1::{ColorScheme, Theme as Zed1Theme};
|
||||
|
||||
fn zed1_color_to_hsla(color: Zed1Color) -> Hsla {
|
||||
let r = color.r as f32 / 255.;
|
||||
|
@ -118,6 +118,13 @@ impl Zed1ThemeConverter {
|
|||
Some(zed1_color_to_hsla(color))
|
||||
}
|
||||
|
||||
let base_theme: ColorScheme = serde_json::from_value(self.theme.base_theme.clone())
|
||||
.with_context(|| "failed to parse `theme.base_theme`")?;
|
||||
|
||||
let lowest = &base_theme.lowest;
|
||||
let middle = &base_theme.middle;
|
||||
let highest = &base_theme.highest;
|
||||
|
||||
let picker = &self.theme.picker;
|
||||
let title_bar = &self.theme.titlebar;
|
||||
let status_bar = &self.theme.workspace.status_bar;
|
||||
|
@ -131,57 +138,93 @@ impl Zed1ThemeConverter {
|
|||
let terminal = &self.theme.terminal;
|
||||
|
||||
Ok(ThemeColorsRefinement {
|
||||
border: convert(active_tab.container.border.color),
|
||||
border_variant: convert(toolbar.container.border.color),
|
||||
background: convert(self.theme.workspace.background),
|
||||
border: convert(lowest.base.default.border),
|
||||
border_variant: convert(lowest.variant.default.border),
|
||||
border_focused: convert(lowest.accent.hovered.border),
|
||||
border_selected: convert(lowest.accent.default.border),
|
||||
border_transparent: Some(gpui::transparent_black()),
|
||||
border_disabled: convert(lowest.base.disabled.border),
|
||||
elevated_surface_background: editor
|
||||
.hover_popover
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
title_bar_background: title_bar.container.background_color.map(zed1_color_to_hsla),
|
||||
status_bar_background: status_bar
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla)
|
||||
.or_else(|| title_bar.container.background_color.map(zed1_color_to_hsla)),
|
||||
panel_background: project_panel
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
text: convert(self.theme.collab_panel.channel_name.text.color),
|
||||
text_muted: convert(tab_bar.pane_button.default_style().color),
|
||||
text_accent: convert(status_bar.panel_buttons.button.active_state().icon_color),
|
||||
text_disabled: convert(status_bar.panel_buttons.button.disabled_style().icon_color),
|
||||
text_placeholder: picker
|
||||
.empty_input_editor
|
||||
.placeholder_text
|
||||
.as_ref()
|
||||
.map(|placeholder_text| placeholder_text.color)
|
||||
.map(zed1_color_to_hsla),
|
||||
surface_background: convert(middle.base.default.background),
|
||||
background: convert(self.theme.workspace.background),
|
||||
element_background: convert(lowest.on.default.background),
|
||||
element_hover: picker
|
||||
.item
|
||||
.hovered
|
||||
.as_ref()
|
||||
.and_then(|hovered| hovered.container.background_color)
|
||||
.map(zed1_color_to_hsla),
|
||||
element_active: convert(lowest.on.active.background),
|
||||
element_selected: picker
|
||||
.item
|
||||
.active_state()
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
tab_bar_background: tab_bar.container.background_color.map(zed1_color_to_hsla),
|
||||
tab_active_background: active_tab
|
||||
element_disabled: convert(lowest.on.disabled.background),
|
||||
drop_target_background: convert(self.theme.workspace.drop_target_overlay_color),
|
||||
ghost_element_background: Some(gpui::transparent_black()),
|
||||
ghost_element_hover: picker
|
||||
.item
|
||||
.hovered
|
||||
.as_ref()
|
||||
.and_then(|hovered| hovered.container.background_color)
|
||||
.map(zed1_color_to_hsla),
|
||||
ghost_element_active: convert(lowest.on.active.background),
|
||||
ghost_element_selected: picker
|
||||
.item
|
||||
.active_state()
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
ghost_element_disabled: convert(lowest.on.disabled.background),
|
||||
icon: convert(lowest.base.default.foreground),
|
||||
icon_muted: convert(lowest.variant.default.foreground),
|
||||
icon_placeholder: convert(lowest.variant.default.foreground), // TODO: What should placeholder be?
|
||||
icon_disabled: convert(lowest.base.disabled.foreground),
|
||||
icon_accent: convert(lowest.accent.default.foreground),
|
||||
text: convert(self.theme.collab_panel.channel_name.text.color),
|
||||
text_muted: convert(tab_bar.pane_button.default_style().color),
|
||||
text_placeholder: picker
|
||||
.empty_input_editor
|
||||
.placeholder_text
|
||||
.as_ref()
|
||||
.map(|placeholder_text| placeholder_text.color)
|
||||
.map(zed1_color_to_hsla),
|
||||
text_disabled: convert(status_bar.panel_buttons.button.disabled_style().icon_color),
|
||||
text_accent: convert(status_bar.panel_buttons.button.active_state().icon_color),
|
||||
status_bar_background: status_bar
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla)
|
||||
.or_else(|| title_bar.container.background_color.map(zed1_color_to_hsla)),
|
||||
title_bar_background: title_bar.container.background_color.map(zed1_color_to_hsla),
|
||||
toolbar_background: toolbar.container.background_color.map(zed1_color_to_hsla),
|
||||
tab_bar_background: tab_bar.container.background_color.map(zed1_color_to_hsla),
|
||||
tab_inactive_background: inactive_tab
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
drop_target_background: convert(self.theme.workspace.drop_target_overlay_color),
|
||||
toolbar_background: toolbar.container.background_color.map(zed1_color_to_hsla),
|
||||
tab_active_background: active_tab
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
panel_background: project_panel
|
||||
.container
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
scrollbar_thumb_background: scrollbar.thumb.background_color.map(zed1_color_to_hsla),
|
||||
scrollbar_thumb_hover_background: scrollbar
|
||||
.thumb
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
scrollbar_thumb_border: convert(scrollbar.thumb.border.color),
|
||||
scrollbar_track_background: convert(highest.base.default.background),
|
||||
scrollbar_track_border: convert(scrollbar.track.border.color),
|
||||
editor_foreground: convert(editor.text_color),
|
||||
editor_background: convert(editor.background),
|
||||
editor_gutter_background: convert(editor.gutter_background),
|
||||
|
@ -189,14 +232,6 @@ impl Zed1ThemeConverter {
|
|||
editor_active_line_number: convert(editor.line_number_active),
|
||||
editor_wrap_guide: convert(editor.wrap_guide),
|
||||
editor_active_wrap_guide: convert(editor.active_wrap_guide),
|
||||
scrollbar_track_background: scrollbar.track.background_color.map(zed1_color_to_hsla),
|
||||
scrollbar_track_border: convert(scrollbar.track.border.color),
|
||||
scrollbar_thumb_background: scrollbar.thumb.background_color.map(zed1_color_to_hsla),
|
||||
scrollbar_thumb_border: convert(scrollbar.thumb.border.color),
|
||||
scrollbar_thumb_hover_background: scrollbar
|
||||
.thumb
|
||||
.background_color
|
||||
.map(zed1_color_to_hsla),
|
||||
terminal_background: convert(terminal.background),
|
||||
terminal_ansi_bright_black: convert(terminal.bright_black),
|
||||
terminal_ansi_bright_red: convert(terminal.bright_red),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue