Skip to content

Commit

Permalink
fix: variantPrefix undefined bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ecklf committed Dec 18, 2021
1 parent 0fac4e6 commit 8fb4876
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 38 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ demo
.github
.vscode
.gitignore
tsconfig.json
tsconfig.json
.scratch
8 changes: 4 additions & 4 deletions demo/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ export default function Home() {
<DropdownMenu.Root>
<DropdownMenu.Trigger
className={cx(
"rdx-state-open:bg-gray-800 group",
"radix-state-open:bg-gray-800 group",
"inline-flex justify-center w-full px-4 py-2 text-sm font-medium text-white bg-gray-600 rounded-md select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"
)}
>
Dropdown
<ChevronDownIcon
className={cx(
"group-rdx-state-open:rotate-180 transform duration-300 ease-in-out",
"group-radix-state-open:rotate-180 transform duration-300 ease-in-out",
"w-5 h-5 ml-2 -mr-1 text-white"
)}
aria-hidden="true"
Expand All @@ -129,7 +129,7 @@ export default function Home() {
align="end"
sideOffset={10}
className={cx(
" rdx-side-bottom:animate-slide-down rdx-side-top:animate-slide-up",
" radix-side-bottom:animate-slide-down radix-side-top:animate-slide-up",
"w-56 px-1 py-1 bg-white rounded-lg shadow-md"
)}
>
Expand Down Expand Up @@ -205,7 +205,7 @@ export default function Home() {
</DropdownMenu.TriggerItem>
<DropdownMenu.Content
className={cx(
"rdx-side-right:animate-scale-in origin-rdx-dropdown-menu",
"radix-side-right:animate-scale-in origin-radix-dropdown-menu",
"px-1 py-1 w-full bg-white text-sm rounded-md shadow-md"
)}
>
Expand Down
6 changes: 1 addition & 5 deletions demo/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ module.exports = {
variants: {
extend: {},
},
plugins: [
require("tailwindcss-radix")({
variantPrefix: "rdx",
}),
],
plugins: [require("tailwindcss-radix")()],
};
36 changes: 18 additions & 18 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
},
"homepage": "https://github.com/ecklf/tailwindcss-radix#readme",
"devDependencies": {
"@types/node": "^16.11.7",
"release-it": "^14.11.7",
"@types/node": "^17.0.0",
"release-it": "^14.11.8",
"rimraf": "^3.0.2",
"tailwindcss": "^3.0.2",
"typescript": "^4.4.4"
"tailwindcss": "^3.0.7",
"typescript": "^4.5.4"
},
"release-it": {
"git": {
Expand Down
16 changes: 10 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ const dataAttributes = {
};

export = plugin.withOptions((options) => ({ addUtilities, addVariant, e }) => {
if (options.variantPrefix === "" && options.skipAttributeNames === true) {
options = options
? options
: {
variantPrefix: "radix",
skipAttributeNames: false,
};

if (options?.variantPrefix === "" && options?.skipAttributeNames === true) {
throw new Error(
"tailwindcss-radix: Cannot use empty `variantPrefix` while `skipAttributeNames` is enabled"
);
}

const variantPrefix = options
? options.variantPrefix === ""
? ""
: `${options.variantPrefix}-`
: "radix-";
const variantPrefix =
options.variantPrefix === "" ? "" : `${options.variantPrefix}-`;

// Adds the following transform origin utilities
// `--radix-dropdown-menu-content-transform-origin`,
Expand Down

0 comments on commit 8fb4876

Please sign in to comment.