This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
# Changes to PostCSS Color Hex Alpha
### 8.0.4 (June 10, 2022)
- Fixed: Issue with SVG hashes being interpreted as hex colors
### 8.0.3 (February 5, 2022)
- Improved `es module` and `commonjs` compatibility
### 8.0.2 (January 2, 2022)
- Removed Sourcemaps from package tarball.
- Moved CLI to CLI Package. See [announcement](https://github.com/csstools/postcss-plugins/discussions/121).
### 8.0.1 (December 16, 2021)
- Changed: now uses `postcss-value-parser` for parsing.
- Updated: documentation
### 8.0.0 (September 22, 2021)
- Updated: PostCSS Values Parser to v8 (major).
- Added missing `dist` to bundle.
- Added missing `exports` to `package.json`
- Added missing `types` to `package.json`
- Added bundling & testing as prepublish step.
### 7.0.0 (January 12, 2021)
- Updated: Support for PostCSS v8+
### 6.0.0 (April 25, 2020)
- Updated: `postcss` to 7.0.27 (patch).
- Updated: `postcss-values-parser` to 3.2.0 (major).
- Updated: Node support to 10.0.0 (major).
- Updated: Feature to use new percentage syntax.
- Removed: Support for the removed `gray()` function.
### 5.0.3 (March 30, 2019)
- Fixed: Issue with SVG hashes being interpretted as hex colors
- Updated: `postcss` to 7.0.14 (patch)
- Updated: `postcss-values-parser` to 2.0.1 (patch)
### 5.0.2 (September 18, 2018)
- Updated: PostCSS Values Parser 2 (patch for this project)
### 5.0.1 (September 18, 2018)
- Fixed: Issue correclty calculating each channel
### 5.0.0 (September 18, 2018)
- Initial version
### 4.0.0 (September 17, 2018)
- Updated: Support for PostCSS v7+
- Updated: Support for Node v6+
- Updated: color v3+
### 3.0.0 (May 15, 2017)
- Added: compatibility with postcss v6.x
- Updated dependencies
### 2.0.0 (September 8, 2015)
- Added: compatibility with postcss v5.x
- Removed: compatiblity with postcss v4.x
### 1.3.0 (August 13, 2015)
- Added: compatibility with postcss v4.1.x
([#3](https://github.com/postcss/postcss-color-hex-alpha/pull/3))
### 1.1.0 (November 25, 2014)
- Enhanced exceptions
### 1.0.0 - (October 4, 2014)
Initial release from [postcss-color](https://github.com/postcss/postcss-color)

View File

@@ -0,0 +1,21 @@
# The MIT License (MIT)
Copyright © PostCSS
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.

View File

@@ -0,0 +1,79 @@
# PostCSS Color Hex Alpha [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-color-hex-alpha.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/hexadecimal-alpha-notation.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
[PostCSS Color Hex Alpha] lets you use 4 & 8 character hex color notation in
CSS, following the [CSS Color Module] specification.
```pcss
body {
background: #9d9c;
}
/* becomes */
body {
background: rgba(153,221,153,0.8);
}
```
## Usage
Add [PostCSS Color Hex Alpha] to your project:
```bash
npm install postcss postcss-color-hex-alpha --save-dev
```
Use it as a [PostCSS] plugin:
```js
const postcss = require('postcss');
const postcssColorHexAlpha = require('postcss-color-hex-alpha');
postcss([
postcssColorHexAlpha(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```
[PostCSS Color Hex Alpha] runs in all Node environments, with special
instructions for:
| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [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 notation
is preserved. By default, it is not preserved.
```js
postcssColorHexAlpha({ preserve: true })
```
```pcss
body {
background: #9d9c;
}
/* becomes */
body {
background: rgba(153,221,153,0.8);
background: #9d9c;
}
```
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
[css-url]: https://cssdb.org/#hexadecimal-alpha-notation
[discord]: https://discord.gg/bUadyRwkJS
[npm-url]: https://www.npmjs.com/package/postcss-color-hex-alpha
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Loader]: https://github.com/postcss/postcss-loader
[PostCSS Color Hex Alpha]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-hex-alpha
[CSS Color Module]: https://www.w3.org/TR/css-color-4/#hex-notation

View File

@@ -0,0 +1 @@
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("postcss-value-parser"));const s=e=>{const s=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(e){if(!/#([0-9A-Fa-f]{4}(?:[0-9A-Fa-f]{4})?)\b/.test(e.value))return;const{value:a}=e,n=t.default(a);n.walk((e=>{if("function"===e.type&&"url"===e.value)return!1;(function(e){return"word"===e.type&&/^#([0-9A-Fa-f]{4}(?:[0-9A-Fa-f]{4})?)$/.test(e.value)})(e)&&r(e)}));const l=n.toString();l!==a&&(e.cloneBefore({value:l}),s.preserve||e.remove())}}};s.postcss=!0;const r=e=>{const t=e.value,s=`0x${5===t.length?t.slice(1).replace(/[0-9A-f]/g,"$&$&"):t.slice(1)}`,[r,a,n,l]=[parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),parseInt(s.slice(6,8),16),Math.round(parseInt(s.slice(8,10),16)/255*1e5)/1e5];e.value=`rgba(${r},${a},${n},${l})`};module.exports=s;

View File

@@ -0,0 +1,6 @@
import type { PluginCreator } from 'postcss';
declare type pluginOptions = {
preserve?: boolean;
};
declare const creator: PluginCreator<pluginOptions>;
export default creator;

View File

@@ -0,0 +1 @@
import e from"postcss-value-parser";const s=s=>{const r=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(s){if(!/#([0-9A-Fa-f]{4}(?:[0-9A-Fa-f]{4})?)\b/.test(s.value))return;const{value:a}=s,n=e(a);n.walk((e=>{if("function"===e.type&&"url"===e.value)return!1;(function(e){return"word"===e.type&&/^#([0-9A-Fa-f]{4}(?:[0-9A-Fa-f]{4})?)$/.test(e.value)})(e)&&t(e)}));const l=n.toString();l!==a&&(s.cloneBefore({value:l}),r.preserve||s.remove())}}};s.postcss=!0;const t=e=>{const s=e.value,t=`0x${5===s.length?s.slice(1).replace(/[0-9A-f]/g,"$&$&"):s.slice(1)}`,[r,a,n,l]=[parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),parseInt(t.slice(6,8),16),Math.round(parseInt(t.slice(8,10),16)/255*1e5)/1e5];e.value=`rgba(${r},${a},${n},${l})`};export{s as default};

View File

@@ -0,0 +1,97 @@
{
"name": "postcss-color-hex-alpha",
"description": "Use 4 & 8 character hex color notation in CSS",
"version": "8.0.4",
"contributors": [
{
"name": "Antonio Laguna",
"email": "antonio@laguna.es",
"url": "https://antonio.laguna.es"
},
{
"name": "Romain Menke",
"email": "romainmenke@gmail.com"
},
{
"name": "Jonathan Neal",
"email": "jonathantneal@hotmail.com"
},
{
"name": "Maxime Thirouin"
}
],
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/csstools"
},
"engines": {
"node": "^12 || ^14 || >=16"
},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
}
},
"files": [
"CHANGELOG.md",
"LICENSE.md",
"README.md",
"dist"
],
"dependencies": {
"postcss-value-parser": "^4.2.0"
},
"peerDependencies": {
"postcss": "^8.4"
},
"scripts": {
"build": "rollup -c ../../rollup/default.js",
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
"docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
"lint": "npm run lint:eslint && npm run lint:package-json",
"lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
"lint:package-json": "node ../../.github/bin/format-package-json.mjs",
"prepublishOnly": "npm run clean && npm run build && npm run test",
"test": "node .tape.mjs && npm run test:exports",
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
},
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-hex-alpha#readme",
"repository": {
"type": "git",
"url": "https://github.com/csstools/postcss-plugins.git",
"directory": "plugins/postcss-color-hex-alpha"
},
"bugs": "https://github.com/csstools/postcss-plugins/issues",
"keywords": [
"4-digit",
"8-digit",
"alpha",
"color",
"css",
"csswg",
"hex",
"postcss",
"postcss-plugin",
"spec",
"specification",
"transparency",
"transparent",
"w3c"
],
"csstools": {
"cssdbId": "hexadecimal-alpha-notation",
"exportName": "postcssColorHexAlpha",
"humanReadableName": "PostCSS Color Hex Alpha",
"specUrl": "https://www.w3.org/TR/css-color-4/#hex-notation"
},
"volta": {
"extends": "../../package.json"
}
}