This commit is contained in:
2026-09-13 15:17:51 +07:00
parent b3991810b6
commit 33e9429cd0
17 changed files with 1032 additions and 742 deletions
+2
View File
@@ -2,6 +2,7 @@ mod dropdown_button;
mod nav_item;
mod pixel_avatar;
mod placeholder;
mod ref_selector;
mod segment_button;
mod setting;
mod status_badge;
@@ -17,6 +18,7 @@ pub use dropdown_button::DropdownButton;
pub use nav_item::NavItem;
pub use pixel_avatar::PixelAvatar;
pub use placeholder::placeholder;
pub use ref_selector::ref_selector_trigger;
pub use segment_button::{CountBadge, SegmentButton};
pub use setting::{SelectOption, setting_block, setting_row};
pub use status_badge::status_badge;
+41
View File
@@ -0,0 +1,41 @@
use assets::CustomIconName;
use gpui::prelude::*;
use gpui::{AnyElement, App, SharedString, div};
use gpui_component::combobox::{Caret, ComboboxTriggerContext};
use gpui_component::searchable_list::SearchableVec;
use gpui_component::{ActiveTheme, Icon, Sizable, h_flex};
/// The kind icon, the selection or placeholder, and the caret. `Combobox`
/// replaces its default trigger entirely, the only way to show an icon inside it.
pub fn ref_selector_trigger(
ctx: &ComboboxTriggerContext<SearchableVec<SharedString>>,
icon: CustomIconName,
cx: &App,
) -> AnyElement {
let muted = cx.theme().muted_foreground;
h_flex()
.w_full()
.min_w_0()
.gap_1()
.items_center()
.child(Icon::new(icon).small().flex_shrink_0())
.child(
div()
.flex_1()
.min_w_0()
.overflow_hidden()
.text_ellipsis()
.whitespace_nowrap()
.when(ctx.selection().is_empty(), |this| this.text_color(muted))
.child(
ctx.selection()
.first()
.map(|(_, item)| item.clone())
.or_else(|| ctx.placeholder().cloned())
.unwrap_or_default(),
),
)
.child(Caret::new(ctx.size()).text_color(muted))
.into_any_element()
}