This commit is contained in:
2026-10-22 18:16:41 +07:00
parent bebb4cebbf
commit bd9f4e2861
7 changed files with 42 additions and 26 deletions
+18 -2
View File
@@ -19,6 +19,7 @@ pub struct Nav {
suffix: Option<AnyElement>,
selected: bool,
clickable: bool,
gap: bool,
#[allow(clippy::type_complexity)]
on_click: Option<Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>>,
}
@@ -38,6 +39,7 @@ impl Nav {
suffix: None,
selected: false,
clickable: false,
gap: true,
on_click: None,
}
}
@@ -48,6 +50,12 @@ impl Nav {
self
}
/// Whether to space the row's contents apart.
pub fn gap(mut self, gap: bool) -> Self {
self.gap = gap;
self
}
/// Sets the element shown before the label, such as an avatar or icon.
pub fn prefix(mut self, prefix: impl IntoElement) -> Self {
self.prefix = Some(prefix.into_any_element());
@@ -107,9 +115,17 @@ impl RenderOnce for Nav {
.h_8()
.w_full()
.px_2()
.gap_2()
.when(self.gap, |this| this.gap_2())
.rounded(cx.theme().radius)
.when_some(self.prefix, |this, prefix| this.child(prefix))
.when_some(self.prefix, |this, prefix| {
this.child(
h_flex()
.w_6()
.flex_shrink_0()
.justify_center()
.child(prefix),
)
})
.child(div().flex_1().min_w_0().truncate().child(self.label))
.when_some(self.suffix, |this, suffix| {
this.child(div().flex_shrink_0().child(suffix))
+1 -1
View File
@@ -297,7 +297,7 @@ impl BrowsePanel {
.px_1()
.rounded(cx.theme().radius)
.bg(cx.theme().sidebar)
.child(Input::new(&self.input).appearance(false).small().flex_1())
.child(Input::new(&self.input).appearance(false).flex_1())
.child(
Button::new("relay-browse")
.icon(IconName::ArrowRight)
+4 -16
View File
@@ -7,7 +7,6 @@ use gpui::{
ParentElement, SharedString, Styled, WeakEntity, div, relative, uniform_list,
};
use gpui_kit::base::StyledExt as _;
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::menu::{ContextMenuExt as _, PopupMenuItem};
use gpui_kit::component::{ActiveTheme, Icon, Sizable, h_flex, v_flex};
use nip29::Group;
@@ -146,24 +145,13 @@ impl Sidebar {
.gap_2()
.child(
h_flex()
.px_2()
.px_4()
.flex_shrink_0()
.justify_between()
.child(
h_flex()
.pl_0p5()
.gap_1()
.flex_shrink_1()
.child(
Button::new("sidebar-back")
.icon(IconName::ArrowLeft)
.tooltip("Back")
.ghost()
.small()
.on_click(cx.listener(|this, _event, _window, cx| {
this.hide_group(cx);
})),
)
.child(Avatar::new(picture).seed(seed.clone()).small())
.child(
v_flex()
@@ -283,19 +271,19 @@ impl Sidebar {
let nav = Nav::new(public_key.to_hex())
.label(person.name())
.text_xs()
.font_medium()
.text_sm()
.clickable(true)
.when(!hide_avatar, |this| {
this.prefix(
Avatar::new(person.avatar())
.seed(person.avatar_seed())
.xsmall(),
.small(),
)
})
.when(!roles.is_empty(), |this| {
this.suffix(
div()
.font_normal()
.truncate()
.text_xs()
.text_color(cx.theme().muted_foreground)
+13 -1
View File
@@ -104,7 +104,19 @@ impl Sidebar {
Box::new(Command::NewChat),
)
}),
),
)
.when(self.group_open, |this| {
this.child(
Button::new("sidebar-back")
.icon(IconName::ArrowLeft)
.tooltip("Back")
.ghost()
.small()
.on_click(cx.listener(|this, _event, _window, cx| {
this.hide_group(cx);
})),
)
}),
)
}
+1 -1
View File
@@ -84,7 +84,6 @@ impl Sidebar {
this.suffix(
h_flex()
.gap_1()
.items_center()
.child(
h_flex()
.py_0p5()
@@ -120,6 +119,7 @@ impl Sidebar {
Nav::new("contacts")
.prefix(Icon::new(IconName::Book).small())
.label("Contacts")
.gap(false)
.text_sm()
.when(contacts_open, |this| this.bg(cx.theme().list_active))
.on_click(cx.listener(|this, _event, window, cx| {
+1 -2
View File
@@ -2,7 +2,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use gpui::{AnyElement, App, IntoElement, ParentElement, SharedString, Styled, Window, img};
use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::component::{Sizable, v_flex};
use gpui_kit::component::v_flex;
use crate::dialogs::import;
@@ -32,7 +32,6 @@ pub(super) fn render_signed_out(_window: &mut Window, _cx: &mut App) -> AnyEleme
Button::new("import")
.label("Import Identity")
.primary()
.large()
.on_click(|_, window, cx| {
import::open(window, cx);
}),
+4 -3
View File
@@ -205,6 +205,7 @@ impl Sidebar {
pub(super) fn render_find(&self, cx: &mut Context<Self>) -> AnyElement {
h_flex()
.mb_2()
.px_2()
.flex_shrink_0()
.w_full()
@@ -214,8 +215,8 @@ impl Sidebar {
.gap_1()
.w_full()
.rounded(cx.theme().radius)
.bg(cx.theme().secondary)
.child(Input::new(&self.find_input).appearance(false).small())
.bg(cx.theme().input_background())
.child(Input::new(&self.find_input).appearance(false))
.child(
Button::new("sidebar-global")
.icon(IconName::Compass)
@@ -224,7 +225,7 @@ impl Sidebar {
} else {
"Enable global search"
})
.small()
.xsmall()
.ghost()
.selected(self.global_open)
.loading(self.global_finding)