Make magnansis a feature for examples

This commit is contained in:
Jonathan Kelley committed 2024-01-18 12:36:42 -08:00
1 parent 451a2b6cfc
commit b8adfb9293
2 files changed
+13 -4

No files matched your search

+8 -4
View File
@@ -1,5 +1,11 @@
use dioxus::prelude::*; use dioxus::prelude::*;
#[cfg(not(feature = "collect-assets"))]
static ASSET_PATH: &str = "examples/assets/logo.png";
#[cfg(feature = "collect-assets")]
static ASSET_PATH: &str = manganis::mg!(image("examples/assets/logo.png").format(ImageType::Avif));
fn main() { fn main() {
launch_desktop(app); launch_desktop(app);
} }
@@ -7,10 +13,8 @@ fn main() {
fn app() -> Element { fn app() -> Element {
rsx! { rsx! {
div { div {
p { p { "This should show an image:" }
"This should show an image:" img { src: ASSET_PATH.to_string() }
}
img { src: manganis::mg!(image("examples/assets/logo.png").format(ImageType::Avif)).to_string() }
} }
} }
} }
+5
View File
@@ -17,6 +17,10 @@ fn main() {
.launch(app) .launch(app)
} }
#[cfg(not(feature = "collect-assets"))]
const _STYLE: &str = include_str!("../examples/assets/fileexplorer.css");
#[cfg(feature = "collect-assets")]
const _STYLE: &str = manganis::mg!(file("./examples/assets/fileexplorer.css")); const _STYLE: &str = manganis::mg!(file("./examples/assets/fileexplorer.css"));
fn app() -> Element { fn app() -> Element {
@@ -31,6 +35,7 @@ fn app() -> Element {
span { } span { }
i { class: "material-icons", onclick: move |_| files.write().go_up(), "logout" } i { class: "material-icons", onclick: move |_| files.write().go_up(), "logout" }
} }
style { "{_STYLE}" }
main { main {
{files.read().path_names.iter().enumerate().map(|(dir_id, path)| { {files.read().path_names.iter().enumerate().map(|(dir_id, path)| {
let path_end = path.split('/').last().unwrap_or(path.as_str()); let path_end = path.split('/').last().unwrap_or(path.as_str());