search_bar.rs

 1use gpui::{Action, FocusHandle, IntoElement};
 2use ui::{prelude::*, Tooltip};
 3use ui::{IconButton, IconButtonShape};
 4
 5pub(super) fn render_nav_button(
 6    icon: ui::IconName,
 7    active: bool,
 8    tooltip: &'static str,
 9    action: &'static dyn Action,
10    focus_handle: FocusHandle,
11) -> impl IntoElement {
12    IconButton::new(
13        SharedString::from(format!("search-nav-button-{}", action.name())),
14        icon,
15    )
16    .shape(IconButtonShape::Square)
17    .on_click(|_, cx| cx.dispatch_action(action.boxed_clone()))
18    .tooltip(move |cx| Tooltip::for_action_in(tooltip, action, &focus_handle, cx))
19    .disabled(!active)
20}