Skip to content

Commit 27aa8d6

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

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-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

+36
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,42 @@ 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']))
495+
.toMatchInlineSnapshot(`
496+
".group-user-valid\\:flex:is(:where(.group):user-valid *) {
497+
display: flex;
498+
}
499+
500+
.peer-user-valid\\:flex:is(:where(.peer):user-valid ~ *) {
501+
display: flex;
502+
}
503+
504+
.user-valid\\:flex:user-valid {
505+
display: flex;
506+
}"
507+
`)
508+
expect(await run(['user-valid/foo:flex'])).toEqual('')
509+
})
510+
511+
test('user-invalid', async () => {
512+
expect(await run(['user-invalid:flex', 'group-user-invalid:flex', 'peer-user-invalid:flex']))
513+
.toMatchInlineSnapshot(`
514+
".group-user-invalid\\:flex:is(:where(.group):user-invalid *) {
515+
display: flex;
516+
}
517+
518+
.peer-user-invalid\\:flex:is(:where(.peer):user-invalid ~ *) {
519+
display: flex;
520+
}
521+
522+
.user-invalid\\:flex:user-invalid {
523+
display: flex;
524+
}"
525+
`)
526+
expect(await run(['invalid/foo:flex'])).toEqual('')
527+
})
528+
493529
test('in-range', async () => {
494530
expect(await run(['in-range:flex', 'group-in-range:flex', 'peer-in-range:flex']))
495531
.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)