#yew-component #front-end #proc-macro #webasm #web

macro yew-autoprops

proc-macro to automatically derive Properties structs from args for Yew components

6 releases (3 breaking)

0.4.1 Dec 4, 2023
0.4.0 Dec 4, 2023
0.3.0 Oct 30, 2023
0.2.2 May 22, 2023
0.1.0 May 21, 2023

#444 in WebAssembly

Download history 77/week @ 2024-05-27 92/week @ 2024-06-03 88/week @ 2024-06-10 117/week @ 2024-06-17 47/week @ 2024-06-24 95/week @ 2024-07-01 78/week @ 2024-07-08 89/week @ 2024-07-15 138/week @ 2024-07-22 144/week @ 2024-07-29 78/week @ 2024-08-05 68/week @ 2024-08-12 92/week @ 2024-08-19 58/week @ 2024-08-26 118/week @ 2024-09-02 100/week @ 2024-09-09

374 downloads per month

MIT/Apache

13KB
245 lines

yew-autoprops

Crate Info API Docs

proc-macro to automatically derive Properties structs from args for Yew components

No more extra one-off Props structs!

Examples

use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops]
#[function_component]
fn CoolComponent(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}
use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops(CoolComponentProps)]
#[function_component(CoolComponent)]
fn cool_component(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}

Dependencies

~265–710KB
~17K SLoC