migrate ui components to gpui-kit

This commit is contained in:
2026-10-21 13:40:29 +07:00
parent 0d4acf5b65
commit d0ad1a6f57
173 changed files with 2775 additions and 10885 deletions
+25 -15
View File
@@ -1,3 +1,7 @@
use crate::nav::Nav;
use gpui_kit::assets::IconName;
use gpui_kit::component::scroll::Scrollbar;
use gpui_kit::component::{ActiveTheme, Icon, Sizable, h_flex, v_flex};
use std::rc::Rc;
use chat::{ChatRegistry, RoomKind};
@@ -8,10 +12,7 @@ use gpui::{
};
use nip29::GroupsRegistry;
use settings::AppSettings;
use theme::{ActiveTheme, TextStyle, Typeset as _, control_radius};
use ui::nav_item::NavItem;
use ui::scroll::Scrollbar;
use ui::{Icon, IconName, Sizable, StyledExt, h_flex, v_flex};
use ui::{TextStyle, Typeset as _, control_radius};
use super::Sidebar;
use super::rows::SidebarRow;
@@ -61,19 +62,23 @@ impl Sidebar {
.flex_1()
.min_h_0()
.relative()
.gap(px(theme::SPACE))
.gap(px(ui::SPACE))
.child(
v_flex()
.px_2()
.gap_1()
.child(
NavItem::new("browse", "Browse", Icon::new(IconName::Compass).small())
Nav::new("browse")
.prefix(Icon::new(IconName::Compass).small())
.label("Browse")
.on_click(|_, window, cx| {
window.dispatch_action(Box::new(Command::ShowBrowse), cx)
}),
)
.child(
NavItem::new("reqs", "Requests", Icon::new(IconName::Invite).small())
Nav::new("reqs")
.prefix(Icon::new(IconName::UserRoundPlus).small())
.label("Requests")
.when(request_count > 0, |this| {
this.suffix(
h_flex()
@@ -86,29 +91,34 @@ impl Sidebar {
.min_w_6()
.justify_center()
.text_style(TextStyle::Caption2)
.text_color(cx.theme().text_muted)
.text_color(cx.theme().muted_foreground)
.text_center()
.rounded(px(control_radius()))
.bg(cx.theme().surface_raised)
.bg(cx.theme().secondary)
.child(SharedString::from(
request_count.to_string(),
)),
)
.when(self.new_requests && !requests_open, |this| {
this.child(
div().size_1().rounded_full().bg(cx.theme().accent),
div()
.size_1()
.rounded_full()
.bg(cx.theme().primary),
)
}),
)
})
.when(requests_open, |this| this.bg(cx.theme().element_active))
.when(requests_open, |this| this.bg(cx.theme().list_active))
.on_click(cx.listener(|this, _event, _window, cx| {
this.toggle_requests(cx);
})),
)
.child(
NavItem::new("contacts", "Contacts", Icon::new(IconName::Book).small())
.when(contacts_open, |this| this.bg(cx.theme().element_active))
Nav::new("contacts")
.prefix(Icon::new(IconName::Book).small())
.label("Contacts")
.when(contacts_open, |this| this.bg(cx.theme().list_active))
.on_click(cx.listener(|this, _event, window, cx| {
this.toggle_contacts(window, cx);
})),
@@ -119,8 +129,8 @@ impl Sidebar {
div()
.px_4()
.text_style(TextStyle::Caption)
.font_semibold()
.text_color(cx.theme().text_muted)
.font_weight(gpui::FontWeight::SEMIBOLD)
.text_color(cx.theme().muted_foreground)
.child(list_title),
)
})