migrate icons to gpui-native-kit
This commit is contained in:
@@ -11,6 +11,7 @@ person = { path = "../person" }
|
||||
gpui.workspace = true
|
||||
gpui-base.workspace = true
|
||||
gpui-kit.workspace = true
|
||||
gpui-native-kit.workspace = true
|
||||
nostr-sdk.workspace = true
|
||||
web-time = "1.1"
|
||||
smallvec.workspace = true
|
||||
|
||||
+82
-5
@@ -1,38 +1,68 @@
|
||||
use gpui::SharedString;
|
||||
use gpui_kit::assets::IconNamed;
|
||||
use gpui::{App, Pixels, SharedString};
|
||||
use gpui_native_kit::icons::IconNamed;
|
||||
use gpui_native_kit::theme::ActiveTheme as _;
|
||||
|
||||
/// Coop icons kept from before the gpui-kit migration; absent from the kit bundle.
|
||||
/// The app-wide icon set: coop's vendored glyphs plus every kit glyph the app uses.
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum IconName {
|
||||
ArrowDownCircle,
|
||||
ArrowLeft,
|
||||
ArrowRight,
|
||||
Ban,
|
||||
Book,
|
||||
CaretDown,
|
||||
CaretRight,
|
||||
Check,
|
||||
CheckCircle,
|
||||
ChevronDown,
|
||||
CircleCheck,
|
||||
CircleX,
|
||||
Close,
|
||||
Coins,
|
||||
Compass,
|
||||
Door,
|
||||
Ellipsis,
|
||||
Emoji,
|
||||
Group,
|
||||
Inbox,
|
||||
Info,
|
||||
Input,
|
||||
Invite,
|
||||
Link,
|
||||
Lock,
|
||||
LogIn,
|
||||
LogOut,
|
||||
Message,
|
||||
MessageSquare,
|
||||
Paperclip,
|
||||
PaperPlaneFill,
|
||||
PanelBottom,
|
||||
PanelBottomOpen,
|
||||
PanelLeft,
|
||||
PanelLeftOpen,
|
||||
PanelRight,
|
||||
PanelRightOpen,
|
||||
Plus,
|
||||
PlusChat,
|
||||
Profile,
|
||||
Relay,
|
||||
Speech,
|
||||
Reply,
|
||||
Search,
|
||||
Settings,
|
||||
Settings2,
|
||||
Speech,
|
||||
SquarePen,
|
||||
TriangleAlert,
|
||||
Unlock,
|
||||
Upload,
|
||||
UserRoundPlus,
|
||||
Wallet,
|
||||
Warning,
|
||||
WindowClose,
|
||||
WindowMaximize,
|
||||
WindowMinimize,
|
||||
WindowRestore,
|
||||
X,
|
||||
}
|
||||
|
||||
impl IconNamed for IconName {
|
||||
@@ -40,34 +70,81 @@ impl IconNamed for IconName {
|
||||
match self {
|
||||
Self::ArrowDownCircle => "icons/arrow-down-circle.svg",
|
||||
Self::ArrowLeft => "icons/arrow-left.svg",
|
||||
Self::ArrowRight => "icons/arrow-right.svg",
|
||||
Self::Ban => "icons/ban.svg",
|
||||
Self::Book => "icons/book.svg",
|
||||
Self::CaretDown => "icons/caret-down.svg",
|
||||
Self::CaretRight => "icons/caret-right.svg",
|
||||
Self::Check => "icons/check.svg",
|
||||
Self::CheckCircle => "icons/check-circle.svg",
|
||||
Self::ChevronDown => "icons/chevron-down.svg",
|
||||
Self::CircleCheck => "icons/circle-check.svg",
|
||||
Self::CircleX => "icons/circle-x.svg",
|
||||
Self::Close => "icons/close.svg",
|
||||
Self::Coins => "icons/coins.svg",
|
||||
Self::Compass => "icons/compass.svg",
|
||||
Self::Door => "icons/door.svg",
|
||||
Self::Ellipsis => "icons/ellipsis.svg",
|
||||
Self::Emoji => "icons/emoji.svg",
|
||||
Self::Group => "icons/group.svg",
|
||||
Self::Inbox => "icons/inbox.svg",
|
||||
Self::Info => "icons/info.svg",
|
||||
Self::Input => "icons/input.svg",
|
||||
Self::Invite => "icons/invite.svg",
|
||||
Self::Link => "icons/link.svg",
|
||||
Self::Lock => "icons/lock.svg",
|
||||
Self::LogIn => "icons/log-in.svg",
|
||||
Self::LogOut => "icons/log-out.svg",
|
||||
Self::Message => "icons/message.svg",
|
||||
Self::MessageSquare => "icons/message-square.svg",
|
||||
Self::Paperclip => "icons/paperclip.svg",
|
||||
Self::PaperPlaneFill => "icons/paper-plane-fill.svg",
|
||||
Self::PanelBottom => "icons/panel-bottom.svg",
|
||||
Self::PanelBottomOpen => "icons/panel-bottom-open.svg",
|
||||
Self::PanelLeft => "icons/panel-left.svg",
|
||||
Self::PanelLeftOpen => "icons/panel-left-open.svg",
|
||||
Self::PanelRight => "icons/panel-right.svg",
|
||||
Self::PanelRightOpen => "icons/panel-right-open.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::Reply => "icons/reply.svg",
|
||||
Self::Search => "icons/search.svg",
|
||||
Self::Settings => "icons/settings.svg",
|
||||
Self::Settings2 => "icons/settings2.svg",
|
||||
Self::Speech => "icons/speech.svg",
|
||||
Self::SquarePen => "icons/square-pen.svg",
|
||||
Self::TriangleAlert => "icons/triangle-alert.svg",
|
||||
Self::Unlock => "icons/unlock.svg",
|
||||
Self::Upload => "icons/upload.svg",
|
||||
Self::UserRoundPlus => "icons/user-round-plus.svg",
|
||||
Self::Wallet => "icons/wallet.svg",
|
||||
Self::Warning => "icons/warning.svg",
|
||||
Self::WindowClose => "icons/x.svg",
|
||||
Self::WindowMaximize => "icons/square.svg",
|
||||
Self::WindowMinimize => "icons/minus.svg",
|
||||
Self::WindowRestore => "icons/copy.svg",
|
||||
Self::X => "icons/x.svg",
|
||||
}
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
// The old kit's identical trait, so its components keep accepting coop icons
|
||||
// until they are replaced in later migration steps.
|
||||
impl gpui_kit::assets::IconNamed for IconName {
|
||||
fn path(self) -> SharedString {
|
||||
IconNamed::path(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// The kit's small icon size, for icons drawn beside labels.
|
||||
pub fn small_icon_size(cx: &App) -> Pixels {
|
||||
cx.theme().sizes.small.icon_size
|
||||
}
|
||||
|
||||
/// The kit's dense icon size, for icons inline with dense rows.
|
||||
pub fn dense_icon_size(cx: &App) -> Pixels {
|
||||
cx.theme().sizes.small.dense_icon_size
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub use avatar::Avatar;
|
||||
pub use form::*;
|
||||
pub use icon::IconName;
|
||||
pub use icon::{IconName, dense_icon_size, small_icon_size};
|
||||
pub use message::*;
|
||||
pub use text::*;
|
||||
pub use window_drag::title_bar_drag_handlers;
|
||||
|
||||
@@ -9,7 +9,6 @@ use gpui::{
|
||||
ParentElement as _, RenderOnce, SharedString, SharedUri, StatefulInteractiveElement as _,
|
||||
StyleRefinement, Styled, StyledImage, Window, div, img, px,
|
||||
};
|
||||
use gpui_kit::assets::IconName;
|
||||
use gpui_kit::component::button::{Button, ButtonVariants as _};
|
||||
use gpui_kit::component::clipboard::Clipboard;
|
||||
use gpui_kit::component::menu::{DropdownMenu as _, PopupMenu, PopupMenuItem};
|
||||
@@ -19,6 +18,8 @@ use gpui_kit::component::{
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::icon::IconName;
|
||||
|
||||
type MouseDownListener = Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>;
|
||||
type ClickListener = Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>;
|
||||
type SharedClickListener = Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>;
|
||||
|
||||
Reference in New Issue
Block a user