@pantoken/rust
v0.1.19
Published
Emit Instructure design tokens as Rust constants for egui (Color32) or iced (Color).
Readme
@pantoken/rust
Emit Instructure design tokens as Rust constants for the two mainstream native Rust GUIs. Colours
become the framework's colour type; dimensions become f32 (px). Icons and non-colour/dimension
tokens are skipped.
| Format | Type | Framework |
| ------ | --------- | ------------------------------------- |
| egui | Color32 | egui |
| iced | Color | iced |
Install
npm i @pantoken/rustUsage
import { writeFileSync } from "node:fs";
import { generateRust } from "@pantoken/rust";
writeFileSync("tokens.rs", generateRust({ format: "egui", theme: "rebrand" }));Or via the CLI:
pantoken generate rust --format egui --out tokens.rs
pantoken generate rust --format iced --out src/tokens.rsOutput
A single Rust module of pub consts — one per colour and dimension token, SCREAMING_SNAKE_CASE,
prefixed with use egui::Color32; or use iced::Color; to match the chosen format. Web-rendered
Rust UIs (Tauri, Dioxus-web, Leptos, Yew) render to HTML/CSS — use @pantoken/css there, not this
package.
API
generateRust(options?): string— emit Rust for a named theme (from the vendored@pantoken/tokensIR). Returns the source string.toRust(tokens, options?): string— same, but for an explicit token IR.RustFormat—"egui" | "iced".RustOptions— theformatandmodeoptions (generateRustalso takestheme).
Related
- Uses
@pantoken/tokensfor the vendored token IR and@pantoken/corefor the flattened Style Dictionary values.
License
MIT
