Skip to content

Commit a9da051

Browse files
committed
Add support peer- and group- to booleans
When using boolean variants (like `aria-disabled:` or `aria-expanded:`), support `group-` and `peer-` prefixed variations. There was already support for enumerable attributes, so follow that established pattern.
1 parent 9f76bb3 commit a9da051

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@ module.exports = plugin(({ addVariant, e }) => {
2121
"required",
2222
"selected",
2323
].forEach(boolean => {
24-
const selector = [ "aria", boolean ].join("-")
25-
24+
const selector = `aria-${boolean}`
2625
addVariant(selector, ({ modifySelectors, separator }) =>
2726
modifySelectors(({ className }) => `[${selector}="true"].${e(`${selector}${separator}${className}`)}`)
2827
)
28+
29+
const groupSelector = `group-aria-${boolean}`
30+
addVariant(groupSelector, ({ modifySelectors, separator }) =>
31+
modifySelectors(({ className }) => `.group[aria-${boolean}="true"] .${e(`${groupSelector}${separator}${className}`)}`)
32+
)
33+
34+
const peerSelector = `peer-aria-${boolean}`
35+
addVariant(peerSelector, ({ modifySelectors, separator }) =>
36+
modifySelectors(({ className }) => `.peer[aria-${boolean}="true"] ~ .${e(`${peerSelector}${separator}${className}`)}`)
37+
)
2938
})
3039

3140
const enumerables = {

0 commit comments

Comments
 (0)