Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Funksjon: toVanillaVariables()

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

Eksperimentell

Konverter en IR-tokenliste til et Vanilla Foundation variables.json-objekt.

Parametere

tokens

skrivbeskyttet Token[]

IR-en (f.eks. fra @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Returnerer

Record<string, unknown>

Det nestede variabelobjektet som skal PUTTES til temaets variables.json-asset.

Eksempler

Konverter en IR til det nestede variabelobjektet

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

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

Mørk modus

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

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