Clean up project panel theme

This commit is contained in:
Max Brunsfeld 2022-04-29 11:08:25 -07:00
parent aa4919a76f
commit 12d45f1655
11 changed files with 247 additions and 339 deletions

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#8b8792", "icon_color": "#8b8792",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#8b8792", "color": "#8b8792",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#5852603d",
"height": 24, "text": {
"background": "#5852603d", "family": "Zed Mono",
"icon_color": "#8b8792", "color": "#e2dfe7",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#e2dfe7", "background": "#5852605c",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#e2dfe7",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#8b8792", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#5852603d",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#e2dfe7", "color": "#efecf4",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#5852603d",
"icon_color": "#8b8792",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#efecf4",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#585260", "icon_color": "#585260",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#585260", "color": "#585260",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#8b87921f",
"height": 24, "text": {
"background": "#8b87921f", "family": "Zed Mono",
"icon_color": "#585260", "color": "#26232a",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#26232a", "background": "#8b87922e",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#26232a",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#585260", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#8b87921f",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#26232a", "color": "#19171c",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#8b87921f",
"icon_color": "#585260",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#19171c",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#555555", "icon_color": "#555555",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#808080", "color": "#808080",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#232323",
"height": 24, "text": {
"background": "#232323", "family": "Zed Mono",
"icon_color": "#555555", "color": "#f1f1f1",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#f1f1f1", "background": "#2b2b2b",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#f1f1f1",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#555555", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#232323",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#f1f1f1", "color": "#ffffff",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#232323",
"icon_color": "#555555",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#ffffff",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#9c9c9c", "icon_color": "#9c9c9c",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#636363", "color": "#636363",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#eaeaea",
"height": 24, "text": {
"background": "#eaeaea", "family": "Zed Mono",
"icon_color": "#9c9c9c", "color": "#2b2b2b",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#2b2b2b", "background": "#e3e3e3",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#2b2b2b",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#9c9c9c", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#eaeaea",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#2b2b2b", "color": "#000000",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#eaeaea",
"icon_color": "#9c9c9c",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#000000",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#93a1a1", "icon_color": "#93a1a1",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#93a1a1", "color": "#93a1a1",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#586e753d",
"height": 24, "text": {
"background": "#586e753d", "family": "Zed Mono",
"icon_color": "#93a1a1", "color": "#eee8d5",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#eee8d5", "background": "#586e755c",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#eee8d5",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#93a1a1", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#586e753d",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#eee8d5", "color": "#fdf6e3",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#586e753d",
"icon_color": "#93a1a1",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#fdf6e3",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#586e75", "icon_color": "#586e75",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#586e75", "color": "#586e75",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#93a1a11f",
"height": 24, "text": {
"background": "#93a1a11f", "family": "Zed Mono",
"icon_color": "#586e75", "color": "#073642",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#073642", "background": "#93a1a12e",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#073642",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#586e75", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#93a1a11f",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#073642", "color": "#002b36",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#93a1a11f",
"icon_color": "#586e75",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#002b36",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#979db4", "icon_color": "#979db4",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#979db4", "color": "#979db4",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#5e66873d",
"height": 24, "text": {
"background": "#5e66873d", "family": "Zed Mono",
"icon_color": "#979db4", "color": "#dfe2f1",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#dfe2f1", "background": "#5e66875c",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#dfe2f1",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#979db4", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#5e66873d",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#dfe2f1", "color": "#f5f7ff",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#5e66873d",
"icon_color": "#979db4",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#f5f7ff",
"size": 14
} }
} }
}, },

View file

@ -937,6 +937,7 @@
"top": 6, "top": 6,
"bottom": 6 "bottom": 6
}, },
"indent_width": 20,
"entry": { "entry": {
"height": 24, "height": 24,
"icon_color": "#5e6687", "icon_color": "#5e6687",
@ -946,41 +947,30 @@
"family": "Zed Mono", "family": "Zed Mono",
"color": "#5e6687", "color": "#5e6687",
"size": 14 "size": 14
} },
}, "hover": {
"hovered_entry": { "background": "#979db41f",
"height": 24, "text": {
"background": "#979db41f", "family": "Zed Mono",
"icon_color": "#5e6687", "color": "#293256",
"icon_size": 8, "size": 14
"icon_spacing": 8, }
"text": { },
"family": "Zed Mono", "active": {
"color": "#293256", "background": "#979db42e",
"size": 14 "text": {
} "family": "Zed Mono",
}, "color": "#293256",
"selected_entry": { "size": 14
"height": 24, }
"icon_color": "#5e6687", },
"icon_size": 8, "active_hover": {
"icon_spacing": 8, "background": "#979db41f",
"text": { "text": {
"family": "Zed Mono", "family": "Zed Mono",
"color": "#293256", "color": "#202746",
"size": 14 "size": 14
} }
},
"hovered_selected_entry": {
"height": 24,
"background": "#979db41f",
"icon_color": "#5e6687",
"icon_size": 8,
"icon_spacing": 8,
"text": {
"family": "Zed Mono",
"color": "#202746",
"size": 14
} }
} }
}, },

