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