Skip to content

Commit

Permalink
fix: fix className type
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Dec 25, 2023
1 parent a5bd67b commit 0383b5d
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"devDependencies": {
"@ampproject/filesize": "^4.3.0",
"@radix-ui/react-accordion": "^1.1.2",
"@swc/core": "^1.3.101",
"@testing-library/react": "^14.1.2",
"@types/react": "^18.2.42",
Expand Down
216 changes: 214 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Button as AriaButton,
ButtonProps as AriaButtonProps,
} from "react-aria-components";
import * as AccordionPrimitive from "@radix-ui/react-accordion";

describe("twc", () => {
beforeEach(cleanup);
Expand Down Expand Up @@ -226,4 +227,11 @@ describe("twc", () => {
expect(button.classList.contains("bg-gray-700")).toBe(true);
expect(button.classList.contains("opacity-35")).toBe(true);
});

test("props are correctly typed", () => {
const Accordion = twc(AccordionPrimitive.Root)<
React.ComponentProps<typeof AccordionPrimitive.Root>
>`py-2`;
render(<Accordion type="single" collapsible></Accordion>);
});
});
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function filterProps(

type Attributes = Record<string, any> | ((props: any) => Record<string, any>);

export const createTwc = <TCompose extends AbstractCompose>(
export const createTwc = <TCompose extends AbstractCompose = typeof clsx>(
config: Config<TCompose> = {},
) => {
const compose = config.compose || clsx;
Expand Down

0 comments on commit 0383b5d

Please sign in to comment.