Skip to content

Commit 2206ef9

Browse files
committed
added support for raw queries
1 parent e53d76e commit 2206ef9

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ node_modules
22
dist
33
yarn.lock
44
package-lock.json
5+
6+
.idea

src/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export = plugin(
44
function containerQueries({ matchUtilities, matchVariant, theme }) {
55
let values: Record<string, string> = theme('containers') ?? {}
66

7-
function parseValue(value: string) {
7+
function parseNumberValue(value: string) {
88
let numericValue = value.match(/^(\d+\.\d+|\d+|\.\d+)\D+/)?.[1] ?? null
99
if (numericValue === null) return null
1010

@@ -24,17 +24,29 @@ export = plugin(
2424
values: {
2525
DEFAULT: 'inline-size',
2626
normal: 'normal',
27+
size: 'size'
2728
},
2829
modifiers: 'any',
2930
}
3031
)
31-
3232
matchVariant(
3333
'@',
3434
(value = '', { modifier }) => {
35-
let parsed = parseValue(value)
35+
let parsedNumber = null;
36+
let parsedObject = null;
37+
38+
if(typeof value === 'object') {
39+
parsedObject = JSON.parse(JSON.stringify(value)) || null;
40+
}else{
41+
parsedNumber = parseNumberValue(value);
42+
}
43+
44+
45+
if(parsedObject !== null) {
46+
return `@container ${modifier ?? ''} ${parsedObject.raw}`
47+
}
3648

37-
return parsed !== null ? `@container ${modifier ?? ''} (min-width: ${value})` : []
49+
return parsedNumber !== null ? `@container ${modifier ?? ''} (min-width: ${value})` : []
3850
},
3951
{
4052
values,

0 commit comments

Comments
 (0)