Skip to content

Commit

Permalink
expose all plugin internals
Browse files Browse the repository at this point in the history
  • Loading branch information
SutuSebastian committed Oct 15, 2024
1 parent 21256d3 commit d4096c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
10 changes: 5 additions & 5 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
"import": "./dist/esm/hooks/*/index.mjs",
"require": "./dist/cjs/hooks/*/index.cjs"
},
"./tailwind": {
"types": "./dist/types/tailwind/index.d.ts",
"import": "./dist/esm/tailwind/index.mjs",
"require": "./dist/cjs/tailwind/index.cjs"
},
"./tailwind/*": {
"types": "./dist/types/tailwind/*.d.ts",
"import": "./dist/esm/tailwind/*.mjs",
"require": "./dist/cjs/tailwind/*.cjs"
},
"./tailwind": {
"types": "./dist/types/tailwind/index.d.ts",
"import": "./dist/esm/tailwind/index.mjs",
"require": "./dist/cjs/tailwind/index.cjs"
},
"./package.json": "./package.json"
},
"main": "dist/cjs/index.cjs",
Expand Down
18 changes: 18 additions & 0 deletions packages/ui/src/tailwind/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { theme } from "./theme";
import type { PluginOptions } from "./types";
import { resolveClassList, resolvePrefix } from "./utils";

import type { Config } from "tailwindcss";

export function getConfig(options: PluginOptions = {}): Partial<Config> {
return {
safelist: getSafelist(options),
theme: {
extend: theme,
},
};
}

export function getSafelist(options: PluginOptions = {}): Config["safelist"] {
return resolvePrefix(resolveClassList(options.components), options.prefix, options.separator);
}
10 changes: 2 additions & 8 deletions packages/ui/src/tailwind/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import plugin from "tailwindcss/plugin";
import { theme } from "./theme";
import { getConfig } from "./config";
import { PluginOptions } from "./types";
import { resolveClassList, resolvePrefix } from "./utils";

export default plugin.withOptions<PluginOptions>(
// plugin
() => () => {},
// config
({ prefix, separator, components } = {}) => ({
safelist: resolvePrefix(resolveClassList(components), prefix, separator),
theme: {
extend: theme,
},
}),
(options) => getConfig(options),
);

0 comments on commit d4096c6

Please sign in to comment.