1use gpui::{div, prelude::*, px, Div, Render, SharedString, Stateful, Styled, View, WindowContext};
2use ui::prelude::*;
3use ui::Tooltip;
4
5pub struct ScrollStory;
6
7impl ScrollStory {
8 pub fn view(cx: &mut WindowContext) -> View<ScrollStory> {
9 cx.build_view(|_cx| ScrollStory)
10 }
11}
12
13impl Render for ScrollStory {
14 type Element = Stateful<Div>;
15
16 fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
17 let theme = cx.theme();
18 let color_1 = theme.status().created;
19 let color_2 = theme.status().modified;
20
21 div()
22 .id("parent")
23 .bg(theme.colors().background)
24 .size_full()
25 .overflow_scroll()
26 .children((0..10).map(|row| {
27 div()
28 .w(px(1000.))
29 .h(px(100.))
30 .flex()
31 .flex_row()
32 .children((0..10).map(|column| {
33 let id = SharedString::from(format!("{}, {}", row, column));
34 let bg = if row % 2 == column % 2 {
35 color_1
36 } else {
37 color_2
38 };
39 div()
40 .id(id)
41 .tooltip(move |cx| Tooltip::text(format!("{}, {}", row, column), cx))
42 .bg(bg)
43 .size(px(100. as f32))
44 .when(row >= 5 && column >= 5, |d| {
45 d.overflow_scroll()
46 .child(div().size(px(50.)).bg(color_1))
47 .child(div().size(px(50.)).bg(color_2))
48 .child(div().size(px(50.)).bg(color_1))
49 .child(div().size(px(50.)).bg(color_2))
50 })
51 }))
52 }))
53 }
54}