Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T02:35:55.337Z 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

ui_macros.rs

44 lines · 1.3 KB · rust
1mod derive_register_component;
2mod dynamic_spacing;
3
4use proc_macro::TokenStream;
5
6/// Generates the DynamicSpacing enum used for density-aware spacing in the UI.
7#[proc_macro]
8pub fn derive_dynamic_spacing(input: TokenStream) -> TokenStream {
9    dynamic_spacing::derive_spacing(input)
10}
11
12/// Registers components that implement the `Component` trait.
13///
14/// This proc macro is used to automatically register structs that implement
15/// the `Component` trait with the [`component::ComponentRegistry`].
16///
17/// If the component trait is not implemented, it will generate a compile-time error.
18///
19/// # Example
20///
21/// ```
22/// use ui::{AnyElement, App, Component, div, IntoElement, Window};
23/// use ui_macros::RegisterComponent;
24///
25/// #[derive(RegisterComponent)]
26/// struct MyComponent;
27///
28/// impl Component for MyComponent {
29///     fn description() -> &'static str {
30///         "My component description"
31///     }
32///
33///      fn preview(_window: &mut Window, cx: &mut App) -> AnyElement {
34///         div().into_any_element()
35///     }
36/// }
37/// ```
38///
39/// This example will add MyComponent to the ComponentRegistry.
40#[proc_macro_derive(RegisterComponent)]
41pub fn derive_register_component(input: TokenStream) -> TokenStream {
42    derive_register_component::derive_register_component(input)
43}
44
Served at tenant.openagents/omega Member data and write actions are omitted.