postcss-clampwind 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -16
- package/dist/clampwind.cjs.cjs +72 -28
- package/dist/clampwind.esm.js +72 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,21 @@ Install the plugin from npm:
|
|
|
28
28
|
```sh
|
|
29
29
|
npm install -D postcss-clampwind
|
|
30
30
|
```
|
|
31
|
+
### Vite project setup
|
|
32
|
+
|
|
33
|
+
If you are using Vite, you are probably using Tailwind with `@tailwindcss/vite`. You need to import the plugin and use it in your `postcss.config.js` file.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
// postcss.config.js
|
|
37
|
+
import clampwind from "postcss-clampwind";
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
plugins: [
|
|
41
|
+
clampwind()
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
**Demo on StackBlitz:** [postcss-clampwind-vite](https://stackblitz.com/edit/postcss-clampwind-vite?file=postcss.config.js)
|
|
31
46
|
|
|
32
47
|
### PostCSS setup
|
|
33
48
|
|
|
@@ -46,6 +61,8 @@ export default {
|
|
|
46
61
|
}
|
|
47
62
|
```
|
|
48
63
|
|
|
64
|
+
**Demo on StackBlitz:** [postcss-clampwind-postcss](https://stackblitz.com/edit/postcss-clampwind-postcss?file=postcss.config.mjs)
|
|
65
|
+
|
|
49
66
|
#### CommonJS usage
|
|
50
67
|
|
|
51
68
|
If you are using CommonJS-based build tools like Webpack, you will need to use the `require` syntax and add `.default` to the import.
|
|
@@ -60,21 +77,6 @@ module.exports = {
|
|
|
60
77
|
};
|
|
61
78
|
```
|
|
62
79
|
|
|
63
|
-
### Vite project setup
|
|
64
|
-
|
|
65
|
-
If you are using Vite, you are probably using Tailwind with `@tailwindcss/vite`. You need to import the plugin and use it in your `postcss.config.js` file.
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
// postcss.config.js
|
|
69
|
-
import clampwind from "postcss-clampwind";
|
|
70
|
-
|
|
71
|
-
export default {
|
|
72
|
-
plugins: [
|
|
73
|
-
clampwind()
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
80
|
## Features
|
|
79
81
|
|
|
80
82
|
### Interchangeable px / rem units
|
|
@@ -369,4 +371,4 @@ or like this:
|
|
|
369
371
|
|
|
370
372
|
This project is licensed under the [Apache-2.0 license](https://apache.org/licenses/LICENSE-2.0).
|
|
371
373
|
|
|
372
|
-
Copyright © 2025 Daniele De Pietri.
|
|
374
|
+
Copyright © 2025 Daniele De Pietri.
|
package/dist/clampwind.cjs.cjs
CHANGED
|
@@ -360,21 +360,41 @@ var clampwind = (opts = {}) => {
|
|
|
360
360
|
const parentParams = decl.parent.parent.params;
|
|
361
361
|
let minScreen = null;
|
|
362
362
|
let maxScreen = null;
|
|
363
|
-
if (parentParams.includes(">")) {
|
|
364
|
-
|
|
365
|
-
if (match)
|
|
363
|
+
if (parentParams.includes(">") || parentParams.includes("min-width")) {
|
|
364
|
+
let match = parentParams.match(/>=?\s*([^),\s]+)/);
|
|
365
|
+
if (match) {
|
|
366
|
+
minScreen = match[1].trim();
|
|
367
|
+
} else {
|
|
368
|
+
match = parentParams.match(/min-width:\s*([^),\s]+)/);
|
|
369
|
+
if (match) minScreen = match[1].trim();
|
|
370
|
+
}
|
|
366
371
|
}
|
|
367
|
-
if (currentParams2.includes(">")
|
|
368
|
-
|
|
369
|
-
if (match)
|
|
372
|
+
if (!minScreen && (currentParams2.includes(">") || currentParams2.includes("min-width"))) {
|
|
373
|
+
let match = currentParams2.match(/>=?\s*([^),\s]+)/);
|
|
374
|
+
if (match) {
|
|
375
|
+
minScreen = match[1].trim();
|
|
376
|
+
} else {
|
|
377
|
+
match = currentParams2.match(/min-width:\s*([^),\s]+)/);
|
|
378
|
+
if (match) minScreen = match[1].trim();
|
|
379
|
+
}
|
|
370
380
|
}
|
|
371
|
-
if (parentParams.includes("<")) {
|
|
372
|
-
|
|
373
|
-
if (match)
|
|
381
|
+
if (parentParams.includes("<") || parentParams.includes("max-width")) {
|
|
382
|
+
let match = parentParams.match(/<\s*([^),\s]+)/);
|
|
383
|
+
if (match) {
|
|
384
|
+
maxScreen = match[1].trim();
|
|
385
|
+
} else {
|
|
386
|
+
match = parentParams.match(/max-width:\s*([^),\s]+)/);
|
|
387
|
+
if (match) maxScreen = match[1].trim();
|
|
388
|
+
}
|
|
374
389
|
}
|
|
375
|
-
if (currentParams2.includes("<")
|
|
376
|
-
|
|
377
|
-
if (match)
|
|
390
|
+
if (!maxScreen && (currentParams2.includes("<") || currentParams2.includes("max-width"))) {
|
|
391
|
+
let match = currentParams2.match(/<\s*([^),\s]+)/);
|
|
392
|
+
if (match) {
|
|
393
|
+
maxScreen = match[1].trim();
|
|
394
|
+
} else {
|
|
395
|
+
match = currentParams2.match(/max-width:\s*([^),\s]+)/);
|
|
396
|
+
if (match) maxScreen = match[1].trim();
|
|
397
|
+
}
|
|
378
398
|
}
|
|
379
399
|
if (minScreen && maxScreen) {
|
|
380
400
|
clampDecls.forEach((decl2) => {
|
|
@@ -391,15 +411,21 @@ var clampwind = (opts = {}) => {
|
|
|
391
411
|
}
|
|
392
412
|
const screenValues = Object.values(screens);
|
|
393
413
|
const currentParams = decl.parent.params;
|
|
394
|
-
if (currentParams.includes(">")) {
|
|
395
|
-
|
|
414
|
+
if (currentParams.includes(">") || currentParams.includes("min-width")) {
|
|
415
|
+
let match = currentParams.match(/>=?\s*([^),\s]+)/);
|
|
416
|
+
if (!match) {
|
|
417
|
+
match = currentParams.match(/min-width:\s*([^),\s]+)/);
|
|
418
|
+
}
|
|
396
419
|
if (match) {
|
|
397
420
|
const minScreen = match[1].trim();
|
|
398
421
|
const maxScreen = defaultClampRange.max || screenValues[screenValues.length - 1];
|
|
399
422
|
processClampDeclaration(decl, minScreen, maxScreen, false);
|
|
400
423
|
}
|
|
401
|
-
} else if (currentParams.includes("<")) {
|
|
402
|
-
|
|
424
|
+
} else if (currentParams.includes("<") || currentParams.includes("max-width")) {
|
|
425
|
+
let match = currentParams.match(/<\s*([^),\s]+)/);
|
|
426
|
+
if (!match) {
|
|
427
|
+
match = currentParams.match(/max-width:\s*([^),\s]+)/);
|
|
428
|
+
}
|
|
403
429
|
if (match) {
|
|
404
430
|
const minScreen = defaultClampRange.min || screenValues[0];
|
|
405
431
|
const maxScreen = match[1].trim();
|
|
@@ -424,20 +450,32 @@ var clampwind = (opts = {}) => {
|
|
|
424
450
|
const parentParams = decl.parent.parent.params;
|
|
425
451
|
let minContainer = null;
|
|
426
452
|
let maxContainer = null;
|
|
427
|
-
if (parentParams.includes(">")) {
|
|
428
|
-
|
|
453
|
+
if (parentParams.includes(">") || parentParams.includes("min-width")) {
|
|
454
|
+
let match = parentParams.match(/>=?\s*([^),\s]+)/);
|
|
455
|
+
if (!match) {
|
|
456
|
+
match = parentParams.match(/min-width:\s*([^),\s]+)/);
|
|
457
|
+
}
|
|
429
458
|
if (match) minContainer = match[1].trim();
|
|
430
459
|
}
|
|
431
|
-
if (currentParams2.includes(">")
|
|
432
|
-
|
|
460
|
+
if (!minContainer && (currentParams2.includes(">") || currentParams2.includes("min-width"))) {
|
|
461
|
+
let match = currentParams2.match(/>=?\s*([^),\s]+)/);
|
|
462
|
+
if (!match) {
|
|
463
|
+
match = currentParams2.match(/min-width:\s*([^),\s]+)/);
|
|
464
|
+
}
|
|
433
465
|
if (match) minContainer = match[1].trim();
|
|
434
466
|
}
|
|
435
|
-
if (parentParams.includes("<")) {
|
|
436
|
-
|
|
467
|
+
if (parentParams.includes("<") || parentParams.includes("max-width")) {
|
|
468
|
+
let match = parentParams.match(/<\s*([^),\s]+)/);
|
|
469
|
+
if (!match) {
|
|
470
|
+
match = parentParams.match(/max-width:\s*([^),\s]+)/);
|
|
471
|
+
}
|
|
437
472
|
if (match) maxContainer = match[1].trim();
|
|
438
473
|
}
|
|
439
|
-
if (currentParams2.includes("<")
|
|
440
|
-
|
|
474
|
+
if (!maxContainer && (currentParams2.includes("<") || currentParams2.includes("max-width"))) {
|
|
475
|
+
let match = currentParams2.match(/<\s*([^),\s]+)/);
|
|
476
|
+
if (!match) {
|
|
477
|
+
match = currentParams2.match(/max-width:\s*([^),\s]+)/);
|
|
478
|
+
}
|
|
441
479
|
if (match) maxContainer = match[1].trim();
|
|
442
480
|
}
|
|
443
481
|
if (minContainer && maxContainer) {
|
|
@@ -460,8 +498,11 @@ var clampwind = (opts = {}) => {
|
|
|
460
498
|
}
|
|
461
499
|
const containerValues = Object.values(containerScreens);
|
|
462
500
|
const currentParams = decl.parent.params;
|
|
463
|
-
if (currentParams.includes(">")) {
|
|
464
|
-
|
|
501
|
+
if (currentParams.includes(">") || currentParams.includes("min-width")) {
|
|
502
|
+
let match = currentParams.match(/>=?\s*([^),\s]+)/);
|
|
503
|
+
if (!match) {
|
|
504
|
+
match = currentParams.match(/min-width:\s*([^),\s]+)/);
|
|
505
|
+
}
|
|
465
506
|
if (match) {
|
|
466
507
|
const minContainer = match[1].trim();
|
|
467
508
|
const maxContainer = containerValues[containerValues.length - 1];
|
|
@@ -472,8 +513,11 @@ var clampwind = (opts = {}) => {
|
|
|
472
513
|
true
|
|
473
514
|
);
|
|
474
515
|
}
|
|
475
|
-
} else if (currentParams.includes("<")) {
|
|
476
|
-
|
|
516
|
+
} else if (currentParams.includes("<") || currentParams.includes("max-width")) {
|
|
517
|
+
let match = currentParams.match(/<\s*([^),\s]+)/);
|
|
518
|
+
if (!match) {
|
|
519
|
+
match = currentParams.match(/max-width:\s*([^),\s]+)/);
|
|
520
|
+
}
|
|
477
521
|
if (match) {
|
|
478
522
|
const minContainer = containerValues[0];
|
|
479
523
|
const maxContainer = match[1].trim();
|
package/dist/clampwind.esm.js
CHANGED
|
@@ -335,21 +335,41 @@ var clampwind = (opts = {}) => {
|
|
|
335
335
|
const parentParams = decl.parent.parent.params;
|
|
336
336
|
let minScreen = null;
|
|
337
337
|
let maxScreen = null;
|
|
338
|
-
if (parentParams.includes(">")) {
|
|
339
|
-
|
|
340
|
-
if (match)
|
|
338
|
+
if (parentParams.includes(">") || parentParams.includes("min-width")) {
|
|
339
|
+
let match = parentParams.match(/>=?\s*([^),\s]+)/);
|
|
340
|
+
if (match) {
|
|
341
|
+
minScreen = match[1].trim();
|
|
342
|
+
} else {
|
|
343
|
+
match = parentParams.match(/min-width:\s*([^),\s]+)/);
|
|
344
|
+
if (match) minScreen = match[1].trim();
|
|
345
|
+
}
|
|
341
346
|
}
|
|
342
|
-
if (currentParams2.includes(">")
|
|
343
|
-
|
|
344
|
-
if (match)
|
|
347
|
+
if (!minScreen && (currentParams2.includes(">") || currentParams2.includes("min-width"))) {
|
|
348
|
+
let match = currentParams2.match(/>=?\s*([^),\s]+)/);
|
|
349
|
+
if (match) {
|
|
350
|
+
minScreen = match[1].trim();
|
|
351
|
+
} else {
|
|
352
|
+
match = currentParams2.match(/min-width:\s*([^),\s]+)/);
|
|
353
|
+
if (match) minScreen = match[1].trim();
|
|
354
|
+
}
|
|
345
355
|
}
|
|
346
|
-
if (parentParams.includes("<")) {
|
|
347
|
-
|
|
348
|
-
if (match)
|
|
356
|
+
if (parentParams.includes("<") || parentParams.includes("max-width")) {
|
|
357
|
+
let match = parentParams.match(/<\s*([^),\s]+)/);
|
|
358
|
+
if (match) {
|
|
359
|
+
maxScreen = match[1].trim();
|
|
360
|
+
} else {
|
|
361
|
+
match = parentParams.match(/max-width:\s*([^),\s]+)/);
|
|
362
|
+
if (match) maxScreen = match[1].trim();
|
|
363
|
+
}
|
|
349
364
|
}
|
|
350
|
-
if (currentParams2.includes("<")
|
|
351
|
-
|
|
352
|
-
if (match)
|
|
365
|
+
if (!maxScreen && (currentParams2.includes("<") || currentParams2.includes("max-width"))) {
|
|
366
|
+
let match = currentParams2.match(/<\s*([^),\s]+)/);
|
|
367
|
+
if (match) {
|
|
368
|
+
maxScreen = match[1].trim();
|
|
369
|
+
} else {
|
|
370
|
+
match = currentParams2.match(/max-width:\s*([^),\s]+)/);
|
|
371
|
+
if (match) maxScreen = match[1].trim();
|
|
372
|
+
}
|
|
353
373
|
}
|
|
354
374
|
if (minScreen && maxScreen) {
|
|
355
375
|
clampDecls.forEach((decl2) => {
|
|
@@ -366,15 +386,21 @@ var clampwind = (opts = {}) => {
|
|
|
366
386
|
}
|
|
367
387
|
const screenValues = Object.values(screens);
|
|
368
388
|
const currentParams = decl.parent.params;
|
|
369
|
-
if (currentParams.includes(">")) {
|
|
370
|
-
|
|
389
|
+
if (currentParams.includes(">") || currentParams.includes("min-width")) {
|
|
390
|
+
let match = currentParams.match(/>=?\s*([^),\s]+)/);
|
|
391
|
+
if (!match) {
|
|
392
|
+
match = currentParams.match(/min-width:\s*([^),\s]+)/);
|
|
393
|
+
}
|
|
371
394
|
if (match) {
|
|
372
395
|
const minScreen = match[1].trim();
|
|
373
396
|
const maxScreen = defaultClampRange.max || screenValues[screenValues.length - 1];
|
|
374
397
|
processClampDeclaration(decl, minScreen, maxScreen, false);
|
|
375
398
|
}
|
|
376
|
-
} else if (currentParams.includes("<")) {
|
|
377
|
-
|
|
399
|
+
} else if (currentParams.includes("<") || currentParams.includes("max-width")) {
|
|
400
|
+
let match = currentParams.match(/<\s*([^),\s]+)/);
|
|
401
|
+
if (!match) {
|
|
402
|
+
match = currentParams.match(/max-width:\s*([^),\s]+)/);
|
|
403
|
+
}
|
|
378
404
|
if (match) {
|
|
379
405
|
const minScreen = defaultClampRange.min || screenValues[0];
|
|
380
406
|
const maxScreen = match[1].trim();
|
|
@@ -399,20 +425,32 @@ var clampwind = (opts = {}) => {
|
|
|
399
425
|
const parentParams = decl.parent.parent.params;
|
|
400
426
|
let minContainer = null;
|
|
401
427
|
let maxContainer = null;
|
|
402
|
-
if (parentParams.includes(">")) {
|
|
403
|
-
|
|
428
|
+
if (parentParams.includes(">") || parentParams.includes("min-width")) {
|
|
429
|
+
let match = parentParams.match(/>=?\s*([^),\s]+)/);
|
|
430
|
+
if (!match) {
|
|
431
|
+
match = parentParams.match(/min-width:\s*([^),\s]+)/);
|
|
432
|
+
}
|
|
404
433
|
if (match) minContainer = match[1].trim();
|
|
405
434
|
}
|
|
406
|
-
if (currentParams2.includes(">")
|
|
407
|
-
|
|
435
|
+
if (!minContainer && (currentParams2.includes(">") || currentParams2.includes("min-width"))) {
|
|
436
|
+
let match = currentParams2.match(/>=?\s*([^),\s]+)/);
|
|
437
|
+
if (!match) {
|
|
438
|
+
match = currentParams2.match(/min-width:\s*([^),\s]+)/);
|
|
439
|
+
}
|
|
408
440
|
if (match) minContainer = match[1].trim();
|
|
409
441
|
}
|
|
410
|
-
if (parentParams.includes("<")) {
|
|
411
|
-
|
|
442
|
+
if (parentParams.includes("<") || parentParams.includes("max-width")) {
|
|
443
|
+
let match = parentParams.match(/<\s*([^),\s]+)/);
|
|
444
|
+
if (!match) {
|
|
445
|
+
match = parentParams.match(/max-width:\s*([^),\s]+)/);
|
|
446
|
+
}
|
|
412
447
|
if (match) maxContainer = match[1].trim();
|
|
413
448
|
}
|
|
414
|
-
if (currentParams2.includes("<")
|
|
415
|
-
|
|
449
|
+
if (!maxContainer && (currentParams2.includes("<") || currentParams2.includes("max-width"))) {
|
|
450
|
+
let match = currentParams2.match(/<\s*([^),\s]+)/);
|
|
451
|
+
if (!match) {
|
|
452
|
+
match = currentParams2.match(/max-width:\s*([^),\s]+)/);
|
|
453
|
+
}
|
|
416
454
|
if (match) maxContainer = match[1].trim();
|
|
417
455
|
}
|
|
418
456
|
if (minContainer && maxContainer) {
|
|
@@ -435,8 +473,11 @@ var clampwind = (opts = {}) => {
|
|
|
435
473
|
}
|
|
436
474
|
const containerValues = Object.values(containerScreens);
|
|
437
475
|
const currentParams = decl.parent.params;
|
|
438
|
-
if (currentParams.includes(">")) {
|
|
439
|
-
|
|
476
|
+
if (currentParams.includes(">") || currentParams.includes("min-width")) {
|
|
477
|
+
let match = currentParams.match(/>=?\s*([^),\s]+)/);
|
|
478
|
+
if (!match) {
|
|
479
|
+
match = currentParams.match(/min-width:\s*([^),\s]+)/);
|
|
480
|
+
}
|
|
440
481
|
if (match) {
|
|
441
482
|
const minContainer = match[1].trim();
|
|
442
483
|
const maxContainer = containerValues[containerValues.length - 1];
|
|
@@ -447,8 +488,11 @@ var clampwind = (opts = {}) => {
|
|
|
447
488
|
true
|
|
448
489
|
);
|
|
449
490
|
}
|
|
450
|
-
} else if (currentParams.includes("<")) {
|
|
451
|
-
|
|
491
|
+
} else if (currentParams.includes("<") || currentParams.includes("max-width")) {
|
|
492
|
+
let match = currentParams.match(/<\s*([^),\s]+)/);
|
|
493
|
+
if (!match) {
|
|
494
|
+
match = currentParams.match(/max-width:\s*([^),\s]+)/);
|
|
495
|
+
}
|
|
452
496
|
if (match) {
|
|
453
497
|
const minContainer = containerValues[0];
|
|
454
498
|
const maxContainer = match[1].trim();
|