Skip to content

pantoken / packages/core/src / toStyleDictionary

Fonction: toStyleDictionary()

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

Bêta

Façonnez l'IR résolu en un dictionnaire plat de tokens Style Dictionary indexé par nom de token (avec le préfixe -- supprimé). Fournissez-le à tools/sd-config pour les émetteurs natifs.

Paramètres

tokens

en lecture seule Token[]

L'IR.

mode?

Mode = "light"

Quel mode de couleur résoudre (par défaut "light").

Renvoie

Record<string, SdLeaf>

Un objet dictionnaire Style Dictionary.

Exemple

Façonner l'IR pour la lignée native

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.