Skip to content

pantoken / packages/core/src / toStyleDictionary

関数: toStyleDictionary()

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

ベータ

解決された 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.