2021-09-30 19:28:00 +00:00
|
|
|
use yew::prelude::*;
|
|
|
|
|
|
|
|
#[derive(Clone, PartialEq, Properties)]
|
2022-06-28 08:57:14 +00:00
|
|
|
pub struct CheckboxProps {
|
2021-09-30 19:28:00 +00:00
|
|
|
#[prop_or_default]
|
|
|
|
pub disabled: bool,
|
|
|
|
#[prop_or_default]
|
|
|
|
pub inline: bool,
|
|
|
|
#[prop_or_default]
|
|
|
|
pub large: bool,
|
|
|
|
#[prop_or_default]
|
|
|
|
pub checked: bool,
|
|
|
|
#[prop_or_default]
|
2022-06-28 08:57:14 +00:00
|
|
|
pub onchange: Callback<Event>,
|
2021-09-30 19:28:00 +00:00
|
|
|
#[prop_or_default]
|
2022-12-14 09:26:26 +00:00
|
|
|
pub label: Html,
|
2021-09-30 19:28:00 +00:00
|
|
|
#[prop_or_default]
|
2022-12-14 09:26:26 +00:00
|
|
|
pub class: Classes,
|
|
|
|
#[prop_or_default]
|
|
|
|
pub children: Children,
|
2021-09-30 19:28:00 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 08:57:14 +00:00
|
|
|
#[function_component(Checkbox)]
|
2022-12-14 09:26:26 +00:00
|
|
|
pub fn checkbox(
|
|
|
|
CheckboxProps {
|
|
|
|
disabled,
|
|
|
|
inline,
|
|
|
|
large,
|
|
|
|
checked,
|
|
|
|
onchange,
|
|
|
|
label,
|
|
|
|
class,
|
|
|
|
children,
|
|
|
|
}: &CheckboxProps,
|
|
|
|
) -> Html {
|
2022-06-28 08:57:14 +00:00
|
|
|
html! {
|
|
|
|
<label
|
|
|
|
class={classes!(
|
2022-12-14 09:26:26 +00:00
|
|
|
"bp3-control",
|
|
|
|
"bp3-checkbox",
|
|
|
|
disabled.then_some("bp3-disabled"),
|
|
|
|
inline.then_some("bp3-inline"),
|
|
|
|
large.then_some("bp3-large"),
|
|
|
|
class.clone(),
|
2022-06-28 08:57:14 +00:00
|
|
|
)}
|
|
|
|
>
|
2022-12-14 09:26:26 +00:00
|
|
|
<input type="checkbox" checked={*checked} {onchange} disabled={*disabled} />
|
|
|
|
<span class="bp3-control-indicator" />
|
|
|
|
{label.clone()}
|
|
|
|
{children.clone()}
|
2022-06-28 08:57:14 +00:00
|
|
|
</label>
|
2021-09-30 19:28:00 +00:00
|
|
|
}
|
|
|
|
}
|