show off the new asset system in the examples

This commit is contained in:
Evan Almloff 2023-12-17 11:45:27 -06:00
parent a647ce2f36
commit d627153ccc
8 changed files with 14 additions and 9 deletions

View file

@ -10,7 +10,7 @@ fn app(cx: Scope) -> Element {
p {
"This should show an image:"
}
img { src: "examples/assets/logo.png" }
img { src: mg!(image("examples/assets/logo.png").format(ImageType::Avif)).to_string() }
}
})
}

View file

@ -18,13 +18,14 @@ fn main() {
);
}
const _STYLE: &str = mg!(file("./examples/assets/fileexplorer.css"));
fn app(cx: Scope) -> Element {
let files = use_ref(cx, Files::new);
cx.render(rsx! {
div {
link { href:"https://fonts.googleapis.com/icon?family=Material+Icons", rel:"stylesheet", }
style { include_str!("./assets/fileexplorer.css") }
header {
i { class: "material-icons icon-menu", "menu" }
h1 { "Files: ", files.read().current() }

View file

@ -30,7 +30,7 @@ watch_path = ["src", "public"]
[web.resource]
# CSS style file
style = ["/tailwind.css"]
style = []
# Javascript code file
script = []

File diff suppressed because one or more lines are too long

View file

@ -2,13 +2,11 @@
use dioxus::prelude::*;
const _STYLE: &str = mg!(file("./public/tailwind.css"));
fn main() {
#[cfg(not(target_arch = "wasm32"))]
dioxus_desktop::launch_cfg(
app,
dioxus_desktop::Config::new()
.with_custom_head(r#"<link rel="stylesheet" href="public/tailwind.css">"#.to_string()),
);
dioxus_desktop::launch(app);
#[cfg(target_arch = "wasm32")]
dioxus_web::launch(app);
}

View file

@ -7,6 +7,8 @@ fn main() {
dioxus_desktop::launch(app);
}
const _STYLE: &str = mg!(file("./examples/assets/todomvc.css"));
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum FilterState {
All,
@ -47,7 +49,6 @@ pub fn app(cx: Scope<()>) -> Element {
cx.render(rsx! {
section { class: "todoapp",
style { include_str!("./assets/todomvc.css") }
TodoHeader {
todos: todos,
}

View file

@ -16,6 +16,7 @@ dioxus-html = { workspace = true, optional = true }
dioxus-core-macro = { workspace = true, optional = true }
dioxus-hooks = { workspace = true, optional = true }
dioxus-rsx = { workspace = true, optional = true }
manganis = { git = "https://github.com/DioxusLabs/collect-assets" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dioxus-hot-reload = { workspace = true, optional = true }

View file

@ -22,6 +22,9 @@ pub use dioxus_rsx as rsx;
pub use dioxus_core_macro as core_macro;
pub mod prelude {
pub use manganis;
pub use manganis::mg;
#[cfg(feature = "hooks")]
pub use crate::hooks::*;