story.rs

 1use gpui::Div;
 2
 3use crate::prelude::*;
 4
 5pub struct Story {}
 6
 7impl Story {
 8    pub fn container<V: 'static>(cx: &mut ViewContext<V>) -> Div<V> {
 9        div()
10            .size_full()
11            .flex()
12            .flex_col()
13            .pt_2()
14            .px_4()
15            .bg(cx.theme().colors().background)
16    }
17
18    pub fn title<V: 'static>(
19        cx: &mut ViewContext<V>,
20        title: impl Into<SharedString>,
21    ) -> impl Element<V> {
22        div()
23            .text_xl()
24            .text_color(cx.theme().colors().text)
25            .child(title.into())
26    }
27
28    pub fn title_for<V: 'static, T>(cx: &mut ViewContext<V>) -> impl Element<V> {
29        Self::title(cx, std::any::type_name::<T>())
30    }
31
32    pub fn label<V: 'static>(
33        cx: &mut ViewContext<V>,
34        label: impl Into<SharedString>,
35    ) -> impl Element<V> {
36        div()
37            .mt_4()
38            .mb_2()
39            .text_xs()
40            .text_color(cx.theme().colors().text)
41            .child(label.into())
42    }
43}