Skip to content

pantoken / packages/core/src / toStyleDictionary

函数: toStyleDictionary()

toStyleDictionary(tokens, mode?): Record<string, SdLeaf>

Beta

将解析后的 IR 组织为以令牌名称为键的扁平 Style Dictionary 令牌字典(其中前导 -- 已被移除)。将此传递给 tools/sd-config 以用于原生发射器。

参数

tokens

只读 Token[]

IR。

mode?

Mode = "light"

要解析为哪种颜色模式(默认 "light")。

返回值

Record<string, SdLeaf>

一个 Style Dictionary 字典对象。

示例

为原生谱系构建 IR

ts
import { buildTokens } from "@pantoken/core/build";
import { toStyleDictionary } from "@pantoken/core";

const dictionary = toStyleDictionary(buildTokens(), "light");
// → { "instui-color-background-base": { value: "#…", type: "color" }, … }
// keys drop the leading "--"; feed this to tools/sd-config.