File tree Expand file tree Collapse file tree 2 files changed +64
-3
lines changed
Expand file tree Collapse file tree 2 files changed +64
-3
lines changed Original file line number Diff line number Diff line change 11import plugin from 'tailwindcss/plugin'
22import { normalize } from 'tailwindcss/lib/util/dataTypes'
33
4- export = plugin ( function containerQueries ( { matchVariant, theme } ) {
4+ export = plugin ( function containerQueries ( { matchUtilities , matchVariant, theme } ) {
55 let values : Record < string , string > = theme ( 'containers' ) ?? { }
66
77 function parseValue ( value : string ) : {
@@ -55,9 +55,28 @@ export = plugin(function containerQueries({ matchVariant, theme }) {
5555 }
5656 }
5757
58+ matchUtilities (
59+ {
60+ container : ( value , { modifier } ) => {
61+ return {
62+ 'container-type' : value ,
63+ 'container-name' : modifier ,
64+ }
65+ } ,
66+ } ,
67+ {
68+ values : {
69+ DEFAULT : 'inline' ,
70+ block : 'block' ,
71+ inline : 'inline' ,
72+ } ,
73+ modifiers : true ,
74+ }
75+ )
76+
5877 matchVariant (
5978 '@' ,
60- ( { value = '' , modifier } ) => {
79+ ( value = '' , { modifier } ) => {
6180 let parsed = parseValue ( value )
6281
6382 return parsed !== null ? `@container ${ modifier ?? '' } ${ parsed . raw } ` : [ ]
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ it('container queries', () => {
66 content : [
77 {
88 raw : html `
9- <div>
9+ <div
10+ class= "container container-block container-inline container/sidebar container-block/sidebar container-inline/sidebar container-[block] container-[block]/sidebar"
11+ >
1012 <div class= "@md:underline" > </ div>
1113 <div class= "@md/container1:underline" > </ div>
1214 <div class= "@md/container2:underline" > </ div>
@@ -54,6 +56,46 @@ it('container queries', () => {
5456
5557 return run ( input , config ) . then ( ( result ) => {
5658 expect ( result . css ) . toMatchFormattedCss ( css `
59+ .block {
60+ display : block;
61+ }
62+
63+ .container {
64+ container-type : inline;
65+ }
66+
67+ .container-block {
68+ container-type : block;
69+ }
70+
71+ .container-inline {
72+ container-type : inline;
73+ }
74+
75+ .container\/sidebar {
76+ container-type : inline;
77+ container-name : sidebar;
78+ }
79+
80+ .container-block\/sidebar {
81+ container-type : block;
82+ container-name : sidebar;
83+ }
84+
85+ .container-inline\/sidebar {
86+ container-type : inline;
87+ container-name : sidebar;
88+ }
89+
90+ .container-\[block \] {
91+ container-type : block;
92+ }
93+
94+ .container-\[block\]\/sidebar {
95+ container-type : block;
96+ container-name : sidebar;
97+ }
98+
5799 @container (min-width : 280px ) and (max-width : 300px ) {
58100 .\@\[\(min-width\:_280px\)_and_\(max-width\:_300px\)\]\:underline {
59101 text-decoration-line : underline;
You can’t perform that action at this time.
0 commit comments