demo.rs 2.0 KB

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