derive.rs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. use dioxus::{events::on::MouseEvent, prelude::*};
  2. use dioxus_core as dioxus;
  3. use dioxus_html_namespace as dioxus_elements;
  4. use dioxus_web::WebsysRenderer;
  5. fn main() {
  6. wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
  7. console_error_panic_hook::set_once();
  8. wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
  9. }
  10. fn App(cx: Context<()>) -> VNode {
  11. let cansee = use_state(&cx, || false);
  12. rsx! { in cx,
  13. div {
  14. "Shadow of the child:"
  15. button { onclick: move |_| cansee.set(!**cansee)
  16. "Gaze into the void"
  17. }
  18. {cansee.then(|| rsx!{ Child {} })}
  19. }
  20. }
  21. }
  22. fn Child(cx: Context<()>) -> VNode {
  23. rsx! { in cx,
  24. section { class: "py-6 bg-coolGray-100 text-coolGray-900"
  25. div { class: "container mx-auto flex flex-col items-center justify-center p-4 space-y-8 md:p-10 md:px-24 xl:px-48"
  26. h1 { class: "text-5xl font-bold leading-none text-center",
  27. "Sign up now"
  28. }
  29. p { class: "text-xl font-medium text-center",
  30. "At a assumenda quas cum earum ut itaque commodi saepe rem aspernatur quam natus quis nihil quod, hic explicabo doloribus magnam neque, exercitationem eius sunt!"
  31. }
  32. div { class: "flex flex-col space-y-4 sm:space-y-0 sm:flex-row sm:space-x-8"
  33. button { class: "px-8 py-3 text-lg font-semibold rounded bg-violet-600 text-coolGray-50",
  34. "Get started"
  35. }
  36. button { class: "px-8 py-3 text-lg font-normal border rounded bg-coolGray-800 text-coolGray-50 border-coolGray-700",
  37. "Learn more"
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }