Skip to content

Commit 79c1473

Browse files
committed
group @custom-variant with different roots
If you migrate both `aria-*` and `data-*` custom variants, then the output would look like this: ```css @custom-variant aria-bar (&[aria-baz="true"]); @custom-variant aria-asc (&[aria-sort="ascending"]); @custom-variant aria-desc (&[aria-sort="descending"]); @custom-variant data-checked (&[data-ui~="checked"]); ``` Instead of ```css @custom-variant aria-bar (&[aria-baz="true"]); @custom-variant aria-asc (&[aria-sort="ascending"]); @custom-variant aria-desc (&[aria-sort="descending"]); @custom-variant data-checked (&[data-ui~="checked"]); ```
1 parent 79cd4a8 commit 79c1473

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,12 @@ async function migrateTheme(
247247
*/
248248
`
249249

250+
let previousRoot = ''
250251
for (let [name, selector] of variants) {
252+
let root = name.split('-')[0]
253+
if (previousRoot !== root) css += '\n'
254+
previousRoot = root
255+
251256
css += `@custom-variant ${name} (${selector});\n`
252257
}
253258
css += '}\n'

0 commit comments

Comments
 (0)