Skip to repository content617 lines · 28.0 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T02:36:08.807Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
shadow.rs
1#![cfg_attr(target_family = "wasm", no_main)]
2
3use gpui::{
4 App, Bounds, BoxShadow, Context, Div, SharedString, Window, WindowBounds, WindowOptions, div,
5 hsla, prelude::*, px, relative, rgb, size,
6};
7use gpui_platform::application;
8
9struct Shadow {}
10
11impl Shadow {
12 fn base() -> Div {
13 div()
14 .size_16()
15 .bg(rgb(0xffffff))
16 .rounded_full()
17 .border_1()
18 .border_color(hsla(0.0, 0.0, 0.0, 0.1))
19 }
20
21 fn square() -> Div {
22 div()
23 .size_16()
24 .bg(rgb(0xffffff))
25 .border_1()
26 .border_color(hsla(0.0, 0.0, 0.0, 0.1))
27 }
28
29 fn rounded_small() -> Div {
30 div()
31 .size_16()
32 .bg(rgb(0xffffff))
33 .rounded(px(4.))
34 .border_1()
35 .border_color(hsla(0.0, 0.0, 0.0, 0.1))
36 }
37
38 fn rounded_medium() -> Div {
39 div()
40 .size_16()
41 .bg(rgb(0xffffff))
42 .rounded(px(8.))
43 .border_1()
44 .border_color(hsla(0.0, 0.0, 0.0, 0.1))
45 }
46
47 fn rounded_large() -> Div {
48 div()
49 .size_16()
50 .bg(rgb(0xffffff))
51 .rounded(px(12.))
52 .border_1()
53 .border_color(hsla(0.0, 0.0, 0.0, 0.1))
54 }
55}
56
57fn example(label: impl Into<SharedString>, example: impl IntoElement) -> impl IntoElement {
58 let label = label.into();
59
60 div()
61 .flex()
62 .flex_col()
63 .justify_center()
64 .items_center()
65 .w(relative(1. / 6.))
66 .border_r_1()
67 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
68 .child(
69 div()
70 .flex()
71 .items_center()
72 .justify_center()
73 .flex_1()
74 .py_12()
75 .child(example),
76 )
77 .child(
78 div()
79 .w_full()
80 .border_t_1()
81 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
82 .p_1()
83 .flex()
84 .items_center()
85 .child(label),
86 )
87}
88
89impl Render for Shadow {
90 fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
91 div()
92 .id("shadow-example")
93 .overflow_y_scroll()
94 .bg(rgb(0xffffff))
95 .size_full()
96 .text_xs()
97 .child(div().flex().flex_col().w_full().children(vec![
98 div()
99 .border_b_1()
100 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
101 .flex()
102 .flex_row()
103 .children(vec![
104 example(
105 "Square",
106 Shadow::square().shadow(vec![
107 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
108 .blur_radius(px(8.)),
109 ]),
110 ),
111 example(
112 "Rounded 4",
113 Shadow::rounded_small().shadow(vec![
114 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
115 .blur_radius(px(8.)),
116 ]),
117 ),
118 example(
119 "Rounded 8",
120 Shadow::rounded_medium().shadow(vec![
121 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
122 .blur_radius(px(8.)),
123 ]),
124 ),
125 example(
126 "Rounded 16",
127 Shadow::rounded_large().shadow(vec![
128 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
129 .blur_radius(px(8.)),
130 ]),
131 ),
132 example(
133 "Circle",
134 Shadow::base().shadow(vec![
135 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
136 .blur_radius(px(8.)),
137 ]),
138 ),
139 ]),
140 div()
141 .border_b_1()
142 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
143 .flex()
144 .w_full()
145 .children(vec![
146 example("None", Shadow::base()),
147 // 2Xsmall shadow
148 example("2X Small", Shadow::base().shadow_2xs()),
149 // Xsmall shadow
150 example("Extra Small", Shadow::base().shadow_xs()),
151 // Small shadow
152 example("Small", Shadow::base().shadow_sm()),
153 // Medium shadow
154 example("Medium", Shadow::base().shadow_md()),
155 // Large shadow
156 example("Large", Shadow::base().shadow_lg()),
157 example("Extra Large", Shadow::base().shadow_xl()),
158 example("2X Large", Shadow::base().shadow_2xl()),
159 ]),
160 // Horizontal list of increasing blur radii
161 div()
162 .border_b_1()
163 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
164 .flex()
165 .children(vec![
166 example(
167 "Blur 0",
168 Shadow::base().shadow(vec![BoxShadow::new(
169 px(0.),
170 px(8.),
171 hsla(0.0, 0.0, 0.0, 0.3),
172 )]),
173 ),
174 example(
175 "Blur 2",
176 Shadow::base().shadow(vec![
177 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
178 .blur_radius(px(2.)),
179 ]),
180 ),
181 example(
182 "Blur 4",
183 Shadow::base().shadow(vec![
184 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
185 .blur_radius(px(4.)),
186 ]),
187 ),
188 example(
189 "Blur 8",
190 Shadow::base().shadow(vec![
191 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
192 .blur_radius(px(8.)),
193 ]),
194 ),
195 example(
196 "Blur 16",
197 Shadow::base().shadow(vec![
198 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
199 .blur_radius(px(16.)),
200 ]),
201 ),
202 ]),
203 // Horizontal list of increasing spread radii
204 div()
205 .border_b_1()
206 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
207 .flex()
208 .children(vec![
209 example(
210 "Spread 0",
211 Shadow::base().shadow(vec![
212 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
213 .blur_radius(px(8.)),
214 ]),
215 ),
216 example(
217 "Spread 2",
218 Shadow::base().shadow(vec![
219 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
220 .blur_radius(px(8.))
221 .spread_radius(px(2.)),
222 ]),
223 ),
224 example(
225 "Spread 4",
226 Shadow::base().shadow(vec![
227 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
228 .blur_radius(px(8.))
229 .spread_radius(px(4.)),
230 ]),
231 ),
232 example(
233 "Spread 8",
234 Shadow::base().shadow(vec![
235 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
236 .blur_radius(px(8.))
237 .spread_radius(px(8.)),
238 ]),
239 ),
240 example(
241 "Spread 16",
242 Shadow::base().shadow(vec![
243 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
244 .blur_radius(px(8.))
245 .spread_radius(px(16.)),
246 ]),
247 ),
248 ]),
249 // Square spread examples
250 div()
251 .border_b_1()
252 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
253 .flex()
254 .children(vec![
255 example(
256 "Square Spread 0",
257 Shadow::square().shadow(vec![
258 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
259 .blur_radius(px(8.)),
260 ]),
261 ),
262 example(
263 "Square Spread 8",
264 Shadow::square().shadow(vec![
265 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
266 .blur_radius(px(8.))
267 .spread_radius(px(8.)),
268 ]),
269 ),
270 example(
271 "Square Spread 16",
272 Shadow::square().shadow(vec![
273 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
274 .blur_radius(px(8.))
275 .spread_radius(px(16.)),
276 ]),
277 ),
278 ]),
279 // Rounded large spread examples
280 div()
281 .border_b_1()
282 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
283 .flex()
284 .children(vec![
285 example(
286 "Rounded Large Spread 0",
287 Shadow::rounded_large().shadow(vec![
288 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
289 .blur_radius(px(8.)),
290 ]),
291 ),
292 example(
293 "Rounded Large Spread 8",
294 Shadow::rounded_large().shadow(vec![
295 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
296 .blur_radius(px(8.))
297 .spread_radius(px(8.)),
298 ]),
299 ),
300 example(
301 "Rounded Large Spread 16",
302 Shadow::rounded_large().shadow(vec![
303 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.3))
304 .blur_radius(px(8.))
305 .spread_radius(px(16.)),
306 ]),
307 ),
308 ]),
309 // Directional shadows
310 div()
311 .border_b_1()
312 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
313 .flex()
314 .children(vec![
315 example(
316 "Left",
317 Shadow::base().shadow(vec![
318 BoxShadow::new(px(-8.), px(0.), hsla(0.0, 0.5, 0.5, 0.3))
319 .blur_radius(px(8.)),
320 ]),
321 ),
322 example(
323 "Right",
324 Shadow::base().shadow(vec![
325 BoxShadow::new(px(8.), px(0.), hsla(0.0, 0.5, 0.5, 0.3))
326 .blur_radius(px(8.)),
327 ]),
328 ),
329 example(
330 "Top",
331 Shadow::base().shadow(vec![
332 BoxShadow::new(px(0.), px(-8.), hsla(0.0, 0.5, 0.5, 0.3))
333 .blur_radius(px(8.)),
334 ]),
335 ),
336 example(
337 "Bottom",
338 Shadow::base().shadow(vec![
339 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
340 .blur_radius(px(8.)),
341 ]),
342 ),
343 ]),
344 // Square directional shadows
345 div()
346 .border_b_1()
347 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
348 .flex()
349 .children(vec![
350 example(
351 "Square Left",
352 Shadow::square().shadow(vec![
353 BoxShadow::new(px(-8.), px(0.), hsla(0.0, 0.5, 0.5, 0.3))
354 .blur_radius(px(8.)),
355 ]),
356 ),
357 example(
358 "Square Right",
359 Shadow::square().shadow(vec![
360 BoxShadow::new(px(8.), px(0.), hsla(0.0, 0.5, 0.5, 0.3))
361 .blur_radius(px(8.)),
362 ]),
363 ),
364 example(
365 "Square Top",
366 Shadow::square().shadow(vec![
367 BoxShadow::new(px(0.), px(-8.), hsla(0.0, 0.5, 0.5, 0.3))
368 .blur_radius(px(8.)),
369 ]),
370 ),
371 example(
372 "Square Bottom",
373 Shadow::square().shadow(vec![
374 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
375 .blur_radius(px(8.)),
376 ]),
377 ),
378 ]),
379 // Rounded large directional shadows
380 div()
381 .border_b_1()
382 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
383 .flex()
384 .children(vec![
385 example(
386 "Rounded Large Left",
387 Shadow::rounded_large().shadow(vec![
388 BoxShadow::new(px(-8.), px(0.), hsla(0.0, 0.5, 0.5, 0.3))
389 .blur_radius(px(8.)),
390 ]),
391 ),
392 example(
393 "Rounded Large Right",
394 Shadow::rounded_large().shadow(vec![
395 BoxShadow::new(px(8.), px(0.), hsla(0.0, 0.5, 0.5, 0.3))
396 .blur_radius(px(8.)),
397 ]),
398 ),
399 example(
400 "Rounded Large Top",
401 Shadow::rounded_large().shadow(vec![
402 BoxShadow::new(px(0.), px(-8.), hsla(0.0, 0.5, 0.5, 0.3))
403 .blur_radius(px(8.)),
404 ]),
405 ),
406 example(
407 "Rounded Large Bottom",
408 Shadow::rounded_large().shadow(vec![
409 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.5, 0.5, 0.3))
410 .blur_radius(px(8.)),
411 ]),
412 ),
413 ]),
414 // Multiple shadows for different shapes
415 div()
416 .border_b_1()
417 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
418 .flex()
419 .children(vec![
420 example(
421 "Circle Multiple",
422 Shadow::base().shadow(vec![
423 BoxShadow::new(
424 px(0.),
425 px(-12.),
426 hsla(0.0 / 360., 1.0, 0.5, 0.3),
427 )
428 .blur_radius(px(8.))
429 .spread_radius(px(2.)),
430 BoxShadow::new(
431 px(12.),
432 px(0.),
433 hsla(60.0 / 360., 1.0, 0.5, 0.3),
434 )
435 .blur_radius(px(8.))
436 .spread_radius(px(2.)),
437 BoxShadow::new(
438 px(0.),
439 px(12.),
440 hsla(120.0 / 360., 1.0, 0.5, 0.3),
441 )
442 .blur_radius(px(8.))
443 .spread_radius(px(2.)),
444 BoxShadow::new(
445 px(-12.),
446 px(0.),
447 hsla(240.0 / 360., 1.0, 0.5, 0.3),
448 )
449 .blur_radius(px(8.))
450 .spread_radius(px(2.)),
451 ]),
452 ),
453 example(
454 "Square Multiple",
455 Shadow::square().shadow(vec![
456 BoxShadow::new(
457 px(0.),
458 px(-12.),
459 hsla(0.0 / 360., 1.0, 0.5, 0.3),
460 )
461 .blur_radius(px(8.))
462 .spread_radius(px(2.)),
463 BoxShadow::new(
464 px(12.),
465 px(0.),
466 hsla(60.0 / 360., 1.0, 0.5, 0.3),
467 )
468 .blur_radius(px(8.))
469 .spread_radius(px(2.)),
470 BoxShadow::new(
471 px(0.),
472 px(12.),
473 hsla(120.0 / 360., 1.0, 0.5, 0.3),
474 )
475 .blur_radius(px(8.))
476 .spread_radius(px(2.)),
477 BoxShadow::new(
478 px(-12.),
479 px(0.),
480 hsla(240.0 / 360., 1.0, 0.5, 0.3),
481 )
482 .blur_radius(px(8.))
483 .spread_radius(px(2.)),
484 ]),
485 ),
486 example(
487 "Rounded Large Multiple",
488 Shadow::rounded_large().shadow(vec![
489 BoxShadow::new(
490 px(0.),
491 px(-12.),
492 hsla(0.0 / 360., 1.0, 0.5, 0.3),
493 )
494 .blur_radius(px(8.))
495 .spread_radius(px(2.)),
496 BoxShadow::new(
497 px(12.),
498 px(0.),
499 hsla(60.0 / 360., 1.0, 0.5, 0.3),
500 )
501 .blur_radius(px(8.))
502 .spread_radius(px(2.)),
503 BoxShadow::new(
504 px(0.),
505 px(12.),
506 hsla(120.0 / 360., 1.0, 0.5, 0.3),
507 )
508 .blur_radius(px(8.))
509 .spread_radius(px(2.)),
510 BoxShadow::new(
511 px(-12.),
512 px(0.),
513 hsla(240.0 / 360., 1.0, 0.5, 0.3),
514 )
515 .blur_radius(px(8.))
516 .spread_radius(px(2.)),
517 ]),
518 ),
519 ]),
520 // Inset shadows (CSS `box-shadow: inset ...`).
521 div()
522 .border_b_1()
523 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
524 .flex()
525 .w_full()
526 .children(vec![
527 example(
528 "Inset basic",
529 Shadow::base().shadow(vec![
530 BoxShadow::new(px(0.), px(0.), hsla(0.0, 0.0, 0.0, 0.5))
531 .blur_radius(px(12.))
532 .inset(),
533 ]),
534 ),
535 example(
536 "Inset offset",
537 Shadow::base().shadow(vec![
538 BoxShadow::new(px(6.), px(6.), hsla(0.0, 0.0, 0.0, 0.5))
539 .blur_radius(px(8.))
540 .inset(),
541 ]),
542 ),
543 example(
544 "Inset spread",
545 Shadow::base().shadow(vec![
546 BoxShadow::new(px(0.), px(0.), hsla(0.0, 0.0, 0.0, 0.5))
547 .blur_radius(px(4.))
548 .spread_radius(px(8.))
549 .inset(),
550 ]),
551 ),
552 example(
553 "Inset rounded",
554 Shadow::rounded_large().shadow(vec![
555 BoxShadow::new(px(0.), px(4.), hsla(0.0, 0.0, 0.0, 0.5))
556 .blur_radius(px(10.))
557 .spread_radius(px(2.))
558 .inset(),
559 ]),
560 ),
561 example(
562 "Inset sharp",
563 Shadow::square().shadow(vec![
564 BoxShadow::new(px(0.), px(0.), hsla(0.0, 0.0, 0.0, 0.6))
565 .spread_radius(px(6.))
566 .inset(),
567 ]),
568 ),
569 ]),
570 // Combined: drop + inset shadows on the same element.
571 div()
572 .border_b_1()
573 .border_color(hsla(0.0, 0.0, 0.0, 1.0))
574 .flex()
575 .w_full()
576 .children(vec![example(
577 "Drop + Inset",
578 Shadow::rounded_medium().shadow(vec![
579 BoxShadow::new(px(0.), px(8.), hsla(0.0, 0.0, 0.0, 0.25))
580 .blur_radius(px(12.)),
581 BoxShadow::new(px(0.), px(2.), hsla(0.0, 0.0, 0.0, 0.4))
582 .blur_radius(px(4.))
583 .inset(),
584 ]),
585 )]),
586 ]))
587 }
588}
589
590fn run_example() {
591 application().run(|cx: &mut App| {
592 let bounds = Bounds::centered(None, size(px(1000.0), px(800.0)), cx);
593 cx.open_window(
594 WindowOptions {
595 window_bounds: Some(WindowBounds::Windowed(bounds)),
596 ..Default::default()
597 },
598 |_, cx| cx.new(|_| Shadow {}),
599 )
600 .unwrap();
601
602 cx.activate(true);
603 });
604}
605
606#[cfg(not(target_family = "wasm"))]
607fn main() {
608 run_example();
609}
610
611#[cfg(target_family = "wasm")]
612#[wasm_bindgen::prelude::wasm_bindgen(start)]
613pub fn start() {
614 gpui_platform::web_init();
615 run_example();
616}
617