Skip to content

Commit 7bd0851

Browse files
Add user-valid and user-invalid variants
Co-authored-by: Robin Malfait <[email protected]>
1 parent c094fad commit 7bd0851

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

+20
Original file line numberDiff line numberDiff line change
@@ -3884,6 +3884,8 @@ exports[`getVariants 1`] = `
38843884
"required",
38853885
"valid",
38863886
"invalid",
3887+
"user-valid",
3888+
"user-invalid",
38873889
"in-range",
38883890
"out-of-range",
38893891
"read-only",
@@ -3936,6 +3938,8 @@ exports[`getVariants 1`] = `
39363938
"required",
39373939
"valid",
39383940
"invalid",
3941+
"user-valid",
3942+
"user-invalid",
39393943
"in-range",
39403944
"out-of-range",
39413945
"read-only",
@@ -4162,6 +4166,20 @@ exports[`getVariants 1`] = `
41624166
"selectors": [Function],
41634167
"values": [],
41644168
},
4169+
{
4170+
"hasDash": true,
4171+
"isArbitrary": false,
4172+
"name": "user-valid",
4173+
"selectors": [Function],
4174+
"values": [],
4175+
},
4176+
{
4177+
"hasDash": true,
4178+
"isArbitrary": false,
4179+
"name": "user-invalid",
4180+
"selectors": [Function],
4181+
"values": [],
4182+
},
41654183
{
41664184
"hasDash": true,
41674185
"isArbitrary": false,
@@ -4275,6 +4293,8 @@ exports[`getVariants 1`] = `
42754293
"required",
42764294
"valid",
42774295
"invalid",
4296+
"user-valid",
4297+
"user-invalid",
42784298
"in-range",
42794299
"out-of-range",
42804300
"read-only",

packages/tailwindcss/src/variants.test.ts

+35
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,41 @@ test('invalid', async () => {
490490
expect(await run(['invalid/foo:flex'])).toEqual('')
491491
})
492492

493+
test('user-valid', async () => {
494+
expect(await run(['user-valid:flex', 'group-user-valid:flex', 'peer-user-valid:flex'])).toMatchInlineSnapshot(`
495+
".group-user-valid\\:flex:is(:where(.group):user-valid *) {
496+
display: flex;
497+
}
498+
499+
.peer-user-valid\\:flex:is(:where(.peer):user-valid ~ *) {
500+
display: flex;
501+
}
502+
503+
.user-valid\\:flex:user-valid {
504+
display: flex;
505+
}"
506+
`)
507+
expect(await run(['user-valid/foo:flex'])).toEqual('')
508+
})
509+
510+
test('user-invalid', async () => {
511+
expect(await run(['user-invalid:flex', 'group-user-invalid:flex', 'peer-user-invalid:flex']))
512+
.toMatchInlineSnapshot(`
513+
".group-user-invalid\\:flex:is(:where(.group):user-invalid *) {
514+
display: flex;
515+
}
516+
517+
.peer-user-invalid\\:flex:is(:where(.peer):user-invalid ~ *) {
518+
display: flex;
519+
}
520+
521+
.user-invalid\\:flex:user-invalid {
522+
display: flex;
523+
}"
524+
`)
525+
expect(await run(['invalid/foo:flex'])).toEqual('')
526+
})
527+
493528
test('in-range', async () => {
494529
expect(await run(['in-range:flex', 'group-in-range:flex', 'peer-in-range:flex']))
495530
.toMatchInlineSnapshot(`

packages/tailwindcss/src/variants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ export function createVariants(theme: Theme): Variants {
438438
staticVariant('required', ['&:required'])
439439
staticVariant('valid', ['&:valid'])
440440
staticVariant('invalid', ['&:invalid'])
441+
staticVariant('user-valid', ['&:user-valid'])
442+
staticVariant('user-invalid', ['&:user-invalid'])
441443
staticVariant('in-range', ['&:in-range'])
442444
staticVariant('out-of-range', ['&:out-of-range'])
443445
staticVariant('read-only', ['&:read-only'])

0 commit comments

Comments
 (0)