details.rs

 1use crate::prelude::*;
 2use crate::theme;
 3
 4#[derive(Element, Clone)]
 5pub struct Details {
 6    text: &'static str,
 7    meta: Option<&'static str>,
 8}
 9
10impl Details {
11    pub fn new(text: &'static str) -> Self {
12        Self { text, meta: None }
13    }
14
15    pub fn meta_text(mut self, meta: &'static str) -> Self {
16        self.meta = Some(meta);
17        self
18    }
19
20    fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
21        let theme = theme(cx);
22
23        div()
24            // .flex()
25            // .w_full()
26            .p_1()
27            .gap_0p5()
28            .text_xs()
29            .text_color(theme.lowest.base.default.foreground)
30            .child(self.text.clone())
31            .children(self.meta.map(|m| m))
32    }
33}