dioxus/packages/dioxus-tui/examples/quadrants.rs

59 lines
1.4 KiB
Rust
Raw Normal View History

2023-05-02 14:38:58 +00:00
#![allow(non_snake_case)]
2022-01-01 04:53:37 +00:00
use dioxus::prelude::*;
fn main() {
dioxus_tui::launch_cfg(app, Default::default());
2023-05-02 14:38:58 +00:00
}
#[component]
fn Quadrant(color: String, text: String) -> Element {
2024-01-14 05:12:21 +00:00
rsx! {
2023-05-02 14:38:58 +00:00
div {
border_width: "1px",
width: "50%",
height: "100%",
justify_content: "center",
align_items: "center",
background_color: "{color}",
"{text}"
2023-05-02 14:38:58 +00:00
}
2024-01-14 05:12:21 +00:00
}
2022-01-01 04:53:37 +00:00
}
fn app() -> Element {
2024-01-14 05:12:21 +00:00
rsx! {
2022-01-01 04:53:37 +00:00
div {
width: "100%",
height: "100%",
flex_direction: "column",
div {
width: "100%",
height: "50%",
flex_direction: "row",
Quadrant {
2023-05-02 14:38:58 +00:00
color: "red".to_string(),
text: "[A]".to_string()
},
Quadrant {
2023-05-02 14:38:58 +00:00
color: "black".to_string(),
text: "[B]".to_string()
2022-01-01 04:53:37 +00:00
}
}
div {
width: "100%",
height: "50%",
flex_direction: "row",
Quadrant {
2023-05-02 14:38:58 +00:00
color: "green".to_string(),
text: "[C]".to_string()
},
Quadrant {
2023-05-02 14:38:58 +00:00
color: "blue".to_string(),
text: "[D]".to_string()
2022-01-01 04:53:37 +00:00
}
}
}
2024-01-14 05:12:21 +00:00
}
2022-01-01 04:53:37 +00:00
}