wip
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
use gpui::SharedString;
|
||||
use gpui_kit::assets::IconNamed;
|
||||
|
||||
/// Coop icons kept from before the gpui-kit migration; absent from the kit bundle.
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum IconName {
|
||||
ArrowDownCircle,
|
||||
ArrowLeft,
|
||||
Book,
|
||||
CaretDown,
|
||||
CaretRight,
|
||||
CheckCircle,
|
||||
Close,
|
||||
Compass,
|
||||
Door,
|
||||
Emoji,
|
||||
Group,
|
||||
Input,
|
||||
Invite,
|
||||
Link,
|
||||
Lock,
|
||||
Message,
|
||||
Paperclip,
|
||||
PaperPlaneFill,
|
||||
Plus,
|
||||
PlusChat,
|
||||
Profile,
|
||||
Relay,
|
||||
Speech,
|
||||
Search,
|
||||
Settings,
|
||||
Settings2,
|
||||
Unlock,
|
||||
Upload,
|
||||
Warning,
|
||||
Wallet,
|
||||
}
|
||||
|
||||
impl IconNamed for IconName {
|
||||
fn path(self) -> SharedString {
|
||||
match self {
|
||||
Self::ArrowDownCircle => "icons/arrow-down-circle.svg",
|
||||
Self::ArrowLeft => "icons/arrow-left.svg",
|
||||
Self::Book => "icons/book.svg",
|
||||
Self::CaretDown => "icons/caret-down.svg",
|
||||
Self::CaretRight => "icons/caret-right.svg",
|
||||
Self::CheckCircle => "icons/check-circle.svg",
|
||||
Self::Close => "icons/close.svg",
|
||||
Self::Compass => "icons/compass.svg",
|
||||
Self::Door => "icons/door.svg",
|
||||
Self::Emoji => "icons/emoji.svg",
|
||||
Self::Group => "icons/group.svg",
|
||||
Self::Input => "icons/input.svg",
|
||||
Self::Invite => "icons/invite.svg",
|
||||
Self::Link => "icons/link.svg",
|
||||
Self::Lock => "icons/lock.svg",
|
||||
Self::Message => "icons/message.svg",
|
||||
Self::Paperclip => "icons/paperclip.svg",
|
||||
Self::PaperPlaneFill => "icons/paper-plane-fill.svg",
|
||||
Self::Plus => "icons/plus.svg",
|
||||
Self::PlusChat => "icons/plus-chat.svg",
|
||||
Self::Profile => "icons/profile.svg",
|
||||
Self::Relay => "icons/relay.svg",
|
||||
Self::Speech => "icons/speech.svg",
|
||||
Self::Search => "icons/search.svg",
|
||||
Self::Settings => "icons/settings.svg",
|
||||
Self::Settings2 => "icons/settings2.svg",
|
||||
Self::Unlock => "icons/unlock.svg",
|
||||
Self::Upload => "icons/upload.svg",
|
||||
Self::Warning => "icons/warning.svg",
|
||||
Self::Wallet => "icons/wallet.svg",
|
||||
}
|
||||
.into()
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
pub use avatar::Avatar;
|
||||
pub use form::*;
|
||||
pub use icon::IconName;
|
||||
pub use message::*;
|
||||
pub use text::*;
|
||||
pub use window_drag::title_bar_drag_handlers;
|
||||
|
||||
pub mod avatar;
|
||||
pub mod form;
|
||||
pub mod icon;
|
||||
pub mod message;
|
||||
pub mod text;
|
||||
pub mod window_drag;
|
||||
|
||||
@@ -251,6 +251,7 @@ pub struct ReplyPreview {
|
||||
author: SharedString,
|
||||
preview: SharedString,
|
||||
on_click: Option<ClickListener>,
|
||||
on_remove: Option<ClickListener>,
|
||||
}
|
||||
|
||||
impl ReplyPreview {
|
||||
@@ -266,6 +267,7 @@ impl ReplyPreview {
|
||||
author: author.into(),
|
||||
preview: preview.into(),
|
||||
on_click: None,
|
||||
on_remove: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +280,16 @@ impl ReplyPreview {
|
||||
self.on_click = Some(Box::new(listener));
|
||||
self
|
||||
}
|
||||
|
||||
/// Show a remove button, calling the handler when it is clicked.
|
||||
#[must_use]
|
||||
pub fn on_remove(
|
||||
mut self,
|
||||
handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
|
||||
) -> Self {
|
||||
self.on_remove = Some(Box::new(handler));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Styled for ReplyPreview {
|
||||
@@ -294,6 +306,7 @@ impl RenderOnce for ReplyPreview {
|
||||
author,
|
||||
preview,
|
||||
on_click,
|
||||
on_remove,
|
||||
} = self;
|
||||
|
||||
div()
|
||||
@@ -304,8 +317,28 @@ impl RenderOnce for ReplyPreview {
|
||||
.border_color(cx.theme().list_active)
|
||||
.text_xs()
|
||||
.refine_style(&style)
|
||||
.child(div().font_semibold().child(author))
|
||||
.child(div().w_full().text_ellipsis().line_clamp(1).child(preview))
|
||||
.child(
|
||||
h_flex()
|
||||
.w_full()
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.child(div().font_semibold().child(author))
|
||||
.child(div().w_full().text_ellipsis().line_clamp(1).child(preview)),
|
||||
)
|
||||
.when_some(on_remove, |this, on_remove| {
|
||||
this.child(
|
||||
Button::new("remove-reply")
|
||||
.icon(IconName::X)
|
||||
.xsmall()
|
||||
.ghost()
|
||||
.tooltip("Remove reply")
|
||||
.flex_shrink_0()
|
||||
.on_click(on_remove),
|
||||
)
|
||||
}),
|
||||
)
|
||||
.hover(|this| this.bg(cx.theme().list_hover))
|
||||
.when_some(on_click, |this, on_click| this.on_click(on_click))
|
||||
.into_any_element()
|
||||
@@ -732,7 +765,7 @@ impl RenderOnce for MessageActions {
|
||||
.when_some(speech, |this, (disabled, speech)| {
|
||||
this.child(
|
||||
Button::new("speech")
|
||||
.icon(crate::IconName::Speech)
|
||||
.icon(IconName::Speech)
|
||||
.tooltip("Read aloud")
|
||||
.small()
|
||||
.ghost()
|
||||
|
||||
Reference in New Issue
Block a user