Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Funksjon: toVanillaVariables()

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

Eksperimentell

Konverter ei IR-tokenliste til eit Vanilla Foundation variables.json-objekt.

Parametrar

tokens

skrivbeskytta Token[]

IR-en (til dømes frå @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Returnerer

Record<string, unknown>

Det nestede variables-objektet som skal PUTtast til temaet sitt variables.json-asset.

Døme

Konverter ein IR til det nestede variables-objektet

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