3 unstable releases

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

#2402 in Web programming

Download history 105/week @ 2024-01-06 152/week @ 2024-01-13 140/week @ 2024-01-20 148/week @ 2024-01-27 196/week @ 2024-02-03 214/week @ 2024-02-10 184/week @ 2024-02-17 247/week @ 2024-02-24 299/week @ 2024-03-02 192/week @ 2024-03-09 84/week @ 2024-03-16 24/week @ 2024-03-23 158/week @ 2024-03-30 196/week @ 2024-04-06 352/week @ 2024-04-13

738 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