3 unstable releases

0.2.0 Oct 4, 2023
0.1.1 Sep 5, 2023
0.1.0 Sep 5, 2023

#2 in #consent

Download history 133/week @ 2024-03-13 62/week @ 2024-03-20 40/week @ 2024-03-27 181/week @ 2024-04-03 284/week @ 2024-04-10 360/week @ 2024-04-17 155/week @ 2024-04-24 295/week @ 2024-05-01 101/week @ 2024-05-08 156/week @ 2024-05-15 74/week @ 2024-05-22 151/week @ 2024-05-29 305/week @ 2024-06-05 152/week @ 2024-06-12 306/week @ 2024-06-19 274/week @ 2024-06-26

1,084 downloads per month

Apache-2.0

8KB
111 lines

yew-consent

crates.io docs.rs

Managing user consent with Yew

Usage

Add it to your project:

cargo add yew-consent

Then, add it your application component:

#[function_component(Application)]
fn application() -> Html {
    let ask = use_callback(|context, ()| html!(<AskConsent {context} />), ());

    html!(
        <Consent<()> {ask}>
            <State/>
        </Consent<()>>
    )
}

And then, you can check consent later:

#[function_component(State)]
fn state() -> Html {
    let consent = use_consent::<()>();

    html!(
        <>
            <dl>
                <dt>{"Consent state"}</dt>
                <dd>{ format!("{consent:#?}")}</dd>
            </dl>
        </>
    )
}

Also see the example here: example.

You can run the example using:

cd example
trunk serve

Dependencies

~11–15MB
~265K SLoC