Skip to content

pantoken / design/swatches/src / toSwatches

Fall: toSwatches()

toSwatches(tokens, mode?): Swatch[]

Tilrauna

Draga token IR saman í flatt lista af litasýningum: leysa upp tilvísanir, velja stillingu, halda aðeins tokenum sem hafa gildi sem hex-litur (tákn og ekki-lita tokenar eru fjarlægðir).

Færibreytur

tokens

readonly Token[]

IR-ið (t.d. frá @pantoken/tokens).

mode?

Mode = "light"

Hvaða litastilling á að leysa (sjálfgefið "light").

Skilar

Swatch[]

Listi sýninga, nefndur eftir tokeni (án --instui- forskeytis).

Dæmi

Draga token IR saman í sýningar fyrir ljósan ham

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

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

Dökkur hamur

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

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