2021-04-01 04:01:42 +00:00
|
|
|
use super::state::TODOS;
|
|
|
|
use crate::recoil::use_atom_family;
|
|
|
|
use dioxus_core::prelude::*;
|
|
|
|
|
|
|
|
#[derive(PartialEq, Props)]
|
|
|
|
pub struct TodoEntryProps {
|
2021-04-02 01:44:18 +00:00
|
|
|
id: uuid::Uuid,
|
2021-04-01 04:01:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-01 22:33:15 +00:00
|
|
|
pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> VNode {
|
2021-04-01 04:01:42 +00:00
|
|
|
let (is_editing, set_is_editing) = use_state(&ctx, || false);
|
2021-06-01 22:33:15 +00:00
|
|
|
let todo = use_atom_family(&ctx, &TODOS, ctx.id);
|
2021-04-01 04:01:42 +00:00
|
|
|
|
|
|
|
ctx.render(rsx! (
|
|
|
|
li {
|
|
|
|
"{todo.id}"
|
|
|
|
input {
|
|
|
|
class: "toggle"
|
|
|
|
type: "checkbox"
|
|
|
|
"{todo.checked}"
|
|
|
|
}
|
2021-04-02 01:44:18 +00:00
|
|
|
{is_editing.then(|| rsx!(
|
|
|
|
input {
|
2021-05-15 16:03:08 +00:00
|
|
|
value: "{todo.contents}"
|
2021-04-02 01:44:18 +00:00
|
|
|
}
|
|
|
|
))}
|
2021-04-01 04:01:42 +00:00
|
|
|
}
|
|
|
|
))
|
|
|
|
}
|