tooltip.rs

 1use gpui::{div, Div, ParentElement, Render, SharedString, Styled, ViewContext};
 2use theme2::ActiveTheme;
 3
 4use crate::StyledExt;
 5
 6#[derive(Clone, Debug)]
 7pub struct TextTooltip {
 8    title: SharedString,
 9}
10
11impl TextTooltip {
12    pub fn new(title: impl Into<SharedString>) -> Self {
13        Self {
14            title: title.into(),
15        }
16    }
17}
18
19impl Render for TextTooltip {
20    type Element = Div<Self>;
21
22    fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
23        div()
24            .elevation_2(cx)
25            .font("Zed Sans")
26            .text_ui()
27            .text_color(cx.theme().colors().text)
28            .py_1()
29            .px_2()
30            .child(self.title.clone())
31    }
32}