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