Skip to content

pantoken-root / design/swatches/src / toSwatches

Fonksiyon: toSwatches() ​

toSwatches(tokens, mode?): Swatch[]

Deneysel

Bir token IR'sini düz bir renk örnekleri listesine indirger: referansları çözer, bir mod seçer, yalnızca değeri hex renk olan tokenları tutar (ikonlar ve renk olmayan tokenlar atılır).

Parametreler ​

tokens ​

salt okunur Token[]

IR (ör. @pantoken/tokens'den).

mode? ​

Mode = "light"

Hangi renk modunun çözüleceği (varsayılan "light").

Döndürür ​

Swatch[]

Token adıyla adlandırılmış örnek listesi ( --instui- öneki olmadan).

Örnekler ​

Token IR'sini açık mod örneklerine indirger

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

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

Karanlık mod

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

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