diff --git a/.github/workflows/design-tokens.yml b/.github/workflows/design-tokens.yml new file mode 100644 index 0000000..80c61b7 --- /dev/null +++ b/.github/workflows/design-tokens.yml @@ -0,0 +1,54 @@ +# design/tokens.json is the only source of the website's CSS custom +# properties (design/README.md). A pull request or merge that touches it, +# the generator or the generated file checks that site/tokens.css is current +# and that every contrast pair passes (or is marked pending), and runs the +# generator's own checks. The generator is a small crate with no +# dependencies, so this needs only Rust: no container or apt packages. +name: Design tokens + +on: + push: + branches: [main] + paths: + - design/** + - site/tokens.css + - .github/workflows/design-tokens.yml + pull_request: + paths: + - design/** + - site/tokens.css + - .github/workflows/design-tokens.yml + workflow_dispatch: + +# A PR's runs share a group, so a new push cancels the one it supersedes. +# Each push to main has a group of its own, so every commit gets a result. +concurrency: + group: design-tokens-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +# The job runs pull request code: its token reads only. +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + name: design tokens + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + # Fork code runs after this, so the token isn't left in git's config. + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + # The generator builds into target/design-build (gitignored), apart + # from the app's builds. + - run: cargo fmt --manifest-path design/Cargo.toml --check + - run: cargo clippy --manifest-path design/Cargo.toml --target-dir target/design-build --all-targets --locked -- -D warnings + - run: cargo test --manifest-path design/Cargo.toml --target-dir target/design-build --locked + - run: design/build --check diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..bc5893f --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,43 @@ +# Publishes site/ to GitHub Pages (aliasproject.github.io/alias-calc) when +# it changes on main. The site is static files with no build step; its +# tokens.css comes from design/build, and the design tokens workflow checks +# that it's up to date. +name: Pages + +on: + push: + branches: [main] + paths: + - "site/**" + - ".github/workflows/pages.yml" + workflow_dispatch: + +# One deployment at a time; a newer push waits rather than cancelling one +# that's halfway out. +concurrency: + group: pages + cancel-in-progress: false + +permissions: + contents: read + +jobs: + deploy: + name: Publish the website + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@v4 + - uses: actions/configure-pages@v6 + - uses: actions/upload-pages-artifact@v5 + with: + path: site + - id: deployment + uses: actions/deploy-pages@v5 diff --git a/README.md b/README.md index 70b5160..17bbcbb 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,12 @@ Hyprland pings every window every 1.5 s to check that it still responds (`xdg_wm [trace] 0.608 ms frame committed (320x480 px) ``` +## Website + +The website, https://aliasproject.github.io/alias-calc/, is the static files in `site/`, with no build step. `.github/workflows/pages.yml` publishes it when `site/` changes on main. To preview it, serve the folder (`python3 -m http.server -d site`) and open http://localhost:8000. + +Its design values come from `site/tokens.css`, which `design/build` generates from `design/tokens.json` (`design/README.md`). Change a value there, never in `style.css`. The benchmark figures on the page come from one `bench/run --bin /usr/bin/alias-calc` table; when they change, replace all of them from a new run. + ## Licence -MIT (`LICENSE`). The JetBrains Mono subsets compiled into the binary are under the SIL Open Font License 1.1 (`fonts/OFL.txt`). +MIT (`LICENSE`). The JetBrains Mono subsets compiled into the binary, and the full fonts the website serves (`site/fonts/`), are under the SIL Open Font License 1.1 (`fonts/OFL.txt`, `site/fonts/OFL.txt`). diff --git a/design/Cargo.lock b/design/Cargo.lock new file mode 100644 index 0000000..affbf4f --- /dev/null +++ b/design/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "design-build" +version = "2.1.0" diff --git a/design/Cargo.toml b/design/Cargo.toml new file mode 100644 index 0000000..7983660 --- /dev/null +++ b/design/Cargo.toml @@ -0,0 +1,18 @@ +# design/build: generates the themes from design/tokens.json and checks +# them (design/README.md). Its own workspace, with no dependencies, so the +# design/ folder can be copied unchanged into any app (Nitrate, Alias Notes, +# Daybreak, bosun, Alias Calc): everything app-specific is in tokens.json. +[package] +name = "design-build" +version = "2.1.0" +edition = "2021" +license = "MIT" +publish = false + +[[bin]] +name = "design-build" +path = "src/main.rs" + +[dependencies] + +[workspace] diff --git a/design/README.md b/design/README.md new file mode 100644 index 0000000..4fdae6f --- /dev/null +++ b/design/README.md @@ -0,0 +1,85 @@ +# Design tokens + +`tokens.json` is the source for every Alias Calc design value (the app's Rust still repeats them as literals: see below): the colours of its one theme, JetBrains Mono and the type scales (the app's and the website's), and the spacing, radii, fixed sizes, motion and multiples the window and the website use. Each value has a note on where it's used. It uses the Design System artifact format: lists of `{name, value, usage}`, with colours given per theme. + +**One theme.** Alias Calc follows the installed aliasOS theme at run time (`colors.toml`), and derives its key fills and label colours from it (`src/ui.rs`). The colours here are its built-in palette, the aliasOS default (`aliasos`), which the app falls back to (`Palette::default`) and which the website is drawn in. The contrast list checks that palette; an installed theme is made readable where it's drawn, by `readable()` in `src/ui.rs`, since this file can't check a theme it hasn't seen. + +`build` turns it into the website's CSS. The generated file starts with a "Generated from design/tokens.json by design/build (design-gen 2.1.0) — don't edit" header: + +| File | What it is | +|---|---| +| `site/tokens.css` | CSS custom properties on `:root`, one `--` per token: colours (`--background`), `--font-mono`, each type style's `--