simple-combo-expr.rsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. fn main() {
  2. rsx! {
  3. div {
  4. {
  5. let millis = timer
  6. .with(|t| {
  7. t
  8. .duration()
  9. .saturating_sub(
  10. t.started_at.map(|x| x.elapsed()).unwrap_or(Duration::ZERO),
  11. )
  12. .as_millis()
  13. });
  14. format!(
  15. "{:02}:{:02}:{:02}.{:01}",
  16. millis / 1000 / 3600 % 3600,
  17. millis / 1000 / 60 % 60,
  18. millis / 1000 % 60,
  19. millis / 100 % 10,
  20. )
  21. }
  22. }
  23. div {
  24. input {
  25. r#type: "number",
  26. min: 0,
  27. max: 99,
  28. value: format!("{:02}", timer.read().hours),
  29. oninput: move |e| {
  30. timer.write().hours = e.value().parse().unwrap_or(0);
  31. },
  32. }
  33. // some comment
  34. input {
  35. r#type: "number",
  36. min: 0,
  37. max: 99,
  38. value: format!("{:02}", timer.read().hours),
  39. oninput: move |e| {
  40. timer.write().hours = e.value().parse().unwrap_or(0);
  41. },
  42. }
  43. }
  44. }
  45. }