derive.rs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // Use `wee_alloc` as the global allocator.
  10. #[global_allocator]
  11. static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
  12. fn App(ctx: Context<()>) -> VNode {
  13. let cansee = use_state_new(&ctx, || false);
  14. rsx! { in ctx,
  15. div {
  16. "Shadow of the child:"
  17. button { onclick: move |_| cansee.set(!**cansee)
  18. "Gaze into the void"
  19. }
  20. {cansee.then(|| rsx!{ Child {} })}
  21. }
  22. }
  23. }
  24. fn Child(ctx: Context<()>) -> VNode {
  25. rsx! { in ctx,
  26. section { class: "py-6 bg-coolGray-100 text-coolGray-900"
  27. 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"
  28. h1 { class: "text-5xl font-bold leading-none text-center",
  29. "Sign up now"
  30. }
  31. p { class: "text-xl font-medium text-center",
  32. "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!"
  33. }
  34. div { class: "flex flex-col space-y-4 sm:space-y-0 sm:flex-row sm:space-x-8"
  35. button { class: "px-8 py-3 text-lg font-semibold rounded bg-violet-600 text-coolGray-50",
  36. "Get started"
  37. }
  38. button { class: "px-8 py-3 text-lg font-normal border rounded bg-coolGray-800 text-coolGray-50 border-coolGray-700",
  39. "Learn more"
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }