diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/postcss-minify-gradients | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/postcss-minify-gradients')
| -rw-r--r-- | node_modules/postcss-minify-gradients/CHANGELOG.md | 26 | ||||
| -rw-r--r-- | node_modules/postcss-minify-gradients/LICENSE-MIT | 22 | ||||
| -rw-r--r-- | node_modules/postcss-minify-gradients/README.md | 66 | ||||
| -rw-r--r-- | node_modules/postcss-minify-gradients/dist/index.js | 126 | ||||
| -rw-r--r-- | node_modules/postcss-minify-gradients/package.json | 57 |
5 files changed, 297 insertions, 0 deletions
diff --git a/node_modules/postcss-minify-gradients/CHANGELOG.md b/node_modules/postcss-minify-gradients/CHANGELOG.md new file mode 100644 index 00000000..80d4f54e --- /dev/null +++ b/node_modules/postcss-minify-gradients/CHANGELOG.md @@ -0,0 +1,26 @@ +# 1.0.5 + +* Resolves a crash on empty `linear-gradient()` functions. + +# 1.0.4 + +* Resolves an issue where `0` was being removed from intermediate colour stops + if preceding colour stops contained `calc()` (thanks to @jaybekster). + +# 1.0.3 + +* Resolves an issue where `0` was being incorrectly stripped from the final + colour stop value. + +# 1.0.2 + +* Resolves an issue where the module would incorrectly parse floating + point numbers. + +# 1.0.1 + +* Reduce function iterations (thanks to @TrySound). + +# 1.0.0 + +* Initial release. diff --git a/node_modules/postcss-minify-gradients/LICENSE-MIT b/node_modules/postcss-minify-gradients/LICENSE-MIT new file mode 100644 index 00000000..fd0e863a --- /dev/null +++ b/node_modules/postcss-minify-gradients/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info) + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/postcss-minify-gradients/README.md b/node_modules/postcss-minify-gradients/README.md new file mode 100644 index 00000000..55e3e4ec --- /dev/null +++ b/node_modules/postcss-minify-gradients/README.md @@ -0,0 +1,66 @@ +# [postcss][postcss]-minify-gradients [][ci] [][npm] [][deps] + +> Minify gradient parameters with PostCSS. + +## Install + +With [npm](https://npmjs.org/package/postcss-minify-gradients) do: + +``` +npm install postcss-minify-gradients +``` + + +## Example + +Where possible, this module will minify gradient parameters. It can convert +linear gradient directional syntax to angles, remove the unnecessary `0%` and +`100%` start and end values, and minimise color stops that use the same length +values (the browser will adjust the value automatically). + +### Input + +```css +h1 { + background: linear-gradient(to bottom, #ffe500 0%, #ffe500 50%, #121 50%, #121 100%) +} +``` + +### Output + +```css +h1 { + background: linear-gradient(180deg, #ffe500, #ffe500 50%, #121 0, #121) +} +``` + + +## Usage + +See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for +examples for your environment. + + +## Contributors + +Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): + +<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> +| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-minify-gradients/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-minify-gradients/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-minify-gradients/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-minify-gradients/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/1448788?v=3" width="100px;"/><br /><sub></sub>](https://github.com/huan086)<br />[🐛](https://github.com/ben-eb/postcss-minify-gradients/issues?q=author%3Ahuan086) | [<img src="https://avatars.githubusercontent.com/u/2485494?v=3" width="100px;"/><br /><sub>Mikhail</sub>](https://github.com/jaybekster)<br />[🐛](https://github.com/ben-eb/postcss-minify-gradients/issues?q=author%3Ajaybekster) [💻](https://github.com/ben-eb/postcss-minify-gradients/commits?author=jaybekster) [⚠️](https://github.com/ben-eb/postcss-minify-gradients/commits?author=jaybekster) | +| :---: | :---: | :---: | :---: | +<!-- ALL-CONTRIBUTORS-LIST:END --> + +This project follows the [all-contributors] specification. Contributions of +any kind welcome! + + +## License + +MIT © [Ben Briggs](http://beneb.info) + + +[all-contributors]: https://github.com/kentcdodds/all-contributors +[ci]: https://travis-ci.org/ben-eb/postcss-minify-gradients +[deps]: https://gemnasium.com/ben-eb/postcss-minify-gradients +[npm]: http://badge.fury.io/js/postcss-minify-gradients +[postcss]: https://github.com/postcss/postcss diff --git a/node_modules/postcss-minify-gradients/dist/index.js b/node_modules/postcss-minify-gradients/dist/index.js new file mode 100644 index 00000000..01ebe2d0 --- /dev/null +++ b/node_modules/postcss-minify-gradients/dist/index.js @@ -0,0 +1,126 @@ +'use strict'; + +exports.__esModule = true; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + +var _postcss = require('postcss'); + +var _postcss2 = _interopRequireDefault(_postcss); + +var _postcssValueParser = require('postcss-value-parser'); + +var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var angles = { + top: '0deg', + right: '90deg', + bottom: '180deg', + left: '270deg' +}; + +function getArguments(node) { + return node.nodes.reduce(function (list, child) { + if (child.type !== 'div') { + list[list.length - 1].push(child); + } else { + list.push([]); + } + return list; + }, [[]]); +} + +function isLessThan(a, b) { + return a.unit === b.unit && parseFloat(a.number) >= parseFloat(b.number); +} + +function optimise(decl) { + if (!~decl.value.indexOf('gradient')) { + return; + } + decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) { + if (node.type !== 'function') { + return false; + } + if (node.value === 'linear-gradient' || node.value === 'repeating-linear-gradient' || node.value === '-webkit-linear-gradient' || node.value === '-webkit-repeating-linear-gradient') { + var _ret = function () { + if (!node.nodes.length) { + return { + v: false + }; + } + var args = getArguments(node); + if (node.nodes[0].value === 'to' && args[0].length === 3) { + node.nodes = node.nodes.slice(2); + node.nodes[0].value = angles[node.nodes[0].value]; + } + var lastStop = null; + args.forEach(function (arg, index) { + if (!arg[2]) { + return; + } + var isFinalStop = index === args.length - 1; + var thisStop = (0, _postcssValueParser.unit)(arg[2].value); + if (lastStop === null) { + lastStop = thisStop; + if (!isFinalStop && lastStop && lastStop.number === '0' && lastStop.unit !== 'deg') { + arg[1].value = arg[2].value = ''; + } + return; + } + if (isLessThan(lastStop, thisStop)) { + arg[2].value = 0; + } + lastStop = thisStop; + if (isFinalStop && arg[2].value === '100%') { + arg[1].value = arg[2].value = ''; + } + }); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + if (node.value === 'radial-gradient' || node.value === 'repeating-radial-gradient' || node.value === '-webkit-radial-gradient' || node.value === '-webkit-repeating-radial-gradient') { + var _ret2 = function () { + if (!node.nodes.length) { + return { + v: false + }; + } + var args = getArguments(node); + var lastStop = void 0; + args.forEach(function (arg) { + if (!arg[2]) { + return; + } + var thisStop = (0, _postcssValueParser.unit)(arg[2].value); + if (!lastStop) { + lastStop = thisStop; + return; + } + if (isLessThan(lastStop, thisStop)) { + arg[2].value = 0; + } + lastStop = thisStop; + }); + return { + v: false + }; + }(); + + if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; + } + }).toString(); +} + +exports.default = _postcss2.default.plugin('postcss-minify-gradients', function () { + return function (css) { + return css.walkDecls(optimise); + }; +}); +module.exports = exports['default'];
\ No newline at end of file diff --git a/node_modules/postcss-minify-gradients/package.json b/node_modules/postcss-minify-gradients/package.json new file mode 100644 index 00000000..f85a7523 --- /dev/null +++ b/node_modules/postcss-minify-gradients/package.json @@ -0,0 +1,57 @@ +{ + "name": "postcss-minify-gradients", + "version": "1.0.5", + "description": "Minify gradient parameters with PostCSS.", + "main": "dist/index.js", + "scripts": { + "contributorAdd": "all-contributors add", + "contributorGenerate": "all-contributors generate", + "pretest": "eslint src", + "prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/", + "test": "ava src/__tests__", + "test-012": "ava src/__tests__" + }, + "files": [ + "LICENSE-MIT", + "dist" + ], + "keywords": [ + "css", + "postcss", + "postcss-plugin" + ], + "license": "MIT", + "devDependencies": { + "all-contributors-cli": "^3.0.5", + "ava": "^0.16.0", + "babel-cli": "^6.3.17", + "babel-core": "^6.3.26", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-preset-es2015": "^6.3.13", + "babel-preset-es2015-loose": "^7.0.0", + "babel-preset-stage-0": "^6.3.13", + "babel-register": "^6.9.0", + "del-cli": "^0.2.0", + "eslint": "^3.0.0", + "eslint-config-cssnano": "^3.0.0", + "eslint-plugin-babel": "^3.3.0", + "eslint-plugin-import": "^2.0.1" + }, + "homepage": "https://github.com/ben-eb/postcss-minify-gradients", + "author": { + "name": "Ben Briggs", + "email": "beneb.info@gmail.com", + "url": "http://beneb.info" + }, + "repository": "ben-eb/postcss-minify-gradients", + "dependencies": { + "postcss": "^5.0.12", + "postcss-value-parser": "^3.3.0" + }, + "ava": { + "require": "babel-register" + }, + "eslintConfig": { + "extends": "cssnano" + } +} |
