Skip to content

pantoken-root / platforms/vanilla/src / toVanillaVariables

Fonction: toVanillaVariables() ​

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

Expérimental

Convertir une liste de tokens IR en un objet Vanilla Foundation variables.json.

Paramètres ​

tokens ​

lecture seule Token[]

L'IR (p. ex. provenant de @pantoken/tokens).

options? ​

ToVanillaOptions = {}

ToVanillaOptions.

Retourne ​

Record<string, unknown>

L'objet de variables imbriqué à PUT vers l'asset variables.json du thème.

Exemples ​

Convertir un IR en l'objet de variables imbriqué

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

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

Mode sombre

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

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