1use gpui2::{
2 div, px, Div, ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext,
3};
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 pub fn build_view<C: VisualContext>(str: SharedString, cx: &mut C) -> C::Result<View<Self>> {
17 cx.build_view(|cx| TextTooltip::new(str))
18 }
19}
20
21impl Render for TextTooltip {
22 type Element = Div<Self>;
23
24 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
25 let theme = cx.theme();
26 div()
27 .bg(theme.colors().background)
28 .rounded(px(8.))
29 .border()
30 .border_color(theme.colors().border)
31 .text_color(theme.colors().text)
32 .pl_2()
33 .pr_2()
34 .child(self.title.clone())
35 }
36}