Support grouped tw

This commit is contained in:
Alex
2024-06-29 10:47:23 -04:00
parent 2a6df0dd4a
commit eaa888e920
7 changed files with 88 additions and 53 deletions

View File

@ -17,7 +17,10 @@ type GetClassName = (className: string) => string;
* Tagged template macro function for Tailwind classes
* @example "tw" => tw`p-2 text-center`
*/
export type TaggedTailwindFunction = (strings: TemplateStringsArray) => string;
export interface TailwindFunction {
(strings: TemplateStringsArray): string;
(group: { [modifier: string]: string }): string;
}
export interface TailwindPluginOptions {
/**
@ -53,13 +56,13 @@ export interface TailwindPluginOptions {
jsxAttributeAction?: "delete" | "preserve" | ["rename", string];
/**
* Tagged template macro function to use for Tailwind classes
* Template macro function to use for Tailwind classes
* @default "tw"
* @example
* declare const tw: TaggedTailwindFunction;
* declare const tw: TailwindFunction;
* "tw" => tw`p-2 text-center`
*/
taggedTemplateName?: string | undefined;
macroFunction?: string | undefined;
/**
* The prefix to use for the generated class names.
@ -98,7 +101,7 @@ export type ResolveTailwindOptions = SetRequired<
| "postCSSPlugins"
| "styleMap"
| "tailwindConfig"
| "taggedTemplateName"
| "macroFunction"
>;
/**
@ -130,7 +133,7 @@ export function getTailwindPlugins(options: TailwindPluginOptions) {
jsxAttributeName: "css",
postCSSPlugins: [],
styleMap: new Map(),
taggedTemplateName: undefined,
macroFunction: undefined,
tailwindConfig: {},
...options,
};