postcss-minify-gradients 5.0.1 → 5.0.5

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/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var _postcssValueParser = _interopRequireWildcard(require("postcss-value-parser"
9
9
 
10
10
  var _cssnanoUtils = require("cssnano-utils");
11
11
 
12
- var _isColorStop = _interopRequireDefault(require("is-color-stop"));
12
+ var _isColorStop = _interopRequireDefault(require("./isColorStop.js"));
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
@@ -62,7 +62,7 @@ function optimise(decl) {
62
62
 
63
63
  let lastStop = null;
64
64
  args.forEach((arg, index) => {
65
- if (!arg[2]) {
65
+ if (arg.length !== 3) {
66
66
  return;
67
67
  }
68
68
 
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isColorStop;
7
+
8
+ var _postcssValueParser = require("postcss-value-parser");
9
+
10
+ var _colord = require("colord");
11
+
12
+ var _names = _interopRequireDefault(require("colord/plugins/names"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ (0, _colord.extend)([_names.default]);
17
+ /* Code derived from https://github.com/pigcan/is-color-stop */
18
+
19
+ const lengthUnits = new Set(['PX', 'IN', 'CM', 'MM', 'EM', 'REM', 'POINTS', 'PC', 'EX', 'CH', 'VW', 'VH', 'VMIN', 'VMAX', '%']);
20
+
21
+ function isCSSLengthUnit(input) {
22
+ return lengthUnits.has(input.toUpperCase());
23
+ }
24
+
25
+ function isStop(str) {
26
+ let stop = !str;
27
+
28
+ if (!stop) {
29
+ const node = (0, _postcssValueParser.unit)(str);
30
+
31
+ if (node) {
32
+ if (node.number === 0 || !isNaN(node.number) && isCSSLengthUnit(node.unit)) {
33
+ stop = true;
34
+ }
35
+ } else {
36
+ stop = /^calc\(\S+\)$/g.test(str);
37
+ }
38
+ }
39
+
40
+ return stop;
41
+ }
42
+
43
+ function isColorStop(color, stop) {
44
+ return (0, _colord.colord)(color).isValid() && isStop(stop);
45
+ }
46
+
47
+ module.exports = exports.default;
package/package.json CHANGED
@@ -1,13 +1,8 @@
1
1
  {
2
2
  "name": "postcss-minify-gradients",
3
- "version": "5.0.1",
3
+ "version": "5.0.5",
4
4
  "description": "Minify gradient parameters with PostCSS.",
5
5
  "main": "dist/index.js",
6
- "scripts": {
7
- "prebuild": "del-cli dist",
8
- "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
9
- "prepublish": "yarn build"
10
- },
11
6
  "files": [
12
7
  "LICENSE-MIT",
13
8
  "dist"
@@ -26,9 +21,9 @@
26
21
  },
27
22
  "repository": "cssnano/cssnano",
28
23
  "dependencies": {
29
- "cssnano-utils": "^2.0.1",
30
- "is-color-stop": "^1.1.0",
31
- "postcss-value-parser": "^4.1.0"
24
+ "colord": "^2.9.1",
25
+ "cssnano-utils": "^3.0.1",
26
+ "postcss-value-parser": "^4.2.0"
32
27
  },
33
28
  "bugs": {
34
29
  "url": "https://github.com/cssnano/cssnano/issues"
@@ -42,5 +37,9 @@
42
37
  "peerDependencies": {
43
38
  "postcss": "^8.2.15"
44
39
  },
45
- "gitHead": "28c247175032fa03f04911cde56ad82d74d211cc"
46
- }
40
+ "scripts": {
41
+ "prebuild": "rimraf dist",
42
+ "build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
43
+ },
44
+ "readme": "# [postcss][postcss]-minify-gradients\n\n> Minify gradient parameters with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-minify-gradients) do:\n\n```\nnpm install postcss-minify-gradients\n```\n\n\n## Example\n\nWhere possible, this module will minify gradient parameters. It can convert\nlinear gradient directional syntax to angles, remove the unnecessary `0%` and\n`100%` start and end values, and minimise color stops that use the same length\nvalues (the browser will adjust the value automatically).\n\n### Input\n\n```css\nh1 {\n background: linear-gradient(to bottom, #ffe500 0%, #ffe500 50%, #121 50%, #121 100%)\n}\n```\n\n### Output\n\n```css\nh1 {\n background: linear-gradient(180deg, #ffe500, #ffe500 50%, #121 0, #121)\n}\n```\n\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
45
+ }
package/CHANGELOG.md DELETED
@@ -1,77 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [5.0.1](https://github.com/cssnano/cssnano/compare/postcss-minify-gradients@5.0.0...postcss-minify-gradients@5.0.1) (2021-05-19)
7
-
8
- **Note:** Version bump only for package postcss-minify-gradients
9
-
10
-
11
-
12
-
13
-
14
- # [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-minify-gradients@5.0.0-rc.2...postcss-minify-gradients@5.0.0) (2021-04-06)
15
-
16
- **Note:** Version bump only for package postcss-minify-gradients
17
-
18
-
19
-
20
-
21
-
22
- # [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-minify-gradients@5.0.0-rc.1...postcss-minify-gradients@5.0.0-rc.2) (2021-03-15)
23
-
24
- **Note:** Version bump only for package postcss-minify-gradients
25
-
26
-
27
-
28
-
29
-
30
- # [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-minify-gradients@5.0.0-rc.0...postcss-minify-gradients@5.0.0-rc.1) (2021-03-04)
31
-
32
- **Note:** Version bump only for package postcss-minify-gradients
33
-
34
-
35
-
36
-
37
-
38
- # 5.0.0-rc.0 (2021-02-19)
39
-
40
-
41
- ### Bug Fixes
42
-
43
- * **postcss-minify-gradients:** don't break gradients with `var` and `env` functions ([#735](https://github.com/cssnano/cssnano/issues/735)) ([7fabd9d](https://github.com/cssnano/cssnano/commit/7fabd9d03c81142c5854d0c0a50bee15ed86c219))
44
-
45
-
46
- ### chore
47
-
48
- * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
49
-
50
-
51
- ### Features
52
-
53
- * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
54
-
55
-
56
- ### BREAKING CHANGES
57
-
58
- * minimum supported `postcss` version is `8.2.1`
59
- * minimum require version of node is 10.13
60
-
61
-
62
-
63
- ## 4.1.9 (2019-02-12)
64
-
65
-
66
- ### Bug Fixes
67
-
68
- * **postcss-minify-gradients:** handle uppercase ([#706](https://github.com/cssnano/cssnano/issues/706)) ([acd5d0e](https://github.com/cssnano/cssnano/commit/acd5d0eb59e76fe62b70faad89d6ee0f76f798ef))
69
-
70
-
71
-
72
- ## 4.1.1 (2018-09-24)
73
-
74
-
75
- ### Bug Fixes
76
-
77
- * **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)