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:
Marshall Bowers 2024-01-09 10:11:20 -05:00 committed by GitHub
parent 29ed067b26
commit fa53353c57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 364 additions and 360 deletions

View file

@ -2,7 +2,7 @@ use gpui::{AnyView, DefiniteLength};
use crate::{prelude::*, IconPosition, KeyBinding};
use crate::{
ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, IconSize, Label, LineHeightStyle,
ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, IconName, IconSize, Label, LineHeightStyle,
};
use super::button_icon::ButtonIcon;
@ -14,11 +14,11 @@ pub struct Button {
label_color: Option<Color>,
label_size: Option<LabelSize>,
selected_label: Option<SharedString>,
icon: Option<Icon>,
icon: Option<IconName>,
icon_position: Option<IconPosition>,
icon_size: Option<IconSize>,
icon_color: Option<Color>,
selected_icon: Option<Icon>,
selected_icon: Option<IconName>,
key_binding: Option<KeyBinding>,
}
@ -54,7 +54,7 @@ impl Button {
self
}
pub fn icon(mut self, icon: impl Into<Option<Icon>>) -> Self {
pub fn icon(mut self, icon: impl Into<Option<IconName>>) -> Self {
self.icon = icon.into();
self
}
@ -74,7 +74,7 @@ impl Button {
self
}
pub fn selected_icon(mut self, icon: impl Into<Option<Icon>>) -> Self {
pub fn selected_icon(mut self, icon: impl Into<Option<IconName>>) -> Self {
self.selected_icon = icon.into();
self
}

View file

@ -1,4 +1,4 @@
use crate::{prelude::*, Icon, IconElement, IconSize};
use crate::{prelude::*, Icon, IconName, IconSize};
/// An icon that appears within a button.
///
@ -6,17 +6,17 @@ use crate::{prelude::*, Icon, IconElement, IconSize};
/// or as a standalone icon, like in [`IconButton`](crate::IconButton).
#[derive(IntoElement)]
pub(super) struct ButtonIcon {
icon: Icon,
icon: IconName,
size: IconSize,
color: Color,
disabled: bool,
selected: bool,
selected_icon: Option<Icon>,
selected_icon: Option<IconName>,
selected_style: Option<ButtonStyle>,
}
impl ButtonIcon {
pub fn new(icon: Icon) -> Self {
pub fn new(icon: IconName) -> Self {
Self {
icon,
size: IconSize::default(),
@ -44,7 +44,7 @@ impl ButtonIcon {
self
}
pub fn selected_icon(mut self, icon: impl Into<Option<Icon>>) -> Self {
pub fn selected_icon(mut self, icon: impl Into<Option<IconName>>) -> Self {
self.selected_icon = icon.into();
self
}
@ -88,6 +88,6 @@ impl RenderOnce for ButtonIcon {
self.color
};
IconElement::new(icon).size(self.size).color(icon_color)
Icon::new(icon).size(self.size).color(icon_color)
}
}

View file

@ -1,21 +1,21 @@
use gpui::{AnyView, DefiniteLength};
use crate::{prelude::*, SelectableButton};
use crate::{ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, IconSize};
use crate::{ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, IconName, IconSize};
use super::button_icon::ButtonIcon;
#[derive(IntoElement)]
pub struct IconButton {
base: ButtonLike,
icon: Icon,
icon: IconName,
icon_size: IconSize,
icon_color: Color,
selected_icon: Option<Icon>,
selected_icon: Option<IconName>,
}
impl IconButton {
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
pub fn new(id: impl Into<ElementId>, icon: IconName) -> Self {
Self {
base: ButtonLike::new(id),
icon,
@ -35,7 +35,7 @@ impl IconButton {
self
}
pub fn selected_icon(mut self, icon: impl Into<Option<Icon>>) -> Self {
pub fn selected_icon(mut self, icon: impl Into<Option<IconName>>) -> Self {
self.selected_icon = icon.into();
self
}