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
|
@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
|
|||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::Arc;
|
||||
use time::{OffsetDateTime, UtcOffset};
|
||||
use ui::{prelude::*, Avatar, Button, Icon, IconButton, Label, TabBar, Tooltip};
|
||||
use ui::{prelude::*, Avatar, Button, IconButton, IconName, Label, TabBar, Tooltip};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
|
@ -281,12 +281,12 @@ impl ChatPanel {
|
|||
)),
|
||||
)
|
||||
.end_child(
|
||||
IconButton::new("notes", Icon::File)
|
||||
IconButton::new("notes", IconName::File)
|
||||
.on_click(cx.listener(Self::open_notes))
|
||||
.tooltip(|cx| Tooltip::text("Open notes", cx)),
|
||||
)
|
||||
.end_child(
|
||||
IconButton::new("call", Icon::AudioOn)
|
||||
IconButton::new("call", IconName::AudioOn)
|
||||
.on_click(cx.listener(Self::join_call))
|
||||
.tooltip(|cx| Tooltip::text("Join call", cx)),
|
||||
),
|
||||
|
@ -395,7 +395,7 @@ impl ChatPanel {
|
|||
.w_8()
|
||||
.visible_on_hover("")
|
||||
.children(message_id_to_remove.map(|message_id| {
|
||||
IconButton::new(("remove", message_id), Icon::XCircle).on_click(
|
||||
IconButton::new(("remove", message_id), IconName::XCircle).on_click(
|
||||
cx.listener(move |this, _, cx| {
|
||||
this.remove_message(message_id, cx);
|
||||
}),
|
||||
|
@ -429,7 +429,7 @@ impl ChatPanel {
|
|||
Button::new("sign-in", "Sign in")
|
||||
.style(ButtonStyle::Filled)
|
||||
.icon_color(Color::Muted)
|
||||
.icon(Icon::Github)
|
||||
.icon(IconName::Github)
|
||||
.icon_position(IconPosition::Start)
|
||||
.full_width()
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
|
@ -622,12 +622,12 @@ impl Panel for ChatPanel {
|
|||
"ChatPanel"
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::Icon> {
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName> {
|
||||
if !is_channels_feature_enabled(cx) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(ui::Icon::MessageBubbles).filter(|_| ChatPanelSettings::get_global(cx).button)
|
||||
Some(ui::IconName::MessageBubbles).filter(|_| ChatPanelSettings::get_global(cx).button)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -168,7 +168,7 @@ impl Render for ChannelModal {
|
|||
.w_px()
|
||||
.flex_1()
|
||||
.gap_1()
|
||||
.child(IconElement::new(Icon::Hash).size(IconSize::Medium))
|
||||
.child(Icon::new(IconName::Hash).size(IconSize::Medium))
|
||||
.child(Label::new(channel_name)),
|
||||
)
|
||||
.child(
|
||||
|
@ -406,7 +406,7 @@ impl PickerDelegate for ChannelModalDelegate {
|
|||
Some(ChannelRole::Guest) => Some(Label::new("Guest")),
|
||||
_ => None,
|
||||
})
|
||||
.child(IconButton::new("ellipsis", Icon::Ellipsis))
|
||||
.child(IconButton::new("ellipsis", IconName::Ellipsis))
|
||||
.children(
|
||||
if let (Some((menu, _)), true) = (&self.context_menu, selected) {
|
||||
Some(
|
||||
|
|
|
@ -155,9 +155,7 @@ impl PickerDelegate for ContactFinderDelegate {
|
|||
.selected(selected)
|
||||
.start_slot(Avatar::new(user.avatar_uri.clone()))
|
||||
.child(Label::new(user.github_login.clone()))
|
||||
.end_slot::<IconElement>(
|
||||
icon_path.map(|icon_path| IconElement::from_path(icon_path)),
|
||||
),
|
||||
.end_slot::<Icon>(icon_path.map(|icon_path| Icon::from_path(icon_path))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::sync::Arc;
|
|||
use theme::{ActiveTheme, PlayerColors};
|
||||
use ui::{
|
||||
h_stack, popover_menu, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon,
|
||||
IconButton, IconElement, TintColor, Tooltip,
|
||||
IconButton, IconName, TintColor, Tooltip,
|
||||
};
|
||||
use util::ResultExt;
|
||||
use vcs_menu::{build_branch_list, BranchList, OpenRecent as ToggleVcsMenu};
|
||||
|
@ -213,7 +213,7 @@ impl Render for CollabTitlebarItem {
|
|||
.child(
|
||||
div()
|
||||
.child(
|
||||
IconButton::new("leave-call", ui::Icon::Exit)
|
||||
IconButton::new("leave-call", ui::IconName::Exit)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(|cx| Tooltip::text("Leave call", cx))
|
||||
.icon_size(IconSize::Small)
|
||||
|
@ -230,9 +230,9 @@ impl Render for CollabTitlebarItem {
|
|||
IconButton::new(
|
||||
"mute-microphone",
|
||||
if is_muted {
|
||||
ui::Icon::MicMute
|
||||
ui::IconName::MicMute
|
||||
} else {
|
||||
ui::Icon::Mic
|
||||
ui::IconName::Mic
|
||||
},
|
||||
)
|
||||
.tooltip(move |cx| {
|
||||
|
@ -256,9 +256,9 @@ impl Render for CollabTitlebarItem {
|
|||
IconButton::new(
|
||||
"mute-sound",
|
||||
if is_deafened {
|
||||
ui::Icon::AudioOff
|
||||
ui::IconName::AudioOff
|
||||
} else {
|
||||
ui::Icon::AudioOn
|
||||
ui::IconName::AudioOn
|
||||
},
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
|
@ -281,7 +281,7 @@ impl Render for CollabTitlebarItem {
|
|||
)
|
||||
.when(!read_only, |this| {
|
||||
this.child(
|
||||
IconButton::new("screen-share", ui::Icon::Screen)
|
||||
IconButton::new("screen-share", ui::IconName::Screen)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.icon_size(IconSize::Small)
|
||||
.selected(is_screen_sharing)
|
||||
|
@ -573,7 +573,7 @@ impl CollabTitlebarItem {
|
|||
| client::Status::ReconnectionError { .. } => Some(
|
||||
div()
|
||||
.id("disconnected")
|
||||
.child(IconElement::new(Icon::Disconnected).size(IconSize::Small))
|
||||
.child(Icon::new(IconName::Disconnected).size(IconSize::Small))
|
||||
.tooltip(|cx| Tooltip::text("Disconnected", cx))
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -643,7 +643,7 @@ impl CollabTitlebarItem {
|
|||
h_stack()
|
||||
.gap_0p5()
|
||||
.child(Avatar::new(user.avatar_uri.clone()))
|
||||
.child(IconElement::new(Icon::ChevronDown).color(Color::Muted)),
|
||||
.child(Icon::new(IconName::ChevronDown).color(Color::Muted)),
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(move |cx| Tooltip::text("Toggle User Menu", cx)),
|
||||
|
@ -665,7 +665,7 @@ impl CollabTitlebarItem {
|
|||
.child(
|
||||
h_stack()
|
||||
.gap_0p5()
|
||||
.child(IconElement::new(Icon::ChevronDown).color(Color::Muted)),
|
||||
.child(Icon::new(IconName::ChevronDown).color(Color::Muted)),
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(move |cx| Tooltip::text("Toggle User Menu", cx)),
|
||||
|
|
|
@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
|
|||
use settings::{Settings, SettingsStore};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use time::{OffsetDateTime, UtcOffset};
|
||||
use ui::{h_stack, prelude::*, v_stack, Avatar, Button, Icon, IconButton, IconElement, Label};
|
||||
use ui::{h_stack, prelude::*, v_stack, Avatar, Button, Icon, IconButton, IconName, Label};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
|
@ -553,7 +553,7 @@ impl Render for NotificationPanel {
|
|||
.border_b_1()
|
||||
.border_color(cx.theme().colors().border)
|
||||
.child(Label::new("Notifications"))
|
||||
.child(IconElement::new(Icon::Envelope)),
|
||||
.child(Icon::new(IconName::Envelope)),
|
||||
)
|
||||
.map(|this| {
|
||||
if self.client.user_id().is_none() {
|
||||
|
@ -564,7 +564,7 @@ impl Render for NotificationPanel {
|
|||
.child(
|
||||
Button::new("sign_in_prompt_button", "Sign in")
|
||||
.icon_color(Color::Muted)
|
||||
.icon(Icon::Github)
|
||||
.icon(IconName::Github)
|
||||
.icon_position(IconPosition::Start)
|
||||
.style(ButtonStyle::Filled)
|
||||
.full_width()
|
||||
|
@ -655,10 +655,10 @@ impl Panel for NotificationPanel {
|
|||
}
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<Icon> {
|
||||
fn icon(&self, cx: &gpui::WindowContext) -> Option<IconName> {
|
||||
(NotificationPanelSettings::get_global(cx).button
|
||||
&& self.notification_store.read(cx).notification_count() > 0)
|
||||
.then(|| Icon::Bell)
|
||||
.then(|| IconName::Bell)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
|
@ -716,7 +716,7 @@ impl Render for NotificationToast {
|
|||
.children(user.map(|user| Avatar::new(user.avatar_uri.clone())))
|
||||
.child(Label::new(self.text.clone()))
|
||||
.child(
|
||||
IconButton::new("close", Icon::Close)
|
||||
IconButton::new("close", IconName::Close)
|
||||
.on_click(cx.listener(|_, _, cx| cx.emit(DismissEvent))),
|
||||
)
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue