applying transfer to react app

This commit is contained in:
Tyler Koenig
2021-09-20 16:54:47 -04:00
parent 8819f31dd0
commit c612b7d702
37373 changed files with 3775588 additions and 2871 deletions
+39
View File
@@ -0,0 +1,39 @@
# Changes to PostCSS Gray
### 5.0.0 (July 26, 2018)
- Rewritten to follow the latest [CSSWG specification](https://drafts.csswg.org/css-color/#grays)
- Added: Compatibility with PostCSS v7.
# 4.1.0 - December 19, 2017
- Changed: relicense ([MIT](https://opensource.org/licenses/MIT) → [ISC](https://opensource.org/licenses/ISC))
- Updated dependencies
# 4.0.0 - May 15, 2017
- Added: compatibility with PostCSS v6
- Updated dependencies
# 3.0.1 - November 28, 2016
- Bump `color` dependency version
(@KenanY)
# 3.0.0 - September 8, 2015
- Added: compatibility with PostCSS v5
- Removed: compatibility with PostCSS v4
# 2.0.0 - January 26, 2015
- Added: compatibility with PostCSS v4
- Removed: compatibility with PostCSS v3
# 1.1.0 - November 25, 2014
- Changed: Enhanced exceptions
# 1.0.0 - November 1, 2014
- Initial release
+18
View File
@@ -0,0 +1,18 @@
# ISC License (ISC)
## Copyright 2018 Shinnosuke Watanabe
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
For more information, please see
https://opensource.org/licenses/ISC.
+97
View File
@@ -0,0 +1,97 @@
# PostCSS Gray [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
[![NPM Version][npm-img]][npm-url]
[![CSS Standard Status][css-img]][css-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]
[PostCSS Gray] lets you use the `gray()` color function in CSS, following the
[CSSWG Specification].
```pcss
body {
background-color: gray(100);
color: gray(0 / 90%);
}
/* becomes */
body {
background-color: rgb(255,255,255);
color: rgba(0,0,0,.9);
}
```
## Usage
Add [PostCSS Gray] to your project:
```bash
npm install postcss-color-gray --save-dev
```
Use [PostCSS Gray] to process your CSS:
```js
import postcssGray from 'postcss-color-gray';
postcssGray.process(YOUR_CSS /*, processOptions, pluginOptions */);
```
Or use it as a [PostCSS] plugin:
```js
import postcss from 'postcss';
import postcssGray from 'postcss-color-gray';
postcss([
postcssGray(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```
[PostCSS Gray] runs in all Node environments, with special instructions for:
| [Node](INSTALL.md#node) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
| --- | --- | --- | --- | --- |
## Options
### preserve
The `preserve` option determines whether the original `gray()` function should
be preserved or replaced. By default, the `gray()` function is replaced.
By setting `preserve` to `true`, the original `gray()` function is preserved.
```js
postcssGray({ preserve: true });
```
```pcss
body {
background-color: gray(100);
color: gray(0 / 90%);
}
/* becomes */
body {
background-color: gray(100);
background-color: rgb(255,255,255);
color: gray(0 / 90%);
color: rgba(0,0,0,.9);
}
```
[cli-img]: https://img.shields.io/travis/postcss/postcss-color-gray.svg
[cli-url]: https://travis-ci.org/postcss/postcss-color-gray
[css-img]: https://cssdb.org/badge/gray-function.svg
[css-url]: https://cssdb.org/#gray-function
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[npm-img]: https://img.shields.io/npm/v/postcss-color-gray.svg
[npm-url]: https://www.npmjs.com/package/postcss-color-gray
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Gray]: https://github.com/postcss/postcss-color-gray
[CSSWG Specification]: https://drafts.csswg.org/css-color/#grays
+184
View File
@@ -0,0 +1,184 @@
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var postcss = _interopDefault(require('postcss'));
var parser = _interopDefault(require('postcss-values-parser'));
var convertColors = require('@csstools/convert-colors');
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var index = postcss.plugin('postcss-color-gray', opts => root => {
// walk all declarations likely containing a gray() function
root.walkDecls(decl => {
if (hasGrayFunction(decl)) {
const originalValue = decl.value; // parse the declaration value
const ast = parser(originalValue).parse(); // walk every node in the value that contains a gray() function
ast.walk(node => {
const _getFunctionGrayArgs = getFunctionGrayArgs(node),
_getFunctionGrayArgs2 = _slicedToArray(_getFunctionGrayArgs, 2),
lightness = _getFunctionGrayArgs2[0],
alpha = _getFunctionGrayArgs2[1];
if (lightness !== undefined) {
// rename the gray() function to rgb()
node.value = 'rgb'; // convert the lab gray lightness into rgb
const _lab2rgb$map = convertColors.lab2rgb(lightness, 0, 0).map(channel => Math.max(Math.min(Math.round(channel * 2.55), 255), 0)),
_lab2rgb$map2 = _slicedToArray(_lab2rgb$map, 3),
r = _lab2rgb$map2[0],
g = _lab2rgb$map2[1],
b = _lab2rgb$map2[2]; // preserve the slash nodes within rgb()
const openingSlash = node.first;
const closingSlash = node.last;
node.removeAll() // replace the contents of rgb with `(r,g,b`
.append(openingSlash).append(parser.number({
value: r
})).append(parser.comma({
value: ','
})).append(parser.number({
value: g
})).append(parser.comma({
value: ','
})).append(parser.number({
value: b
})); // if an alpha channel was defined
if (alpha < 1) {
// rename the rgb() function to rgba()
node.value += 'a';
node // append the contents of rgba with `,a`
.append(parser.comma({
value: ','
})).append(parser.number({
value: alpha
}));
} // append the contents of rgb/rgba with `)`
node.append(closingSlash);
}
});
const modifiedValue = ast.toString(); // if the modified value has changed from the original value
if (originalValue !== modifiedValue) {
// if the original gray() color is to be preserved
if (Object(opts).preserve) {
// insert the declaration value with the fallback before the current declaration
decl.cloneBefore({
value: modifiedValue
});
} else {
// otherwise, overwrite the declaration value with the fallback
decl.value = modifiedValue;
}
}
}
});
}); // return whether a string contains a gray() function
const hasGrayFunctionRegExp = /(^|[^\w-])gray\(/i;
const hasGrayFunction = decl => hasGrayFunctionRegExp.test(Object(decl).value); // return whether a node matches a specific type
const isNumber = node => Object(node).type === 'number';
const isOperator = node => Object(node).type === 'operator';
const isFunction = node => Object(node).type === 'func';
const isCalcRegExp = /^calc$/i;
const isFunctionCalc = node => isFunction(node) && isCalcRegExp.test(node.value);
const isGrayRegExp = /^gray$/i;
const isFunctionGrayWithArgs = node => isFunction(node) && isGrayRegExp.test(node.value) && node.nodes && node.nodes.length;
const isNumberPercentage = node => isNumber(node) && node.unit === '%';
const isNumberUnitless = node => isNumber(node) && node.unit === '';
const isOperatorSlash = node => isOperator(node) && node.value === '/'; // return valid values from a node, otherwise undefined
const getNumberUnitless = node => isNumberUnitless(node) ? Number(node.value) : undefined;
const getOperatorSlash = node => isOperatorSlash(node) ? null : undefined;
const getAlpha = node => isFunctionCalc(node) ? String(node) : isNumberUnitless(node) ? Number(node.value) : isNumberPercentage(node) ? Number(node.value) / 100 : undefined; // return valid arguments from a gray() function
const functionalGrayArgs = [getNumberUnitless, getOperatorSlash, getAlpha];
const getFunctionGrayArgs = node => {
const validArgs = []; // if the node is a gray() function with arguments
if (isFunctionGrayWithArgs(node)) {
// get all the gray() function arguments between `(` and `)`
const nodes = node.nodes.slice(1, -1); // validate each argument
for (const index in nodes) {
const arg = typeof functionalGrayArgs[index] === 'function' ? functionalGrayArgs[index](nodes[index]) : undefined; // if the argument was validated
if (arg !== undefined) {
// push any non-null argument to the valid arguments array
if (arg !== null) {
validArgs.push(arg);
}
} else {
// otherwise, return an empty array
return [];
}
} // return the valid arguments array
return validArgs;
} else {
// otherwise, return an empty array
return [];
}
};
module.exports = index;
+180
View File
@@ -0,0 +1,180 @@
import postcss from 'postcss';
import parser from 'postcss-values-parser';
import { lab2rgb } from '@csstools/convert-colors';
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var index = postcss.plugin('postcss-color-gray', opts => root => {
// walk all declarations likely containing a gray() function
root.walkDecls(decl => {
if (hasGrayFunction(decl)) {
const originalValue = decl.value; // parse the declaration value
const ast = parser(originalValue).parse(); // walk every node in the value that contains a gray() function
ast.walk(node => {
const _getFunctionGrayArgs = getFunctionGrayArgs(node),
_getFunctionGrayArgs2 = _slicedToArray(_getFunctionGrayArgs, 2),
lightness = _getFunctionGrayArgs2[0],
alpha = _getFunctionGrayArgs2[1];
if (lightness !== undefined) {
// rename the gray() function to rgb()
node.value = 'rgb'; // convert the lab gray lightness into rgb
const _lab2rgb$map = lab2rgb(lightness, 0, 0).map(channel => Math.max(Math.min(Math.round(channel * 2.55), 255), 0)),
_lab2rgb$map2 = _slicedToArray(_lab2rgb$map, 3),
r = _lab2rgb$map2[0],
g = _lab2rgb$map2[1],
b = _lab2rgb$map2[2]; // preserve the slash nodes within rgb()
const openingSlash = node.first;
const closingSlash = node.last;
node.removeAll() // replace the contents of rgb with `(r,g,b`
.append(openingSlash).append(parser.number({
value: r
})).append(parser.comma({
value: ','
})).append(parser.number({
value: g
})).append(parser.comma({
value: ','
})).append(parser.number({
value: b
})); // if an alpha channel was defined
if (alpha < 1) {
// rename the rgb() function to rgba()
node.value += 'a';
node // append the contents of rgba with `,a`
.append(parser.comma({
value: ','
})).append(parser.number({
value: alpha
}));
} // append the contents of rgb/rgba with `)`
node.append(closingSlash);
}
});
const modifiedValue = ast.toString(); // if the modified value has changed from the original value
if (originalValue !== modifiedValue) {
// if the original gray() color is to be preserved
if (Object(opts).preserve) {
// insert the declaration value with the fallback before the current declaration
decl.cloneBefore({
value: modifiedValue
});
} else {
// otherwise, overwrite the declaration value with the fallback
decl.value = modifiedValue;
}
}
}
});
}); // return whether a string contains a gray() function
const hasGrayFunctionRegExp = /(^|[^\w-])gray\(/i;
const hasGrayFunction = decl => hasGrayFunctionRegExp.test(Object(decl).value); // return whether a node matches a specific type
const isNumber = node => Object(node).type === 'number';
const isOperator = node => Object(node).type === 'operator';
const isFunction = node => Object(node).type === 'func';
const isCalcRegExp = /^calc$/i;
const isFunctionCalc = node => isFunction(node) && isCalcRegExp.test(node.value);
const isGrayRegExp = /^gray$/i;
const isFunctionGrayWithArgs = node => isFunction(node) && isGrayRegExp.test(node.value) && node.nodes && node.nodes.length;
const isNumberPercentage = node => isNumber(node) && node.unit === '%';
const isNumberUnitless = node => isNumber(node) && node.unit === '';
const isOperatorSlash = node => isOperator(node) && node.value === '/'; // return valid values from a node, otherwise undefined
const getNumberUnitless = node => isNumberUnitless(node) ? Number(node.value) : undefined;
const getOperatorSlash = node => isOperatorSlash(node) ? null : undefined;
const getAlpha = node => isFunctionCalc(node) ? String(node) : isNumberUnitless(node) ? Number(node.value) : isNumberPercentage(node) ? Number(node.value) / 100 : undefined; // return valid arguments from a gray() function
const functionalGrayArgs = [getNumberUnitless, getOperatorSlash, getAlpha];
const getFunctionGrayArgs = node => {
const validArgs = []; // if the node is a gray() function with arguments
if (isFunctionGrayWithArgs(node)) {
// get all the gray() function arguments between `(` and `)`
const nodes = node.nodes.slice(1, -1); // validate each argument
for (const index in nodes) {
const arg = typeof functionalGrayArgs[index] === 'function' ? functionalGrayArgs[index](nodes[index]) : undefined; // if the argument was validated
if (arg !== undefined) {
// push any non-null argument to the valid arguments array
if (arg !== null) {
validArgs.push(arg);
}
} else {
// otherwise, return an empty array
return [];
}
} // return the valid arguments array
return validArgs;
} else {
// otherwise, return an empty array
return [];
}
};
export default index;
+93
View File
@@ -0,0 +1,93 @@
{
"_from": "postcss-color-gray@^5.0.0",
"_id": "postcss-color-gray@5.0.0",
"_inBundle": false,
"_integrity": "sha512-q6BuRnAGKM/ZRpfDascZlIZPjvwsRye7UDNalqVz3s7GDxMtqPY6+Q871liNxsonUw8oC61OG+PSaysYpl1bnw==",
"_location": "/postcss-color-gray",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "postcss-color-gray@^5.0.0",
"name": "postcss-color-gray",
"escapedName": "postcss-color-gray",
"rawSpec": "^5.0.0",
"saveSpec": null,
"fetchSpec": "^5.0.0"
},
"_requiredBy": [
"/postcss-preset-env"
],
"_resolved": "https://registry.npmjs.org/postcss-color-gray/-/postcss-color-gray-5.0.0.tgz",
"_shasum": "532a31eb909f8da898ceffe296fdc1f864be8547",
"_spec": "postcss-color-gray@^5.0.0",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/postcss-preset-env",
"author": {
"name": "Shinnosuke Watanabe",
"url": "https://github.com/shinnn"
},
"bugs": {
"url": "https://github.com/postcss/postcss-color-gray/issues"
},
"bundleDependencies": false,
"dependencies": {
"@csstools/convert-colors": "^1.4.0",
"postcss": "^7.0.5",
"postcss-values-parser": "^2.0.0"
},
"deprecated": false,
"description": "Use the gray() color function in CSS",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.6.1",
"eslint-config-dev": "^2.0.0",
"postcss-tape": "^2.2.0",
"pre-commit": "^1.2.2",
"rollup": "^0.66.5",
"rollup-plugin-babel": "^4.0.1"
},
"engines": {
"node": ">=6.0.0"
},
"eslintConfig": {
"extends": "dev",
"parser": "babel-eslint"
},
"files": [
"index.cjs.js",
"index.es.js"
],
"homepage": "https://github.com/postcss/postcss-color-gray#readme",
"keywords": [
"postcss",
"css",
"postcss-plugin",
"gray",
"color",
"lab",
"transform",
"function",
"csswg",
"w3c",
"specification"
],
"license": "ISC",
"main": "index.cjs.js",
"module": "index.es.js",
"name": "postcss-color-gray",
"repository": {
"type": "git",
"url": "git+https://github.com/postcss/postcss-color-gray.git"
},
"scripts": {
"prepublishOnly": "npm test",
"pretest": "rollup -c .rollup.js --silent",
"test": "echo 'Running tests...'; npm run test:js && npm run test:tape",
"test:ec": "echint --ignore index.*.js test",
"test:js": "eslint *.js --cache --ignore-path .gitignore --quiet",
"test:tape": "postcss-tape"
},
"version": "5.0.0"
}