Use an `IconButton` for the tab close button

Marshall Bowers created

Change summary

crates/ui2/src/elements/icon.rs | 10 ----------
crates/workspace2/src/pane.rs   | 19 ++++++++-----------
2 files changed, 8 insertions(+), 21 deletions(-)

Detailed changes

crates/ui2/src/elements/icon.rs 🔗

@@ -159,7 +159,6 @@ impl Icon {
 pub struct IconElement {
     icon: Icon,
     color: IconColor,
-    hover_color: Option<IconColor>,
     size: IconSize,
 }
 
@@ -168,7 +167,6 @@ impl IconElement {
         Self {
             icon,
             color: IconColor::default(),
-            hover_color: None,
             size: IconSize::default(),
         }
     }
@@ -178,11 +176,6 @@ impl IconElement {
         self
     }
 
-    pub fn hover_color(mut self, hover_color: impl Into<Option<IconColor>>) -> Self {
-        self.hover_color = hover_color.into();
-        self
-    }
-
     pub fn size(mut self, size: IconSize) -> Self {
         self.size = size;
         self
@@ -199,9 +192,6 @@ impl IconElement {
             .flex_none()
             .path(self.icon.path())
             .text_color(self.color.color(cx))
-            .when_some(self.hover_color, |this, hover_color| {
-                this.hover(|style| style.text_color(hover_color.color(cx)))
-            })
     }
 }
 

crates/workspace2/src/pane.rs 🔗

@@ -9,8 +9,8 @@ use crate::{
 use anyhow::Result;
 use collections::{HashMap, HashSet, VecDeque};
 use gpui::{
-    AnyView, AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle,
-    Model, PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
+    AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle, Model,
+    PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
 };
 use parking_lot::Mutex;
 use project2::{Project, ProjectEntryId, ProjectPath};
@@ -1366,15 +1366,12 @@ impl Pane {
                 .id(item.id())
                 .invisible()
                 .group_hover("", |style| style.visible())
-                .child(
-                    IconElement::new(Icon::Close)
-                        .color(IconColor::Muted)
-                        .hover_color(IconColor::Accent),
-                )
-                .on_click(move |pane: &mut Self, _, cx| {
-                    pane.close_item_by_id(id, SaveIntent::Close, cx)
-                        .detach_and_log_err(cx);
-                })
+                .child(IconButton::<Self>::new("close_tab", Icon::Close).on_click(
+                    move |pane: &mut Self, cx| {
+                        pane.close_item_by_id(id, SaveIntent::Close, cx)
+                            .detach_and_log_err(cx);
+                    },
+                ))
         };
 
         let (text_color, tab_bg, tab_hover_bg, tab_active_bg) = match ix == self.active_item_index {