Skip to content

pantoken / design/swatches/src / toSwatches

دالة: toSwatches()

toSwatches(tokens, mode?): Swatch[]

تجريبي

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

المعلمات

tokens

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

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

mode?

Mode = "light"

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

القيم المرجعة

Swatch[]

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

أمثلة

تقليص 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");