Skip to content

pantoken-root / design/swatches/src / toSwatches

Függvény: toSwatches() ​

toSwatches(tokens, mode?): Swatch[]

Kísérleti

Csökkentse az IR tokent egy lapos szín mintalista: oldja fel az utalásokat, válasszon egy módot, tartsa csak azokat a tokenokat, amelyek értéke hex szín (az ikonok és nem szín tokenok el vannak vetítve).

Paraméterek ​

tokens ​

csak olvasható Token[]

Az IR (pl. @pantoken/tokens-ből).

mode? ​

Mode = "light"

Melyik szín mód oldja fel (alapértelmezett "light").

Visszatérési érték ​

Swatch[]

A mintalista, token után elnevezve (az --instui- előtag nélkül).

Példák ​

Csökkentse az IR tokent fény mód mintákra

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

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

Sötét mód

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

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