1use strum::IntoEnumIterator;
2use ui::prelude::*;
3use ui::{h_stack, v_stack, Tab};
4
5use crate::story::Story;
6
7#[derive(Element, Default)]
8pub struct TabStory {}
9
10impl TabStory {
11 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
12 let git_statuses = GitStatus::iter();
13 let fs_statuses = FileSystemStatus::iter();
14
15 Story::container(cx)
16 .child(Story::title_for::<_, Tab>(cx))
17 .child(
18 h_stack().child(
19 v_stack()
20 .gap_2()
21 .child(Story::label(cx, "Default"))
22 .child(Tab::new()),
23 ),
24 )
25 .child(
26 h_stack().child(
27 v_stack().gap_2().child(Story::label(cx, "Current")).child(
28 h_stack()
29 .gap_4()
30 .child(Tab::new().title("Current".to_string()).current(true))
31 .child(Tab::new().title("Not Current".to_string()).current(false)),
32 ),
33 ),
34 )
35 .child(
36 h_stack().child(
37 v_stack()
38 .gap_2()
39 .child(Story::label(cx, "Titled"))
40 .child(Tab::new().title("label".to_string())),
41 ),
42 )
43 .child(
44 h_stack().child(
45 v_stack()
46 .gap_2()
47 .child(Story::label(cx, "With Icon"))
48 .child(
49 Tab::new()
50 .title("label".to_string())
51 .icon(Some(ui::Icon::Envelope)),
52 ),
53 ),
54 )
55 .child(
56 h_stack().child(
57 v_stack()
58 .gap_2()
59 .child(Story::label(cx, "Close Side"))
60 .child(
61 h_stack()
62 .gap_4()
63 .child(
64 Tab::new()
65 .title("Left".to_string())
66 .close_side(IconSide::Left),
67 )
68 .child(Tab::new().title("Right".to_string())),
69 ),
70 ),
71 )
72 .child(
73 v_stack()
74 .gap_2()
75 .child(Story::label(cx, "Git Status"))
76 .child(h_stack().gap_4().children(git_statuses.map(|git_status| {
77 Tab::new()
78 .title(git_status.to_string())
79 .git_status(git_status)
80 }))),
81 )
82 .child(
83 v_stack()
84 .gap_2()
85 .child(Story::label(cx, "File System Status"))
86 .child(h_stack().gap_4().children(fs_statuses.map(|fs_status| {
87 Tab::new().title(fs_status.to_string()).fs_status(fs_status)
88 }))),
89 )
90 }
91}