1use std::cmp::Ordering;
2
3use gpui::Render;
4use story::Story;
5
6use crate::{Indicator, Tab};
7use crate::{TabPosition, prelude::*};
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 .icon_color(Color::Muted)
33 .size(ButtonSize::None)
34 .icon_size(IconSize::XSmall),
35 )
36 .child("Tab 1"),
37 ),
38 )
39 .child(Story::label("List of tabs", cx))
40 .child(
41 h_flex()
42 .child(Tab::new("tab_1").child("Tab 1"))
43 .child(Tab::new("tab_2").child("Tab 2")),
44 )
45 .child(Story::label("List of tabs with first tab selected", cx))
46 .child(
47 h_flex()
48 .child(
49 Tab::new("tab_1")
50 .toggle_state(true)
51 .position(TabPosition::First)
52 .child("Tab 1"),
53 )
54 .child(
55 Tab::new("tab_2")
56 .position(TabPosition::Middle(Ordering::Greater))
57 .child("Tab 2"),
58 )
59 .child(
60 Tab::new("tab_3")
61 .position(TabPosition::Middle(Ordering::Greater))
62 .child("Tab 3"),
63 )
64 .child(Tab::new("tab_4").position(TabPosition::Last).child("Tab 4")),
65 )
66 .child(Story::label("List of tabs with last tab selected", cx))
67 .child(
68 h_flex()
69 .child(
70 Tab::new("tab_1")
71 .position(TabPosition::First)
72 .child("Tab 1"),
73 )
74 .child(
75 Tab::new("tab_2")
76 .position(TabPosition::Middle(Ordering::Less))
77 .child("Tab 2"),
78 )
79 .child(
80 Tab::new("tab_3")
81 .position(TabPosition::Middle(Ordering::Less))
82 .child("Tab 3"),
83 )
84 .child(
85 Tab::new("tab_4")
86 .position(TabPosition::Last)
87 .toggle_state(true)
88 .child("Tab 4"),
89 ),
90 )
91 .child(Story::label("List of tabs with second tab selected", cx))
92 .child(
93 h_flex()
94 .child(
95 Tab::new("tab_1")
96 .position(TabPosition::First)
97 .child("Tab 1"),
98 )
99 .child(
100 Tab::new("tab_2")
101 .position(TabPosition::Middle(Ordering::Equal))
102 .toggle_state(true)
103 .child("Tab 2"),
104 )
105 .child(
106 Tab::new("tab_3")
107 .position(TabPosition::Middle(Ordering::Greater))
108 .child("Tab 3"),
109 )
110 .child(Tab::new("tab_4").position(TabPosition::Last).child("Tab 4")),
111 )
112 }
113}