story.rs

 1use gpui2::Div;
 2
 3use crate::prelude::*;
 4
 5pub struct Story {}
 6
 7impl Story {
 8    pub fn container<S: 'static + Send + Sync>(cx: &mut ViewContext<S>) -> Div<S> {
 9        let theme = theme(cx);
10
11        div()
12            .size_full()
13            .flex()
14            .flex_col()
15            .pt_2()
16            .px_4()
17            .font("Zed Mono")
18            .bg(theme.background)
19    }
20
21    pub fn title<S: 'static + Send + Sync>(
22        cx: &mut ViewContext<S>,
23        title: &str,
24    ) -> impl Element<ViewState = S> {
25        let theme = theme(cx);
26
27        div()
28            .text_xl()
29            .text_color(theme.text)
30            .child(title.to_owned())
31    }
32
33    pub fn title_for<S: 'static + Send + Sync, T>(
34        cx: &mut ViewContext<S>,
35    ) -> impl Element<ViewState = S> {
36        Self::title(cx, std::any::type_name::<T>())
37    }
38
39    pub fn label<S: 'static + Send + Sync>(
40        cx: &mut ViewContext<S>,
41        label: &str,
42    ) -> impl Element<ViewState = S> {
43        let theme = theme(cx);
44
45        div()
46            .mt_4()
47            .mb_2()
48            .text_xs()
49            .text_color(theme.text)
50            .child(label.to_owned())
51    }
52}