tooltip.rs

 1use gpui::{div, Div, ParentComponent, 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(str: SharedString) -> Self {
13        Self { title: str }
14    }
15}
16
17impl Render for TextTooltip {
18    type Element = Div<Self>;
19
20    fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
21        div()
22            .elevation_2(cx)
23            .font("Zed Sans")
24            .text_ui()
25            .text_color(cx.theme().colors().text)
26            .py_1()
27            .px_2()
28            .child(self.title.clone())
29    }
30}