rsxt.rs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. use dioxus_core_macro::rsx;
  2. pub mod dioxus {
  3. pub mod builder {
  4. pub struct Builder;
  5. struct AttrVal;
  6. impl Into<AttrVal> for &'static str {
  7. fn into(self) -> AttrVal {
  8. todo!()
  9. }
  10. }
  11. impl Into<AttrVal> for String {
  12. fn into(self) -> AttrVal {
  13. todo!()
  14. }
  15. }
  16. // impl<T> From<T> for AttrVal {
  17. // fn from(_: T) -> Self {
  18. // todo!()
  19. // }
  20. // }
  21. impl Builder {
  22. // fn attr<T>(mut self, key: &str, value: impl Into<AttrVal>) -> Self {
  23. pub fn attr<T>(mut self, key: &str, value: T) -> Self {
  24. Self
  25. }
  26. pub fn on<T>(mut self, key: &str, value: T) -> Self {
  27. Self
  28. }
  29. pub fn finish(mut self) {
  30. // Self
  31. }
  32. }
  33. pub struct Bump;
  34. pub fn div(bump: &Bump) -> Builder {
  35. todo!()
  36. }
  37. pub fn h1(bump: &Bump) -> Builder {
  38. todo!()
  39. }
  40. pub fn h2(bump: &Bump) -> Builder {
  41. todo!()
  42. }
  43. }
  44. }
  45. use dioxus::builder::Bump;
  46. pub fn main() {
  47. // render(rsx! {
  48. // div { // we can actually support just a list of nodes too
  49. // h1 {"Hello Dioxus"}
  50. // p {"This is a beautful app you're building"}
  51. // section {
  52. // "custom section to the rescue",
  53. // class: "abc123"
  54. // }
  55. // span {
  56. // class: "abc123"
  57. // "Try backwards too."
  58. // "Anything goes!"
  59. // "As long as it's within the rules"
  60. // {0..10.map(|f| rsx!{
  61. // div {
  62. // h3 {"totally okay to drop in iterators and expressions"}
  63. // p {"however, debug information is lost"}
  64. // }
  65. // })}
  66. // }
  67. // span {
  68. // "Feel free"
  69. // class: "abc123"
  70. // "To mix to your heart's content"
  71. // }
  72. // span { class: "some-very-long-and-tedious-class-name-is-now-separated"
  73. // "Very ergonomic"
  74. // }
  75. // span { "Innovative design 🛠"
  76. // class: "some-very-long-and-tedious-class-name-is-now-separated"
  77. // }
  78. // }
  79. // });
  80. let g = String::from("asd");
  81. // let lazy = rsx! {
  82. // div {
  83. // a: "asd",
  84. // a: "asd",
  85. // a: "asd",
  86. // a: "asd",
  87. // a: "asd",
  88. // // a: {rsx!{ h1 {"hello world"} }}, // include
  89. // a: {&g},
  90. // b: {1 + 2},
  91. // onclick: {move |e: ()| {
  92. // println!("hello world!")
  93. // }},
  94. // div {
  95. // a: "asd"
  96. // div {
  97. // div {
  98. // div {
  99. // }
  100. // }
  101. // }
  102. // }
  103. // h1 {
  104. // }
  105. // h2 {
  106. // "child"
  107. // }
  108. // "Childnode"
  109. // }
  110. // };
  111. // render(lazy);
  112. }
  113. fn render(f: impl Fn(&dioxus::builder::Bump)) {}