Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Funció: toVanillaVariables()

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

Experimental

Convertir una llista de tokens IR en un objecte variables.json de Vanilla Foundation.

Paràmetres

tokens

només de lectura Token[]

La IR (p. ex. de @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Retorna

Record<string, unknown>

L'objecte de variables imbricades per PUT a l'actiu variables.json del tema.

Exemples

Convertir un IR a l'objecte de variables imbricades

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

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

Mode fosc

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

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