2021-01-15 01:56:28 +00:00
|
|
|
use std::future::Future;
|
|
|
|
|
|
|
|
use dioxus_core::{component::AnyContext, prelude::*};
|
2021-01-16 04:25:29 +00:00
|
|
|
// use virtual_dom_rs::Closure;
|
2021-01-15 01:56:28 +00:00
|
|
|
|
2021-01-15 07:52:47 +00:00
|
|
|
// Stop-gap while developing
|
|
|
|
// Need to update the macro
|
|
|
|
type VirtualNode = VNode;
|
|
|
|
|
2021-01-15 01:56:28 +00:00
|
|
|
pub fn main() {
|
|
|
|
let dom = VirtualDom::new(root);
|
2021-01-16 06:30:48 +00:00
|
|
|
// let mut renderer = TextRenderer::new(dom);
|
|
|
|
// let output = renderer.render();
|
2021-01-15 01:56:28 +00:00
|
|
|
}
|
|
|
|
|
2021-01-15 07:52:47 +00:00
|
|
|
fn root(ctx: &mut AnyContext) -> VNode {
|
2021-01-15 01:56:28 +00:00
|
|
|
// the regular html syntax
|
|
|
|
|
|
|
|
// html! {
|
|
|
|
// <html>
|
|
|
|
// <Head />
|
|
|
|
// <Body />
|
|
|
|
// <Footer />
|
|
|
|
// </html>
|
|
|
|
// }
|
|
|
|
|
|
|
|
// or a manually crated vnode
|
|
|
|
{
|
2021-01-15 07:52:47 +00:00
|
|
|
let mut node_0 = VNode::element("div");
|
2021-01-16 04:25:29 +00:00
|
|
|
{
|
|
|
|
if let Some(ref mut element_node) = node_0.as_velement_mut() {
|
|
|
|
// element_node.attrs.insert("blah", "blah");
|
|
|
|
// element_node.children.extend(node_0.into_iter());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 01:56:28 +00:00
|
|
|
let mut node_1: IterableNodes = ("Hello world!").into();
|
|
|
|
node_1.first().insert_space_before_text();
|
2021-01-15 07:52:47 +00:00
|
|
|
let mut node_2 = VNode::element("button");
|
2021-01-16 04:25:29 +00:00
|
|
|
|
|
|
|
let node_3 = VNode::Component(VComponent {});
|
2021-01-15 01:56:28 +00:00
|
|
|
{
|
|
|
|
// let closure = Closure::wrap(Box::new(|_| {}) as Box<FnMut(_)>);
|
|
|
|
// let closure_rc = std::rc::Rc::new(closure);
|
|
|
|
// node_2
|
|
|
|
// .as_velement_mut()
|
|
|
|
// .expect("Not an element")
|
|
|
|
// .events
|
|
|
|
// .0
|
|
|
|
// .insert("onclick".to_string(), closure_rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(ref mut element_node) = node_0.as_velement_mut() {
|
|
|
|
element_node.children.extend(node_1.into_iter());
|
|
|
|
}
|
|
|
|
if let Some(ref mut element_node) = node_0.as_velement_mut() {
|
|
|
|
element_node.children.extend(node_2.into_iter());
|
|
|
|
}
|
|
|
|
|
|
|
|
node_0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 07:52:47 +00:00
|
|
|
fn Head(ctx: &mut AnyContext) -> VNode {
|
2021-01-15 01:56:28 +00:00
|
|
|
html! {
|
|
|
|
<head>
|
|
|
|
{"Head Section"}
|
|
|
|
</head>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 07:52:47 +00:00
|
|
|
fn Body(ctx: &mut AnyContext) -> VNode {
|
2021-01-15 01:56:28 +00:00
|
|
|
html! {
|
|
|
|
<body>
|
|
|
|
{"Footer Section"}
|
|
|
|
</body>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 07:52:47 +00:00
|
|
|
fn Footer(ctx: &mut AnyContext) -> VNode {
|
2021-01-15 01:56:28 +00:00
|
|
|
html! {
|
|
|
|
<div>
|
|
|
|
{"Footer Section"}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|