Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Funktion: toVanillaVariables()

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

Eksperimentel

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

Parametre

tokens

skrivbeskyttet Token[]

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

options?

ToVanillaOptions = {}

ToVanillaOptions.

Returnerer

Record<string, unknown>

Det indlejrede variable-objekt at PUT'e til temets variables.json aktiv.

Eksempler

Konverter en IR til det indlejrede variable-objekt

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

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

Mørk tilstand

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

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