mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-26 08:31:04 +00:00
baa07e935e
This PR extracts the various UI elements from the `storybook` crate into a new `ui` library crate. Release Notes: - N/A
37 lines
868 B
Rust
37 lines
868 B
Rust
use gpui2::elements::div;
|
|
use gpui2::style::StyleHelpers;
|
|
use gpui2::{Element, IntoElement, ParentElement, ViewContext};
|
|
|
|
use crate::theme;
|
|
|
|
#[derive(Element, Clone)]
|
|
pub struct Details {
|
|
text: &'static str,
|
|
meta: Option<&'static str>,
|
|
}
|
|
|
|
pub fn details(text: &'static str) -> Details {
|
|
Details { text, meta: None }
|
|
}
|
|
|
|
impl Details {
|
|
pub fn meta_text(mut self, meta: &'static str) -> Self {
|
|
self.meta = Some(meta);
|
|
self
|
|
}
|
|
|
|
fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
|
|
let theme = theme(cx);
|
|
|
|
div()
|
|
// .flex()
|
|
// .w_full()
|
|
.p_1()
|
|
.gap_0p5()
|
|
.text_xs()
|
|
.text_color(theme.lowest.base.default.foreground)
|
|
.child(self.text.clone())
|
|
.children(self.meta.map(|m| m))
|
|
}
|
|
}
|