Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:33:27.751Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

grid_layout.rs

90 lines · 3.1 KB · rust
1#![cfg_attr(target_family = "wasm", no_main)]
2
3use gpui::{
4    App, Bounds, Context, Hsla, Window, WindowBounds, WindowOptions, container_query, div,
5    prelude::*, px, rgb, size,
6};
7use gpui_platform::application;
8
9// https://en.wikipedia.org/wiki/Holy_grail_(web_design)
10//
11// Resize the window: the layout is chosen by `container_query` based on the
12// measured size of the container, collapsing to a single stacked column when
13// it becomes too narrow for the three-column grid.
14struct HolyGrailExample {}
15
16impl Render for HolyGrailExample {
17    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
18        container_query(|container_size, _window, _cx| {
19            let block = |color: Hsla| {
20                div()
21                    .size_full()
22                    .bg(color)
23                    .border_1()
24                    .border_dashed()
25                    .rounded_md()
26                    .border_color(gpui::white())
27                    .items_center()
28            };
29
30            let header = block(gpui::white()).child(format!("Header — {}", container_size.width));
31            let table_of_contents = block(gpui::red()).child("Table of contents");
32            let content = block(gpui::green()).child("Content");
33            let ad = block(gpui::blue()).child("AD :(").text_color(gpui::white());
34            let footer = block(gpui::black())
35                .text_color(gpui::white())
36                .child("Footer");
37
38            let container = div().gap_1().bg(rgb(0x505050)).shadow_lg().size_full();
39
40            if container_size.width < px(400.) {
41                container
42                    .flex()
43                    .flex_col()
44                    .child(header.h_12().flex_none())
45                    .child(table_of_contents.h_20().flex_none())
46                    .child(content.flex_1())
47                    .child(ad.h_20().flex_none())
48                    .child(footer.h_12().flex_none())
49            } else {
50                container
51                    .grid()
52                    .grid_cols(5)
53                    .grid_rows(5)
54                    .child(header.row_span(1).col_span_full())
55                    .child(table_of_contents.col_span(1).h_56())
56                    .child(content.col_span(3).row_span(3))
57                    .child(ad.col_span(1).row_span(3))
58                    .child(footer.row_span(1).col_span_full())
59            }
60        })
61    }
62}
63
64fn run_example() {
65    application().run(|cx: &mut App| {
66        let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);
67        cx.open_window(
68            WindowOptions {
69                window_bounds: Some(WindowBounds::Windowed(bounds)),
70                ..Default::default()
71            },
72            |_, cx| cx.new(|_| HolyGrailExample {}),
73        )
74        .unwrap();
75        cx.activate(true);
76    });
77}
78
79#[cfg(not(target_family = "wasm"))]
80fn main() {
81    run_example();
82}
83
84#[cfg(target_family = "wasm")]
85#[wasm_bindgen::prelude::wasm_bindgen(start)]
86pub fn start() {
87    gpui_platform::web_init();
88    run_example();
89}
90
Served at tenant.openagents/omega Member data and write actions are omitted.