codify "platform" into resolution logic, server-fn/fullstack overhaul (#4596)
overhaul dioxus fullstack using a new implementation of server_fn This PR is a complete rewrite of dioxus fullstack designed to improve compatibility with axum and to fix a number of compilation errors based on feature flag unification plumbing through macros.
This commit is contained in:
1 parent
8421c3aef0
commit
f2b1c6d97f
424 files changed
+17284
-6624
No files matched your search
@@ -0,0 +1,25 @@
|
||||
//! A simple demonstration of how to set attributes on buttons to disable them.
|
||||
//!
|
||||
//! This example also showcases the shorthand syntax for attributes, and how signals themselves implement IntoAttribute
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let mut disabled = use_signal(|| false);
|
||||
|
||||
rsx! {
|
||||
div { text_align: "center", margin: "20px", display: "flex", flex_direction: "column", align_items: "center",
|
||||
button {
|
||||
onclick: move |_| disabled.toggle(),
|
||||
"click to "
|
||||
if disabled() { "enable" } else { "disable" }
|
||||
" the lower button"
|
||||
}
|
||||
button { disabled, "lower button" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//! Nested Listeners
|
||||
//!
|
||||
//! This example showcases how to control event bubbling from child to parents.
|
||||
//!
|
||||
//! Both web and desktop support bubbling and bubble cancellation.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
rsx! {
|
||||
div {
|
||||
onclick: move |_| println!("clicked! top"),
|
||||
"- div"
|
||||
button {
|
||||
onclick: move |_| println!("clicked! bottom propagate"),
|
||||
"Propagate"
|
||||
}
|
||||
button {
|
||||
onclick: move |evt| {
|
||||
println!("clicked! bottom no bubbling");
|
||||
evt.stop_propagation();
|
||||
},
|
||||
"Dont propagate"
|
||||
}
|
||||
button {
|
||||
"Does not handle clicks - only propagate"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//! Thanks to @japsu and their project https://github.com/japsu/jatsi for the example!
|
||||
//!
|
||||
//! This example shows how to create a simple dice rolling app using SVG and Dioxus.
|
||||
//! The `svg` element and its children have a custom namespace, and are attached using different methods than regular
|
||||
//! HTML elements. Any element can specify a custom namespace by using the `namespace` meta attribute.
|
||||
//!
|
||||
//! If you `go-to-definition` on the `svg` element, you'll see its custom namespace.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use rand::{Rng, rng};
|
||||
|
||||
fn main() {
|
||||
dioxus::launch(|| {
|
||||
rsx! {
|
||||
div { user_select: "none", webkit_user_select: "none", margin_left: "10%", margin_right: "10%",
|
||||
h1 { "Click die to generate a new value" }
|
||||
div { cursor: "pointer", height: "100%", width: "100%", Dice {} }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn Dice() -> Element {
|
||||
const Y: bool = true;
|
||||
const N: bool = false;
|
||||
const DOTS: [(i64, i64); 7] = [(-1, -1), (-1, -0), (-1, 1), (1, -1), (1, 0), (1, 1), (0, 0)];
|
||||
const DOTS_FOR_VALUE: [[bool; 7]; 6] = [
|
||||
[N, N, N, N, N, N, Y],
|
||||
[N, N, Y, Y, N, N, N],
|
||||
[N, N, Y, Y, N, N, Y],
|
||||
[Y, N, Y, Y, N, Y, N],
|
||||
[Y, N, Y, Y, N, Y, Y],
|
||||
[Y, Y, Y, Y, Y, Y, N],
|
||||
];
|
||||
|
||||
let mut value = use_signal(|| 5);
|
||||
let active_dots = use_memo(move || &DOTS_FOR_VALUE[(value() - 1) as usize]);
|
||||
|
||||
rsx! {
|
||||
svg {
|
||||
view_box: "-1000 -1000 2000 2000",
|
||||
onclick: move |event| {
|
||||
event.prevent_default();
|
||||
value.set(rng().random_range(1..=6))
|
||||
},
|
||||
rect { x: -1000, y: -1000, width: 2000, height: 2000, rx: 200, fill: "#aaa" }
|
||||
for ((x, y), _) in DOTS.iter().zip(active_dots.read().iter()).filter(|(_, active)| **active) {
|
||||
circle {
|
||||
cx: *x * 600,
|
||||
cy: *y * 600,
|
||||
r: 200,
|
||||
fill: "#333"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user