Skip to content

pantoken / design/swatches/src / toSwatches

Swyddogaeth: toSwatches()

toSwatches(tokens, mode?): Swatch[]

Arbrofol

Lleihau IR tocyn i restr syth o swatches lliw: datrys cyfeiriadau, dewis modd, a chadw dim ond tocynnau y mae eu gwerth yn liw hecs (caiff eiconau a thocynnau nad ydynt yn lliw eu tynnu).

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

Swatch[]

Y rhestr swatch, wedi'i enwi gan docyn (heb y rhagddodiad --instui-).

Enghreifftiau

Lleihau IR tocyn i swatches modd golau

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

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

Modd tywyll

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

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