|
1 |
| -# postcss-color-function [](https://travis-ci.org/postcss/postcss-color-function) |
| 1 | +# postcss-color-function [](https://travis-ci.org/postcss/postcss-color-function) |
2 | 2 |
|
3 |
| -> [PostCSS](https://github.com/postcss/postcss) plugin to transform [W3C CSS color function](http://dev.w3.org/csswg/css-color/#modifying-colors) to more compatible CSS. |
| 3 | +> [PostCSS](https://github.com/postcss/postcss) plugin to transform [W3C CSS color function][specs] to more compatible CSS. |
4 | 4 |
|
5 | 5 | ## Installation
|
6 | 6 |
|
7 |
| -```bash |
| 7 | +```console |
8 | 8 | $ npm install postcss-color-function
|
9 | 9 | ```
|
10 | 10 |
|
@@ -43,19 +43,67 @@ body {
|
43 | 43 | }
|
44 | 44 | ```
|
45 | 45 |
|
46 |
| -Checkout [tests](test) for more examples. |
| 46 | +Checkout [tests](test) for examples. |
| 47 | + |
| 48 | +## Interface (according to CSS specs) |
| 49 | + |
| 50 | +``` |
| 51 | +color( [ <color> | <hue> ] <color-adjuster>* ) |
| 52 | +``` |
| 53 | + |
| 54 | +### List of `color-adjuster` |
| 55 | + |
| 56 | +- `[red( | green( | blue( | alpha( | a(] ['+' | '-']? [<number> | <percentage>] )` |
| 57 | +- `[red( | green( | blue( | alpha( | a(] '*' <percentage> )` |
| 58 | +- ~~`rgb( ['+' | '-'] [<number> | <percentage>]{3} )`~~ @todo |
| 59 | +- ~~`rgb( ['+' | '-'] <hash-token> )`~~ @todo |
| 60 | +- ~~`rgb( '*' <percentage> ) |`~~ @todo |
| 61 | +- `[hue( | h(] ['+' | '-' | '*']? <angle> )` |
| 62 | +- `[saturation( | s(] ['+' | '-' | '*']? <percentage> )` |
| 63 | +- `[lightness( | l(] ['+' | '-' | '*']? <percentage> )` |
| 64 | +- `[whiteness( | w(] ['+' | '-' | '*']? <percentage> )` |
| 65 | +- `[blackness( | b(] ['+' | '-' | '*']? <percentage> )` |
| 66 | +- `tint( <percentage> )` |
| 67 | +- `shade( <percentage> )` |
| 68 | +- `blend( <color> <percentage> [rgb | hsl | hwb]? )` |
| 69 | +- ~~`blenda( <color> <percentage> [rgb | hsl | hwb]? )`~~ @todo |
| 70 | +- ~~`contrast( <percentage>? )`~~ @todo |
| 71 | + |
| 72 | +Notes: |
| 73 | + |
| 74 | +- some adjusts have shortcuts, |
| 75 | +- can be used on every value on any property, |
| 76 | +- some values can use add/subtract/scale modifiers or a direct value. |
| 77 | + |
| 78 | +[Read the specs][specs] for more information. |
| 79 | + |
| 80 | +### Examples |
| 81 | + |
| 82 | +```css |
| 83 | +whatever { |
| 84 | + color: color(red a(10%); |
| 85 | + |
| 86 | + background-color: color(red lightness(50%)); /* == color(red l(50%)); */ |
| 87 | + |
| 88 | + border-color: color(hsla(125, 50%, 50%, .4) saturation(+ 10%) w(- 20%)); |
| 89 | +} |
| 90 | +``` |
47 | 91 |
|
48 | 92 | ---
|
49 | 93 |
|
50 | 94 | ## Contributing
|
51 | 95 |
|
52 | 96 | Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
|
53 | 97 |
|
54 |
| - $ git clone https://github.com/postcss/postcss-color-function.git |
55 |
| - $ git checkout -b patch-1 |
56 |
| - $ npm install |
57 |
| - $ npm test |
| 98 | +```console |
| 99 | +$ git clone https://github.com/postcss/postcss-color-function.git |
| 100 | +$ git checkout -b patch-1 |
| 101 | +$ npm install |
| 102 | +$ npm test |
| 103 | +``` |
58 | 104 |
|
59 | 105 | ## [Changelog](CHANGELOG.md)
|
60 | 106 |
|
61 | 107 | ## [License](LICENSE)
|
| 108 | + |
| 109 | +[specs]: (http://dev.w3.org/csswg/css-color/#modifying-colors) |
0 commit comments