Skip to content

pantoken / packages/core/src / toStyleDictionary

Funksjon: toStyleDictionary()

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

Beta

Formater den løste IR-en som et flatt Style Dictionary-tokenordbok nøkkelt på token-navn (med den ledende -- fjernet). Send dette til tools/sd-config for de native emitterne.

Parametere

tokens

readonly Token[]

IR-en.

mode?

Mode = "light"

Hvilken fargemodus som skal løses (standard "light").

Returnerer

Record<string, SdLeaf>

Et Style Dictionary-ordbokobjekt.

Eksempel

Formater IR-en for den native avstamningen

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.