postcss-double-position-gradients 3.0.5 → 3.1.0
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/CHANGELOG.md +14 -0
- package/README.md +24 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changes to PostCSS Double Position Gradients
|
|
2
2
|
|
|
3
|
+
### 3.1.0 (February 15, 2022)
|
|
4
|
+
|
|
5
|
+
- Ignore values in relevant `@supports` rules.
|
|
6
|
+
- Support double position gradients in Custom Properties.
|
|
7
|
+
|
|
8
|
+
```css
|
|
9
|
+
@supports (order: linear-gradient(90deg, black 25% 50%, blue 50% 75%)) {
|
|
10
|
+
.support {
|
|
11
|
+
/* is not processed */
|
|
12
|
+
order: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
3
17
|
### 3.0.5 (February 5, 2022)
|
|
4
18
|
|
|
5
19
|
- Improved `es module` and `commonjs` compatibility
|
package/README.md
CHANGED
|
@@ -92,6 +92,30 @@ postcssDoublePositionGradients({ preserve: false })
|
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
### enableProgressiveCustomProperties
|
|
96
|
+
|
|
97
|
+
The `enableProgressiveCustomProperties` option determines whether the original notation
|
|
98
|
+
is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.
|
|
99
|
+
|
|
100
|
+
⚠️ We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties. See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
postcssDoublePositionGradients({ enableProgressiveCustomProperties: false })
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```pcss
|
|
107
|
+
:root {
|
|
108
|
+
--a-gradient: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* becomes */
|
|
112
|
+
|
|
113
|
+
:root {
|
|
114
|
+
--a-gradient: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%); /* will never be used, not even in older browser */
|
|
115
|
+
--a-gradient: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
95
119
|
[css-url]: https://cssdb.org/#double-position-gradients
|
|
96
120
|
[discord]: https://discord.gg/bUadyRwkJS
|
|
97
121
|
[npm-url]: https://www.npmjs.com/package/postcss-double-position-gradients
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),t=require("postcss-value-parser");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),i=r(t);function a(e){return e.includes("conic-gradient(")||e.includes("linear-gradient(")||e.includes("radial-gradient(")||e.includes("repeating-conic-gradient(")||e.includes("repeating-linear-gradient(")||e.includes("repeating-radial-gradient(")}const s=e=>"div"===e.type&&","===e.value;function o(e){try{return!1!==i.default.unit(null==e?void 0:e.value)}catch(e){return!1}}const u=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(t,{result:r}){if(!a(t.value))return;if(function(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name&&a(t.params))return!0;t=t.parent}else t=t.parent;return!1}(t))return;let n;try{n=i.default(t.value)}catch(e){t.warn(r,`Failed to parse value '${t.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===n)return;n.walk((e=>{if("function"!==e.type||"conic-gradient"!==(t=e.value)&&"linear-gradient"!==t&&"radial-gradient"!==t&&"repeating-conic-gradient"!==t&&"repeating-linear-gradient"!==t&&"repeating-radial-gradient"!==t)return;var t;return e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type)).forEach(((t,r,n)=>{const i=Object(n[r-1]),a=Object(n[r-2]),u=Object(n[r+1]);if(a.type&&o(i)&&o(t)){const r={type:a.type,value:a.value},n={type:"div",value:",",before:s(u)?u.before:"",after:s(u)?"":" "};!function(e,t,...r){const n=e.findIndex((e=>e===t));e.splice.apply(e,[n-1,0].concat(Array.prototype.slice.call(...r,0)))}(e.nodes,t,[n,r])}})),!1}));const u=n.toString();if(u!==t.value){if(e.preserve)return void t.cloneBefore({value:u});t.value=u}}});u.postcss=!0;const l=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[n.default(),u(t)]}:u(t)};l.postcss=!0,module.exports=l;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"postcss-value-parser";
|
|
1
|
+
import e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";function r(e){return e.includes("conic-gradient(")||e.includes("linear-gradient(")||e.includes("radial-gradient(")||e.includes("repeating-conic-gradient(")||e.includes("repeating-linear-gradient(")||e.includes("repeating-radial-gradient(")}const n=e=>"div"===e.type&&","===e.value;function i(e){try{return!1!==t.unit(null==e?void 0:e.value)}catch(e){return!1}}const a=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(a,{result:s}){if(!r(a.value))return;if(function(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name&&r(t.params))return!0;t=t.parent}else t=t.parent;return!1}(a))return;let o;try{o=t(a.value)}catch(e){a.warn(s,`Failed to parse value '${a.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===o)return;o.walk((e=>{if("function"!==e.type||"conic-gradient"!==(t=e.value)&&"linear-gradient"!==t&&"radial-gradient"!==t&&"repeating-conic-gradient"!==t&&"repeating-linear-gradient"!==t&&"repeating-radial-gradient"!==t)return;var t;return e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type)).forEach(((t,r,a)=>{const s=Object(a[r-1]),o=Object(a[r-2]),c=Object(a[r+1]);if(o.type&&i(s)&&i(t)){const r={type:o.type,value:o.value},i={type:"div",value:",",before:n(c)?c.before:"",after:n(c)?"":" "};!function(e,t,...r){const n=e.findIndex((e=>e===t));e.splice.apply(e,[n-1,0].concat(Array.prototype.slice.call(...r,0)))}(e.nodes,t,[i,r])}})),!1}));const c=o.toString();if(c!==a.value){if(e.preserve)return void a.cloneBefore({value:c});a.value=c}}});a.postcss=!0;const s=t=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),a(r)]}:a(r)};s.postcss=!0;export{s as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-double-position-gradients",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Use double-position gradients in CSS",
|
|
5
5
|
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
|
6
6
|
"license": "CC0-1.0",
|
|
@@ -27,19 +27,17 @@
|
|
|
27
27
|
"lint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
|
|
28
28
|
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
29
29
|
"stryker": "stryker run --logLevel error",
|
|
30
|
-
"test": "
|
|
31
|
-
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs"
|
|
30
|
+
"test": "node .tape.mjs && npm run test:exports",
|
|
31
|
+
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
|
|
32
|
+
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
32
33
|
},
|
|
33
34
|
"engines": {
|
|
34
35
|
"node": "^12 || ^14 || >=16"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
38
|
+
"@csstools/postcss-progressive-custom-properties": "^1.1.0",
|
|
37
39
|
"postcss-value-parser": "^4.2.0"
|
|
38
40
|
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"postcss": "^8.3.6",
|
|
41
|
-
"postcss-tape": "^6.0.1"
|
|
42
|
-
},
|
|
43
41
|
"peerDependencies": {
|
|
44
42
|
"postcss": "^8.4"
|
|
45
43
|
},
|