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>(cx: &mut ViewContext<V>, title: &str) -> impl Component<V> {
19        div()
20            .text_xl()
21            .text_color(cx.theme().colors().text)
22            .child(title.to_owned())
23    }
24
25    pub fn title_for<V: 'static, T>(cx: &mut ViewContext<V>) -> impl Component<V> {
26        Self::title(cx, std::any::type_name::<T>())
27    }
28
29    pub fn label<V: 'static>(cx: &mut ViewContext<V>, label: &str) -> impl Component<V> {
30        div()
31            .mt_4()
32            .mb_2()
33            .text_xs()
34            .text_color(cx.theme().colors().text)
35            .child(label.to_owned())
36    }
37}