feat: support app-defined icon sets

This commit is contained in:
2026-11-09 20:35:04 +07:00
parent 1c091db699
commit ec906839ed
17 changed files with 274 additions and 173 deletions
+9 -6
View File
@@ -3,7 +3,7 @@ use gpui::{
App, IntoElement, ParentElement as _, RenderOnce, SharedString, StyleRefinement, Styled as _,
Window, div, relative,
};
use gpui_native_icons::{IconRole, icon};
use gpui_native_icons::Icon;
use gpui_native_theme::{ActiveTheme as _, Size};
use crate::common::{StyledExt, v_flex};
@@ -11,7 +11,7 @@ use crate::common::{StyledExt, v_flex};
/// The centered "nothing here yet" panel for lists, tables, and searches.
#[derive(IntoElement)]
pub struct EmptyState {
icon: Option<IconRole>,
icon: Option<Icon>,
headline: SharedString,
hint: Option<SharedString>,
action: Option<gpui::AnyElement>,
@@ -34,8 +34,11 @@ impl EmptyState {
}
/// Sets a large muted icon above the headline.
pub fn icon(mut self, role: IconRole) -> Self {
self.icon = Some(role);
pub fn icon<I>(mut self, icon: I) -> Self
where
I: Into<Icon>,
{
self.icon = Some(icon.into());
self
}
@@ -78,11 +81,11 @@ impl RenderOnce for EmptyState {
.justify_center()
.text_center()
.p_4()
.when_some(self.icon, |state, role| {
.when_some(self.icon, |state, icon| {
state.child(
div()
.mb_2()
.child(icon(role).size(illustration).color(muted_foreground)),
.child(icon.size(illustration).color(muted_foreground)),
)
})
.child(