quadrants.rs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. use dioxus_tui::Config;
  4. fn main() {
  5. dioxus_tui::launch_cfg(app, Config::default());
  6. }
  7. #[derive(Props, PartialEq)]
  8. struct QuadrentProps {
  9. color: String,
  10. text: String,
  11. }
  12. fn Quadrant(cx: Scope<QuadrentProps>) -> Element {
  13. cx.render(rsx! {
  14. div {
  15. border_width: "1px",
  16. width: "50%",
  17. height: "100%",
  18. background_color: "{cx.props.color}",
  19. justify_content: "center",
  20. align_items: "center",
  21. "{cx.props.text}"
  22. }
  23. })
  24. }
  25. fn app(cx: Scope) -> Element {
  26. cx.render(rsx! {
  27. div {
  28. width: "100%",
  29. height: "100%",
  30. flex_direction: "column",
  31. div {
  32. width: "100%",
  33. height: "50%",
  34. flex_direction: "row",
  35. Quadrant{
  36. color: "red".to_string(),
  37. text: "[A]".to_string()
  38. },
  39. Quadrant{
  40. color: "black".to_string(),
  41. text: "[B]".to_string()
  42. }
  43. }
  44. div {
  45. width: "100%",
  46. height: "50%",
  47. flex_direction: "row",
  48. Quadrant{
  49. color: "green".to_string(),
  50. text: "[C]".to_string()
  51. },
  52. Quadrant{
  53. color: "blue".to_string(),
  54. text: "[D]".to_string()
  55. }
  56. }
  57. }
  58. })
  59. }