0.1.1 • Published 3d ago
@pantoken/android
Licence
MIT
Version
0.1.1
Deps
4
Size
8 kB
Vulns
0
Weekly
0
@pantoken/android
Emit Instructure design tokens as Android resource XML. It flattens the token IR to concrete,
single-mode values and writes res/values/colors.xml and res/values/dimens.xml, with the Android
Style Dictionary transforms applied (#aarrggbb colours, dp/sp dimensions).
Install
npm i @pantoken/android
Usage
import { generateAndroid } from "@pantoken/android";
const [colors, dimens] = await generateAndroid({
outDir: "./app/src/main",
theme: "rebrand",
mode: "light",
icons: ["add", "check"], // optional: also emit res/drawable/ic_*.xml VectorDrawables
});
Or via the CLI, straight into a consumer repo:
pantoken generate android --out ./app/src/main
pantoken generate android --out ./app/src/main --theme canvas --icons add,check
Output
res/values/colors.xml— colour tokens as<color name="…">#aarrggbb</color>.res/values/dimens.xml— dimension tokens as<dimen name="…">…dp</dimen>.res/drawable/ic_<name>.xml— one VectorDrawable per requested icon (only wheniconsis set).
Reference the values from layouts and themes as @color/… and @dimen/…. Use this package for
Android View-system (XML) UIs; for Jetpack Compose, use @pantoken/compose.
API
generateAndroid(options): Promise<string[]>— emit XML for a named theme (from the vendored@pantoken/tokensIR). Returns the written file paths.toAndroid(tokens, options): Promise<string[]>— same, but for an explicit token IR you pass in. Returns the written file paths.GenerateAndroidOptions— theoutDir,theme,mode, andiconsoptions both take.
Related
- Pairs with
@pantoken/composefor the Jetpack Compose (Kotlin) counterpart. - Uses
@pantoken/tokensfor the vendored token IR and@pantoken/sd-configfor the Style Dictionary platforms.
License
MIT