1 | # PostCSS Gray [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
|
---|
2 |
|
---|
3 | [![NPM Version][npm-img]][npm-url]
|
---|
4 | [![CSS Standard Status][css-img]][css-url]
|
---|
5 | [![Build Status][cli-img]][cli-url]
|
---|
6 | [![Support Chat][git-img]][git-url]
|
---|
7 |
|
---|
8 | [PostCSS Gray] lets you use the `gray()` color function in CSS, following the
|
---|
9 | [CSSWG Specification].
|
---|
10 |
|
---|
11 | ```pcss
|
---|
12 | body {
|
---|
13 | background-color: gray(100);
|
---|
14 | color: gray(0 / 90%);
|
---|
15 | }
|
---|
16 |
|
---|
17 | /* becomes */
|
---|
18 |
|
---|
19 | body {
|
---|
20 | background-color: rgb(255,255,255);
|
---|
21 | color: rgba(0,0,0,.9);
|
---|
22 | }
|
---|
23 | ```
|
---|
24 |
|
---|
25 | ## Usage
|
---|
26 |
|
---|
27 | Add [PostCSS Gray] to your project:
|
---|
28 |
|
---|
29 | ```bash
|
---|
30 | npm install postcss-color-gray --save-dev
|
---|
31 | ```
|
---|
32 |
|
---|
33 | Use [PostCSS Gray] to process your CSS:
|
---|
34 |
|
---|
35 | ```js
|
---|
36 | import postcssGray from 'postcss-color-gray';
|
---|
37 |
|
---|
38 | postcssGray.process(YOUR_CSS /*, processOptions, pluginOptions */);
|
---|
39 | ```
|
---|
40 |
|
---|
41 | Or use it as a [PostCSS] plugin:
|
---|
42 |
|
---|
43 | ```js
|
---|
44 | import postcss from 'postcss';
|
---|
45 | import postcssGray from 'postcss-color-gray';
|
---|
46 |
|
---|
47 | postcss([
|
---|
48 | postcssGray(/* pluginOptions */)
|
---|
49 | ]).process(YOUR_CSS /*, processOptions */);
|
---|
50 | ```
|
---|
51 |
|
---|
52 | [PostCSS Gray] runs in all Node environments, with special instructions for:
|
---|
53 |
|
---|
54 | | [Node](INSTALL.md#node) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
|
---|
55 | | --- | --- | --- | --- | --- |
|
---|
56 |
|
---|
57 | ## Options
|
---|
58 |
|
---|
59 | ### preserve
|
---|
60 |
|
---|
61 | The `preserve` option determines whether the original `gray()` function should
|
---|
62 | be preserved or replaced. By default, the `gray()` function is replaced.
|
---|
63 |
|
---|
64 | By setting `preserve` to `true`, the original `gray()` function is preserved.
|
---|
65 |
|
---|
66 | ```js
|
---|
67 | postcssGray({ preserve: true });
|
---|
68 | ```
|
---|
69 |
|
---|
70 | ```pcss
|
---|
71 | body {
|
---|
72 | background-color: gray(100);
|
---|
73 | color: gray(0 / 90%);
|
---|
74 | }
|
---|
75 |
|
---|
76 | /* becomes */
|
---|
77 |
|
---|
78 | body {
|
---|
79 | background-color: gray(100);
|
---|
80 | background-color: rgb(255,255,255);
|
---|
81 | color: gray(0 / 90%);
|
---|
82 | color: rgba(0,0,0,.9);
|
---|
83 | }
|
---|
84 | ```
|
---|
85 |
|
---|
86 | [cli-img]: https://img.shields.io/travis/postcss/postcss-color-gray.svg
|
---|
87 | [cli-url]: https://travis-ci.org/postcss/postcss-color-gray
|
---|
88 | [css-img]: https://cssdb.org/badge/gray-function.svg
|
---|
89 | [css-url]: https://cssdb.org/#gray-function
|
---|
90 | [git-img]: https://img.shields.io/badge/support-chat-blue.svg
|
---|
91 | [git-url]: https://gitter.im/postcss/postcss
|
---|
92 | [npm-img]: https://img.shields.io/npm/v/postcss-color-gray.svg
|
---|
93 | [npm-url]: https://www.npmjs.com/package/postcss-color-gray
|
---|
94 |
|
---|
95 | [PostCSS]: https://github.com/postcss/postcss
|
---|
96 | [PostCSS Gray]: https://github.com/postcss/postcss-color-gray
|
---|
97 | [CSSWG Specification]: https://drafts.csswg.org/css-color/#grays
|
---|