Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:42:19.923Z 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

decorated_icon.rs

100 lines · 3.0 KB · rust
1use gpui::{AnyElement, IntoElement, Point};
2
3use crate::{IconDecoration, IconDecorationKind, prelude::*};
4
5#[derive(IntoElement, RegisterComponent)]
6pub struct DecoratedIcon {
7    icon: Icon,
8    decoration: Option<IconDecoration>,
9}
10
11impl DecoratedIcon {
12    pub fn new(icon: Icon, decoration: Option<IconDecoration>) -> Self {
13        Self { icon, decoration }
14    }
15}
16
17impl RenderOnce for DecoratedIcon {
18    fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
19        div()
20            .relative()
21            .size(self.icon.size)
22            .child(self.icon)
23            .children(self.decoration)
24    }
25}
26
27impl Component for DecoratedIcon {
28    fn scope() -> ComponentScope {
29        ComponentScope::Images
30    }
31
32    fn description() -> &'static str {
33        "An icon with an optional decoration overlay (like an X, triangle, or dot) \
34        that can be positioned relative to the icon"
35    }
36
37    fn preview(_window: &mut Window, cx: &mut App) -> AnyElement {
38        let decoration_x = IconDecoration::new(
39            IconDecorationKind::X,
40            cx.theme().colors().surface_background,
41            cx,
42        )
43        .color(cx.theme().status().error)
44        .position(Point {
45            x: px(-2.),
46            y: px(-2.),
47        });
48
49        let decoration_triangle = IconDecoration::new(
50            IconDecorationKind::Triangle,
51            cx.theme().colors().surface_background,
52            cx,
53        )
54        .color(cx.theme().status().error)
55        .position(Point {
56            x: px(-2.),
57            y: px(-2.),
58        });
59
60        let decoration_dot = IconDecoration::new(
61            IconDecorationKind::Dot,
62            cx.theme().colors().surface_background,
63            cx,
64        )
65        .color(cx.theme().status().error)
66        .position(Point {
67            x: px(-2.),
68            y: px(-2.),
69        });
70
71        v_flex()
72            .gap_6()
73            .children(vec![example_group_with_title(
74                "Decorations",
75                vec![
76                    single_example(
77                        "No Decoration",
78                        DecoratedIcon::new(Icon::new(IconName::FileDoc), None).into_any_element(),
79                    ),
80                    single_example(
81                        "X Decoration",
82                        DecoratedIcon::new(Icon::new(IconName::FileDoc), Some(decoration_x))
83                            .into_any_element(),
84                    ),
85                    single_example(
86                        "Triangle Decoration",
87                        DecoratedIcon::new(Icon::new(IconName::FileDoc), Some(decoration_triangle))
88                            .into_any_element(),
89                    ),
90                    single_example(
91                        "Dot Decoration",
92                        DecoratedIcon::new(Icon::new(IconName::FileDoc), Some(decoration_dot))
93                            .into_any_element(),
94                    ),
95                ],
96            )])
97            .into_any_element()
98    }
99}
100
Served at tenant.openagents/omega Member data and write actions are omitted.