1use gpui::{Div, Render};
2use story::Story;
3
4use crate::{prelude::*, Avatar};
5use crate::{Icon, ListItem};
6
7pub struct ListItemStory;
8
9impl Render for ListItemStory {
10 type Element = Div;
11
12 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
13 Story::container()
14 .bg(cx.theme().colors().background)
15 .child(Story::title_for::<ListItem>())
16 .child(Story::label("Default"))
17 .child(ListItem::new("hello_world").child("Hello, world!"))
18 .child(Story::label("Inset"))
19 .child(
20 ListItem::new("inset_list_item")
21 .inset(true)
22 .start_slot(
23 IconElement::new(Icon::Bell)
24 .size(IconSize::Small)
25 .color(Color::Muted),
26 )
27 .child("Hello, world!")
28 .end_slot(
29 IconElement::new(Icon::Bell)
30 .size(IconSize::Small)
31 .color(Color::Muted),
32 ),
33 )
34 .child(Story::label("With start slot icon"))
35 .child(
36 ListItem::new("with start slot_icon")
37 .child("Hello, world!")
38 .start_slot(
39 IconElement::new(Icon::Bell)
40 .size(IconSize::Small)
41 .color(Color::Muted),
42 ),
43 )
44 .child(Story::label("With start slot avatar"))
45 .child(
46 ListItem::new("with_start slot avatar")
47 .child("Hello, world!")
48 .start_slot(Avatar::new(SharedString::from(
49 "https://avatars.githubusercontent.com/u/1714999?v=4",
50 ))),
51 )
52 .child(Story::label("With end slot"))
53 .child(
54 ListItem::new("with_left_avatar")
55 .child("Hello, world!")
56 .end_slot(Avatar::new(SharedString::from(
57 "https://avatars.githubusercontent.com/u/1714999?v=4",
58 ))),
59 )
60 .child(Story::label("With end hover slot"))
61 .child(
62 ListItem::new("with_end_hover_slot")
63 .child("Hello, world!")
64 .end_slot(
65 h_stack()
66 .gap_2()
67 .child(Avatar::new(SharedString::from(
68 "https://avatars.githubusercontent.com/u/1789?v=4",
69 )))
70 .child(Avatar::new(SharedString::from(
71 "https://avatars.githubusercontent.com/u/1789?v=4",
72 )))
73 .child(Avatar::new(SharedString::from(
74 "https://avatars.githubusercontent.com/u/1789?v=4",
75 )))
76 .child(Avatar::new(SharedString::from(
77 "https://avatars.githubusercontent.com/u/1789?v=4",
78 )))
79 .child(Avatar::new(SharedString::from(
80 "https://avatars.githubusercontent.com/u/1789?v=4",
81 ))),
82 )
83 .end_hover_slot(Avatar::new(SharedString::from(
84 "https://avatars.githubusercontent.com/u/1714999?v=4",
85 ))),
86 )
87 .child(Story::label("With `on_click`"))
88 .child(
89 ListItem::new("with_on_click")
90 .child("Click me")
91 .on_click(|_event, _cx| {
92 println!("Clicked!");
93 }),
94 )
95 .child(Story::label("With `on_secondary_mouse_down`"))
96 .child(
97 ListItem::new("with_on_secondary_mouse_down")
98 .child("Right click me")
99 .on_secondary_mouse_down(|_event, _cx| {
100 println!("Right mouse down!");
101 }),
102 )
103 }
104}