@@ -405,3 +405,104 @@ test('with @apply', () => {
405
405
` )
406
406
} )
407
407
} )
408
+
409
+ test ( 'partial arbitrary variants' , ( ) => {
410
+ let config = {
411
+ content : [
412
+ {
413
+ raw : html `
414
+ <div class= "container-[sidebar] container-type-inline-size" >
415
+ <div class= "contain-[sidebar,min:500px]:flex" > </ div>
416
+ <div class= "contain-[sidebar,max:500px]:flex" > </ div>
417
+ <div class= "contain-[min:500px]:flex" > </ div>
418
+ <div class= "contain-[max:500px]:flex" > </ div>
419
+ <div class= "contain-[500px]:flex" > </ div>
420
+ </ div>
421
+ ` ,
422
+ } ,
423
+ ] ,
424
+ corePlugins : { preflight : false } ,
425
+ plugins : [
426
+ ( { addUtilities, matchVariant, matchUtilities } ) => {
427
+ addUtilities ( {
428
+ '.container-type-size' : { 'container-type' : 'size' } ,
429
+ '.container-type-inline-size' : { 'container-type' : 'inline-size' } ,
430
+ '.container-type-block-size' : { 'container-type' : 'block-size' } ,
431
+ '.container-type-style' : { 'container-type' : 'style' } ,
432
+ '.container-type-state' : { 'container-type' : 'state' } ,
433
+ } )
434
+
435
+ matchUtilities ( {
436
+ container : ( value ) => {
437
+ return {
438
+ 'container-name' : value ,
439
+ }
440
+ } ,
441
+ } )
442
+
443
+ matchVariant ( {
444
+ contain : ( args ) => {
445
+ if ( args . includes ( ',' ) ) {
446
+ let [ name , query ] = args . split ( ',' )
447
+ let [ type , value ] = query . split ( ':' )
448
+ return `@container ${ name } (${
449
+ { min : 'min-width' , max : 'max-width' } [ type ]
450
+ } : ${ value } )`
451
+ } else if ( args . includes ( ':' ) ) {
452
+ let [ type , value ] = args . split ( ':' )
453
+ return `@container (${ { min : 'min-width' , max : 'max-width' } [ type ] } : ${ value } )`
454
+ } else {
455
+ return `@container (min-width: ${ args } )`
456
+ }
457
+ } ,
458
+ } )
459
+ } ,
460
+ ] ,
461
+ }
462
+
463
+ let input = css `
464
+ @tailwind utilities;
465
+ `
466
+
467
+ return run ( input , config ) . then ( ( result ) => {
468
+ expect ( result . css ) . toMatchFormattedCss ( css `
469
+ .container-type-inline-size {
470
+ container-type : inline-size;
471
+ }
472
+
473
+ .container-\[sidebar \] {
474
+ container-name : sidebar;
475
+ }
476
+
477
+ @container sidebar (min-width : 500px ) {
478
+ .contain-\[sidebar\2c min\:500px\]\:flex {
479
+ display : flex;
480
+ }
481
+ }
482
+
483
+ @container sidebar (max-width : 500px ) {
484
+ .contain-\[sidebar\2c max\:500px\]\:flex {
485
+ display : flex;
486
+ }
487
+ }
488
+
489
+ @container (min-width : 500px ) {
490
+ .contain-\[min\:500px\]\:flex {
491
+ display : flex;
492
+ }
493
+ }
494
+
495
+ @container (max-width : 500px ) {
496
+ .contain-\[max\:500px\]\:flex {
497
+ display : flex;
498
+ }
499
+ }
500
+
501
+ @container (min-width : 500px ) {
502
+ .contain-\[500px\]\:flex {
503
+ display : flex;
504
+ }
505
+ }
506
+ ` )
507
+ } )
508
+ } )
0 commit comments