main.rs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. const _STYLE: &str = mg!(file("./public/tailwind.css"));
  4. fn main() {
  5. #[cfg(not(target_arch = "wasm32"))]
  6. dioxus_desktop::launch(app);
  7. #[cfg(target_arch = "wasm32")]
  8. dioxus_web::launch(app);
  9. }
  10. pub fn app(cx: Scope) -> Element {
  11. let grey_background = true;
  12. cx.render(rsx!(
  13. div {
  14. header {
  15. class: "text-gray-400 body-font",
  16. // you can use optional attributes to optionally apply a tailwind class
  17. class: if grey_background { "bg-gray-900" },
  18. div { class: "container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center",
  19. a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
  20. StacksIcon {}
  21. span { class: "ml-3 text-xl", "Hello Dioxus!"}
  22. }
  23. nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center",
  24. a { class: "mr-5 hover:text-white", "First Link"}
  25. a { class: "mr-5 hover:text-white", "Second Link"}
  26. a { class: "mr-5 hover:text-white", "Third Link"}
  27. a { class: "mr-5 hover:text-white", "Fourth Link"}
  28. }
  29. button {
  30. class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
  31. "Button"
  32. RightArrowIcon {}
  33. }
  34. }
  35. }
  36. section { class: "text-gray-400 bg-gray-900 body-font",
  37. div { class: "container mx-auto flex px-5 py-24 md:flex-row flex-col items-center",
  38. div { class: "lg:flex-grow md:w-1/2 lg:pr-24 md:pr-16 flex flex-col md:items-start md:text-left mb-16 md:mb-0 items-center text-center",
  39. h1 { class: "title-font sm:text-4xl text-3xl mb-4 font-medium text-white",
  40. br { class: "hidden lg:inline-block" }
  41. "Dioxus Sneak Peek"
  42. }
  43. p {
  44. class: "mb-8 leading-relaxed",
  45. "Dioxus is a new UI framework that makes it easy and simple to write cross-platform apps using web
  46. technologies! It is functional, fast, and portable. Dioxus can run on the web, on the desktop, and
  47. on mobile and embedded platforms."
  48. }
  49. div { class: "flex justify-center",
  50. button {
  51. class: "inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg",
  52. "Learn more"
  53. }
  54. button {
  55. class: "ml-4 inline-flex text-gray-400 bg-gray-800 border-0 py-2 px-6 focus:outline-none hover:bg-gray-700 hover:text-white rounded text-lg",
  56. "Build an app"
  57. }
  58. }
  59. }
  60. div { class: "lg:max-w-lg lg:w-full md:w-1/2 w-5/6",
  61. img {
  62. class: "object-cover object-center rounded",
  63. src: "https://i.imgur.com/oK6BLtw.png",
  64. referrerpolicy:"no-referrer",
  65. alt: "hero",
  66. }
  67. }
  68. }
  69. }
  70. }
  71. ))
  72. }
  73. pub fn StacksIcon(cx: Scope) -> Element {
  74. cx.render(rsx!(
  75. svg {
  76. fill: "none",
  77. stroke: "currentColor",
  78. stroke_linecap: "round",
  79. stroke_linejoin: "round",
  80. stroke_width: "2",
  81. class: "w-10 h-10 text-white p-2 bg-indigo-500 rounded-full",
  82. view_box: "0 0 24 24",
  83. path { d: "M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"}
  84. }
  85. ))
  86. }
  87. pub fn RightArrowIcon(cx: Scope) -> Element {
  88. cx.render(rsx!(
  89. svg {
  90. fill: "none",
  91. stroke: "currentColor",
  92. stroke_linecap: "round",
  93. stroke_linejoin: "round",
  94. stroke_width: "2",
  95. class: "w-4 h-4 ml-1",
  96. view_box: "0 0 24 24",
  97. path { d: "M5 12h14M12 5l7 7-7 7"}
  98. }
  99. ))
  100. }