Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Function: toVanillaVariables()

toVanillaVariables(tokens, options?): Record<string, unknown>

Experimental

Convert an IR token list into a Vanilla Foundation variables.json object.

Parameters

tokens

readonly Token[]

The IR (e.g. from @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Returns

Record<string, unknown>

The nested variables object to PUT to the theme's variables.json asset.

Examples

Convert an IR to the nested variables object

ts
import { toVanillaVariables } from "@pantoken/vanilla";
import { byTheme } from "@pantoken/tokens";

const vars = toVanillaVariables(byTheme("rebrand"));
// { global: { mainColors: { primary: "#…" }, … }, titleBar: { … }, button: { … } }

Dark mode

ts
import { toVanillaVariables } from "@pantoken/vanilla";
import { byTheme } from "@pantoken/tokens";

const vars = toVanillaVariables(byTheme("canvas"), { mode: "dark" });