wip: pre vnodes instead of vnode
This commit is contained in:
1 parent
e3d9db0847
commit
fe6938ceb3
21 files changed
+303
-441
No files matched your search
@@ -0,0 +1,36 @@
|
||||
//! Basic example that renders a simple VNode to the browser.
|
||||
|
||||
use dioxus_core::prelude::*;
|
||||
use dioxus_web::*;
|
||||
|
||||
fn main() {
|
||||
// Setup logging
|
||||
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
// Run the app
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |ctx| {
|
||||
ctx.render(rsx! {
|
||||
Calcier {
|
||||
h2 {"abc 1"}
|
||||
h2 {"abc 2"}
|
||||
h2 {"abc 3"}
|
||||
h2 {"abc 4"}
|
||||
h2 {"abc 5"}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
static Calcier: FC<()> = |ctx| {
|
||||
ctx.render(rsx! {
|
||||
div {
|
||||
h1 {
|
||||
"abc 0"
|
||||
}
|
||||
{ctx.children()}
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -52,7 +52,7 @@ struct ButtonProps {
|
||||
id: u8,
|
||||
}
|
||||
|
||||
fn CustomButton(ctx: Context, props: &ButtonProps) -> VNode {
|
||||
fn CustomButton(ctx: Context<ButtonProps>) -> VNode {
|
||||
let names = ctx.use_context::<CustomContext>();
|
||||
let name = names.0[ctx.id as usize];
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//! Basic example that renders a simple VNode to the browser.
|
||||
|
||||
use dioxus_core::prelude::*;
|
||||
use dioxus_web::*;
|
||||
|
||||
fn main() {
|
||||
// Setup logging
|
||||
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
// Run the app
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |ctx| {
|
||||
ctx.render(rsx! {
|
||||
h2 { "abc 1" }
|
||||
h2 { "abc 1" }
|
||||
h2 { "abc 1" }
|
||||
h2 { "abc 1" }
|
||||
h2 { "abc 1" }
|
||||
h2 { "abc 1" }
|
||||
div {
|
||||
"hello world!"
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
use dioxus_core::prelude::*;
|
||||
use dioxus_web::WebsysRenderer;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
static Example: FC<()> = |ctx| {
|
||||
ctx.render(rsx! {
|
||||
div {
|
||||
span {
|
||||
class: "px-2 py-1 flex w-36 mt-4 items-center text-xs rounded-md font-semibold text-yellow-500 bg-yellow-100"
|
||||
"DUE DATE : 18 JUN"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -53,7 +53,7 @@ struct ButtonProps<'src, F: Fn(MouseEvent)> {
|
||||
handler: F
|
||||
}
|
||||
|
||||
fn CustomButton<'b, 'a, F: Fn(MouseEvent)>(ctx: Context<'a>, props: &'b ButtonProps<'b, F>) -> VNode {
|
||||
fn CustomButton<'a, F: Fn(MouseEvent)>(ctx: Context<'a, ButtonProps<'a, F>>) -> VNode {
|
||||
ctx.render(rsx!{
|
||||
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"
|
||||
@@ -74,7 +74,7 @@ impl<F: Fn(MouseEvent)> PartialEq for ButtonProps<'_, F> {
|
||||
struct PlaceholderProps {
|
||||
val: &'static str
|
||||
}
|
||||
fn Placeholder(ctx: Context, props: &PlaceholderProps) -> VNode {
|
||||
fn Placeholder(ctx: Context<PlaceholderProps>) -> VNode {
|
||||
ctx.render(rsx!{
|
||||
div {
|
||||
"child: {ctx.val}"
|
||||
|
||||
Reference in new issue
Block a user