├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── test.yml ├── .gitignore ├── .rollup.js ├── .tape.js ├── CHANGELOG.md ├── CONTRIBUTING.md ├── INSTALL.md ├── LICENSE.md ├── README.md ├── package.json ├── src ├── index.d.ts ├── index.js ├── onCSSDeclaration.js └── options.js └── test ├── basic.css ├── basic.expect.css ├── basic.preserve.expect.css ├── clip-path.css └── clip-path.expect.css /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = tab 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | 13 | [*.{json,md,yml}] 14 | indent_size = 2 15 | indent_style = space 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | on: 3 | push: 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | node: [12, 16] 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-node@v2 14 | with: 15 | node-version: ${{ matrix.node }} 16 | 17 | - run: yarn install --ignore-scripts 18 | - run: yarn run test 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | package-lock.json 4 | yarn.lock 5 | *.log* 6 | *.result.css 7 | .* 8 | !.editorconfig 9 | !.gitattributes 10 | !.github 11 | !.gitignore 12 | !.rollup.js 13 | !.tape.js 14 | -------------------------------------------------------------------------------- /.rollup.js: -------------------------------------------------------------------------------- 1 | import babel from '@rollup/plugin-babel' 2 | import copy from 'rollup-plugin-copy' 3 | 4 | export default { 5 | input: 'src/index.js', 6 | output: [ 7 | { file: 'dist/index.cjs', format: 'cjs', sourcemap: true, exports: 'default' }, 8 | { file: 'dist/index.mjs', format: 'esm', sourcemap: true }, 9 | ], 10 | plugins: [ 11 | babel({ 12 | babelHelpers: 'bundled', 13 | plugins: [ 14 | '@babel/plugin-syntax-dynamic-import' 15 | ], 16 | presets: [ 17 | [ 18 | '@babel/env', 19 | { 20 | modules: false, 21 | targets: { 22 | node: 10, 23 | }, 24 | }, 25 | ], 26 | ], 27 | }), 28 | copy({ 29 | targets: [ 30 | { 31 | src: 'src/index.d.ts', 32 | dest: 'dist' 33 | }, 34 | ], 35 | }), 36 | ], 37 | } 38 | -------------------------------------------------------------------------------- /.tape.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'basic': { 3 | message: 'supports basic usage' 4 | }, 5 | 'basic:preserve': { 6 | message: 'supports { preserve: true } usage', 7 | options: { 8 | preserve: true 9 | } 10 | }, 11 | 'clip-path': { 12 | message: 'ignores clip-path with hash in url' 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changes to PostCSS Color Hex Alpha 2 | 3 | ### 8.0.0 (September 22, 2021) 4 | 5 | - Updated: PostCSS Values Parser to v8 (major). 6 | - Added missing `dist` to bundle. 7 | - Added missing `exports` to `package.json` 8 | - Added missing `types` to `package.json` 9 | - Added bundling & testing as prepublish step. 10 | 11 | ### 7.0.0 (January 12, 2021) 12 | 13 | - Updated: Support for PostCSS v8+ 14 | 15 | ### 6.0.0 (April 25, 2020) 16 | 17 | - Updated: `postcss` to 7.0.27 (patch). 18 | - Updated: `postcss-values-parser` to 3.2.0 (major). 19 | - Updated: Node support to 10.0.0 (major). 20 | - Updated: Feature to use new percentage syntax. 21 | - Removed: Support for the removed `gray()` function. 22 | 23 | ### 5.0.3 (March 30, 2019) 24 | 25 | - Fixed: Issue with SVG hashes being interpretted as hex colors 26 | - Updated: `postcss` to 7.0.14 (patch) 27 | - Updated: `postcss-values-parser` to 2.0.1 (patch) 28 | 29 | ### 5.0.2 (September 18, 2018) 30 | 31 | - Updated: PostCSS Values Parser 2 (patch for this project) 32 | 33 | ### 5.0.1 (September 18, 2018) 34 | 35 | - Fixed: Issue correclty calculating each channel 36 | 37 | ### 5.0.0 (September 18, 2018) 38 | 39 | - Initial version 40 | 41 | ### 4.0.0 (September 17, 2018) 42 | 43 | - Updated: Support for PostCSS v7+ 44 | - Updated: Support for Node v6+ 45 | - Updated: color v3+ 46 | 47 | ### 3.0.0 (May 15, 2017) 48 | 49 | - Added: compatibility with postcss v6.x 50 | - Updated dependencies 51 | 52 | ### 2.0.0 (September 8, 2015) 53 | 54 | - Added: compatibility with postcss v5.x 55 | - Removed: compatiblity with postcss v4.x 56 | 57 | ### 1.3.0 (August 13, 2015) 58 | 59 | - Added: compatibility with postcss v4.1.x 60 | ([#3](https://github.com/postcss/postcss-color-hex-alpha/pull/3)) 61 | 62 | ### 1.1.0 (November 25, 2014) 63 | 64 | - Enhanced exceptions 65 | 66 | ### 1.0.0 - (October 4, 2014) 67 | 68 | Initial release from [postcss-color](https://github.com/postcss/postcss-color) 69 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to PostCSS Color Hex Alpha 2 | 3 | You want to help? You rock! Now, take a moment to be sure your contributions 4 | make sense to everyone else. 5 | 6 | ## Reporting Issues 7 | 8 | Found a problem? Want a new feature? 9 | 10 | - See if your issue or idea has [already been reported]. 11 | - Provide a [reduced test case] or a [live example]. 12 | 13 | Remember, a bug is a _demonstrable problem_ caused by _our_ code. 14 | 15 | ## Submitting Pull Requests 16 | 17 | Pull requests are the greatest contributions, so be sure they are focused in 18 | scope and avoid unrelated commits. 19 | 20 | 1. To begin; [fork this project], clone your fork, and add our upstream. 21 | ```bash 22 | # Clone your fork of the repo into the current directory 23 | git clone git@github.com:YOUR_USER/postcss-color-hex-alpha.git 24 | 25 | # Navigate to the newly cloned directory 26 | cd postcss-color-hex-alpha 27 | 28 | # Assign the original repo to a remote called "upstream" 29 | git remote add upstream git@github.com:postcss/postcss-color-hex-alpha.git 30 | 31 | # Install the tools necessary for testing 32 | npm install 33 | ``` 34 | 35 | 2. Create a branch for your feature or fix: 36 | ```bash 37 | # Move into a new branch for your feature 38 | git checkout -b feature/thing 39 | ``` 40 | ```bash 41 | # Move into a new branch for your fix 42 | git checkout -b fix/something 43 | ``` 44 | 45 | 3. If your code follows our practices, then push your feature branch: 46 | ```bash 47 | # Test current code 48 | npm test 49 | ``` 50 | ```bash 51 | # Push the branch for your new feature 52 | git push origin feature/thing 53 | ``` 54 | ```bash 55 | # Or, push the branch for your update 56 | git push origin update/something 57 | ``` 58 | 59 | That’s it! Now [open a pull request] with a clear title and description. 60 | 61 | [already been reported]: issues 62 | [fork this project]: fork 63 | [live example]: https://codepen.io/pen 64 | [open a pull request]: https://help.github.com/articles/using-pull-requests/ 65 | [reduced test case]: https://css-tricks.com/reduced-test-cases/ 66 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installing PostCSS Color Hex Alpha 2 | 3 | [PostCSS Color Hex Alpha] runs in all Node environments, with special instructions for: 4 | 5 | | [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) | 6 | | --- | --- | --- | --- | --- | --- | 7 | 8 | ## Node 9 | 10 | Add [PostCSS Color Hex Alpha] to your project: 11 | 12 | ```bash 13 | npm install postcss-color-hex-alpha --save-dev 14 | ``` 15 | 16 | Use [PostCSS Color Hex Alpha] to process your CSS: 17 | 18 | ```js 19 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 20 | 21 | postcssColorHexAlpha.process(YOUR_CSS /*, processOptions, pluginOptions */); 22 | ``` 23 | 24 | Or use it as a [PostCSS] plugin: 25 | 26 | ```js 27 | const postcss = require('postcss'); 28 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 29 | 30 | postcss([ 31 | postcssColorHexAlpha(/* pluginOptions */) 32 | ]).process(YOUR_CSS /*, processOptions */); 33 | ``` 34 | 35 | ## PostCSS CLI 36 | 37 | Add [PostCSS CLI] to your project: 38 | 39 | ```bash 40 | npm install postcss-cli --save-dev 41 | ``` 42 | 43 | Use [PostCSS Color Hex Alpha] in your `postcss.config.js` configuration file: 44 | 45 | ```js 46 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 47 | 48 | module.exports = { 49 | plugins: [ 50 | postcssColorHexAlpha(/* pluginOptions */) 51 | ] 52 | } 53 | ``` 54 | 55 | ## Webpack 56 | 57 | Add [PostCSS Loader] to your project: 58 | 59 | ```bash 60 | npm install postcss-loader --save-dev 61 | ``` 62 | 63 | Use [PostCSS Color Hex Alpha] in your Webpack configuration: 64 | 65 | ```js 66 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 67 | 68 | module.exports = { 69 | module: { 70 | rules: [ 71 | { 72 | test: /\.css$/, 73 | use: [ 74 | 'style-loader', 75 | { loader: 'css-loader', options: { importLoaders: 1 } }, 76 | { loader: 'postcss-loader', options: { 77 | ident: 'postcss', 78 | plugins: () => [ 79 | postcssColorHexAlpha(/* pluginOptions */) 80 | ] 81 | } } 82 | ] 83 | } 84 | ] 85 | } 86 | } 87 | ``` 88 | 89 | ## Create React App 90 | 91 | Add [React App Rewired] and [React App Rewire PostCSS] to your project: 92 | 93 | ```bash 94 | npm install react-app-rewired react-app-rewire-postcss --save-dev 95 | ``` 96 | 97 | Use [React App Rewire PostCSS] and [PostCSS Color Hex Alpha] in your 98 | `config-overrides.js` file: 99 | 100 | ```js 101 | const reactAppRewirePostcss = require('react-app-rewire-postcss'); 102 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 103 | 104 | module.exports = config => reactAppRewirePostcss(config, { 105 | plugins: () => [ 106 | postcssColorHexAlpha(/* pluginOptions */) 107 | ] 108 | }); 109 | ``` 110 | 111 | ## Gulp 112 | 113 | Add [Gulp PostCSS] to your project: 114 | 115 | ```bash 116 | npm install gulp-postcss --save-dev 117 | ``` 118 | 119 | Use [PostCSS Color Hex Alpha] in your Gulpfile: 120 | 121 | ```js 122 | const postcss = require('gulp-postcss'); 123 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 124 | 125 | gulp.task('css', () => gulp.src('./src/*.css').pipe( 126 | postcss([ 127 | postcssColorHexAlpha(/* pluginOptions */) 128 | ]) 129 | ).pipe( 130 | gulp.dest('.') 131 | )); 132 | ``` 133 | 134 | ## Grunt 135 | 136 | Add [Grunt PostCSS] to your project: 137 | 138 | ```bash 139 | npm install grunt-postcss --save-dev 140 | ``` 141 | 142 | Use [PostCSS Color Hex Alpha] in your Gruntfile: 143 | 144 | ```js 145 | const postcssColorHexAlpha = require('postcss-color-hex-alpha'); 146 | 147 | grunt.loadNpmTasks('grunt-postcss'); 148 | 149 | grunt.initConfig({ 150 | postcss: { 151 | options: { 152 | use: [ 153 | postcssColorHexAlpha(/* pluginOptions */) 154 | ] 155 | }, 156 | dist: { 157 | src: '*.css' 158 | } 159 | } 160 | }); 161 | ``` 162 | 163 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss 164 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss 165 | [PostCSS]: https://github.com/postcss/postcss 166 | [PostCSS CLI]: https://github.com/postcss/postcss-cli 167 | [PostCSS Loader]: https://github.com/postcss/postcss-loader 168 | [PostCSS Color Hex Alpha]: https://github.com/postcss/postcss-color-hex-alpha 169 | [React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss 170 | [React App Rewired]: https://github.com/timarney/react-app-rewired 171 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright © PostCSS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
3 | 4 | # PostCSS Color Hex Alpha [