Rename IconElement
to just Icon
(#3974)
This PR renames the `IconElement` component to just `Icon`. This better matches the rest of our components, as `IconElement` was the only one using this naming convention. The `Icon` enum has been renamed to `IconName` to free up the name. I was trying to come up with a way that would allow rendering an `Icon::Zed` directly (and thus make the `IconElement` a hidden part of the API), but I couldn't come up with a way to do this cleanly. Release Notes: - N/A
This commit is contained in:
parent
29ed067b26
commit
fa53353c57
45 changed files with 364 additions and 360 deletions
|
@ -31,7 +31,7 @@ use smallvec::SmallVec;
|
|||
use std::{mem, sync::Arc};
|
||||
use theme::{ActiveTheme, ThemeSettings};
|
||||
use ui::{
|
||||
prelude::*, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconElement, IconSize, Label,
|
||||
prelude::*, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconName, IconSize, Label,
|
||||
ListHeader, ListItem, Tooltip,
|
||||
};
|
||||
use util::{maybe, ResultExt, TryFutureExt};
|
||||
|
@ -848,7 +848,7 @@ impl CollabPanel {
|
|||
.end_slot(if is_pending {
|
||||
Label::new("Calling").color(Color::Muted).into_any_element()
|
||||
} else if is_current_user {
|
||||
IconButton::new("leave-call", Icon::Exit)
|
||||
IconButton::new("leave-call", IconName::Exit)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.on_click(move |_, cx| Self::leave_call(cx))
|
||||
.tooltip(|cx| Tooltip::text("Leave Call", cx))
|
||||
|
@ -897,7 +897,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(is_last, false, cx))
|
||||
.child(IconButton::new(0, Icon::Folder)),
|
||||
.child(IconButton::new(0, IconName::Folder)),
|
||||
)
|
||||
.child(Label::new(project_name.clone()))
|
||||
.tooltip(move |cx| Tooltip::text(format!("Open {}", project_name), cx))
|
||||
|
@ -918,7 +918,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(is_last, false, cx))
|
||||
.child(IconButton::new(0, Icon::Screen)),
|
||||
.child(IconButton::new(0, IconName::Screen)),
|
||||
)
|
||||
.child(Label::new("Screen"))
|
||||
.when_some(peer_id, |this, _| {
|
||||
|
@ -959,7 +959,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(false, true, cx))
|
||||
.child(IconButton::new(0, Icon::File)),
|
||||
.child(IconButton::new(0, IconName::File)),
|
||||
)
|
||||
.child(div().h_7().w_full().child(Label::new("notes")))
|
||||
.tooltip(move |cx| Tooltip::text("Open Channel Notes", cx))
|
||||
|
@ -980,7 +980,7 @@ impl CollabPanel {
|
|||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(false, false, cx))
|
||||
.child(IconButton::new(0, Icon::MessageBubbles)),
|
||||
.child(IconButton::new(0, IconName::MessageBubbles)),
|
||||
)
|
||||
.child(Label::new("chat"))
|
||||
.tooltip(move |cx| Tooltip::text("Open Chat", cx))
|
||||
|
@ -1724,7 +1724,7 @@ impl CollabPanel {
|
|||
.child(
|
||||
Button::new("sign_in", "Sign in")
|
||||
.icon_color(Color::Muted)
|
||||
.icon(Icon::Github)
|
||||
.icon(IconName::Github)
|
||||
.icon_position(IconPosition::Start)
|
||||
.style(ButtonStyle::Filled)
|
||||
.full_width()
|
||||
|
@ -1921,7 +1921,7 @@ impl CollabPanel {
|
|||
let button = match section {
|
||||
Section::ActiveCall => channel_link.map(|channel_link| {
|
||||
let channel_link_copy = channel_link.clone();
|
||||
IconButton::new("channel-link", Icon::Copy)
|
||||
IconButton::new("channel-link", IconName::Copy)
|
||||
.icon_size(IconSize::Small)
|
||||
.size(ButtonSize::None)
|
||||
.visible_on_hover("section-header")
|
||||
|
@ -1933,13 +1933,13 @@ impl CollabPanel {
|
|||
.into_any_element()
|
||||
}),
|
||||
Section::Contacts => Some(
|
||||
IconButton::new("add-contact", Icon::Plus)
|
||||
IconButton::new("add-contact", IconName::Plus)
|
||||
.on_click(cx.listener(|this, _, cx| this.toggle_contact_finder(cx)))
|
||||
.tooltip(|cx| Tooltip::text("Search for new contact", cx))
|
||||
.into_any_element(),
|
||||
),
|
||||
Section::Channels => Some(
|
||||
IconButton::new("add-channel", Icon::Plus)
|
||||
IconButton::new("add-channel", IconName::Plus)
|
||||
.on_click(cx.listener(|this, _, cx| this.new_root_channel(cx)))
|
||||
.tooltip(|cx| Tooltip::text("Create a channel", cx))
|
||||
.into_any_element(),
|
||||
|
@ -2010,7 +2010,7 @@ impl CollabPanel {
|
|||
})
|
||||
.when(!calling, |el| {
|
||||
el.child(
|
||||
IconButton::new("remove_contact", Icon::Close)
|
||||
IconButton::new("remove_contact", IconName::Close)
|
||||
.icon_color(Color::Muted)
|
||||
.visible_on_hover("")
|
||||
.tooltip(|cx| Tooltip::text("Remove Contact", cx))
|
||||
|
@ -2071,13 +2071,13 @@ impl CollabPanel {
|
|||
|
||||
let controls = if is_incoming {
|
||||
vec![
|
||||
IconButton::new("decline-contact", Icon::Close)
|
||||
IconButton::new("decline-contact", IconName::Close)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_contact_request(user_id, false, cx);
|
||||
}))
|
||||
.icon_color(color)
|
||||
.tooltip(|cx| Tooltip::text("Decline invite", cx)),
|
||||
IconButton::new("accept-contact", Icon::Check)
|
||||
IconButton::new("accept-contact", IconName::Check)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_contact_request(user_id, true, cx);
|
||||
}))
|
||||
|
@ -2086,7 +2086,7 @@ impl CollabPanel {
|
|||
]
|
||||
} else {
|
||||
let github_login = github_login.clone();
|
||||
vec![IconButton::new("remove_contact", Icon::Close)
|
||||
vec![IconButton::new("remove_contact", IconName::Close)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.remove_contact(user_id, &github_login, cx);
|
||||
}))
|
||||
|
@ -2126,13 +2126,13 @@ impl CollabPanel {
|
|||
};
|
||||
|
||||
let controls = [
|
||||
IconButton::new("reject-invite", Icon::Close)
|
||||
IconButton::new("reject-invite", IconName::Close)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_channel_invite(channel_id, false, cx);
|
||||
}))
|
||||
.icon_color(color)
|
||||
.tooltip(|cx| Tooltip::text("Decline invite", cx)),
|
||||
IconButton::new("accept-invite", Icon::Check)
|
||||
IconButton::new("accept-invite", IconName::Check)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.respond_to_channel_invite(channel_id, true, cx);
|
||||
}))
|
||||
|
@ -2150,7 +2150,7 @@ impl CollabPanel {
|
|||
.child(h_stack().children(controls)),
|
||||
)
|
||||
.start_slot(
|
||||
IconElement::new(Icon::Hash)
|
||||
Icon::new(IconName::Hash)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
|
@ -2162,7 +2162,7 @@ impl CollabPanel {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> ListItem {
|
||||
ListItem::new("contact-placeholder")
|
||||
.child(IconElement::new(Icon::Plus))
|
||||
.child(Icon::new(IconName::Plus))
|
||||
.child(Label::new("Add a Contact"))
|
||||
.selected(is_selected)
|
||||
.on_click(cx.listener(|this, _, cx| this.toggle_contact_finder(cx)))
|
||||
|
@ -2246,7 +2246,7 @@ impl CollabPanel {
|
|||
};
|
||||
|
||||
let messages_button = |cx: &mut ViewContext<Self>| {
|
||||
IconButton::new("channel_chat", Icon::MessageBubbles)
|
||||
IconButton::new("channel_chat", IconName::MessageBubbles)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(if has_messages_notification {
|
||||
Color::Default
|
||||
|
@ -2258,7 +2258,7 @@ impl CollabPanel {
|
|||
};
|
||||
|
||||
let notes_button = |cx: &mut ViewContext<Self>| {
|
||||
IconButton::new("channel_notes", Icon::File)
|
||||
IconButton::new("channel_notes", IconName::File)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(if has_notes_notification {
|
||||
Color::Default
|
||||
|
@ -2315,9 +2315,13 @@ impl CollabPanel {
|
|||
},
|
||||
))
|
||||
.start_slot(
|
||||
IconElement::new(if is_public { Icon::Public } else { Icon::Hash })
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
Icon::new(if is_public {
|
||||
IconName::Public
|
||||
} else {
|
||||
IconName::Hash
|
||||
})
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
.child(
|
||||
h_stack()
|
||||
|
@ -2386,7 +2390,7 @@ impl CollabPanel {
|
|||
.indent_level(depth + 1)
|
||||
.indent_step_size(px(20.))
|
||||
.start_slot(
|
||||
IconElement::new(Icon::Hash)
|
||||
Icon::new(IconName::Hash)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
);
|
||||
|
@ -2500,10 +2504,10 @@ impl Panel for CollabPanel {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::Icon> {
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::IconName> {
|
||||
CollaborationPanelSettings::get_global(cx)
|
||||
.button
|
||||
.then(|| ui::Icon::Collab)
|
||||
.then(|| ui::IconName::Collab)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
|
@ -2646,11 +2650,11 @@ impl Render for DraggedChannelView {
|
|||
.p_1()
|
||||
.gap_1()
|
||||
.child(
|
||||
IconElement::new(
|
||||
Icon::new(
|
||||
if self.channel.visibility == proto::ChannelVisibility::Public {
|
||||
Icon::Public
|
||||
IconName::Public
|
||||
} else {
|
||||
Icon::Hash
|
||||
IconName::Hash
|
||||
},
|
||||
)
|
||||
.size(IconSize::Small)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue