Skip to content

pantoken / platforms/vanilla/src / toVanillaVariables

Ֆունկցիա: toVanillaVariables()

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

Փորձարկումային

Փոխարկել IR տոկենների ցուցակը դեպի Vanilla Foundation variables.json օբյեկտ.

Պարամետրեր

tokens

միայն կարդացվող Token[]

IR (օր. @pantoken/tokens-ից):

options?

ToVanillaOptions = {}

ToVanillaOptions.

Վերադարձվող արժեք

Record<string, unknown>

Ներդրված փոփոխականների օբյեկտը, որը պետք է PUT անել թեմայի variables.json ռեսուրսին.

Օրինակներ

IR-ը փոխարկել ներդրված փոփոխականների օբյեկտի

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

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

Մութ ռեժիմ

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

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