WIP: remove FC
This commit is contained in:
1 parent
3740f81383
commit
92d9521a73
24 files changed
+801
-451
No files matched your search
@@ -0,0 +1,41 @@
|
||||
use dioxus_core::prelude::*;
|
||||
use dioxus_core::scope::FC;
|
||||
use dioxus_core_macro::fc;
|
||||
|
||||
use std::marker::PhantomData;
|
||||
// #[derive(PartialEq)]
|
||||
// pub struct Example<'a> {
|
||||
// b: &'a str,
|
||||
// ___p: std::marker::PhantomData<&'a ()>,
|
||||
// }
|
||||
|
||||
// impl<'a> FC for Example<'a> {
|
||||
// fn render(ctx: Context<'_>, props: &Example<'a>) -> DomTree {
|
||||
// let Example { b, .. } = props;
|
||||
// {
|
||||
// ctx.render(rsx! {
|
||||
// div { "abcd {b}" }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// always try to fill in with Default
|
||||
|
||||
#[fc]
|
||||
fn Example(ctx: Context, a: &str, b: &str, c: &str) -> DomTree {
|
||||
ctx.render(rsx! {
|
||||
div {
|
||||
SomeComponent {
|
||||
a: "123"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[fc]
|
||||
fn SomeComponent(ctx: Context, a: &str, b: &str) -> DomTree {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -3,33 +3,53 @@ use dioxus_core::prelude::*;
|
||||
|
||||
fn main() {}
|
||||
|
||||
trait SProps {}
|
||||
|
||||
trait Comp {
|
||||
type Props;
|
||||
}
|
||||
|
||||
impl<T> Comp for FC<T> {
|
||||
type Props = T;
|
||||
}
|
||||
|
||||
fn test() {
|
||||
// let g: FC<ButtonProps> = CustomButton;
|
||||
}
|
||||
|
||||
trait Render {
|
||||
fn render(ctx: Context, props: &Self) -> DomTree;
|
||||
}
|
||||
// include as much as you might accept
|
||||
struct ButtonProps<'a> {
|
||||
struct Button<'a> {
|
||||
onhover: Option<&'a dyn Fn()>,
|
||||
// // A list of any attrs
|
||||
// attrs: AttrList<'a>,
|
||||
}
|
||||
|
||||
fn CustomButton(ctx: Context, props: ButtonProps) -> DomTree {
|
||||
let onfocus = move |evt: ()| log::debug!("Focused");
|
||||
impl Render for Button<'_> {
|
||||
fn render(ctx: Context, props: &Self) -> DomTree {
|
||||
let onfocus = move |evt: ()| log::debug!("Focused");
|
||||
|
||||
// todo!()
|
||||
ctx.render(rsx! {
|
||||
button {
|
||||
// ..props.attrs,
|
||||
class: "abc123",
|
||||
// style: { a: 2, b: 3, c: 4 },
|
||||
onclick: move |evt| {
|
||||
// log::info("hello world");
|
||||
},
|
||||
// Custom1 { a: 123 }
|
||||
// Custom2 { a: 456, "abc", h1 {"1"}, h2 {"2"} }
|
||||
// Custom3 { a: "sometext goes here" }
|
||||
// Custom4 { onclick: |evt| log::info("click") }
|
||||
}
|
||||
})
|
||||
// todo!()
|
||||
ctx.render(rsx! {
|
||||
button {
|
||||
// ..props.attrs,
|
||||
class: "abc123",
|
||||
// style: { a: 2, b: 3, c: 4 },
|
||||
onclick: move |evt| {
|
||||
// log::info("hello world");
|
||||
},
|
||||
// Custom1 { a: 123 }
|
||||
// Custom2 { a: 456, "abc", h1 {"1"}, h2 {"2"} }
|
||||
// Custom3 { a: "sometext goes here" }
|
||||
// Custom4 { onclick: |evt| log::info("click") }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// #[fc]
|
||||
// fn Button(ctx: Context, onhover: Option<&dyn Fn()>) -> DomTree {}
|
||||
|
||||
// h1 {
|
||||
// tag: "type", abc: 123, class: "big small wide short",
|
||||
// "title1"
|
||||
|
||||
@@ -4,7 +4,7 @@ fn main() -> Result<(), ()> {
|
||||
let p1 = Props { name: "bob".into() };
|
||||
|
||||
let mut vdom = VirtualDom::new_with_props(Example, p1);
|
||||
vdom.update_props(|p: &mut Props| {});
|
||||
// vdom.update_props(|p: &mut Props| {});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user