tailwindcss-radix
Advanced tools
Comparing version 2.8.0 to 2.9.0
@@ -1,5 +0,11 @@ | ||
/// <reference types="./types/plugin" /> | ||
interface Options { | ||
variantPrefix?: string; | ||
} | ||
declare const _default: { | ||
handler: (helpers: Helpers) => void; | ||
(options: Options): { | ||
handler: import("tailwindcss/types/config").PluginCreator; | ||
config?: Partial<import("tailwindcss/types/config").Config> | undefined; | ||
}; | ||
__isOptionsFunction: true; | ||
}; | ||
export = _default; |
@@ -6,26 +6,2 @@ "use strict"; | ||
const plugin_1 = __importDefault(require("tailwindcss/plugin")); | ||
const dataAttributes = ["disabled", "highlighted", "placeholder"]; | ||
const namedDataAttributes = { | ||
align: ["center", "end", "start"], | ||
state: [ | ||
"active", | ||
"checked", | ||
"closed", | ||
"delayed-open", | ||
"hidden", | ||
"inactive", | ||
"indeterminate", | ||
"instant-open", | ||
"off", | ||
"on", | ||
"open", | ||
"unchecked", | ||
"visible", | ||
], | ||
side: ["bottom", "left", "right", "top"], | ||
orientation: ["horizontal", "vertical"], | ||
motion: ["from-end", "from-start", "to-end", "to-start"], | ||
swipe: ["cancel", "end", "move", "start"], | ||
"swipe-direction": ["down", "left", "right", "up"], | ||
}; | ||
module.exports = plugin_1.default.withOptions((options) => ({ addUtilities, addVariant, e }) => { | ||
@@ -42,3 +18,41 @@ options = options | ||
: `${options.variantPrefix}-`; | ||
const transformOrigins = [ | ||
["disabled", "highlighted", "placeholder"].forEach((attributeValue) => { | ||
let variantName = `${variantPrefix}${attributeValue}`; | ||
let selector = `data-${attributeValue}`; | ||
addVariant(variantName, `&[${selector}]`); | ||
addVariant(`group-${variantName}`, `:merge(.group)[${selector}] &`); | ||
addVariant(`peer-${variantName}`, `:merge(.peer)[${selector}] ~ &`); | ||
}); | ||
Object.entries({ | ||
align: ["center", "end", "start"], | ||
state: [ | ||
"active", | ||
"checked", | ||
"closed", | ||
"delayed-open", | ||
"hidden", | ||
"inactive", | ||
"indeterminate", | ||
"instant-open", | ||
"off", | ||
"on", | ||
"open", | ||
"unchecked", | ||
"visible", | ||
], | ||
side: ["bottom", "left", "right", "top"], | ||
orientation: ["horizontal", "vertical"], | ||
motion: ["from-end", "from-start", "to-end", "to-start"], | ||
swipe: ["cancel", "end", "move", "start"], | ||
"swipe-direction": ["down", "left", "right", "up"], | ||
}).forEach(([attributeName, attributeValues]) => { | ||
attributeValues.forEach((attributeValue) => { | ||
let variantName = `${variantPrefix}${attributeName}-${attributeValue}`; | ||
let selector = `data-${attributeName}="${attributeValue}"`; | ||
addVariant(variantName, `&[${selector}]`); | ||
addVariant(`group-${variantName}`, `:merge(.group)[${selector}] &`); | ||
addVariant(`peer-${variantName}`, `:merge(.peer)[${selector}] ~ &`); | ||
}); | ||
}); | ||
[ | ||
"context-menu", | ||
@@ -51,4 +65,3 @@ "dropdown-menu", | ||
"tooltip", | ||
]; | ||
transformOrigins.forEach((transformOrigin) => { | ||
].forEach((transformOrigin) => { | ||
addUtilities({ | ||
@@ -60,48 +73,7 @@ [`.origin-${variantPrefix}${transformOrigin}`]: { | ||
}); | ||
dataAttributes.forEach((attributeValue) => { | ||
let variantName = `${variantPrefix}${attributeValue}`; | ||
let selector = `data-${attributeValue}`; | ||
addVariant(`${variantName}`, ({ modifySelectors, separator }) => { | ||
modifySelectors(({ className }) => { | ||
return `.${e(`${variantName}${separator}${className}`)}[${selector}]`; | ||
}); | ||
}); | ||
addVariant(`group-${variantName}`, ({ modifySelectors, separator }) => { | ||
modifySelectors(({ className }) => { | ||
return `.group[${selector}] .${e(`group-${variantName}${separator}${className}`)}`; | ||
}); | ||
}); | ||
addVariant(`peer-${variantName}`, ({ modifySelectors, separator }) => { | ||
modifySelectors(({ className }) => { | ||
return `.peer[${selector}] ~ .${e(`peer-${variantName}${separator}${className}`)}`; | ||
}); | ||
}); | ||
}); | ||
Object.keys(namedDataAttributes).forEach((attributeName) => { | ||
namedDataAttributes[attributeName].forEach((attributeValue) => { | ||
let variantName = `${variantPrefix}${attributeName}-${attributeValue}`; | ||
let selector = `data-${attributeName}="${attributeValue}"`; | ||
addVariant(`${variantName}`, ({ modifySelectors, separator }) => { | ||
modifySelectors(({ className }) => { | ||
return `.${e(`${variantName}${separator}${className}`)}[${selector}]`; | ||
}); | ||
}); | ||
addVariant(`group-${variantName}`, ({ modifySelectors, separator }) => { | ||
modifySelectors(({ className }) => { | ||
return `.group[${selector}] .${e(`group-${variantName}${separator}${className}`)}`; | ||
}); | ||
}); | ||
addVariant(`peer-${variantName}`, ({ modifySelectors, separator }) => { | ||
modifySelectors(({ className }) => { | ||
return `.peer[${selector}] ~ .${e(`peer-${variantName}${separator}${className}`)}`; | ||
}); | ||
}); | ||
}); | ||
}); | ||
const dimensionAttributes = [ | ||
[ | ||
"accordion-content", | ||
"collapsible-content", | ||
"navigation-menu-viewport", | ||
]; | ||
dimensionAttributes.forEach((component) => { | ||
].forEach((component) => { | ||
addUtilities({ | ||
@@ -118,3 +90,3 @@ [`.w-${variantPrefix}${component}`]: { | ||
}); | ||
const sizeConstraintsAttributes = [ | ||
[ | ||
"context-menu", | ||
@@ -127,6 +99,5 @@ "dropdown-menu", | ||
"tooltip", | ||
]; | ||
sizeConstraintsAttributes.forEach((component) => { | ||
].forEach((component) => { | ||
addUtilities({ | ||
[`.w-${variantPrefix}${component}-content-available-width`]: { | ||
[`.w-${variantPrefix}${component}`]: { | ||
width: `var(--radix-${component}-content-available-width)`, | ||
@@ -161,4 +132,3 @@ }, | ||
}); | ||
const tooltipAttributes = ["toast-swipe-end", "toast-swipe-move"]; | ||
tooltipAttributes.forEach((component) => { | ||
["toast-swipe-end", "toast-swipe-move"].forEach((component) => { | ||
addUtilities({ | ||
@@ -165,0 +135,0 @@ [`.translate-x-${variantPrefix}${component}-x`]: { |
{ | ||
"name": "tailwindcss-radix", | ||
"version": "2.8.0", | ||
"version": "2.9.0", | ||
"description": "Utilities and variants for styling Radix state", | ||
@@ -9,4 +9,4 @@ "main": "dist/index.js", | ||
"lint": "prettier --write .", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rimraf dist/ && tsc --removeComments && cp -R types dist/", | ||
"test": "vitest", | ||
"build": "rimraf dist/ && tsc --removeComments", | ||
"release": "npm run build && release-it" | ||
@@ -35,9 +35,11 @@ }, | ||
"devDependencies": { | ||
"@types/node": "^18.0.6", | ||
"husky": "^8.0.1", | ||
"prettier": "2.7.1", | ||
"release-it": "^15.1.3", | ||
"rimraf": "^3.0.2", | ||
"tailwindcss": "^3.1.6", | ||
"typescript": "^4.7.4" | ||
"@types/node": "^20.11.30", | ||
"husky": "^9.0.11", | ||
"postcss": "^8.4.38", | ||
"prettier": "3.2.5", | ||
"release-it": "^17.1.1", | ||
"rimraf": "^5.0.5", | ||
"tailwindcss": "^3.4.1", | ||
"typescript": "^5.4.3", | ||
"vitest": "^1.4.0" | ||
}, | ||
@@ -44,0 +46,0 @@ "release-it": { |
@@ -22,16 +22,10 @@ <p align="center"> | ||
TL;DR it's [@headlessui-tailwindcss](https://github.com/tailwindlabs/headlessui/tree/main/packages/@headlessui-tailwindcss) for Radix | ||
## Installation | ||
```sh | ||
npm i tailwindcss-radix | ||
pnpm add tailwindcss-radix | ||
``` | ||
```sh | ||
yarn add tailwindcss-radix | ||
``` | ||
## Migrate from v1 | ||
To prevent a possible future name clashing the `skipAttributeNames` option has been removed. In case you used this option, please update the class names accordingly. | ||
## Demo | ||
@@ -286,1 +280,5 @@ | ||
[![npm downloads](https://img.shields.io/npm/dm/tailwindcss-radix.svg)](https://www.npmjs.com/package/tailwindcss-radix) --> | ||
## Migrate from v1 | ||
To prevent a possible future name clashing the `skipAttributeNames` option has been removed. In case you used this option, please update the class names accordingly. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
24281
10
342
0
9
283
1