tooltip.rs

 1use std::time::Duration;
 2
 3use gpui2::{div, px, Div, ParentElement, Render, SharedString, Styled, ViewContext};
 4use theme2::ActiveTheme;
 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        let theme = cx.theme();
22        div()
23            .bg(theme.colors().background)
24            .rounded(px(8.))
25            .border()
26            .font("Zed Sans")
27            .border_color(theme.colors().border)
28            .text_color(theme.colors().text)
29            .pl_2()
30            .pr_2()
31            .child(self.title.clone())
32    }
33}