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

+7 -6
View File
@@ -336,9 +336,10 @@ impl Render for CommitTooltip {
format!("#{}", pr.number),
)
.color(Color::Muted)
.icon(IconName::PullRequest)
.icon_color(Color::Muted)
.icon_position(IconPosition::Start)
.start_icon(
Icon::new(IconName::PullRequest)
.color(Color::Muted),
)
.style(ButtonStyle::Subtle)
.on_click(move |_, _, cx| {
cx.stop_propagation();
@@ -354,9 +355,9 @@ impl Render for CommitTooltip {
)
.style(ButtonStyle::Subtle)
.color(Color::Muted)
.icon(IconName::FileGit)
.icon_color(Color::Muted)
.icon_position(IconPosition::Start)
.start_icon(
Icon::new(IconName::FileGit).color(Color::Muted),
)
.on_click(
move |_, window, cx| {
CommitView::open(