Skip to content

pantoken / design/swatches/src / toSwatches

Funkcija: toSwatches()

toSwatches(tokens, mode?): Swatch[]

Eksperimentalno

Zmanjšaj token IR na plosko listo barvnih vzorcev: razreši reference, izberi način, zadrži samo tokene, katerih vrednost je heksadecimalna barva (ikone in tokeni, ki niso barvne vrednosti, so izpuščeni).

Parametri

tokens

readonly Token[]

IR (npr. iz @pantoken/tokens).

mode?

Mode = "light"

Kateri barvni način razrešiti (privzeto "light").

Vrne

Swatch[]

Seznam vzorcev, poimenovan po tokenu (brez predpone --instui-).

Primeri

Zmanjšaj token IR na vzorce v svetlem načinu

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

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

Temni način

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

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