main.rs 4.2 KB

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