Skip to content

pantoken / formats/dtcg/src / toDtcg

Swyddogaeth: toDtcg()

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

Bêta

Trosi rhestr o tokenau IR yn ddogfen DTCG.

Paramedrau

tokens

darllen-yn-unig Token[]

Yr IR (er enghraifft o @pantoken/tokens).

mode?

Mode = "light"

Pa fodd lliw i'w ddatrys (diofyn "light").

Yn dychwelyd

Record<string, DtcgNode>

Coeden tokenau DTCG wedi'i nythu.

Enghreifftiau

Trosi'r IR diofyn i goeden DTCG

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

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

Datrys modd tywyll ar gyfer thema arall

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

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