Tooltip on tabs

Co-Authored-By: Julia <julia@zed.dev>
This commit is contained in:
Conrad Irwin 2023-11-03 14:02:46 -06:00
parent 26e64fb843
commit 33245d119e
6 changed files with 77 additions and 7 deletions

View file

@ -31,6 +31,7 @@ mod theme_selector;
mod title_bar;
mod toast;
mod toolbar;
mod tooltip;
mod traffic_lights;
mod workspace;
@ -67,5 +68,6 @@ pub use theme_selector::*;
pub use title_bar::*;
pub use toast::*;
pub use toolbar::*;
pub use tooltip::*;
pub use traffic_lights::*;
pub use workspace::*;

View file

@ -0,0 +1,36 @@
use gpui2::{
div, px, Div, ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext,
};
use theme2::ActiveTheme;
#[derive(Clone, Debug)]
pub struct TextTooltip {
title: SharedString,
}
impl TextTooltip {
pub fn new(str: SharedString) -> Self {
Self { title: str }
}
pub fn build_view<C: VisualContext>(str: SharedString, cx: &mut C) -> C::Result<View<Self>> {
cx.build_view(|cx| TextTooltip::new(str))
}
}
impl Render for TextTooltip {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let theme = cx.theme();
div()
.bg(theme.colors().background)
.rounded(px(8.))
.border()
.border_color(theme.colors().border)
.text_color(theme.colors().text)
.pl_2()
.pr_2()
.child(self.title.clone())
}
}