3 unstable releases

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

#1 in #consent

Download history 265/week @ 2024-07-22 199/week @ 2024-07-29 209/week @ 2024-08-05 21/week @ 2024-08-12 105/week @ 2024-08-19 161/week @ 2024-08-26 72/week @ 2024-09-02 138/week @ 2024-09-09 84/week @ 2024-09-16 137/week @ 2024-09-23 66/week @ 2024-09-30 130/week @ 2024-10-07 167/week @ 2024-10-14 491/week @ 2024-10-21 265/week @ 2024-10-28 368/week @ 2024-11-04

1,291 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–20MB
~274K SLoC