1use gpui::{
2 App, Application, Bounds, Context, Hsla, Window, WindowBounds, WindowOptions, div, prelude::*,
3 px, rgb, size,
4};
5
6// https://en.wikipedia.org/wiki/Holy_grail_(web_design)
7struct HolyGrailExample {}
8
9impl Render for HolyGrailExample {
10 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
11 let block = |color: Hsla| {
12 div()
13 .size_full()
14 .bg(color)
15 .border_1()
16 .border_dashed()
17 .rounded_md()
18 .border_color(gpui::white())
19 .items_center()
20 };
21
22 div()
23 .gap_1()
24 .grid()
25 .bg(rgb(0x505050))
26 .size(px(500.0))
27 .shadow_lg()
28 .border_1()
29 .size_full()
30 .grid_cols(5)
31 .grid_rows(5)
32 .child(
33 block(gpui::white())
34 .row_span(1)
35 .col_span_full()
36 .child("Header"),
37 )
38 .child(
39 block(gpui::red())
40 .col_span(1)
41 .h_56()
42 .child("Table of contents"),
43 )
44 .child(
45 block(gpui::green())
46 .col_span(3)
47 .row_span(3)
48 .child("Content"),
49 )
50 .child(
51 block(gpui::blue())
52 .col_span(1)
53 .row_span(3)
54 .child("AD :(")
55 .text_color(gpui::white()),
56 )
57 .child(
58 block(gpui::black())
59 .row_span(1)
60 .col_span_full()
61 .text_color(gpui::white())
62 .child("Footer"),
63 )
64 }
65}
66
67fn main() {
68 Application::new().run(|cx: &mut App| {
69 let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);
70 cx.open_window(
71 WindowOptions {
72 window_bounds: Some(WindowBounds::Windowed(bounds)),
73 ..Default::default()
74 },
75 |_, cx| cx.new(|_| HolyGrailExample {}),
76 )
77 .unwrap();
78 cx.activate(true);
79 });
80}