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