1use gpui::{Div, Render, Stateful};
2use story::Story;
3use ui::prelude::*;
4
5pub struct CursorStory;
6
7impl Render for CursorStory {
8 fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
9 let all_cursors: [(&str, Box<dyn Fn(Stateful<Div>) -> Stateful<Div>>); 19] = [
10 (
11 "cursor_default",
12 Box::new(|el: Stateful<Div>| el.cursor_default()),
13 ),
14 (
15 "cursor_pointer",
16 Box::new(|el: Stateful<Div>| el.cursor_pointer()),
17 ),
18 (
19 "cursor_text",
20 Box::new(|el: Stateful<Div>| el.cursor_text()),
21 ),
22 (
23 "cursor_move",
24 Box::new(|el: Stateful<Div>| el.cursor_move()),
25 ),
26 (
27 "cursor_not_allowed",
28 Box::new(|el: Stateful<Div>| el.cursor_not_allowed()),
29 ),
30 (
31 "cursor_context_menu",
32 Box::new(|el: Stateful<Div>| el.cursor_context_menu()),
33 ),
34 (
35 "cursor_crosshair",
36 Box::new(|el: Stateful<Div>| el.cursor_crosshair()),
37 ),
38 (
39 "cursor_vertical_text",
40 Box::new(|el: Stateful<Div>| el.cursor_vertical_text()),
41 ),
42 (
43 "cursor_alias",
44 Box::new(|el: Stateful<Div>| el.cursor_alias()),
45 ),
46 (
47 "cursor_copy",
48 Box::new(|el: Stateful<Div>| el.cursor_copy()),
49 ),
50 (
51 "cursor_no_drop",
52 Box::new(|el: Stateful<Div>| el.cursor_no_drop()),
53 ),
54 (
55 "cursor_grab",
56 Box::new(|el: Stateful<Div>| el.cursor_grab()),
57 ),
58 (
59 "cursor_grabbing",
60 Box::new(|el: Stateful<Div>| el.cursor_grabbing()),
61 ),
62 (
63 "cursor_col_resize",
64 Box::new(|el: Stateful<Div>| el.cursor_col_resize()),
65 ),
66 (
67 "cursor_row_resize",
68 Box::new(|el: Stateful<Div>| el.cursor_row_resize()),
69 ),
70 (
71 "cursor_n_resize",
72 Box::new(|el: Stateful<Div>| el.cursor_n_resize()),
73 ),
74 (
75 "cursor_e_resize",
76 Box::new(|el: Stateful<Div>| el.cursor_e_resize()),
77 ),
78 (
79 "cursor_s_resize",
80 Box::new(|el: Stateful<Div>| el.cursor_s_resize()),
81 ),
82 (
83 "cursor_w_resize",
84 Box::new(|el: Stateful<Div>| el.cursor_w_resize()),
85 ),
86 ];
87
88 Story::container(cx)
89 .flex()
90 .gap_1()
91 .child(Story::title("cursor", cx))
92 .children(all_cursors.map(|(name, apply_cursor)| {
93 div().gap_1().flex().text_color(gpui::white()).child(
94 div()
95 .flex()
96 .items_center()
97 .justify_center()
98 .id(name)
99 .map(apply_cursor)
100 .w_64()
101 .h_8()
102 .bg(gpui::red())
103 .active(|style| style.bg(gpui::green()))
104 .text_sm()
105 .child(Story::label(name, cx)),
106 )
107 }))
108 }
109}