1use crate::theme::theme;
2use gpui2::style::{StyleHelpers, Styleable};
3use gpui2::{elements::div, IntoElement};
4use gpui2::{Element, ParentElement, ViewContext};
5
6#[derive(Element)]
7pub(crate) struct Tab {
8 title: &'static str,
9 enabled: bool,
10}
11
12pub fn tab<V: 'static>(title: &'static str, enabled: bool) -> impl Element<V> {
13 Tab { title, enabled }
14}
15
16impl Tab {
17 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
18 let theme = theme(cx);
19
20 div()
21 .px_2()
22 .py_0p5()
23 .flex()
24 .items_center()
25 .justify_center()
26 .rounded_lg()
27 .fill(if self.enabled {
28 theme.highest.on.default.background
29 } else {
30 theme.highest.base.default.background
31 })
32 .hover()
33 .fill(if self.enabled {
34 theme.highest.on.hovered.background
35 } else {
36 theme.highest.base.hovered.background
37 })
38 .active()
39 .fill(if self.enabled {
40 theme.highest.on.pressed.background
41 } else {
42 theme.highest.base.pressed.background
43 })
44 .child(
45 div()
46 .text_sm()
47 .text_color(if self.enabled {
48 theme.highest.base.default.foreground
49 } else {
50 theme.highest.variant.default.foreground
51 })
52 .child(self.title),
53 )
54 }
55}