demo.rs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //! An example where the dioxus vdom is running in a native thread, interacting with webview
  2. //! Content is passed from the native thread into the webview
  3. use dioxus_core as dioxus;
  4. use dioxus_core::prelude::*;
  5. fn main() {
  6. dioxus_desktop::launch(
  7. |builder| {
  8. builder
  9. .title("Test Dioxus App")
  10. .size(320, 480)
  11. .resizable(false)
  12. .debug(true)
  13. },
  14. (),
  15. Example,
  16. )
  17. .expect("Webview finished");
  18. }
  19. // pub static Example: FC<()> = |cx, props|{
  20. // cx.render(html! {
  21. // <div>
  22. // <svg class="octicon octicon-star v-align-text-bottom"
  23. // viewBox="0 0 14 16" version="1.1"
  24. // width="14" height="16"
  25. // xmlns="http://www.w3.org/2000/svg"
  26. // >
  27. // <path
  28. // d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14"
  29. // xmlns="http://www.w3.org/2000/svg"
  30. // >
  31. // </path>
  32. // </svg>
  33. // </div>
  34. // })
  35. // };
  36. pub static Example: FC<()> = |cx, props| {
  37. cx.render(rsx! {
  38. div {
  39. class: "flex items-center justify-center flex-col"
  40. div {
  41. class: "flex items-center justify-center"
  42. div {
  43. class: "flex flex-col bg-white rounded p-4 w-full max-w-xs"
  44. div { class: "font-bold text-xl", "Example desktop app" }
  45. div { class: "text-sm text-gray-500", "This is running natively" }
  46. div {
  47. class: "flex flex-row items-center justify-center mt-6"
  48. div { class: "font-medium text-6xl", "100%" }
  49. }
  50. div {
  51. class: "flex flex-row justify-between mt-6"
  52. a {
  53. href: "https://www.dioxuslabs.com"
  54. class: "underline"
  55. "Made with dioxus"
  56. }
  57. }
  58. ul {
  59. {(0..10).map(|f| rsx!(li {
  60. key: "{f}"
  61. "{f}"
  62. }))}
  63. }
  64. }
  65. }
  66. }
  67. })
  68. };