remove cx.render

This commit is contained in:
Jonathan Kelley committed 2024-01-13 21:12:21 -08:00
1 parent fae0b08e61
commit 1dde044697
159 files changed
+600 -658

No files matched your search

@@ -27,7 +27,7 @@ enum Event {
const MAX_EVENTS: usize = 8;
fn app() -> Element {
let events = use_ref(Vec::new);
let events = use_signal(Vec::new);
let events_lock = events.read();
let first_index = events_lock.len().saturating_sub(MAX_EVENTS);
@@ -44,7 +44,7 @@ fn app() -> Element {
events.write().push(event);
};
cx.render(rsx! {
rsx! {
div { width: "100%", height: "100%", flex_direction: "column",
div {
width: "80%",
@@ -73,5 +73,5 @@ fn app() -> Element {
}
div { width: "80%", height: "50%", flex_direction: "column", {events_rendered} }
}
})
}
}
+3 -3
View File
@@ -5,9 +5,9 @@ fn main() {
}
fn app() -> Element {
let radius = use_state(|| 0);
let radius = use_signal(|| 0);
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -23,5 +23,5 @@ fn app() -> Element {
"{radius}"
}
})
}
}
+6 -6
View File
@@ -13,15 +13,15 @@ struct ButtonProps {
#[allow(non_snake_case)]
fn Button(cx: Scope<ButtonProps>) -> Element {
let toggle = use_state(|| false);
let hovered = use_state(|| false);
let toggle = use_signal(|| false);
let hovered = use_signal(|| false);
let hue = cx.props.color_offset % 255;
let saturation = if *toggle.get() { 50 } else { 25 } + if *hovered.get() { 50 } else { 25 };
let brightness = saturation / 2;
let color = format!("hsl({hue}, {saturation}, {brightness})");
cx.render(rsx! {
rsx! {
div{
width: "100%",
height: "100%",
@@ -47,11 +47,11 @@ fn Button(cx: Scope<ButtonProps>) -> Element {
flex_direction: "column",
p{ "tabindex: {cx.props.layer}" }
}
})
}
}
fn app() -> Element {
cx.render(rsx! {
rsx! {
div {
display: "flex",
flex_direction: "column",
@@ -80,5 +80,5 @@ fn app() -> Element {
}
}
}
})
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ fn main() {
fn app() -> Element {
let steps = 50;
cx.render(rsx! {
rsx! {
div{
width: "100%",
height: "100%",
@@ -34,5 +34,5 @@ fn app() -> Element {
}
}
}
})
}
}
+4 -4
View File
@@ -9,12 +9,12 @@ fn main() {
}
fn app() -> Element {
let hue = use_state(|| 0.0);
let brightness = use_state(|| 0.0);
let hue = use_signal(|| 0.0);
let brightness = use_signal(|| 0.0);
let tui_query: Query = cx.consume_context().unwrap();
let mapping: DioxusElementToNodeId = cx.consume_context().unwrap();
// disable templates so that every node has an id and can be queried
cx.render(rsx! {
rsx! {
div {
width: "100%",
background_color: "hsl({hue}, 70%, {brightness}%)",
@@ -31,5 +31,5 @@ fn app() -> Element {
},
"hsl({hue}, 70%, {brightness}%)"
}
})
}
}
+2 -2
View File
@@ -5,7 +5,7 @@ fn main() {
}
fn app() -> Element {
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -78,5 +78,5 @@ fn app() -> Element {
"asd"
}
}
})
}
}
+10 -10
View File
@@ -23,20 +23,20 @@ fn app() -> Element {
127 * b
}
let q1_color = use_state(|| [200; 3]);
let q2_color = use_state(|| [200; 3]);
let q3_color = use_state(|| [200; 3]);
let q4_color = use_state(|| [200; 3]);
let q1_color = use_signal(|| [200; 3]);
let q2_color = use_signal(|| [200; 3]);
let q3_color = use_signal(|| [200; 3]);
let q4_color = use_signal(|| [200; 3]);
let q1_color_str = to_str(q1_color);
let q2_color_str = to_str(q2_color);
let q3_color_str = to_str(q3_color);
let q4_color_str = to_str(q4_color);
let page_coordinates = use_state(|| "".to_string());
let element_coordinates = use_state(|| "".to_string());
let buttons = use_state(|| "".to_string());
let modifiers = use_state(|| "".to_string());
let page_coordinates = use_signal(|| "".to_string());
let element_coordinates = use_signal(|| "".to_string());
let buttons = use_signal(|| "".to_string());
let modifiers = use_signal(|| "".to_string());
let update_data = move |event: Event<MouseData>| {
let mouse_data = event.inner();
@@ -51,7 +51,7 @@ fn app() -> Element {
modifiers.set(format!("{:?}", mouse_data.modifiers()));
};
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -129,5 +129,5 @@ fn app() -> Element {
div { "Buttons: {buttons}" }
div { "Modifiers: {modifiers}" }
}
})
}
}
+2 -2
View File
@@ -5,7 +5,7 @@ fn main() {
}
fn app() -> Element {
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -24,5 +24,5 @@ fn app() -> Element {
}
}
}
})
}
}
@@ -19,7 +19,7 @@ struct BoxProps {
}
#[allow(non_snake_case)]
fn Box(cx: Scope<BoxProps>) -> Element {
let count = use_state(|| 0);
let count = use_signal(|| 0);
let x = cx.props.x * 2;
let y = cx.props.y * 2;
@@ -28,7 +28,7 @@ fn Box(cx: Scope<BoxProps>) -> Element {
let count = count.get();
let alpha = cx.props.alpha + (count % 100) as f32;
cx.render(rsx! {
rsx! {
div {
left: "{x}%",
top: "{y}%",
@@ -38,7 +38,7 @@ fn Box(cx: Scope<BoxProps>) -> Element {
align_items: "center",
p{"{display_hue:03}"}
}
})
}
}
#[derive(Props, PartialEq)]
@@ -48,8 +48,8 @@ struct GridProps {
#[allow(non_snake_case)]
fn Grid(cx: Scope<GridProps>) -> Element {
let size = cx.props.size;
let count = use_state(|| 0);
let counts = use_ref(|| vec![0; size * size]);
let count = use_signal(|| 0);
let counts = use_signal(|| vec![0; size * size]);
let ctx: TuiContext = cx.consume_context().unwrap();
if *count.get() + 1 >= (size * size) {
@@ -98,7 +98,7 @@ fn Grid(cx: Scope<GridProps>) -> Element {
}
fn app(cx: Scope<usize>) -> Element {
cx.render(rsx! {
rsx! {
div{
width: "100%",
height: "100%",
@@ -106,5 +106,5 @@ fn app(cx: Scope<usize>) -> Element {
size: *cx.props,
}
}
})
}
}
+2 -2
View File
@@ -5,7 +5,7 @@ fn main() {
}
fn app() -> Element {
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -46,5 +46,5 @@ fn app() -> Element {
}
}
}
})
}
}
+4 -4
View File
@@ -14,7 +14,7 @@ struct QuadrentProps {
}
fn Quadrant(cx: Scope<QuadrentProps>) -> Element {
cx.render(rsx! {
rsx! {
div {
border_width: "1px",
width: "50%",
@@ -25,11 +25,11 @@ fn Quadrant(cx: Scope<QuadrentProps>) -> Element {
"{cx.props.text}"
}
})
}
}
fn app() -> Element {
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -63,5 +63,5 @@ fn app() -> Element {
}
}
}
})
}
}
@@ -5,7 +5,7 @@ fn main() {
}
fn app() -> Element {
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "10px",
@@ -15,5 +15,5 @@ fn app() -> Element {
"Hello world!"
}
})
}
}
+4 -4
View File
@@ -5,9 +5,9 @@ fn main() {
}
fn app() -> Element {
let count = use_state(|| 0);
let count = use_signal(|| 0);
use_future((), move |_| {
use_future(move |_| {
let count = count.to_owned();
let update = cx.schedule_update();
async move {
@@ -19,7 +19,7 @@ fn app() -> Element {
}
});
cx.render(rsx! {
rsx! {
div { width: "100%",
div { width: "50%", height: "5px", background_color: "blue", justify_content: "center", align_items: "center",
"Hello {count}!"
@@ -28,5 +28,5 @@ fn app() -> Element {
"Hello {count}!"
}
}
})
}
}
+3 -3
View File
@@ -5,9 +5,9 @@ fn main() {
}
fn app() -> Element {
let alpha = use_state(|| 100);
let alpha = use_signal(|| 100);
cx.render(rsx! {
rsx! {
div {
width: "100%",
height: "100%",
@@ -109,5 +109,5 @@ fn app() -> Element {
}
}
}
})
}
}
+3 -3
View File
@@ -6,10 +6,10 @@ fn main() {
}
fn app() -> Element {
let bg_green = use_state(|| false);
let bg_green = use_signal(|| false);
let color = if *bg_green.get() { "green" } else { "red" };
cx.render(rsx! {
rsx! {
div{
width: "100%",
background_color: "{color}",
@@ -89,5 +89,5 @@ fn app() -> Element {
height: "10%",
}
}
})
}
}