mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add focus-within variant
This commit is contained in:
parent
14f1ba6cb9
commit
9e4e8a6d05
@ -69,6 +69,27 @@ test('it can generate focus variants', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('it can generate focus-within variants', () => {
|
||||
const input = `
|
||||
@variants focus-within {
|
||||
.banana { color: yellow; }
|
||||
.chocolate { color: brown; }
|
||||
}
|
||||
`
|
||||
|
||||
const output = `
|
||||
.banana { color: yellow; }
|
||||
.chocolate { color: brown; }
|
||||
.focus-within\\:banana:focus-within { color: yellow; }
|
||||
.focus-within\\:chocolate:focus-within { color: brown; }
|
||||
`
|
||||
|
||||
return run(input).then(result => {
|
||||
expect(result.css).toMatchCss(output)
|
||||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
test('it can generate group-hover variants', () => {
|
||||
const input = `
|
||||
@variants group-hover {
|
||||
|
||||
@ -828,6 +828,7 @@ module.exports = {
|
||||
| - responsive
|
||||
| - hover
|
||||
| - focus
|
||||
| - focus-within
|
||||
| - active
|
||||
| - group-hover
|
||||
|
|
||||
|
||||
@ -30,6 +30,7 @@ const variantGenerators = {
|
||||
},
|
||||
hover: generatePseudoClassVariant('hover'),
|
||||
focus: generatePseudoClassVariant('focus'),
|
||||
'focus-within': generatePseudoClassVariant('focus-within'),
|
||||
active: generatePseudoClassVariant('active'),
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ export default function(config) {
|
||||
|
||||
atRule.before(atRule.clone().nodes)
|
||||
|
||||
_.forEach(['group-hover', 'hover', 'focus', 'active'], variant => {
|
||||
_.forEach(['group-hover', 'hover', 'focus', 'focus-within', 'active'], variant => {
|
||||
if (variants.includes(variant)) {
|
||||
variantGenerators[variant](atRule, unwrappedConfig)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user