Skip to content

Commit 610cb27

Browse files
authored
extend progressive-custom-properties to the var() function (#979)
* extend progressive-custom-properties to the var function * Update plugin-packs/postcss-preset-env/.tape.mjs * change the plugin order
1 parent e92a4f9 commit 610cb27

File tree

82 files changed

+753
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+753
-157
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin-packs/postcss-preset-env/dist/index.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

plugin-packs/postcss-preset-env/dist/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

plugin-packs/postcss-preset-env/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"postcss": "^8.4"
111111
},
112112
"devDependencies": {
113+
"@csstools/postcss-debug-logger": "1.0.0",
113114
"@csstools/postcss-tape": "*",
114115
"@webref/css": "^6.5.1",
115116
"postcss-simple-vars": "^7.0.1"

plugin-packs/postcss-preset-env/src/lib/ids-by-execution-order.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// ids ordered by required execution, then alphabetically
22
export default [
33
'custom-media-queries',
4-
'custom-properties',
54
'environment-variables', // run environment-variables here to access transpiled custom media params and properties
65
'image-set-function', // run images-set-function before nesting-rules so that it may fix nested media
76
'media-query-ranges', // run media-query-range
@@ -56,5 +55,8 @@ export default [
5655
'nested-calc',
5756
// Math functions.
5857

58+
// must be after all value related rules
59+
'custom-properties',
60+
5961
'cascade-layers',
6062
];

plugin-packs/postcss-preset-env/test/basic.autoprefixer.expect.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@
457457
text-indent: 2em;
458458
content: var(--value-2ic);
459459
left: 2em;
460-
left: var(--non-existing, 2ic);
460+
left: var(--non-existing, 2em);
461461
width: calc(8em + 20px);
462462
height: 10px;
463463
margin: 0.5em 1em .2em;
@@ -593,7 +593,7 @@
593593

594594
@supports (background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%)) and (color: hsl(0 0% 0% / 0)) {
595595
.gradients-interpolation-method {
596-
--background-image: linear-gradient(in oklch decreasing hue, hsl(0, 85%, 75%) 0%, hsl(180, 80%, 65%) 100%);
596+
--background-image: linear-gradient(in oklch decreasing hue, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%);
597597
}
598598
}
599599

@@ -610,3 +610,9 @@
610610
color-9: rgb(130, 31, 0);
611611
color-9: color(display-p3 0.48896 0.1211 0);
612612
}
613+
614+
.test-property-with-var {
615+
--opacity: 1;
616+
color: rgba(87, 107, 149, 1);
617+
color: rgba(87, 107, 149, var(--opacity));
618+
}

plugin-packs/postcss-preset-env/test/basic.autoprefixer.false.expect.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@
457457
text-indent: 2em;
458458
content: var(--value-2ic);
459459
left: 2em;
460-
left: var(--non-existing, 2ic);
460+
left: var(--non-existing, 2em);
461461
width: calc(8em + 20px);
462462
height: 10px;
463463
margin: 0.5em 1em .2em;
@@ -593,7 +593,7 @@
593593

594594
@supports (background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%)) and (color: hsl(0 0% 0% / 0)) {
595595
.gradients-interpolation-method {
596-
--background-image: linear-gradient(in oklch decreasing hue, hsl(0, 85%, 75%) 0%, hsl(180, 80%, 65%) 100%);
596+
--background-image: linear-gradient(in oklch decreasing hue, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%);
597597
}
598598
}
599599

@@ -610,3 +610,9 @@
610610
color-9: rgb(130, 31, 0);
611611
color-9: color(display-p3 0.48896 0.1211 0);
612612
}
613+
614+
.test-property-with-var {
615+
--opacity: 1;
616+
color: rgba(87, 107, 149, 1);
617+
color: rgba(87, 107, 149, var(--opacity));
618+
}

plugin-packs/postcss-preset-env/test/basic.ch38.expect.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@
368368
text-indent: 2em;
369369
content: var(--value-2ic);
370370
left: 2em;
371-
left: var(--non-existing, 2ic);
371+
left: var(--non-existing, 2em);
372372
width: calc(8em + 20px);
373373
height: 10px;
374374
margin: 0.5em 1em .2em;
@@ -503,7 +503,7 @@
503503

504504
@supports (background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%)) and (color: hsl(0 0% 0% / 0)) {
505505
.gradients-interpolation-method {
506-
--background-image: linear-gradient(in oklch decreasing hue, hsl(0, 85%, 75%) 0%, hsl(180, 80%, 65%) 100%);
506+
--background-image: linear-gradient(in oklch decreasing hue, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%);
507507
}
508508
}
509509

@@ -520,3 +520,9 @@
520520
color-9: rgb(130, 31, 0);
521521
color-9: color(display-p3 0.48896 0.1211 0);
522522
}
523+
524+
.test-property-with-var {
525+
--opacity: 1;
526+
color: rgba(87, 107, 149, 1);
527+
color: rgba(87, 107, 149, var(--opacity));
528+
}

plugin-packs/postcss-preset-env/test/basic.ch88-ff78-saf10.expect.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
501501

502502
@supports (background: linear-gradient(in oklch, red 0%, red 0% 1%, red 2%)) and (color: hsl(0 0% 0% / 0)) {
503503
.gradients-interpolation-method {
504-
--background-image: linear-gradient(in oklch decreasing hue, hsl(0, 85%, 75%) 0%, hsl(180, 80%, 65%) 100%);
504+
--background-image: linear-gradient(in oklch decreasing hue, hsl(0deg 85% 75%) 0%, hsl(180deg 80% 65%) 100%);
505505
}
506506
}
507507

@@ -518,3 +518,8 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
518518
color-9: rgb(130, 31, 0);
519519
color-9: color(display-p3 0.48896 0.1211 0);
520520
}
521+
522+
.test-property-with-var {
523+
--opacity: 1;
524+
color: rgba(87, 107, 149, var(--opacity));
525+
}

plugin-packs/postcss-preset-env/test/basic.ch88-ff78.expect.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,8 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
512512
color-9: rgb(130, 31, 0);
513513
color-9: color(display-p3 0.48896 0.1211 0);
514514
}
515+
516+
.test-property-with-var {
517+
--opacity: 1;
518+
color: rgba(87 107 149 / var(--opacity));
519+
}

0 commit comments

Comments
 (0)