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
19 lines
515 B
Rust
19 lines
515 B
Rust
use gpui::{Action, IntoElement};
|
|
use ui::IconButton;
|
|
use ui::{prelude::*, Tooltip};
|
|
|
|
pub(super) fn render_nav_button(
|
|
icon: ui::IconName,
|
|
active: bool,
|
|
tooltip: &'static str,
|
|
action: &'static dyn Action,
|
|
) -> impl IntoElement {
|
|
IconButton::new(
|
|
SharedString::from(format!("search-nav-button-{}", action.name())),
|
|
icon,
|
|
)
|
|
.on_click(|_, cx| cx.dispatch_action(action.boxed_clone()))
|
|
.tooltip(move |cx| Tooltip::for_action(tooltip, action, cx))
|
|
.disabled(!active)
|
|
}
|