Skip to content

pantoken-root / packages/plugin-kit/src / definePlugin

دالة: definePlugin() ​

definePlugin(config): PantokenPlugin

Beta

إنشاء مكوّن إضافي لـ pantoken من الـ hooks الخاصة به. الناتج هو PantokenPlugin عادي مُعلَّم بال القدرات المستنتجة من الـ hooks التي قدمتها.

Parameters ​

config ​

PantokenPlugin

المكوّن الإضافي name بالإضافة إلى أيٍ من الـ hooks tokens/icons/css/rehype/native.

Returns ​

PantokenPlugin

مكوّن مُعلَّم من نوع PantokenPlugin.

Example ​

مكوّن موحّد للـ tokens و css

ts
import { capabilitiesOf, definePlugin } from "@pantoken/plugin-kit";

const brand = definePlugin({
  name: "@acme/brand",
  tokens: (ctx) => [
    ...ctx.tokens,
    ctx.define({ name: "--instui-brand", value: "var(--instui-color-background-brand)" }),
  ],
  css: () => ({ append: ":root { color-scheme: light dark; }" }),
});

capabilitiesOf(brand); // → ["tokens", "css"]