2021-03-02 05:14:28 +00:00
|
|
|
use bumpalo::Bump;
|
2021-03-02 06:24:53 +00:00
|
|
|
use dioxus::{events::EventTrigger, prelude::*};
|
2021-03-02 05:14:28 +00:00
|
|
|
use dioxus_core as dioxus;
|
|
|
|
use dioxus_web::WebsysRenderer;
|
|
|
|
|
2021-03-02 06:24:53 +00:00
|
|
|
// creates a proxy address that gets transpiled at compile time
|
|
|
|
// all asset ids are shuttled through the renderer
|
|
|
|
// static IMG: ImgAsset = dioxus_asset!("");
|
|
|
|
|
2021-03-02 05:14:28 +00:00
|
|
|
fn main() {
|
2021-03-04 17:03:22 +00:00
|
|
|
// wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
|
|
|
// console_error_panic_hook::set_once();
|
2021-03-02 05:14:28 +00:00
|
|
|
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example))
|
|
|
|
}
|
|
|
|
|
|
|
|
static Example: FC<()> = |ctx, props| {
|
|
|
|
let (name, set_name) = use_state(&ctx, || "...?");
|
|
|
|
|
2021-03-04 23:40:05 +00:00
|
|
|
|
2021-03-02 06:24:53 +00:00
|
|
|
|
2021-03-02 05:14:28 +00:00
|
|
|
ctx.render(rsx! {
|
2021-03-02 06:24:53 +00:00
|
|
|
div {
|
|
|
|
class: "py-12 px-4 text-center w-full max-w-2xl mx-auto"
|
|
|
|
span {
|
2021-03-02 05:14:28 +00:00
|
|
|
class: "text-sm font-semibold"
|
2021-03-02 06:24:53 +00:00
|
|
|
"Dioxus Example: Jack and Jill"
|
2021-03-02 05:14:28 +00:00
|
|
|
}
|
2021-03-02 06:24:53 +00:00
|
|
|
h2 {
|
2021-03-02 05:14:28 +00:00
|
|
|
class: "text-5xl mt-2 mb-6 leading-tight font-semibold font-heading"
|
2021-03-02 06:24:53 +00:00
|
|
|
"Hello, {name}"
|
2021-03-02 05:14:28 +00:00
|
|
|
}
|
2021-03-02 06:24:53 +00:00
|
|
|
button {
|
|
|
|
class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
|
|
|
|
onmouseover: move |_| set_name("jack")
|
|
|
|
"Jack!"
|
|
|
|
}
|
|
|
|
button {
|
|
|
|
class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
|
2021-03-04 17:03:22 +00:00
|
|
|
onmouseover: move |_| set_name("jill")
|
2021-03-02 06:24:53 +00:00
|
|
|
"Jill!"
|
2021-03-02 05:14:28 +00:00
|
|
|
}
|
2021-03-04 17:03:22 +00:00
|
|
|
button {
|
|
|
|
class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
|
|
|
|
onmouseover: move |e| set_name("....")
|
|
|
|
"Reset!"
|
|
|
|
}
|
2021-03-02 05:14:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
2021-03-02 06:24:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// onclick: {move |_| set_name("jill")}
|