postcss-colornorm

1.0.1 • Public • Published

PostCSS Colornorm

npm version GitHub Workflow Status

PostCSS plugin to normalize colors using colornorm to a specific format.

.foo {
  background-color: rgb(255 0 0 / 1);
  border-color: #ff0000ff;
  outline-color: Red;
  color: hsla(0, 100%, 50%, 1);
}
.foo {
  background-color: hsl(0 100% 50%);
  border-color: hsl(0 100% 50%);
  outline-color: hsl(0 100% 50%);
  color: hsl(0 100% 50%);
}

Defaults to hsl, as this is the most intuitive for humans, and supports all browsers back to IE9. This can be changed with a setting.

Usage

Step 1: Install plugin:

npm install --save-dev postcss postcss-colornorm

Step 2: Check you project for existed PostCSS config: postcss.config.js in the project root, "postcss" section in package.json or postcss in bundle config.

If you do not use PostCSS, add it according to official docs and set this plugin in settings.

Step 3: Add the plugin to plugins list:

module.exports = {
  plugins: [
+   require('postcss-colornorm'),
    require('autoprefixer')
  ]
}

Or to choose a different color output format, try:

Valid output color formats can be found on the colornorm docs.

module.exports = {
  plugins: [
+   require('postcss-colornorm')({ output: "hex" }),
    require('autoprefixer')
  ]
}

Package Sidebar

Install

npm i postcss-colornorm

Weekly Downloads

11

Version

1.0.1

License

MIT

Unpacked Size

7.79 kB

Total Files

10

Last publish

Collaborators

  • tbjgolden