postcss-double-position-gradients 3.0.4 → 3.1.1
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 +24 -0
- package/README.md +27 -3
- package/dist/has-supports-at-rule-ancestor.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +1 -1
- package/dist/is-gradient.d.ts +2 -0
- package/package.json +72 -60
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changes to PostCSS Double Position Gradients
|
|
2
2
|
|
|
3
|
+
### 3.1.1 (March 7, 2022)
|
|
4
|
+
|
|
5
|
+
- Add typescript support
|
|
6
|
+
- Fix color functions.
|
|
7
|
+
- Fix `at` keyword with `at 20px 20px` being interpreted as a double position color stop.
|
|
8
|
+
|
|
9
|
+
### 3.1.0 (February 15, 2022)
|
|
10
|
+
|
|
11
|
+
- Ignore values in relevant `@supports` rules.
|
|
12
|
+
- Support double position gradients in Custom Properties.
|
|
13
|
+
|
|
14
|
+
```css
|
|
15
|
+
@supports (order: linear-gradient(90deg, black 25% 50%, blue 50% 75%)) {
|
|
16
|
+
.support {
|
|
17
|
+
/* is not processed */
|
|
18
|
+
order: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 3.0.5 (February 5, 2022)
|
|
24
|
+
|
|
25
|
+
- Improved `es module` and `commonjs` compatibility
|
|
26
|
+
|
|
3
27
|
### 3.0.4 (January 2, 2022)
|
|
4
28
|
|
|
5
29
|
- Removed Sourcemaps from package tarball.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# PostCSS Double Position Gradients [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
|
|
2
2
|
|
|
3
3
|
[<img alt="NPM Version" src="https://img.shields.io/npm/v/postcss-double-position-gradients.svg" height="20">][npm-url]
|
|
4
|
-
[<img alt="CSS Standard Status" src="https://cssdb.org/
|
|
5
|
-
[<img alt="
|
|
4
|
+
[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/double-position-gradients.svg" height="20">][css-url]
|
|
5
|
+
[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
|
|
6
6
|
|
|
7
7
|
[PostCSS Double Position Gradients] lets you use double-position gradients in
|
|
8
8
|
CSS, following the [CSS Image Values and Replaced Content] specification.
|
|
@@ -92,8 +92,32 @@ 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
|
|
98
122
|
|
|
99
123
|
[CSS Image Values and Replaced Content]: https://www.w3.org/TR/css-images-4/#color-stop-syntax
|
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 s(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 a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],o=e=>"div"===e.type&&","===e.value;function l(e){try{return!1!==i.default.unit(null==e?void 0:e.value)}catch(e){return!1}}const c=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(t,{result:r}){if(!s(t.value))return;if(function(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name&&s(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;const r=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let n=!1;r.forEach(((t,r,i)=>{if("word"===t.type&&a.includes(t.value)&&(n=!0),"div"===t.type&&","===t.value&&(n=!1),n)return;const s=Object(i[r-1]),c=Object(i[r-2]),u=Object(i[r+1]);if(c.type&&l(s)&&l(t)){const r=c,n={type:"div",value:",",before:o(u)?u.before:"",after:o(u)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const c=n.toString();if(c!==t.value){if(e.preserve)return void t.cloneBefore({value:c});t.value=c}}});c.postcss=!0;const u=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[n.default(),c(t)]}:c(t)};u.postcss=!0,module.exports=u;
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],i=e=>"div"===e.type&&","===e.value;function s(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:o}){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 l;try{l=t(a.value)}catch(e){a.warn(o,`Failed to parse value '${a.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===l)return;l.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;const r=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let a=!1;r.forEach(((t,r,o)=>{if("word"===t.type&&n.includes(t.value)&&(a=!0),"div"===t.type&&","===t.value&&(a=!1),a)return;const l=Object(o[r-1]),c=Object(o[r-2]),u=Object(o[r+1]);if(c.type&&s(l)&&s(t)){const r=c,n={type:"div",value:",",before:i(u)?u.before:"",after:i(u)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const c=l.toString();if(c!==a.value){if(e.preserve)return void a.cloneBefore({value:c});a.value=c}}});a.postcss=!0;const o=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)};o.postcss=!0;export{o as default};
|
package/package.json
CHANGED
|
@@ -1,62 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
"name": "postcss-double-position-gradients",
|
|
3
|
+
"description": "Use double-position gradients in CSS",
|
|
4
|
+
"version": "3.1.1",
|
|
5
|
+
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
|
6
|
+
"license": "CC0-1.0",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": "^12 || ^14 || >=16"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.cjs",
|
|
11
|
+
"module": "dist/index.mjs",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.cjs",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"LICENSE.md",
|
|
23
|
+
"README.md",
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@csstools/postcss-progressive-custom-properties": "^1.1.0",
|
|
28
|
+
"postcss-value-parser": "^4.2.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"postcss": "^8.4"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "rollup -c ../../rollup/default.js",
|
|
35
|
+
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
|
|
36
|
+
"docs": "node ../../.github/bin/generate-docs/install.mjs",
|
|
37
|
+
"lint": "npm run lint:eslint && npm run lint:package-json",
|
|
38
|
+
"lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
|
|
39
|
+
"lint:package-json": "node ../../.github/bin/format-package-json.mjs",
|
|
40
|
+
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
41
|
+
"test": "node .tape.mjs && npm run test:exports",
|
|
42
|
+
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
|
|
43
|
+
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/csstools/postcss-plugins.git",
|
|
49
|
+
"directory": "plugins/postcss-double-position-gradients"
|
|
50
|
+
},
|
|
51
|
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
|
52
|
+
"keywords": [
|
|
53
|
+
"color",
|
|
54
|
+
"conic",
|
|
55
|
+
"css",
|
|
56
|
+
"double",
|
|
57
|
+
"gradients",
|
|
58
|
+
"linear",
|
|
59
|
+
"position",
|
|
60
|
+
"postcss",
|
|
61
|
+
"postcss-plugin",
|
|
62
|
+
"radial",
|
|
63
|
+
"repeating",
|
|
64
|
+
"stop",
|
|
65
|
+
"syntax"
|
|
66
|
+
],
|
|
67
|
+
"csstools": {
|
|
68
|
+
"exportName": "postcssDoublePositionGradients",
|
|
69
|
+
"humanReadableName": "PostCSS Double Position Gradients"
|
|
70
|
+
},
|
|
71
|
+
"volta": {
|
|
72
|
+
"extends": "../../package.json"
|
|
73
|
+
}
|
|
62
74
|
}
|