1use std::cmp::Ordering;
2
3use gpui::Render;
4use story::Story;
5
6use crate::{IconButtonShape, TabPosition, prelude::*};
7use crate::{Indicator, Tab};
8
9pub struct TabStory;
10
11impl Render for TabStory {
12 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
13 Story::container(cx)
14 .child(Story::title_for::<Tab>(cx))
15 .child(Story::label("Default", cx))
16 .child(h_flex().child(Tab::new("tab_1").child("Tab 1")))
17 .child(Story::label("With indicator", cx))
18 .child(
19 h_flex().child(
20 Tab::new("tab_1")
21 .start_slot(Indicator::dot().color(Color::Warning))
22 .child("Tab 1"),
23 ),
24 )
25 .child(Story::label("With close button", cx))
26 .child(
27 h_flex().child(
28 Tab::new("tab_1")
29 .end_slot(
30 IconButton::new("close_button", IconName::Close)
31 .visible_on_hover("")
32 .shape(IconButtonShape::Square)
33 .icon_color(Color::Muted)
34 .size(ButtonSize::None)
35 .icon_size(IconSize::XSmall),
36 )
37 .child("Tab 1"),
38 ),
39 )
40 .child(Story::label("List of tabs", cx))
41 .child(
42 h_flex()
43 .child(Tab::new("tab_1").child("Tab 1"))
44 .child(Tab::new("tab_2").child("Tab 2")),
45 )
46 .child(Story::label("List of tabs with first tab selected", cx))
47 .child(
48 h_flex()
49 .child(
50 Tab::new("tab_1")
51 .toggle_state(true)
52 .position(TabPosition::First)
53 .child("Tab 1"),
54 )
55 .child(
56 Tab::new("tab_2")
57 .position(TabPosition::Middle(Ordering::Greater))
58 .child("Tab 2"),
59 )
60 .child(
61 Tab::new("tab_3")
62 .position(TabPosition::Middle(Ordering::Greater))
63 .child("Tab 3"),
64 )
65 .child(Tab::new("tab_4").position(TabPosition::Last).child("Tab 4")),
66 )
67 .child(Story::label("List of tabs with last tab selected", cx))
68 .child(
69 h_flex()
70 .child(
71 Tab::new("tab_1")
72 .position(TabPosition::First)
73 .child("Tab 1"),
74 )
75 .child(
76 Tab::new("tab_2")
77 .position(TabPosition::Middle(Ordering::Less))
78 .child("Tab 2"),
79 )
80 .child(
81 Tab::new("tab_3")
82 .position(TabPosition::Middle(Ordering::Less))
83 .child("Tab 3"),
84 )
85 .child(
86 Tab::new("tab_4")
87 .position(TabPosition::Last)
88 .toggle_state(true)
89 .child("Tab 4"),
90 ),
91 )
92 .child(Story::label("List of tabs with second tab selected", cx))
93 .child(
94 h_flex()
95 .child(
96 Tab::new("tab_1")
97 .position(TabPosition::First)
98 .child("Tab 1"),
99 )
100 .child(
101 Tab::new("tab_2")
102 .position(TabPosition::Middle(Ordering::Equal))
103 .toggle_state(true)
104 .child("Tab 2"),
105 )
106 .child(
107 Tab::new("tab_3")
108 .position(TabPosition::Middle(Ordering::Greater))
109 .child("Tab 3"),
110 )
111 .child(Tab::new("tab_4").position(TabPosition::Last).child("Tab 4")),
112 )
113 }
114}