Skip to content

pantoken-root / design/swatches/src / toSwatches

دالة: toSwatches() ​

toSwatches(tokens, mode?): Swatch[]

Experimental

تقليص IR التوكن إلى قائمة مسطحة من عينات الألوان: حل المراجع، اختيار وضع، والاحتفاظ فقط بالرموز التي قيمتها لون بنظام هيكس (يتم إسقاط الأيقونات والرموز غير المتعلقة بالألوان).

Parameters ​

tokens ​

للقراءة فقط Token[]

IR (مثلاً من @pantoken/tokens).

mode? ​

Mode = "light"

أي وضع لون ليتم حله (الافتراضي "light").

Returns ​

Swatch[]

قائمة العينات، مسماة حسب التوكن (بدون بادئة --instui-).

Examples ​

تقليص IR التوكن إلى عينات وضع الإضاءة

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

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

الوضع الداكن

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

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