Flatten theme styles by eliminating top-level ui key
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
9b7756f566
commit
9ff764983d
6 changed files with 24 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
[ui]
|
[workspace]
|
||||||
background = "$surface.0"
|
background = "$surface.0"
|
||||||
|
|
||||||
[ui.tab]
|
[tab]
|
||||||
background = "$surface.1"
|
background = "$surface.1"
|
||||||
text = "$text_color.dull"
|
text = "$text_color.dull"
|
||||||
border = { color = "#000000", width = 1.0 }
|
border = { color = "#000000", width = 1.0 }
|
||||||
|
@ -10,12 +10,12 @@ icon_close = "#383839"
|
||||||
icon_dirty = "#556de8"
|
icon_dirty = "#556de8"
|
||||||
icon_conflict = "#e45349"
|
icon_conflict = "#e45349"
|
||||||
|
|
||||||
[ui.active_tab]
|
[active_tab]
|
||||||
extends = "$ui.tab"
|
extends = "$tab"
|
||||||
background = "$surface.2"
|
background = "$surface.2"
|
||||||
text = "$text_color.bright"
|
text = "$text_color.bright"
|
||||||
|
|
||||||
[ui.selector]
|
[selector]
|
||||||
background = "$surface.3"
|
background = "$surface.3"
|
||||||
text = "$text_color.bright"
|
text = "$text_color.bright"
|
||||||
padding = { top = 6.0, bottom = 6.0, left = 6.0, right = 6.0 }
|
padding = { top = 6.0, bottom = 6.0, left = 6.0, right = 6.0 }
|
||||||
|
@ -23,15 +23,15 @@ margin.top = 12.0
|
||||||
corner_radius = 6.0
|
corner_radius = 6.0
|
||||||
shadow = { offset = [0.0, 0.0], blur = 12.0, color = "#00000088" }
|
shadow = { offset = [0.0, 0.0], blur = 12.0, color = "#00000088" }
|
||||||
|
|
||||||
[ui.selector.item]
|
[selector.item]
|
||||||
background = "#424344"
|
background = "#424344"
|
||||||
text = "#cccccc"
|
text = "#cccccc"
|
||||||
highlight_text = { color = "#18a3ff", weight = "bold" }
|
highlight_text = { color = "#18a3ff", weight = "bold" }
|
||||||
border = { color = "#000000", width = 1.0 }
|
border = { color = "#000000", width = 1.0 }
|
||||||
padding = { top = 6.0, bottom = 6.0, left = 6.0, right = 6.0 }
|
padding = { top = 6.0, bottom = 6.0, left = 6.0, right = 6.0 }
|
||||||
|
|
||||||
[ui.selector.active_item]
|
[selector.active_item]
|
||||||
extends = "$ui.selector.item"
|
extends = "$selector.item"
|
||||||
background = "#094771"
|
background = "#094771"
|
||||||
|
|
||||||
[editor]
|
[editor]
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl View for FileFinder {
|
||||||
.with_child(Expanded::new(1.0, self.render_matches()).boxed())
|
.with_child(Expanded::new(1.0, self.render_matches()).boxed())
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_style(&settings.theme.ui.selector.container)
|
.with_style(&settings.theme.selector.container)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_max_width(600.0)
|
.with_max_width(600.0)
|
||||||
|
@ -107,7 +107,7 @@ impl FileFinder {
|
||||||
settings.ui_font_family,
|
settings.ui_font_family,
|
||||||
settings.ui_font_size,
|
settings.ui_font_size,
|
||||||
)
|
)
|
||||||
.with_style(&settings.theme.ui.selector.label)
|
.with_style(&settings.theme.selector.label)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_margin_top(6.0)
|
.with_margin_top(6.0)
|
||||||
|
@ -142,9 +142,9 @@ impl FileFinder {
|
||||||
let selected_index = self.selected_index();
|
let selected_index = self.selected_index();
|
||||||
let settings = self.settings.borrow();
|
let settings = self.settings.borrow();
|
||||||
let style = if index == selected_index {
|
let style = if index == selected_index {
|
||||||
&settings.theme.ui.selector.active_item
|
&settings.theme.selector.active_item
|
||||||
} else {
|
} else {
|
||||||
&settings.theme.ui.selector.item
|
&settings.theme.selector.item
|
||||||
};
|
};
|
||||||
let (file_name, file_name_positions, full_path, full_path_positions) =
|
let (file_name, file_name_positions, full_path, full_path_positions) =
|
||||||
self.labels_for_match(path_match);
|
self.labels_for_match(path_match);
|
||||||
|
|
|
@ -30,18 +30,18 @@ pub struct HighlightId(u32);
|
||||||
pub struct Theme {
|
pub struct Theme {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub ui: Ui,
|
pub workspace: Workspace,
|
||||||
|
pub tab: Tab,
|
||||||
|
pub active_tab: Tab,
|
||||||
|
pub selector: Selector,
|
||||||
pub editor: Editor,
|
pub editor: Editor,
|
||||||
#[serde(deserialize_with = "deserialize_syntax_theme")]
|
#[serde(deserialize_with = "deserialize_syntax_theme")]
|
||||||
pub syntax: Vec<(String, TextStyle)>,
|
pub syntax: Vec<(String, TextStyle)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize)]
|
||||||
pub struct Ui {
|
pub struct Workspace {
|
||||||
pub background: Color,
|
pub background: Color,
|
||||||
pub tab: Tab,
|
|
||||||
pub active_tab: Tab,
|
|
||||||
pub selector: Selector,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
@ -800,8 +800,6 @@ mod tests {
|
||||||
fn test_highlight_map() {
|
fn test_highlight_map() {
|
||||||
let theme = Theme {
|
let theme = Theme {
|
||||||
name: "test".into(),
|
name: "test".into(),
|
||||||
ui: Default::default(),
|
|
||||||
editor: Default::default(),
|
|
||||||
syntax: [
|
syntax: [
|
||||||
("function", Color::from_u32(0x100000ff)),
|
("function", Color::from_u32(0x100000ff)),
|
||||||
("function.method", Color::from_u32(0x200000ff)),
|
("function.method", Color::from_u32(0x200000ff)),
|
||||||
|
@ -813,6 +811,7 @@ mod tests {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, color)| (name.to_string(), (*color).into()))
|
.map(|(name, color)| (name.to_string(), (*color).into()))
|
||||||
.collect(),
|
.collect(),
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let capture_names = &[
|
let capture_names = &[
|
||||||
|
|
|
@ -207,7 +207,7 @@ impl ThemeSelector {
|
||||||
settings.ui_font_family,
|
settings.ui_font_family,
|
||||||
settings.ui_font_size,
|
settings.ui_font_size,
|
||||||
)
|
)
|
||||||
.with_style(&settings.theme.ui.selector.label)
|
.with_style(&settings.theme.selector.label)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_margin_top(6.0)
|
.with_margin_top(6.0)
|
||||||
|
@ -240,7 +240,7 @@ impl ThemeSelector {
|
||||||
|
|
||||||
fn render_match(&self, theme_match: &StringMatch, index: usize) -> ElementBox {
|
fn render_match(&self, theme_match: &StringMatch, index: usize) -> ElementBox {
|
||||||
let settings = self.settings.borrow();
|
let settings = self.settings.borrow();
|
||||||
let theme = &settings.theme.ui;
|
let theme = &settings.theme;
|
||||||
|
|
||||||
let container = Container::new(
|
let container = Container::new(
|
||||||
Label::new(
|
Label::new(
|
||||||
|
@ -286,7 +286,7 @@ impl View for ThemeSelector {
|
||||||
.with_child(Expanded::new(1.0, self.render_matches(cx)).boxed())
|
.with_child(Expanded::new(1.0, self.render_matches(cx)).boxed())
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_style(&settings.theme.ui.selector.container)
|
.with_style(&settings.theme.selector.container)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_max_width(600.0)
|
.with_max_width(600.0)
|
||||||
|
|
|
@ -885,7 +885,7 @@ impl View for Workspace {
|
||||||
.with_children(self.modal.as_ref().map(|m| ChildView::new(m.id()).boxed()))
|
.with_children(self.modal.as_ref().map(|m| ChildView::new(m.id()).boxed()))
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_background_color(settings.theme.ui.background)
|
.with_background_color(settings.theme.workspace.background)
|
||||||
.named("workspace")
|
.named("workspace")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl Pane {
|
||||||
|
|
||||||
fn render_tabs(&self, cx: &AppContext) -> ElementBox {
|
fn render_tabs(&self, cx: &AppContext) -> ElementBox {
|
||||||
let settings = self.settings.borrow();
|
let settings = self.settings.borrow();
|
||||||
let theme = &settings.theme.ui;
|
let theme = &settings.theme;
|
||||||
let line_height = cx.font_cache().line_height(
|
let line_height = cx.font_cache().line_height(
|
||||||
cx.font_cache().default_font(settings.ui_font_family),
|
cx.font_cache().default_font(settings.ui_font_family),
|
||||||
settings.ui_font_size,
|
settings.ui_font_size,
|
||||||
|
@ -304,7 +304,7 @@ impl Pane {
|
||||||
tab_hovered: bool,
|
tab_hovered: bool,
|
||||||
is_dirty: bool,
|
is_dirty: bool,
|
||||||
has_conflict: bool,
|
has_conflict: bool,
|
||||||
theme: &theme::Ui,
|
theme: &theme::Theme,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
enum TabCloseButton {}
|
enum TabCloseButton {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue