kitchen_sink.rs

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