use gpui::prelude::FluentBuilder;
use gpui::{
    div, relative, App, AppContext, Context, Entity, IntoElement, ParentElement, Render,
    SharedString, Styled, Window,
};
use theme::ActiveTheme;

pub struct Tooltip {
    text: SharedString,
}

impl Tooltip {
    pub fn new(text: impl Into<SharedString>, _window: &mut Window, cx: &mut App) -> Entity<Self> {
        cx.new(|_| Self { text: text.into() })
    }
}

impl Render for Tooltip {
    fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        div().child(
            div()
                .font_family(".SystemUIFont")
                .m_3()
                .p_1p5()
                .border_1()
                .border_color(cx.theme().border)
                .bg(cx.theme().surface_background)
                .when(cx.theme().shadow, |this| this.shadow_sm())
                .rounded(cx.theme().radius)
                .text_xs()
                .text_color(cx.theme().text)
                .line_height(relative(1.25))
                .child(self.text.clone()),
        )
    }
}
