Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Fonction: toVanillaVariables()

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

Expérimental

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

Paramètres

tokens

lecture seule Token[]

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

options?

ToVanillaOptions = {}

ToVanillaOptions.

Renvoie

Record<string, unknown>

L'objet de variables imbriquées à envoyer via PUT dans la ressource variables.json du thème.

Exemples

Convertir un IR en l'objet de variables imbriquées

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" });