ui: Refactor the Button component icon methods (#51496)

Previously, if you wanted to have a button that contains icons on both
edges, you'd need to use a `ButtonLike` component, which takes any
children. Meanwhile, the `Button` would only take one icon, where you
could control its position through the `IconPosition` enum. This has
always felt unnecessarily limiting. So, this PR removes this limitation
by adding two new methods to the button: `start_icon` and `end_icon`.

In the meantime, I have also been bothered by the unnecessary
indirection in the `IconButton` due to the existence of the `ButtonIcon`
component. So I figured I could also completely eliminate that by adding
some of its methods directly to the `IconButton` and in the Button, just
using a regular `Icon` component.

---
## Before
```rust
Button::new("id", "Label")
    .icon(IconName::Plus)
    .icon_position(IconPosition::Start)
    .icon_size(IconSize::Small)
    .icon_color(Color::Muted)
```

## After
```rust
Button::new("id", "Label")
    .start_icon(Icon::new(IconName::Check))
    .end_icon(Icon::new(IconName::ChevronDown).size(IconSize::XSmall))
```

This should have no visual impact to the UI.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal authored and GitHub committed 2026-03-13 14:13:12 -03:00
1 parent a623dc3d1a
commit 4e8937b62d
64 files changed
+584 -847

No files matched your search

+5 -4
View File
@@ -524,10 +524,11 @@ impl CommitView {
.when(self.stash.is_none(), |this| {
this.child(
Button::new("sha", "Commit SHA")
.icon(copy_icon)
.icon_color(copy_icon_color)
.icon_position(IconPosition::Start)
.icon_size(IconSize::Small)
.start_icon(
Icon::new(copy_icon)
.size(IconSize::Small)
.color(copy_icon_color),
)
.tooltip({
let commit_sha = commit_sha.clone();
move |_, cx| {