Skip to content

pantoken / design/swatches/src / toSwatches

Feidhm: toSwatches()

toSwatches(tokens, mode?): Swatch[]

Turgnamhach

Laghdú IR token go liosta chothrománach de shamhailí datha: réitigh tagairtí, roghnaigh mód, agus coinnigh amháin tokena a bhfuil luach heicsdheachanta datha acu (bainfear íomhánna agus tokena neamh-datha).

Paraiméadair

tokens

neamh-inathraitheach Token[]

An IR (m.sh. ó @pantoken/tokens).

mode?

Mode = "light"

Cén mód datha le réiteach (réamhshocraithe "light").

Tuairisceáin

Swatch[]

An liosta samhlacha, ainmnithe de réir an token (gan an réamhriail --instui-).

Samplaí

Laghdú IR an token go samhlacha mhóide éadrom

ts
import { toSwatches } from "@pantoken/swatches";
import { tokens } from "@pantoken/tokens";

const swatches = toSwatches(tokens); // [{ name: "color-background-brand", hex: "#…" }, …]

Mód dorcha

ts
import { toSwatches } from "@pantoken/swatches";
import { byTheme } from "@pantoken/tokens";

const swatches = toSwatches(byTheme("canvas"), "dark");