derive.rs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. use dioxus::{events::on::MouseEvent, prelude::*};
  2. use dioxus_core as dioxus;
  3. use dioxus_web::WebsysRenderer;
  4. fn main() {
  5. wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
  6. console_error_panic_hook::set_once();
  7. wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
  8. }
  9. fn App(cx: Context<()>) -> VNode {
  10. let cansee = use_state(&cx, || false);
  11. rsx! { in cx,
  12. div {
  13. "Shadow of the child:"
  14. button { onclick: move |_| cansee.set(!**cansee)
  15. "Gaze into the void"
  16. }
  17. {cansee.then(|| rsx!{ Child {} })}
  18. }
  19. }
  20. }
  21. fn Child(cx: Context<()>) -> VNode {
  22. rsx! { in cx,
  23. section { class: "py-6 bg-coolGray-100 text-coolGray-900"
  24. 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"
  25. h1 { class: "text-5xl font-bold leading-none text-center",
  26. "Sign up now"
  27. }
  28. p { class: "text-xl font-medium text-center",
  29. "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!"
  30. }
  31. div { class: "flex flex-col space-y-4 sm:space-y-0 sm:flex-row sm:space-x-8"
  32. button { class: "px-8 py-3 text-lg font-semibold rounded bg-violet-600 text-coolGray-50",
  33. "Get started"
  34. }
  35. button { class: "px-8 py-3 text-lg font-normal border rounded bg-coolGray-800 text-coolGray-50 border-coolGray-700",
  36. "Learn more"
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }