diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1c8b425..6ca2cc5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,6 @@ -# https://github.com/actions/deploy-pages -# https://github.com/actions/upload-pages-artifact -name: Publish/Deploy +# https://docs.github.com/en/actions +name: Build/Publish/Deploy on: push: @@ -34,23 +33,27 @@ jobs: # ~/.npm # key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: cargo-bins/cargo-binstall@main - name: Install Dioxus and TailwindCSS run: | - cargo install dioxus-cli - npm -g install -D tailwindcss + cargo binstall dioxus-cli + npm install tailwindcss -D -g - name: Build Project run: | #cargo r --bin syncd -F syncdep npx tailwindcss -m -i tailwind_base.css -o assets/tailwind.css - dx build --release + dx build -r --platform web cargo t #- name: Setup GitHub Pages # uses: actions/configure-pages@v4 - name: Upload Artifacts uses: actions/upload-pages-artifact@v3 - with: - path: dist + #env: + # REPO_NAME: ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/} + with: # https://github.com/actions/upload-pages-artifact + path: target/dx/${{ github.event.repository.name }}/release/web/public + # path: target/dx/${{ env.REPO_NAME }}/release/web/public deploy: #if: github.ref == 'refs/heads/master' @@ -65,7 +68,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - steps: + steps: # https://github.com/actions/deploy-pages - name: Deploy to GitHub Pages uses: actions/deploy-pages@v4 id: deployment diff --git a/Cargo.toml b/Cargo.toml index a970b9b..0b51596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,14 +13,10 @@ keywords = ["periodic", "periodic-table", "elements", "chemistry-elements", "dio # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dioxus = { version = "0.5", features = ["web"], optional = true } # "web", "fullstack", "router" -#dioxus-sdk = { version = "0.5", features = ["i18n"] } -#dioxus-logger = "0.5" # Debug -#manganis = "0.2" +dioxus = { version = "0.6", optional = true } # features = ["fullstack", "router"], +#dioxus-sdk = { version = "0.6", features = ["i18n"], optional = true } -#mendeleev = "0.8" - -reqwest = { version = "0.12", optional = true } #, features = ["blocking"] #, "json" +reqwest = { version = "0.12", optional = true } # features = ["blocking"], #, "json" tokio = { version = "1.42", features = ["full"], optional = true } serde = { version = "1.0", features = ["derive"], optional = true } serde_json = { version = "1.0", optional = true } @@ -28,12 +24,12 @@ scraper = { version = "0.21", optional = true } csv = { version = "1.3", optional = true } [features] -default = [] +default = [] # "desktop", "web", "mobile" syncdep = ["reqwest", "tokio", "serde", "serde_json", "scraper", "csv"] -desktop = ["dioxus/desktop"] -server = ["dioxus/axum"] -web = ["dioxus/web"] +desktop = ["dioxus", "dioxus/desktop"] +mobile = ["dioxus", "dioxus/mobile"] +web = ["dioxus", "dioxus/web"] [[bin]] name = "inperiod" @@ -44,13 +40,6 @@ name = "syncd" path = "src/syncd.rs" # default in src/bin/ required-features = ["syncdep"] -[profile.dev] -opt-level = 1 -#incremental = false - -#[profile.dev.package."*"] -#opt-level = 3 - [profile.release] codegen-units = 1 strip = true # "debuginfo" @@ -60,5 +49,21 @@ lto = true #debug = false #incremental = false +[profile.dev] +opt-level = 1 +#incremental = false + +#[profile.dev.package."*"] +#opt-level = 3 + +[profile.wasm-dev] +inherits = "dev" + +[profile.server-dev] +inherits = "dev" + +[profile.android-dev] +inherits = "dev" + [workspace] diff --git a/Dioxus.toml b/Dioxus.toml index 9e879c8..3215732 100644 --- a/Dioxus.toml +++ b/Dioxus.toml @@ -1,16 +1,22 @@ -# cargo install dioxus-cli # --git https://github.com/Dioxuslabs/cli +# cargo binstall dioxus-cli # dx new foo +# https://github.com/DioxusLabs/dioxus/blob/main/packages/cli/assets/dioxus.toml [application] -name = "inperiod" # App (Project) Name -out_dir = "dist" # `build` & `serve` dist path -asset_dir = "assets" # resource (assets) file folder +name = "inperiod" # dioxus project name -# Dioxus App Default Platform: web, desktop, fullstack -default_platform = "web" +# you can also use `dx serve/build --platform XXX` to use other platform +default_platform = "web" # value: web | desktop | mobile + +#asset_dir = "assets" # resource (static) file folder +#out_dir = "dist" # Web `build` & `serve` dist path +#hot_reload = true # hot reload by default + +[web.wasm_opt] +level = "4" # The level wasm-opt should target. z is the smallest. 4 is the fastest. [web.app] -title = "Elements Periodic Table" # HTML title tag content +#title = "Elements Periodic Table" # HTML title tag content base_path = "inperiod" # "/" #index_on_404 = true @@ -20,9 +26,9 @@ reload_html = true # when watcher trigger, regenerate the `index.html` # which files or dirs will be watcher monitoring watch_path = ["src", "assets", "index.html", "tailwind_base.css", "tailwind.config.js"] -[web.resource] # include `assets` in web platform -style = ["tailwind.css"] # CSS style file -script = [] # Javascript code file +#[web.resource] # include `assets` in web platform, DEPRECATED +#style = ["assets/tailwind.css"] # CSS style file +#script = [] # Javascript code file [web.resource.dev] script = [] # Javascript code file, serve: [dev-server] only @@ -31,3 +37,15 @@ script = [] # Javascript code file, serve: [dev-server] only [bundle] icon = ["assets/ptable.svg"] +identifier = "io.github.mhfan" +publisher = "MeiHui FAN" +resources = ["public/*"] +category = "Utility" + +copyright = "All rights reserved. © 2024 M.H.Fan" +short_description = "Modern fancy interactive online periodic table of chemistry elements" + +#long_description = """ +#An amazing dioxus application. +#""" + diff --git a/README.md b/README.md index 5dc5e64..776f615 100644 --- a/README.md +++ b/README.md @@ -36,17 +36,20 @@ all kinds of information and data about the elements. 3. Run the following command in the root of the project to start the tailwind CSS compiler: ```bash -npx tailwindcss -i tailwind_base.css -o assets/tailwind.css --watch +npm install tailwindcss -D -g + +npx tailwindcss -i tailwind_base.css -o assets/tailwind.css -w #-m ``` -Launch the Dioxus Web/Desktop app: +Launch the Dioxus Web/Desktop/Mobile app: ```bash -dx serve #--verbose -dx serve --platform web +dx serve --platform web #--verbose dx serve --platform desktop #rm -rf dist -cd dist && cargo r --features desktop +#cd dist && cargo r -F desktop + +dx serve --platform android #ios ``` Open the browser to diff --git a/build.rs b/build.rs deleted file mode 100644 index 75a7a4f..0000000 --- a/build.rs +++ /dev/null @@ -1,27 +0,0 @@ - -// https://doc.rust-lang.org/stable/cargo/reference/build-scripts.html - -use std::process; -fn main() -> Result<(), Box> { - println!("cargo:rerun-if-changed=build.rs"); // XXX: prevent re-run indead - let (twcfg, twcss) = ("tailwind.config.js", "tailwind_base.css"); - println!("cargo:rerun-if-changed={twcfg}"); - println!("cargo:rerun-if-changed={twcss}"); - println!("cargo:rerun-if-changed=src"); - - if std::path::Path::new(twcss).exists() { return Ok(()) } -/* npm install -D tailwindcss; npm install tw-elements - sh -c "[ ! -d node_modules ] && npm i; npm run build_css" - - process::Command::new("npm").args(["run", "build_css"]).status()?; - - npx tailwindcss init # generate a mininum tailwind.config.js - npx tailwindcss -m -i tailwind_base.css -o assets/tailwind.css #-c tailwind.config.js #-w */ - - let minify = if let Ok("release") = - std::env::var("PROFILE").as_deref() { "-m" } else { "" }; - process::Command::new("npx").args(["tailwindcss", minify, //"-c", twcfg, - "-i", twcss, "-o", "assets/tailwind.css"]).status()?; - Ok(()) -} - diff --git a/index.html b/index.html index 5a39168..b49b192 100644 --- a/index.html +++ b/index.html @@ -4,42 +4,39 @@ - - {app_title} - - - - - - {style_include}{script_include} - - + {app_title} diff --git a/src/main.rs b/src/main.rs index 8443ebe..a6ed41d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,32 +1,36 @@ #![allow(non_snake_case)] use dioxus::prelude::*; -//use dioxus_logger::tracing; - -// URLs are relative to your Cargo.toml file -//const _TAILWIND_CSS: &str = manganis::mg!(file("assets/tailwind.css")); fn main() { - //dioxus_logger::init(tracing::Level::INFO).expect("failed to init logger"); - //tracing::info!("starting app"); - - #[cfg(not(feature = "desktop"))] launch(App); - #[cfg(feature = "desktop")] LaunchBuilder::desktop().with_cfg(dioxus::desktop::Config::new() - .with_window(dioxus::desktop::WindowBuilder::new().with_title(env!("CARGO_PKG_NAME"))) - //.with_custom_head("