Skip to content

pantoken / formats/dtcg/src / toDtcg

Funksjon: toDtcg()

toDtcg(tokens, mode?): Record<string, DtcgNode>

Beta

Konverter ei IR-tokenliste til eit DTCG-dokument.

Parametrar

tokens

skrivbeskytta Token[]

IR-en (til dømes frå @pantoken/tokens).

mode?

Mode = "light"

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

Returnerer

Record<string, DtcgNode>

Eit nestet DTCG-token-tre.

Døme

Konverter standard-IR-en til eit DTCG-tre

ts
import { toDtcg } from "@pantoken/dtcg";
import { tokens } from "@pantoken/tokens";

const doc = toDtcg(tokens);
// doc.color.background.brand === { $value: "#0374b5", $type: "color" }

Løys mørk modus for eit anna tema

ts
import { toDtcg } from "@pantoken/dtcg";
import { byTheme } from "@pantoken/tokens";

toDtcg(byTheme("canvas"), "dark");