Feat: update websys with lifecycle

This commit is contained in:
Jonathan Kelley committed 2021-02-24 02:22:05 -05:00
1 parent 83451372aa
commit 4d01455729
6 files changed
+76 -179

No files matched your search

+7 -10
View File
@@ -1,17 +1,14 @@
//! basic example that renders a simple domtree to the page :)
//! Basic example that renders a simple domtree to the browser.
use dioxus_core::prelude::*;
use dioxus_web::*;
fn main() {
// Enable logging
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
}
// Route panic as console_log
console_error_panic_hook::set_once();
// Render the app
WebsysRenderer::simple_render(html! {
static App: FC<()> = |ctx, _| {
ctx.view(html! {
<div>
<div class="flex items-center justify-center flex-col">
<div class="font-bold text-xl"> "Count is {}" </div>
@@ -19,5 +16,5 @@ fn main() {
<button onclick={move |_| log::info!("button2 clicked!")}> "decrement" </button>
</div>
</div>
});
}
})
};
+28 -33
View File
@@ -8,45 +8,40 @@ use dioxus_web::*;
fn main() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
console_error_panic_hook::set_once();
// todo: wire up the component macro macro
// div! { class = "asd" onclick = move |_| {}
// div! { class = "asd" onclick = move |_| {} }
// h1! { "123456" "123456" "123456" }
// h2! { "123456" "123456" "123456" }
// h3! { "123456" "123456" "123456" }
// };
WebsysRenderer::simple_render(html! {
<div>
<div class="flex items-center justify-center flex-col">
<div class="flex items-center justify-center">
<div class="flex flex-col bg-white rounded p-4 w-full max-w-xs">
// Title
<div class="font-bold text-xl">
"Jon's awesome site!!11"
</div>
// Subtext / description
<div class="text-sm text-gray-500">
"He worked so hard on it :)"
</div>
<div class="flex flex-row items-center justify-center mt-6">
// Main number
<div class="font-medium text-6xl">
"1337"
WebsysRenderer::new(|ctx, _| {
ctx.view(html! {
<div>
<div class="flex items-center justify-center flex-col">
<div class="flex items-center justify-center">
<div class="flex flex-col bg-white rounded p-4 w-full max-w-xs">
// Title
<div class="font-bold text-xl">
"Jon's awesome site!!11"
</div>
</div>
// Try another
<div class="flex flex-row justify-between mt-6">
// <a href=format!("http://localhost:8080/fib/{}", other_fib_to_try) class="underline">
"Legit made my own React"
// </a>
// Subtext / description
<div class="text-sm text-gray-500">
"He worked so hard on it :)"
</div>
<div class="flex flex-row items-center justify-center mt-6">
// Main number
<div class="font-medium text-6xl">
"1337"
</div>
</div>
// Try another
<div class="flex flex-row justify-between mt-6">
// <a href=format!("http://localhost:8080/fib/{}", other_fib_to_try) class="underline">
"Legit made my own React"
// </a>
</div>
</div>
</div>
</div>
</div>
</div>
})
});
}