{"name":"postcss-color-mod-function","version":"4.1.0","keywords":["postcss","css","postcss-plugin","colors","colours","modifications","mods","adjusters","adjustments","csswg","rgba","hsla","white","black","red","green","blue","alpha","hue","saturation","lightness","whiteness","blackness","tint","shade","blenda","contrast"],"author":{"name":"Jonathan Neal","email":"jonathantneal@hotmail.com"},"license":"CC0-1.0","_id":"postcss-color-mod-function@4.1.0","maintainers":[{"name":"romainmenke","email":"romainmenke@gmail.com"},{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"homepage":"https://github.com/jonathantneal/postcss-color-mod-function#readme","bugs":{"url":"https://github.com/jonathantneal/postcss-color-mod-function/issues"},"dist":{"shasum":"61ea8f55328510fe48e2a41a8807b68509f72634","tarball":"http://registry-npm.ywwl.com/postcss-color-mod-function/download/postcss-color-mod-function-4.1.0.tgz","fileCount":7,"integrity":"sha512-3OwwvrAopWai7uAYmH2uhiop8gYfAi3J8U5t4efN3bWERgzBsQwvw7kS3qavvxDtSJFp6oxydDzqgbsPGpkRvg==","signatures":[{"sig":"MEQCIE4nUv8oRcJXI8lcHYXQH6STojwpAhTIVPscNgKjA1bkAiBQeg2HjJ+nSGzRx2I7xMuPrqnUsJAfLq4gDg3PxLDTnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":343690,"size":61957,"noattachment":false,"key":"/postcss-color-mod-function/-/postcss-color-mod-function-4.1.0.tgz"},"main":"index.cjs.js","module":"index.es.mjs","engines":{"node":">= 18"},"gitHead":"008f01340a97619739b0e42eac621455f76d9060","scripts":{"test":"postcss-tape","build":"rollup -c .rollup.mjs --silent","pretest":"npm run build","prepublishOnly":"npm test"},"_npmUser":{"name":"romainmenke","email":"romainmenke@gmail.com"},"repository":{"url":"git+https://github.com/jonathantneal/postcss-color-mod-function.git","type":"git"},"_npmVersion":"10.8.3","description":"Modify colors using the color-mod() function in CSS","directories":{},"_nodeVersion":"20.17.0","dependencies":{"postcss-value-parser":"^4.2.0","@csstools/convert-colors":"^1.4.0"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.24.0","postcss":"^8.2.15","postcss-tape":"^6.0.1"},"peerDependencies":{"postcss":"^8.2.15"},"_npmOperationalInternal":{"tmp":"tmp/postcss-color-mod-function_4.1.0_1729261161834_0.9932935084487258","host":"s3://npm-registry-packages"},"readme":"# PostCSS color-mod() Function [<img src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS Logo\" width=\"90\" height=\"90\" align=\"right\">][postcss]\n\n[![NPM Version][npm-img]][npm-url]\n[![Test](https://github.com/csstools/postcss-color-mod-function/actions/workflows/test.yml/badge.svg)](https://github.com/csstools/postcss-color-mod-function/actions/workflows/test.yml)\n\n[PostCSS color-mod() Function] lets you modify colors using the `color-mod()`\nfunction in CSS, following the outdated version of [CSS Color Module Level 4] specification (05 July 2016).\n\n**⚠️ `color-mod()` has been removed from [Color Module Level 4 specification](https://www.w3.org/TR/css-color-4/#changes-from-20160705). ([Here's why](https://github.com/w3c/csswg-drafts/commit/034b063697c3dadf144504f52e0858a79cd84414))**\n\n```pcss\n:root {\n  --brand-red:      color-mod(yellow blend(red 50%));\n  --brand-red-hsl:  color-mod(yellow blend(red 50% hsl));\n  --brand-red-hwb:  color-mod(yellow blend(red 50% hwb));\n  --brand-red-dark: color-mod(red blackness(20%));\n}\n\n/* becomes */\n\n:root {\n  --brand-red:      rgb(255, 127.5, 0);\n  --brand-red-hsl:  rgb(255, 127.5, 255);\n  --brand-red-hwb:  rgb(255, 127.5, 0);\n  --brand-red-dark: rgb(204, 0, 0);\n}\n\n/* or, using stringifier(color) { return color.toString() } */\n\n:root {\n  --brand-red:      rgb(100% 50% 0% / 100%);\n  --brand-red-hsl:  hsl(30 100% 50% / 100%);\n  --brand-red-hwb:  hwb(30 0% 0% / 100%);\n  --brand-red-dark: hwb(0 0% 20% / 100%);\n}\n```\n\n### Supported Colors\n\nThe `color-mod()` function accepts `rgb()`, legacy comma-separated `rgb()`,\n`rgba()`, `hsl()`, legacy comma-separated `hsl()`, `hsla()`, `hwb()`, and\n`color-mod()` colors, as well as 3, 4, 6, and 8 digit hex colors, and named\ncolors without the need for additional plugins.\n\nImplemention details are available in\n[the specification](https://www.w3.org/TR/2016/WD-css-color-4-20160705/#funcdef-color-mod).\n\n### Supported Color Adjusters\n\nThe `color-mod()` function accepts `red()`, `green()`, `blue()`, `a()` /\n`alpha()`, `rgb()`, `h()` / `hue()`, `s()` / `saturation()`, `l()` /\n`lightness()`, `w()` / `whiteness()`, `b()` / `blackness()`, `tint()`,\n`shade()`, `blend()`, `blenda()`, and `contrast()` color adjusters.\n\nImplemention details are available in\n[the specification](https://www.w3.org/TR/css-color-4/#typedef-color-adjuster).\n\n### Supported Variables\n\nBy default, `var()` variables will be used if their corresponding Custom\nProperties are found in a `:root` rule, or if a fallback value is specified.\n\n## Usage\n\nAdd [PostCSS color-mod() Function] to your project:\n\n```bash\nnpm install postcss postcss-color-mod-function --save-dev\n```\n\nUse [PostCSS color-mod() Function] to process your CSS:\n\n```js\nconst postcssColorMod = require('postcss-color-mod-function');\n\npostcssColorMod.process(YOUR_CSS /*, processOptions, pluginOptions */);\n```\n\nOr use it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssColorMod = require('postcss-color-mod-function');\n\npostcss([\n  postcssColorMod(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[PostCSS color-mod() Function] runs in all Node environments, with special instructions for:\n\n| [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) |\n| --- | --- | --- | --- | --- | --- |\n\n## Options\n\n### stringifier\n\nThe `stringifier` option defines how transformed colors will be produced in CSS.\nBy default, legacy `rgb()` and `rgba()` colors are produced, but this can be\neasily updated to support [CSS Color Module Level 4 colors] colors.\n\n```js\nimport postcssColorMod from 'postcss-color-mod-function';\n\npostcssColorMod({\n  stringifier(color) {\n    return color.toString(); // use CSS Color Module Level 4 colors (rgb, hsl, hwb)\n  }\n});\n```\n\nFuture major releases of [PostCSS color-mod() Function] may reverse this\nfunctionality so that CSS Color Module Level 4 colors are produced by default.\n\n### unresolved\n\nThe `unresolved` option defines how unresolved functions and arguments should\nbe handled. The available options are `throw`, `warn`, and `ignore`. The\ndefault option is to `throw`.\n\nIf `ignore` is used, the `color-mod()` function will remain unchanged.\n\n```js\nimport postcssColorMod from 'postcss-color-mod-function';\n\npostcssColorMod({\n  unresolved: 'ignore' // ignore unresolved color-mod() functions\n});\n```\n\n### transformVars\n\nThe `transformVars` option defines whether `var()` variables used within\n`color-mod()` should be transformed into their corresponding Custom Properties\navailable in `:root`, or their fallback value if it is specified. By default,\n`var()` variables will be transformed.\n\nHowever, because these transformations occur at build time, they cannot be\nconsidered accurate. Accurately resolving cascading variables relies on\nknowledge of the living DOM tree.\n\n### importFrom\n\nThe `importFrom` option allows you to import variables from other sources,\nwhich might be CSS, JS, and JSON files, and directly passed objects.\n\n```js\npostcssColorMod({\n  importFrom: 'path/to/file.css' // :root { --brand-dark: blue; --brand-main: var(--brand-dark); }\n});\n```\n\n```pcss\n.brand-faded {\n  color: color-mod(var(--brand-main) a(50%));\n}\n\n/* becomes */\n\n.brand-faded {\n  color: rgba(0, 0, 255, .5);\n}\n```\n\nMultiple files can be passed into this option, and they will be parsed in the\norder they were received. JavaScript files, JSON files, and objects will need\nto namespace custom properties under a `customProperties` or\n`custom-properties` key.\n\n```js\npostcssColorMod({\n  importFrom: [\n    'path/to/file.css',   // :root { --brand-dark: blue; --brand-main: var(--brand-dark); }\n    'and/then/this.js',   // module.exports = { customProperties: { '--brand-dark': 'blue', '--brand-main': 'var(--brand-dark)' } }\n    'and/then/that.json', // { \"custom-properties\": { \"--brand-dark\": \"blue\", \"--brand-main\": \"var(--brand-dark)\" } }\n    {\n      customProperties: {\n        '--brand-dark': 'blue',\n        '--brand-main': 'var(--brand-dark)'\n      }\n    }\n  ]\n});\n```\n\nVariables may reference other variables, and this plugin will attempt to\nresolve them. If `transformVars` is set to `false` then `importFrom` will not\nbe used.\n\n[npm-img]: https://img.shields.io/npm/v/postcss-color-mod-function.svg\n[npm-url]: https://www.npmjs.com/package/postcss-color-mod-function\n\n[CSS Color Module Level 4]: https://www.w3.org/TR/2016/WD-css-color-4-20160705/#funcdef-color-mod\n[Gulp PostCSS]: https://github.com/postcss/gulp-postcss\n[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS color-mod() Function]: https://github.com/csstools/postcss-color-mod-function\n","publish_time":1729261162057,"_cnpm_publish_time":1729261162057,"dist-tags":{"latest":"4.1.1"}}