View file

@ -1,8 +1,9 @@
use editor::Editor;
use gpui::{ use gpui::{
actions, actions,
elements::{ elements::{
Align, ConstrainedBox, Empty, Flex, Label, MouseEventHandler, ParentElement, ScrollTarget, ConstrainedBox, Empty, Flex, Label, MouseEventHandler, ParentElement, ScrollTarget, Svg,
Svg, UniformList, UniformListState, UniformList, UniformListState,
}, },
impl_internal_actions, keymap, impl_internal_actions, keymap,
platform::CursorStyle, platform::CursorStyle,
@ -477,35 +478,26 @@ impl ProjectPanel {
) -> ElementBox { ) -> ElementBox {
let is_dir = details.is_dir; let is_dir = details.is_dir;
MouseEventHandler::new::<Self, _, _>(entry_id.to_usize(), cx, |state, _| { MouseEventHandler::new::<Self, _, _>(entry_id.to_usize(), cx, |state, _| {
let style = match (details.is_selected, state.hovered) { let style = theme.entry.style_for(state, details.is_selected);
(false, false) => &theme.entry,
(false, true) => &theme.hovered_entry,
(true, false) => &theme.selected_entry,
(true, true) => &theme.hovered_selected_entry,
};
Flex::row() Flex::row()
.with_child( .with_child(
ConstrainedBox::new( ConstrainedBox::new(if is_dir {
Align::new( if details.is_expanded {
ConstrainedBox::new(if is_dir { Svg::new("icons/disclosure-open.svg")
if details.is_expanded { .with_color(style.icon_color)
Svg::new("icons/disclosure-open.svg") .boxed()
.with_color(style.icon_color) } else {
.boxed() Svg::new("icons/disclosure-closed.svg")
} else { .with_color(style.icon_color)
Svg::new("icons/disclosure-closed.svg") .boxed()
.with_color(style.icon_color) }
.boxed() } else {
} Empty::new().boxed()
} else { })
Empty::new().boxed() .with_max_width(style.icon_size)
}) .with_max_height(style.icon_size)
.with_max_width(style.icon_size) .aligned()
.with_max_height(style.icon_size) .constrained()
.boxed(),
)
.boxed(),
)
.with_width(style.icon_size) .with_width(style.icon_size)
.boxed(), .boxed(),
) )
@ -518,10 +510,12 @@ impl ProjectPanel {
.boxed(), .boxed(),
) )
.constrained() .constrained()
.with_height(theme.entry.height) .with_height(theme.entry.default.height)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.with_padding_left(theme.container.padding.left + details.depth as f32 * 20.) .with_padding_left(
theme.container.padding.left + details.depth as f32 * theme.indent_width,
)
.boxed() .boxed()
}) })
.on_click(move |cx| { .on_click(move |cx| {

View file

@ -208,10 +208,8 @@ pub struct ChatPanel {
pub struct ProjectPanel { pub struct ProjectPanel {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
pub entry: ProjectPanelEntry, pub entry: Interactive<ProjectPanelEntry>,
pub hovered_entry: ProjectPanelEntry, pub indent_width: f32,
pub selected_entry: ProjectPanelEntry,
pub hovered_selected_entry: ProjectPanelEntry,
} }
#[derive(Debug, Deserialize, Default)] #[derive(Debug, Deserialize, Default)]

View file

@ -1,34 +1,30 @@
import Theme from "../themes/theme"; import Theme from "../themes/theme";
import { Color } from "../utils/color";
import { panel } from "./app"; import { panel } from "./app";
import { backgroundColor, iconColor, text, TextColor } from "./components"; import { backgroundColor, iconColor, text } from "./components";
export default function projectPanel(theme: Theme) { export default function projectPanel(theme: Theme) {
function entry(theme: Theme, textColor: TextColor, background?: Color) { return {
return { ...panel,
padding: { left: 12, right: 12, top: 6, bottom: 6 },
indentWidth: 20,
entry: {
height: 24, height: 24,
background,
iconColor: iconColor(theme, "muted"), iconColor: iconColor(theme, "muted"),
iconSize: 8, iconSize: 8,
iconSpacing: 8, iconSpacing: 8,
text: text(theme, "mono", textColor, { size: "sm" }), text: text(theme, "mono", "muted", { size: "sm" }),
}; hover: {
} background: backgroundColor(theme, 300, "hovered"),
text: text(theme, "mono", "primary", { size: "sm" }),
return { },
...panel, active: {
entry: entry(theme, "muted"), background: backgroundColor(theme, 300, "active"),
hoveredEntry: entry( text: text(theme, "mono", "primary", { size: "sm" }),
theme, },
"primary", activeHover: {
backgroundColor(theme, 300, "hovered") background: backgroundColor(theme, 300, "hovered"),
), text: text(theme, "mono", "active", { size: "sm" }),
selectedEntry: entry(theme, "primary"), }
hoveredSelectedEntry: entry( },
theme,
"active",
backgroundColor(theme, 300, "hovered")
),
padding: { left: 12, right: 12, top: 6, bottom: 6 },
}; };
} }