bubba-macros 0.1.0

Procedural macros for the Bubba mobile framework (view! macro)
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 17.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 314.07 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nia-cloud-official

view! Procedural Macro

Transforms declarative JSX-like UI syntax into Rust [Element] builder calls.

Input (what you write)

view! {
    <h1 class="title">"Welcome to Bubba"</h1>
    <button class="primary-btn" onclick=alert("Tapped!")>
        "Tap me"
    </button>
    <input class="text-input" oninput=log("Typing...") />
}

Output (what it expands to)

{
    use bubba_core::ui::Element;
    use bubba_core::events::EventHandler;

    let mut __root = Element::div();
    __root = __root.child(
        Element::h1()
            .class("title")
            .text("Welcome to Bubba")
    );
    __root = __root.child(
        Element::button()
            .class("primary-btn")
            .text("Tap me")
            .on(EventHandler::onclick(|_| { alert("Tapped!") }))
    );
    __root = __root.child(
        Element::input()
            .class("text-input")
            .on(EventHandler::oninput(|_| { log("Typing...") }))
    );
    bubba_core::ui::Screen::new(__root)
}