use gpui::{
App, Application, Bounds, Context, SharedString, Window, WindowBounds, WindowOptions, div,
prelude::*, px, rgb, size,
};
use builderx::bx;
struct Demo {
title: SharedString,
}
impl Render for Demo {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
bx! {
div[
flex,
flex_col,
gap_3,
bg(rgb(0x202020)),
size(px(260.0)),
text_color(rgb(0xffffff)),
p_3,
rounded_md,
]{
div[text_lg]{ self.title.clone() },
div[border_1, border_color(rgb(0x808080)), p_2, rounded_sm]{ "Nested node" },
..(0..3).map(|i| bx! { div[text_sm]{ format!("Item {i}") } }),
}
}
}
}
fn main() {
Application::new().run(|cx: &mut App| {
let bounds = Bounds::centered(None, size(px(300.0), px(220.0)), cx);
let _ = cx.open_window(
WindowOptions {
window_bounds: Some(WindowBounds::Windowed(bounds)),
..Default::default()
},
|_window, cx| cx.new(|_cx| Demo { title: "bx! demo".into() }),
);
});
}