quadrants.rs 1.4 KB

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