rsx_usage.rs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. use dioxus_core::prelude::*;
  2. fn main() {}
  3. // include as much as you might accept
  4. struct ButtonProps<'a> {
  5. onhover: Option<&'a dyn Fn()>,
  6. // // A list of any attrs
  7. // attrs: AttrList<'a>,
  8. }
  9. fn CustomButton(ctx: Context, props: ButtonProps) -> DomTree {
  10. let onfocus = move |evt: ()| log::debug!("Focused");
  11. todo!()
  12. // ctx.render(rsx! {
  13. // // button {
  14. // // // ..props.attrs,
  15. // // class: "abc123",
  16. // // // style: { a: 2, b: 3, c: 4 },
  17. // // onclick: {move |evt| {
  18. // // log::info("hello world");
  19. // // }},
  20. // // // Custom1 { a: 123 }
  21. // // // Custom2 { a: 456, "abc", h1 {"1"}, h2 {"2"} }
  22. // // // Custom3 { a: "sometext goes here" }
  23. // // // Custom4 { onclick: |evt| log::info("click") }
  24. // // }
  25. // })
  26. }
  27. // h1 {
  28. // tag: "type", abc: 123, class: "big small wide short",
  29. // "title1"
  30. // "title1"
  31. // "title1"
  32. // "title"
  33. // }
  34. // h1 ("title") {
  35. // tag: "type",
  36. // abc: 123,
  37. // class: "big small wide short",
  38. // }
  39. // // <button
  40. // // class="inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
  41. // // onclick={move |_| set_name("jill")}
  42. // // onclick={move |_| set_name("jill")}
  43. // // >
  44. // // "Jill!"
  45. // // </button>
  46. // button { "Jill!",
  47. // class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
  48. // onclick: move |_| set_name("jill"),
  49. // onclick: move |_| set_name("jill"),
  50. // }
  51. // button {
  52. // class: "inline-block py-4 px-8 mr-6 leading-none text-white bg-indigo-600 hover:bg-indigo-900 font-semibold rounded shadow"
  53. // onclick: move |_| set_name("jill"),
  54. // onclick: move |_| set_name("jill"),
  55. // // this is valid
  56. // "Jill!",
  57. // // this is also valid
  58. // {"Jill!"}
  59. // }
  60. // h1 { "Text", class: "inline-block py-4 px-8 mr-6 leading-none" }
  61. // // <h1 class="inline-block py-4 px-8 mr-6 leading-none">
  62. // // "Text"
  63. // // </h1>
  64. // h1 {
  65. // div {
  66. // h1 {}
  67. // h2 {}
  68. // Brick {}
  69. // p {}
  70. // p {
  71. // tag: "type",
  72. // abc: 123,
  73. // enabled: true,
  74. // class: "big small wide short",
  75. // a { "abcder" },
  76. // h2 { "whatsup", class: "abc-123" },
  77. // CustomComponent { a: 123, b: 456, key: "1" },
  78. // }
  79. // div { class: "big small wide short",
  80. // div {},
  81. // div {},
  82. // div {},
  83. // div {},
  84. // }
  85. // }
  86. // }
  87. // h2 {}
  88. // h3 {}
  89. // "abcd123"