@@ -377,3 +377,104 @@ test('with @apply', () => {
377
377
` )
378
378
} )
379
379
} )
380
+
381
+ test ( 'partial arbitrary variants' , ( ) => {
382
+ let config = {
383
+ content : [
384
+ {
385
+ raw : html `
386
+ <div class= "container-[sidebar] container-type-inline-size" >
387
+ <div class= "contain-[sidebar,min:500px]:flex" > </ div>
388
+ <div class= "contain-[sidebar,max:500px]:flex" > </ div>
389
+ <div class= "contain-[min:500px]:flex" > </ div>
390
+ <div class= "contain-[max:500px]:flex" > </ div>
391
+ <div class= "contain-[500px]:flex" > </ div>
392
+ </ div>
393
+ ` ,
394
+ } ,
395
+ ] ,
396
+ corePlugins : { preflight : false } ,
397
+ plugins : [
398
+ ( { addUtilities, matchVariant, matchUtilities } ) => {
399
+ addUtilities ( {
400
+ '.container-type-size' : { 'container-type' : 'size' } ,
401
+ '.container-type-inline-size' : { 'container-type' : 'inline-size' } ,
402
+ '.container-type-block-size' : { 'container-type' : 'block-size' } ,
403
+ '.container-type-style' : { 'container-type' : 'style' } ,
404
+ '.container-type-state' : { 'container-type' : 'state' } ,
405
+ } )
406
+
407
+ matchUtilities ( {
408
+ container : ( value ) => {
409
+ return {
410
+ 'container-name' : value ,
411
+ }
412
+ } ,
413
+ } )
414
+
415
+ matchVariant ( {
416
+ contain : ( args ) => {
417
+ if ( args . includes ( ',' ) ) {
418
+ let [ name , query ] = args . split ( ',' )
419
+ let [ type , value ] = query . split ( ':' )
420
+ return `@container ${ name } (${
421
+ { min : 'min-width' , max : 'max-width' } [ type ]
422
+ } : ${ value } )`
423
+ } else if ( args . includes ( ':' ) ) {
424
+ let [ type , value ] = args . split ( ':' )
425
+ return `@container (${ { min : 'min-width' , max : 'max-width' } [ type ] } : ${ value } )`
426
+ } else {
427
+ return `@container (min-width: ${ args } )`
428
+ }
429
+ } ,
430
+ } )
431
+ } ,
432
+ ] ,
433
+ }
434
+
435
+ let input = css `
436
+ @tailwind utilities;
437
+ `
438
+
439
+ return run ( input , config ) . then ( ( result ) => {
440
+ expect ( result . css ) . toMatchFormattedCss ( css `
441
+ .container-type-inline-size {
442
+ container-type : inline-size;
443
+ }
444
+
445
+ .container-\[sidebar \] {
446
+ container-name : sidebar;
447
+ }
448
+
449
+ @container sidebar (min-width : 500px ) {
450
+ .contain-\[sidebar\2c min\:500px\]\:flex {
451
+ display : flex;
452
+ }
453
+ }
454
+
455
+ @container sidebar (max-width : 500px ) {
456
+ .contain-\[sidebar\2c max\:500px\]\:flex {
457
+ display : flex;
458
+ }
459
+ }
460
+
461
+ @container (min-width : 500px ) {
462
+ .contain-\[min\:500px\]\:flex {
463
+ display : flex;
464
+ }
465
+ }
466
+
467
+ @container (max-width : 500px ) {
468
+ .contain-\[max\:500px\]\:flex {
469
+ display : flex;
470
+ }
471
+ }
472
+
473
+ @container (min-width : 500px ) {
474
+ .contain-\[500px\]\:flex {
475
+ display : flex;
476
+ }
477
+ }
478
+ ` )
479
+ } )
480
+ } )
0 commit comments