diff options
Diffstat (limited to 'node_modules/postcss-calc')
| -rwxr-xr-x | node_modules/postcss-calc/CHANGELOG.md | 63 | ||||
| -rwxr-xr-x | node_modules/postcss-calc/LICENSE | 20 | ||||
| -rwxr-xr-x | node_modules/postcss-calc/README.md | 171 | ||||
| -rwxr-xr-x | node_modules/postcss-calc/index.js | 62 | ||||
| -rw-r--r-- | node_modules/postcss-calc/package.json | 33 |
5 files changed, 349 insertions, 0 deletions
diff --git a/node_modules/postcss-calc/CHANGELOG.md b/node_modules/postcss-calc/CHANGELOG.md new file mode 100755 index 00000000..f71a0d08 --- /dev/null +++ b/node_modules/postcss-calc/CHANGELOG.md @@ -0,0 +1,63 @@ +# 5.3.1 - 2016-08-22 + +- Fixed: avoid security issue related to ``reduce-css-calc@< 1.2.4``. + +# 5.3.0 - 2016-07-11 + +- Added: support for selector transformation via `selectors` option. + ([#29](https://github.com/postcss/postcss-calc/pull/29) - @uniquegestaltung) + +# 5.2.1 - 2016-04-10 + +- Fixed: support for multiline value + ([#27](https://github.com/postcss/postcss-calc/pull/27))
+ +# 5.2.0 - 2016-01-08 + +- Added: "mediaQueries" option for `@media` support +([#22](https://github.com/postcss/postcss-calc/pull/22)) + +# 5.1.0 - 2016-01-07 + +- Added: "warnWhenCannotResolve" option to warn when calc() are not reduced to a single value +([#20](https://github.com/postcss/postcss-calc/pull/20)) + +# 5.0.0 - 2015-08-25 + +- Removed: compatibility with postcss v4.x +- Added: compatibility with postcss v5.x + +# 4.1.0 - 2015-04-09 + +- Added: compatibility with postcss v4.1.x ([#12](https://github.com/postcss/postcss-calc/pull/12)) + +# 4.0.1 - 2015-04-09 + +- Fixed: `preserve` option does not create duplicated values ([#7](https://github.com/postcss/postcss-calc/issues/7)) + +# 4.0.0 - 2015-01-26 + +- Added: compatibility with postcss v4.x +- Changed: partial compatiblity with postcss v3.x (stack traces have lost filename) + +# 3.0.0 - 2014-11-24 + +- Added: GNU like exceptions ([#4](https://github.com/postcss/postcss-calc/issues/4)) +- Added: `precision` option ([#5](https://github.com/postcss/postcss-calc/issues/5)) +- Added: `preserve` option ([#6](https://github.com/postcss/postcss-calc/issues/6)) + +# 2.1.0 - 2014-10-15 + +- Added: source of the error (gnu like message) (fix [#3](https://github.com/postcss/postcss-calc/issues/3)) + +# 2.0.1 - 2014-08-10 + +- Fixed: correctly ignore unrecognized values (fix [#2](https://github.com/postcss/postcss-calc/issues/2)) + +# 2.0.0 - 2014-08-06 + +- Changed: Plugin now return a function to have a consistent api. ([ref 1](https://github.com/ianstormtaylor/rework-color-function/issues/6), [ref 2](https://twitter.com/jongleberry/status/496552790416576513)) + +# 1.0.0 - 2014-08-04 + +✨ First release based on [rework-calc](https://github.com/reworkcss/rework-calc) v1.1.0 (code mainly exported to [`reduce-css-calc`](https://github.com/MoOx/reduce-css-calc)) diff --git a/node_modules/postcss-calc/LICENSE b/node_modules/postcss-calc/LICENSE new file mode 100755 index 00000000..8b39b8f1 --- /dev/null +++ b/node_modules/postcss-calc/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Maxime Thirouin + +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-calc/README.md b/node_modules/postcss-calc/README.md new file mode 100755 index 00000000..a2caa03e --- /dev/null +++ b/node_modules/postcss-calc/README.md @@ -0,0 +1,171 @@ +# postcss-calc [](https://travis-ci.org/postcss/postcss-calc) + +> [PostCSS](https://github.com/postcss/postcss) plugin to reduce `calc()`. + +This plugin reduce `calc()` references whenever it's possible. +This can be particularly useful with the [postcss-custom-properties](https://github.com/postcss/postcss-custom-properties) plugin. + +**Note:** When multiple units are mixed together in the same expression, the `calc()` statement is left as is, to fallback to the [w3c calc() feature](http://www.w3.org/TR/css3-values/#calc). + +## Installation + +```console +$ npm install postcss-calc +``` + +## Usage + +```js +// dependencies +var fs = require("fs") +var postcss = require("postcss") +var calc = require("postcss-calc") + +// css to be processed +var css = fs.readFileSync("input.css", "utf8") + +// process css +var output = postcss() + .use(calc()) + .process(css) + .css +``` + +**Example** (with [postcss-custom-properties](https://github.com/postcss/postcss-custom-properties) enabled as well): + +```js +// dependencies +var fs = require("fs") +var postcss = require("postcss") +var customProperties = require("postcss-custom-properties") +var calc = require("postcss-calc") + +// css to be processed +var css = fs.readFileSync("input.css", "utf8") + +// process css +var output = postcss() + .use(customProperties()) + .use(calc()) + .process(css) + .css +``` + +Using this `input.css`: + +```css +:root { + --main-font-size: 16px; +} + +body { + font-size: var(--main-font-size); +} + +h1 { + font-size: calc(var(--main-font-size) * 2); + height: calc(100px - 2em); + margin-bottom: calc( + var(--main-font-size) + * 1.5 + ) +} +``` + +you will get: + +```css +body { + font-size: 16px +} + +h1 { + font-size: 32px; + height: calc(100px - 2em); + margin-bottom: 24px +} +``` + +Checkout [tests](test) for more examples. + +### Options + +#### `precision` (default: `5`) + +Allow you to definine the precision for decimal numbers. + +```js +var out = postcss() + .use(calc({precision: 10})) + .process(css) + .css +``` + +#### `preserve` (default: `false`) + +Allow you to preserve calc() usage in output so browsers will handle decimal precision themselves. + +```js +var out = postcss() + .use(calc({preserve: true})) + .process(css) + .css +``` + +#### `warnWhenCannotResolve` (default: `false`) + +Adds warnings when calc() are not reduced to a single value. + +```js +var out = postcss() + .use(calc({warnWhenCannotResolve: true})) + .process(css) + .css +``` + +#### `mediaQueries` (default: `false`) + +Allows calc() usage as part of media query declarations. + +```js +var out = postcss() + .use(calc({mediaQueries: true})) + .process(css) + .css +``` + +#### `selectors` (default: `false`) + +Allows calc() usage as part of selectors. + +```js +var out = postcss() + .use(calc({selectors: true})) + .process(css) + .css +``` + +Example: + +```css +div[data-size="calc(3*3)"] { + width: 100px; +} +``` + +--- + +## Contributing + +Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. + +```console +$ git clone https://github.com/postcss/postcss-calc.git +$ git checkout -b patch-1 +$ npm install +$ npm test +``` + +## [Changelog](CHANGELOG.md) + +## [License](LICENSE) diff --git a/node_modules/postcss-calc/index.js b/node_modules/postcss-calc/index.js new file mode 100755 index 00000000..f0791b15 --- /dev/null +++ b/node_modules/postcss-calc/index.js @@ -0,0 +1,62 @@ +/** + * Module dependencies. + */ +var reduceCSSCalc = require("reduce-css-calc") +var helpers = require("postcss-message-helpers") +var postcss = require("postcss") + +var CONTAINS_CALC = /\bcalc\([\s\S]*?\)/ + +/** + * PostCSS plugin to reduce calc() function calls. + */ +module.exports = postcss.plugin("postcss-calc", function(options) { + options = options || {} + var precision = options.precision + var preserve = options.preserve + var warnWhenCannotResolve = options.warnWhenCannotResolve + var mediaQueries = options.mediaQueries + var selectors = options.selectors + + return function(style, result) { + function transformValue(node, property) { + var value = node[property] + + if (!value || !CONTAINS_CALC.test(value)) { + return + } + + helpers.try(function transformCSSCalc() { + var reducedValue = reduceCSSCalc(value, precision) + + if (warnWhenCannotResolve && CONTAINS_CALC.test(reducedValue)) { + result.warn("Could not reduce expression: " + value, + {plugin: "postcss-calc", node: node}) + } + + if (!preserve) { + node[property] = reducedValue + return + } + + if (reducedValue != value) { + var clone = node.clone() + clone[property] = reducedValue + node.parent.insertBefore(node, clone) + } + }, node.source) + } + + style.walk(function(rule) { + if (mediaQueries && rule.type === "atrule") { + return transformValue(rule, "params") + } + else if (rule.type === "decl") { + return transformValue(rule, "value") + } + else if (selectors && rule.type === "rule") { + return transformValue(rule, "selector") + } + }) + } +}) diff --git a/node_modules/postcss-calc/package.json b/node_modules/postcss-calc/package.json new file mode 100644 index 00000000..a0c52816 --- /dev/null +++ b/node_modules/postcss-calc/package.json @@ -0,0 +1,33 @@ +{ + "name": "postcss-calc", + "version": "5.3.1", + "description": "PostCSS plugin to reduce calc()", + "keywords": [ + "css", + "postcss", + "postcss-plugin", + "calculation", + "calc" + ], + "author": "Maxime Thirouin", + "license": "MIT", + "repository": "https://github.com/postcss/postcss-calc.git", + "files": [ + "index.js" + ], + "dependencies": { + "postcss-message-helpers": "^2.0.0", + "reduce-css-calc": "^1.2.6", + "postcss": "^5.0.2" + }, + "devDependencies": { + "eslint": "^1.0.0", + "npmpub": "^3.1.0", + "postcss-custom-properties": "^5.0.0", + "tape": "^3.0.0" + }, + "scripts": { + "test": "eslint . && tape test", + "release": "npmpub" + } +} |
