kitchen_sink.rs

 1use gpui::{prelude::*, Div, Render, Stateful, View};
 2use story::Story;
 3use strum::IntoEnumIterator;
 4use ui::prelude::*;
 5
 6use crate::story_selector::ComponentStory;
 7
 8pub struct KitchenSinkStory;
 9
10impl KitchenSinkStory {
11    pub fn view(cx: &mut WindowContext) -> View<Self> {
12        cx.build_view(|cx| Self)
13    }
14}
15
16impl Render for KitchenSinkStory {
17    type Element = Stateful<Div>;
18
19    fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
20        let component_stories = ComponentStory::iter()
21            .map(|selector| selector.story(cx))
22            .collect::<Vec<_>>();
23
24        Story::container()
25            .id("kitchen-sink")
26            .overflow_y_scroll()
27            .child(Story::title("Kitchen Sink"))
28            .child(Story::label("Components"))
29            .child(div().flex().flex_col().children(component_stories))
30            // Add a bit of space at the bottom of the kitchen sink so elements
31            // don't end up squished right up against the bottom of the screen.
32            .child(div().p_4())
33    }
34}