51 lines
1.7 KiB
Rust
51 lines
1.7 KiB
Rust
// Copyright (C) 2025 Emilis Bliūdžius
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
use yew::prelude::*;
|
|
|
|
use crate::components::Button;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Properties)]
|
|
pub struct BinaryChoiceProps {
|
|
pub on_chosen: Option<Callback<bool>>,
|
|
#[prop_or_default]
|
|
pub children: Html,
|
|
}
|
|
|
|
#[function_component]
|
|
pub fn BinaryChoice(
|
|
BinaryChoiceProps {
|
|
on_chosen,
|
|
children,
|
|
}: &BinaryChoiceProps,
|
|
) -> Html {
|
|
let on_chosen_yes = on_chosen.clone();
|
|
let yes = on_chosen_yes
|
|
.map(|on_chosen| Callback::from(move |_| on_chosen.emit(true)))
|
|
.unwrap_or_default();
|
|
let on_chosen = on_chosen.clone();
|
|
let no = on_chosen
|
|
.map(|on_chosen| Callback::from(move |_| on_chosen.emit(false)))
|
|
.unwrap_or_default();
|
|
html! {
|
|
<div class="column-list binary">
|
|
{children.clone()}
|
|
<div class="button-container">
|
|
<Button on_click={yes}>{"Yes"}</Button>
|
|
<Button on_click={no}>{"No"}</Button>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|