Skip to content

pantoken / formats/dtcg/src / toDtcg

Fonksiyon: toDtcg()

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

Beta

Bir IR token listesini DTCG belgesine dönüştür.

Parametreler

tokens

salt okunur Token[]

IR (ör. @pantoken/tokens'den).

mode?

Mode = "light"

Hangi renk modunun çözüleceği (varsayılan "light").

Döndürür

Record<string, DtcgNode>

İç içe geçmiş bir DTCG token ağacı.

Örnekler

Varsayılan IR'i bir DTCG ağacına dönüştür

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

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

Başka bir temanın koyu modunu çözümle

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

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