Skip to content

pantoken / packages/core/src / toStyleDictionary

Funksjon: toStyleDictionary()

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

Beta

Forme den løyste IR-en som ei flat Style Dictionary-tokenordbok med nøkkel per tokennamn (med den leiande -- fjerna). Send dette til tools/sd-config for dei native emitterane.

Parametrar

tokens

skrivbeskytta Token[]

IR-en.

mode?

Mode = "light"

Kva fargemodus som skal løysast (standard "light").

Returnerer

Record<string, SdLeaf>

Eit Style Dictionary-ordbokobjekt.

Døme

Form IR-en for den native linja

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.