Skip to content

pantoken / packages/core/src / toStyleDictionary

函式: toStyleDictionary()

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

Beta(測試)

將已解析的 IR 形塑為以 token 名稱為鍵的平面 Style Dictionary 代幣字典(會移除開頭的 --)。 將此輸出提供給 tools/sd-config 以供原生 emitters 使用。

參數

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.