todoitem.rs 832 B

123456789101112131415161718192021222324252627282930313233343536
  1. use super::state::TODOS;
  2. use crate::recoil::use_atom_family;
  3. use dioxus_core::prelude::*;
  4. use uuid::Uuid;
  5. #[derive(PartialEq, Props)]
  6. pub struct TodoEntryProps {
  7. id: Uuid,
  8. }
  9. pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree {
  10. let (is_editing, set_is_editing) = use_state(&ctx, || false);
  11. let todo = use_atom_family(&ctx, &TODOS, props.id);
  12. ctx.render(rsx! (
  13. li {
  14. "{todo.id}"
  15. input {
  16. class: "toggle"
  17. type: "checkbox"
  18. "{todo.checked}"
  19. }
  20. {is_editing.then(|| {
  21. rsx!(input {
  22. value: "{contents}"
  23. })
  24. })}
  25. }
  26. ))
  27. }
  28. pub fn Example(ctx: Context, id: Uuid, name: String) -> DomTree {
  29. ctx.render(rsx! {
  30. div {}
  31. })
  32. }