1
0

complex.rsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. rsx! {
  2. // Complex nesting with components
  3. button {
  4. class: "flex items-center pl-3 py-3 pr-2 text-gray-500 hover:bg-indigo-50 rounded",
  5. onclick: move |evt| {
  6. show_user_menu.set(!show_user_menu.get());
  7. evt.cancel_bubble();
  8. },
  9. onmousedown: move |evt| show_user_menu.set(!show_user_menu.get()),
  10. span { class: "inline-block mr-4", icons::icon_14 {} }
  11. span { "Settings" }
  12. }
  13. // Complex nesting with handlers
  14. li {
  15. Link {
  16. class: "flex items-center pl-3 py-3 pr-4 {active_class} rounded",
  17. to: "{to}",
  18. span { class: "inline-block mr-3", icons::icon_0 {} }
  19. span { "{name}" }
  20. {children.is_some().then(|| rsx! {
  21. span {
  22. class: "inline-block ml-auto hover:bg-gray-500",
  23. onclick: move |evt| {
  24. evt.cancel_bubble();
  25. },
  26. icons::icon_8 {}
  27. }
  28. })}
  29. }
  30. div { class: "px-4",
  31. {is_current.then(|| rsx! {
  32. {children}
  33. })}
  34. }
  35. }
  36. // No nesting
  37. Component {
  38. adsasd: "asd",
  39. onclick: move |_| {
  40. let blah = 120;
  41. },
  42. }
  43. // Component path
  44. my::thing::Component {
  45. adsasd: "asd",
  46. onclick: move |_| {
  47. let blah = 120;
  48. },
  49. }
  50. for i in 0..10 {
  51. Component { key: "{i}", blah: 120 }
  52. }
  53. for i in 0..10 {
  54. Component { key: "{i}" }
  55. }
  56. for i in 0..10 {
  57. div { key: "{i}", blah: 120 }
  58. }
  59. for i in 0..10 {
  60. div { key: "{i}" }
  61. }
  62. div {
  63. "asdbascasdbasd"
  64. "asbdasbdabsd"
  65. {asbdabsdbasdbas}
  66. }
  67. }