tooltip.rs

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