wip: staticify?

This commit is contained in:
Jonathan Kelley committed 2021-03-11 12:27:01 -05:00
1 parent 78d093a945
commit 5ad81885e4
21 files changed
+433 -346

No files matched your search

+23 -22
View File
@@ -13,26 +13,27 @@ fn main() {
}
static App: FC<()> = |ctx, _| {
log::info!("Ran component");
use dioxus::builder::*;
todo!()
// ctx.render(|b| {
// div(b)
// .child(text("hello"))
// .listeners([on(b, "click", |_| {
// //
// log::info!("button1 clicked!");
// })])
// .finish()
// })
// ctx.render(html! {
// <div onclick={move |_| log::info!("button1 clicked!")}>
// "Hello"
// // <div class="flex items-center justify-center flex-col">
// // <div class="font-bold text-xl"> "Count is ..." </div>
// // <button onclick={move |_| log::info!("button1 clicked!")}> "increment" </button>
// // <button onclick={move |_| log::info!("button2 clicked!")}> "decrement" </button>
// // </div>
// </div>
// })
ctx.render(rsx! {
div {
h1 {"hello"}
C1 {}
C2 {}
}
})
};
static C1: FC<()> = |ctx, props| {
ctx.render(rsx! {
button {
"numba 1"
}
})
};
static C2: FC<()> = |ctx, props| {
ctx.render(rsx! {
button {
"numba 2"
}
})
};
+21 -4
View File
@@ -6,6 +6,7 @@ fn main() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
console_error_panic_hook::set_once();
log::info!("hello world");
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example));
}
@@ -18,6 +19,8 @@ static Example: FC<()> = |ctx, _props| {
set_event(Some(evt));
};
log::info!("hello world");
ctx.render(rsx! {
div {
@@ -35,21 +38,35 @@ static Example: FC<()> = |ctx, _props| {
id: "json"
"{event}"
}
Example2 { name: "{event}" }
// Example2 { name: "{event}".to_string() }
}
})
};
#[derive(Debug, PartialEq)]
struct Props {
#[derive(Debug, PartialEq, Props)]
struct ExampleProps {
name: String
}
static Example2: FC<Props> = |ctx, props| {
static Example2: FC<ExampleProps> = |ctx, props| {
ctx.render(rsx!{
div {
h1 {"hello {props.name}"}
}
})
};
impl Properties for ExampleProps {
type Builder = ExamplePropsBuilder<((),)>;
type StaticOutput = ExampleProps;
fn builder() -> Self::Builder {
ExampleProps::builder()
}
unsafe fn into_static(self) -> Self::StaticOutput {
todo!()
}
}
+5 -17
View File
@@ -1,23 +1,17 @@
use bumpalo::Bump;
use dioxus::{events::EventTrigger, prelude::*};
#![allow(non_snake_case)]
use dioxus_core as dioxus;
use dioxus::prelude::*;
use dioxus_web::WebsysRenderer;
// creates a proxy address that gets transpiled at compile time
// all asset ids are shuttled through the renderer
// static IMG: ImgAsset = dioxus_asset!("");
fn main() {
// wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
// console_error_panic_hook::set_once();
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
console_error_panic_hook::set_once();
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example))
}
static Example: FC<()> = |ctx, props| {
static Example: FC<()> = |ctx, _props| {
let (name, set_name) = use_state(&ctx, || "...?");
ctx.render(rsx! {
div {
class: "py-12 px-4 text-center w-full max-w-2xl mx-auto"
@@ -47,9 +41,3 @@ static Example: FC<()> = |ctx, props| {
}
})
};
// onclick: {move |_| set_name("jill")}