use crate::{
components::{Button, ButtonSize, ButtonVariant},
icons::Icon,
t3::craft::sans,
theme::color,
tokens::ColorRole,
};
use gpui_kit::{App, Div, ElementId, ParentElement, SharedString, Styled, Window, div};
use std::rc::Rc;
pub(crate) type IndexHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>;
pub(crate) type TextHandler = Rc<dyn Fn(SharedString, &mut Window, &mut App)>;
pub(crate) fn icon_button(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
icon: impl Into<Icon>,
) -> Button {
Button::new(id, label)
.icon(icon)
.icon_only(true)
.variant(ButtonVariant::Ghost)
.size(ButtonSize::Sm)
}
pub(crate) fn title_tooltip(
text: SharedString,
) -> impl Fn(&mut Window, &mut App) -> gpui_kit::AnyView {
move |window, cx| gpui_kit::component::tooltip::Tooltip::new(text.clone()).build(window, cx)
}
pub(crate) fn card_sub(text: impl Into<SharedString>) -> Div {
sans(div(), 12., 400)
.text_color(color(ColorRole::TextSecondary))
.child(text.into())
}
pub(crate) fn child_id(id: &ElementId, part: &str, i: usize) -> ElementId {
ElementId::from((id.clone(), SharedString::from(format!("{part}-{i}"))))
}