Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Functie: toVanillaVariables()

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

Experimenteel

Converteer een IR-tokenlijst naar een Vanilla Foundation variables.json object.

Parameters

tokens

alleen-lezen Token[]

De IR (bijvoorbeeld van @pantoken/tokens).

options?

ToVanillaOptions = {}

ToVanillaOptions.

Retourneert

Record<string, unknown>

Het geneste variables-object dat naar het thema's variables.json-asset moet worden PUT.

Voorbeelden

Converteer een IR naar het geneste variables-object

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

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

Donkere modus

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

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