rsx_usage.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. use dioxus_core::prelude::*;
  2. fn main() {}
  3. trait SProps {}
  4. trait Comp {
  5. type Props;
  6. }
  7. impl<T> Comp for FC<T> {
  8. type Props = T;
  9. }
  10. fn test() {
  11. // let g: FC<ButtonProps> = CustomButton;
  12. }
  13. trait Render: Sized {
  14. fn render(ctx: Context<Self>) -> VNode;
  15. }
  16. // include as much as you might accept
  17. struct Button {
  18. onhover: Option<Box<dyn Fn()>>,
  19. }
  20. impl Render for Button {
  21. fn render(ctx: Context<Self>) -> VNode {
  22. let _onfocus = move |_evt: ()| log::debug!("Focused");
  23. // todo!()
  24. ctx.render(rsx! {
  25. button {
  26. // ..ctx.attrs,
  27. class: "abc123",
  28. // style: { a: 2, b: 3, c: 4 },
  29. onclick: move |_evt| {
  30. // log::info("hello world");
  31. },
  32. // Custom1 { a: 123 }
  33. // Custom2 { a: 456, "abc", h1 {"1"}, h2 {"2"} }
  34. // Custom3 { a: "sometext goes here" }
  35. // Custom4 { onclick: |evt| log::info("click") }
  36. }
  37. })
  38. }
  39. }