yew-consent

Crates.ioyew-consent
lib.rsyew-consent
version0.2.0
sourcesrc
created_at2023-09-05 15:38:33.202242
updated_at2023-10-04 08:44:08.954537
descriptionManaging consent with Yew
homepage
repositoryhttps://github.com/ctron/yew-consent
max_upload_size
id964450
size18,990
Jens Reimann (ctron)

documentation

README

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
Commit count: 6

cargo fmt