Assign each `IconButton` an ID based on the icon

Marshall Bowers created

Change summary

crates/ui2/src/components/icon_button.rs | 4 ++--
crates/ui2/src/elements/icon.rs          | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

Detailed changes

crates/ui2/src/components/icon_button.rs 🔗

@@ -88,8 +88,8 @@ impl<S: 'static + Send + Sync> IconButton<S> {
         };
 
         let mut button = h_stack()
-            // TODO: We need to pass the ID in so that `IconButton`s can be differentiated from one another.
-            .id("icon_button")
+            // TODO: We probably need a more robust method for differentiating `IconButton`s from one another.
+            .id(SharedString::from(format!("{:?}", self.icon)))
             .justify_center()
             .rounded_md()
             .py(ui_size(cx, 0.25))

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

@@ -44,7 +44,7 @@ impl IconColor {
     }
 }
 
-#[derive(Default, PartialEq, Copy, Clone, EnumIter)]
+#[derive(Debug, Default, PartialEq, Copy, Clone, EnumIter)]
 pub enum Icon {
     Ai,
     ArrowLeft,