1use gpui::{
2 div, prelude::*, px, rgb, size, App, Application, Bounds, Context, SharedString, Window,
3 WindowBounds, WindowOptions,
4};
5
6struct HelloWorld {
7 text: SharedString,
8}
9
10impl Render for HelloWorld {
11 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
12 div()
13 .flex()
14 .flex_col()
15 .gap_3()
16 .bg(rgb(0x505050))
17 .size(px(500.0))
18 .justify_center()
19 .items_center()
20 .shadow_lg()
21 .border_1()
22 .border_color(rgb(0x0000ff))
23 .text_xl()
24 .text_color(rgb(0xffffff))
25 .child(format!("Hello, {}!", &self.text))
26 .child(
27 div()
28 .flex()
29 .gap_2()
30 .child(div().size_8().bg(gpui::red()))
31 .child(div().size_8().bg(gpui::green()))
32 .child(div().size_8().bg(gpui::blue()))
33 .child(div().size_8().bg(gpui::yellow()))
34 .child(div().size_8().bg(gpui::black()))
35 .child(div().size_8().bg(gpui::white())),
36 )
37 }
38}
39
40fn main() {
41 Application::new().run(|cx: &mut App| {
42 let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);
43 cx.open_window(
44 WindowOptions {
45 window_bounds: Some(WindowBounds::Windowed(bounds)),
46 ..Default::default()
47 },
48 |_, cx| {
49 cx.new(|_| HelloWorld {
50 text: "World".into(),
51 })
52 },
53 )
54 .unwrap();
55 });
56}