Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git_panel: Add some UI improvements (#54630)

Danilo Leala00f07381c33
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index 6f5463d65a3..e2bd1c553f8 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -4939,57 +4939,46 @@ impl GitPanel {
let toggle_state = self.header_state(header.header);
let section = header.header;
let weak = cx.weak_entity();
- let show_checkbox_persistently = !matches!(&toggle_state, ToggleState::Unselected);
h_flex()
.id(id)
- .group(group_name.clone())
+ .cursor_pointer()
+ .group(group_name)
.h(self.list_item_height())
.w_full()
- .items_center()
.pl_3()
.pr_1()
- .gap_1p5()
+ .gap_2()
+ .justify_between()
+ .hover(|s| s.bg(cx.theme().colors().ghost_element_hover))
.border_1()
.border_r_2()
.child(
- h_flex().flex_1().child(
- Label::new(header.title())
- .color(Color::Muted)
- .size(LabelSize::Small)
- .line_height_style(LineHeightStyle::UiLabel)
- .single_line(),
- ),
+ Label::new(header.title())
+ .color(Color::Muted)
+ .size(LabelSize::Small),
)
.child(
- div()
- .flex_none()
- .cursor_pointer()
- .child(
- Checkbox::new(checkbox_id, toggle_state)
- .disabled(!has_write_access)
- .fill()
- .elevation(ElevationIndex::Surface)
- .on_click_ext(move |_, _, window, cx| {
- if !has_write_access {
- return;
- }
-
- weak.update(cx, |this, cx| {
- this.toggle_staged_for_entry(
- &GitListEntry::Header(GitHeaderEntry { header: section }),
- window,
- cx,
- );
- cx.stop_propagation();
- })
- .ok();
- }),
- )
- .when(!show_checkbox_persistently, |this| {
- this.visible_on_hover(group_name)
- }),
+ Checkbox::new(checkbox_id, toggle_state)
+ .disabled(!has_write_access)
+ .fill()
+ .elevation(ElevationIndex::Surface),
)
+ .on_click(move |_, window, cx| {
+ if !has_write_access {
+ return;
+ }
+
+ weak.update(cx, |this, cx| {
+ this.toggle_staged_for_entry(
+ &GitListEntry::Header(GitHeaderEntry { header: section }),
+ window,
+ cx,
+ );
+ cx.stop_propagation();
+ })
+ .ok();
+ })
.into_any_element()
}
@@ -6123,10 +6112,6 @@ impl RenderOnce for PanelRepoFooter {
util::truncate_and_trailoff(branch_name.trim_ascii(), branch_display_len)
};
- let repo_selector_trigger = Button::new("repo-selector", truncated_repo_name)
- .size(ButtonSize::None)
- .label_size(LabelSize::Small);
-
let repo_selector = PopoverMenu::new("repository-switcher")
.menu({
let project = project;
@@ -6136,8 +6121,9 @@ impl RenderOnce for PanelRepoFooter {
}
})
.trigger_with_tooltip(
- repo_selector_trigger
- .when(single_repo, |this| this.disabled(true).color(Color::Muted))
+ Button::new("repo-selector", truncated_repo_name)
+ .size(ButtonSize::None)
+ .label_size(LabelSize::Small)
.truncate(true),
move |_, cx| {
if single_repo {
@@ -6179,7 +6165,7 @@ impl RenderOnce for PanelRepoFooter {
});
h_flex()
- .h(px(36.))
+ .h_9()
.w_full()
.px_2()
.justify_between()
@@ -6196,14 +6182,14 @@ impl RenderOnce for PanelRepoFooter {
Color::Muted
},
))
- .child(repo_selector)
- .when(show_separator, |this| {
- this.child(
- div()
- .text_sm()
- .text_color(cx.theme().colors().icon_muted.opacity(0.5))
- .child("/"),
- )
+ .when(!single_repo, |this| {
+ this.child(repo_selector).when(show_separator, |this| {
+ this.child(
+ Label::new("/").size(LabelSize::Small).color(Color::Custom(
+ cx.theme().colors().text_muted.opacity(0.4),
+ )),
+ )
+ })
})
.child(branch_selector),
)