Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Funktion: toVanillaVariables()

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

Experimentell

Konvertera en IR-tokenlista till ett Vanilla Foundation variables.json-objekt.

Parametrar

tokens

skrivskyddad Token[]

IR:n (t.ex. från @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Returnerar

Record<string, unknown>

Det nästlade variabelobjektet som ska PUT:as till tematets variables.json-resurs.

Exempel

Konvertera en IR till det nästlade variabelobjektet

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

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

Mörkt läge

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

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