assistant2: Derive the Context
icon at render time instead of storing (#22397)
This PR is a follow up to #22385 that makes it so we treat the icon as derived state. Release Notes: - N/A
This commit is contained in:
parent
564936e1fe
commit
4c84600630
3 changed files with 10 additions and 22 deletions
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
|||
use gpui::ClickEvent;
|
||||
use ui::{prelude::*, IconButtonShape};
|
||||
|
||||
use crate::context::Context;
|
||||
use crate::context::{Context, ContextKind};
|
||||
|
||||
#[derive(IntoElement)]
|
||||
pub struct ContextPill {
|
||||
|
@ -32,6 +32,12 @@ impl RenderOnce for ContextPill {
|
|||
} else {
|
||||
px(4.)
|
||||
};
|
||||
let icon = match self.context.kind {
|
||||
ContextKind::File => IconName::File,
|
||||
ContextKind::Directory => IconName::Folder,
|
||||
ContextKind::FetchedUrl => IconName::Globe,
|
||||
ContextKind::Thread => IconName::MessageCircle,
|
||||
};
|
||||
|
||||
h_flex()
|
||||
.gap_1()
|
||||
|
@ -42,11 +48,7 @@ impl RenderOnce for ContextPill {
|
|||
.border_color(cx.theme().colors().border.opacity(0.5))
|
||||
.bg(cx.theme().colors().element_background)
|
||||
.rounded_md()
|
||||
.child(
|
||||
Icon::new(self.context.icon)
|
||||
.size(IconSize::XSmall)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
.child(Icon::new(icon).size(IconSize::XSmall).color(Color::Muted))
|
||||
.child(Label::new(self.context.name.clone()).size(LabelSize::Small))
|
||||
.when_some(self.on_remove, |parent, on_remove| {
|
||||
parent.child(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue