story.rs

 1use gpui::{div, Div, Element, ParentElement, SharedString, Styled, WindowContext};
 2
 3use crate::ActiveTheme;
 4
 5pub struct Story {}
 6
 7impl Story {
 8    pub fn container(cx: &mut WindowContext) -> Div {
 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(cx: &mut WindowContext, title: SharedString) -> impl Element {
20        div()
21            .text_xl()
22            .text_color(cx.theme().colors().text)
23            .child(title)
24    }
25
26    pub fn title_for<T>(cx: &mut WindowContext) -> impl Element {
27        Self::title(cx, std::any::type_name::<T>().into())
28    }
29
30    pub fn label(cx: &mut WindowContext, label: impl Into<SharedString>) -> impl Element {
31        div()
32            .mt_4()
33            .mb_2()
34            .text_xs()
35            .text_color(cx.theme().colors().text)
36            .child(label.into())
37    }
38}