PostCSS plugin to transform gray() function to today's CSS
.foo {
color: gray(0);
}
.bar {
color: gray(255, 50%);
}
.baz {
color: gray;
}
↓
.foo {
color: rgb(0, 0, 0);
}
.bar {
color: rgba(255, 255, 255, 0.5);
}
.baz {
color: gray;
}
npm install postcss-color-gray
var postcssColorGray = require('postcss-color-gray');
Return: Function
It converts gray(A)
to rgb(A,A,A)
, and converts gray(A,B)
to rgba(A,A,A,B)
.
var postcss = require('postcss');
var colorGray = require('postcss-color-gray');
postcss()
.use(colorGray())
.process('a {color: gray(85); background-color: gray(10%, .25)}')
.css;
//=> 'a {color: rgb(85, 85, 85); background-color: rgba(26, 26, 26, 0.25)}'
Note that gray() may have a keyword argument to specify a color via "luminance". Current version of postcss-color-gray doesn't support this feature.
Copyright (c) 2017 Shinnosuke Watanabe
Licensed under the MIT License.