From b8adfb9293a69533a766666732e97f31dd06222c Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Thu, 18 Jan 2024 12:36:42 -0800 Subject: [PATCH] Make magnansis a feature for examples --- examples/custom_assets.rs | 12 ++++++++---- examples/file_explorer.rs | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/custom_assets.rs b/examples/custom_assets.rs index f449ef6fe..2c5114ab2 100644 --- a/examples/custom_assets.rs +++ b/examples/custom_assets.rs @@ -1,5 +1,11 @@ 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() { launch_desktop(app); } @@ -7,10 +13,8 @@ fn main() { fn app() -> Element { rsx! { div { - p { - "This should show an image:" - } - img { src: manganis::mg!(image("examples/assets/logo.png").format(ImageType::Avif)).to_string() } + p { "This should show an image:" } + img { src: ASSET_PATH.to_string() } } } } diff --git a/examples/file_explorer.rs b/examples/file_explorer.rs index ba688f3a5..b4c028ff5 100644 --- a/examples/file_explorer.rs +++ b/examples/file_explorer.rs @@ -17,6 +17,10 @@ fn main() { .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")); fn app() -> Element { @@ -31,6 +35,7 @@ fn app() -> Element { span { } i { class: "material-icons", onclick: move |_| files.write().go_up(), "logout" } } + style { "{_STYLE}" } main { {files.read().path_names.iter().enumerate().map(|(dir_id, path)| { let path_end = path.split('/').last().unwrap_or(path.as_str());