Merge branch 'upstream' into query-system

This commit is contained in:
Evan Almloff committed 2023-04-18 10:33:40 -05:00
commit 223c7efce2
27 files changed
+480 -87

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 15 KiB

+36
View File
@@ -0,0 +1,36 @@
//! Comparison example with leptos' counter example
//! https://github.com/leptos-rs/leptos/blob/main/examples/counters/src/lib.rs
use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let counters = use_state(cx, || vec![0, 0, 0]);
let sum: usize = counters.iter().copied().sum();
render! {
div {
button { onclick: move |_| counters.make_mut().push(0), "Add counter" }
button { onclick: move |_| { counters.make_mut().pop(); }, "Remove counter" }
p { "Total: {sum}" }
for (i, counter) in counters.iter().enumerate() {
li {
button { onclick: move |_| counters.make_mut()[i] -= 1, "-1" }
input {
value: "{counter}",
oninput: move |e| {
if let Ok(value) = e.value.parse::<usize>() {
counters.make_mut()[i] = value;
}
}
}
button { onclick: move |_| counters.make_mut()[i] += 1, "+1" }
button { onclick: move |_| { counters.make_mut().remove(i); }, "x" }
}
}
}
}
}
+3 -2
View File
@@ -7,9 +7,10 @@ fn main() {
fn app(cx: Scope) -> Element {
cx.render(rsx! {
div {
"This should show an image:"
p {
"This should show an image:"
}
img { src: "examples/assets/logo.png" }
img { src: "/Users/jonkelley/Desktop/blitz.png" }
}
})
}