Skip to content

pantoken / design/swatches/src / toSwatches

Fonksyon: toSwatches()

toSwatches(tokens, mode?): Swatch[]

Eksperimantal

Redui yon IR token an yon lis plat echantiyon koulè: rezoud referans yo, chwazi yon mòd, kenbe sèlman token ki gen valè yon koulè hex (ikon ak token ki pa koulè yo retire).

Paramèt

tokens

sèlman lekti Token[]

IR la (pa egzanp soti nan @pantoken/tokens).

mode?

Mode = "light"

Ki mòd koulè pou rezoud (default "light").

Retounen

Swatch[]

Lis echantiyon yo, nonmen pa token (san prefiks --instui-).

Egzanp

Redui token IR a echantiyon mòd limyè

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

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

Mòd fènwa

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

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