wip: worked backwards a bit and got it slightly figured out

This commit is contained in:
Jonathan Kelley committed 2021-10-30 17:11:15 -04:00
1 parent ba9e1dbb8f
commit 9ee2bfb010
10 files changed
+322 -147

No files matched your search

+11 -11
View File
@@ -41,22 +41,22 @@ struct RowProps {
label: Label,
}
fn Row((cx, props): Scope<RowProps>) -> Element {
fn Row<'a>((cx, props): Scope<'a, RowProps>) -> Element<'a> {
let handler = move |evt: MouseEvent| {
let g = evt.button;
};
cx.render(rsx! {
tr {
td { class:"col-md-1", "{props.row_id}" }
td { class:"col-md-1", onclick: move |_| { /* run onselect */ }
a { class: "lbl", "{props.label}" }
}
td { class: "col-md-1"
a { class: "remove", onclick: {handler}
span { class: "glyphicon glyphicon-remove remove" aria_hidden: "true" }
}
}
td { class: "col-md-6" }
// td { class:"col-md-1", "{props.row_id}" }
// td { class:"col-md-1", onclick: move |_| { /* run onselect */ }
// a { class: "lbl", "{props.label}" }
// }
// td { class: "col-md-1"
// a { class: "remove", onclick: {handler}
// span { class: "glyphicon glyphicon-remove remove" aria_hidden: "true" }
// }
// }
// td { class: "col-md-6" }
}
})
}
+43 -9
View File
@@ -57,10 +57,11 @@ fn App3((cx, props): Scope<()>) -> Element {
bame: 10,
}
};
cx.render(rsx!(Child {
bame: 102,
..ChildProps { bame: 10 }
}))
todo!()
// cx.render(rsx!(Child {
// bame: 102,
// ..ChildProps { bame: 10 }
// }))
}
#[derive(Props, PartialEq, Debug)]
@@ -97,11 +98,11 @@ impl<'a> Children<'a> {
}
}
}
impl<'a> IntoVNodeList<'a> for &Children<'a> {
fn into_vnode_list(self, cx: NodeFactory<'a>) -> &'a [VNode<'a>] {
todo!()
}
}
// impl<'a> IntoVNodeList<'a> for &Children<'a> {
// fn into_vnode_list(self, cx: NodeFactory<'a>) -> &'a [VNode<'a>] {
// todo!()
// }
// }
static Bapp: FC<()> = |(cx, props)| {
let name = cx.use_state(|| 0);
@@ -117,3 +118,36 @@ static Bapp: FC<()> = |(cx, props)| {
}
))
};
static Match: FC<()> = |(cx, props)| {
//
let b: Box<dyn Fn(NodeFactory) -> VNode> = Box::new(|f| todo!());
let b = match "ag" {
"a" => {
let __b: Box<dyn FnOnce(NodeFactory) -> VNode> = Box::new(|f: NodeFactory| todo!());
__b
}
_ => {
let __b: Box<dyn FnOnce(NodeFactory) -> VNode> = Box::new(|f: NodeFactory| todo!());
__b
}
};
// let b: Box<dyn Fn(NodeFactory) -> VNode> = match "alph" {
// "beta" => Box::new(|f: NodeFactory| {
// //
// todo!()
// }),
// _ => Box::new(|f: NodeFactory| {
// //
// todo!()
// }),
// };
cx.render(rsx! {
div {
}
})
};
+71
View File
@@ -0,0 +1,71 @@
use std::marker::PhantomData;
use dioxus::component::Scope;
use dioxus::events::on::MouseEvent;
use dioxus::nodes::{IntoVNode, IntoVNodeList};
use dioxus_core as dioxus;
use dioxus_core::prelude::*;
use dioxus_core_macro::*;
use dioxus_html as dioxus_elements;
fn main() {}
fn t() {
let g = rsx! {
div {
div {
}
}
};
let g = {
let ___p: Box<dyn FnOnce(NodeFactory) -> VNode> = Box::new(|__cx: NodeFactory| {
use dioxus_elements::{GlobalAttributes, SvgAttributes};
__cx.element(dioxus_elements::div, [], [], [], None)
});
// let __z = ___p as ;
// __z
};
}
fn App((cx, props): Scope<()>) -> Element {
let a = rsx! {
div {
"asd"
}
};
let p = (0..10).map(|f| {
rsx! {
div {
}
}
});
let g = match "text" {
"a" => rsx!("asd"),
b => rsx!("asd"),
};
let items = ["bob", "bill", "jack"];
let f = items
.iter()
.filter(|f| f.starts_with('b'))
.map(|f| rsx!("hello {f}"));
cx.render(rsx! {
div {
div {
{a}
{p}
{g}
{f}
}
}
})
}
// std::boxed::Box<dyn for<'r> std::ops::FnOnce(dioxus_core::NodeFactory<'r>) -> dioxus_core::VNode<'_>>