1 | # [postcss][postcss]-convert-values [![Build Status](https://travis-ci.org/ben-eb/postcss-convert-values.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-convert-values.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-convert-values.svg)][deps]
|
2 |
|
3 | > Convert values with PostCSS (e.g. ms -> s)
|
4 |
|
5 | ## Install
|
6 |
|
7 | With [npm](https://npmjs.org/package/postcss-convert-values) do:
|
8 |
|
9 | ```
|
10 | npm install postcss-convert-values --save
|
11 | ```
|
12 |
|
13 | ## Example
|
14 |
|
15 | This plugin reduces CSS size by converting values to use different units
|
16 | where possible; for example, `500ms` can be represented as `.5s`. You can
|
17 | read more about these units in [this article][csstricks].
|
18 |
|
19 | ### Input
|
20 |
|
21 | ```css
|
22 | h1 {
|
23 | font-size: 16px;
|
24 | width: 0em
|
25 | }
|
26 | ```
|
27 |
|
28 | ### Output
|
29 |
|
30 | ```css
|
31 | h1 {
|
32 | font-size: 1pc;
|
33 | width: 0
|
34 | }
|
35 | ```
|
36 |
|
37 | Note that this plugin only covers conversions for duration and absolute length
|
38 | values. For color conversions, use [postcss-colormin][colormin].
|
39 |
|
40 | ## API
|
41 |
|
42 | ### convertValues([options])
|
43 |
|
44 | #### options
|
45 |
|
46 | ##### length
|
47 |
|
48 | Type: `boolean`
|
49 | Default: `true`
|
50 |
|
51 | Pass `false` to disable conversion from `px` to other absolute length units,
|
52 | such as `pc` & `pt` & vice versa.
|
53 |
|
54 | ##### time
|
55 |
|
56 | Type: `boolean`
|
57 | Default: `true`
|
58 |
|
59 | Pass `false` to disable conversion from `ms` to `s` & vice versa.
|
60 |
|
61 | ##### angle
|
62 |
|
63 | Type: `boolean`
|
64 | Default: `true`
|
65 |
|
66 | Pass `false` to disable conversion from `deg` to `turn` & vice versa.
|
67 |
|
68 | ## Contributing
|
69 |
|
70 | Pull requests are welcome. If you add functionality, then please add unit tests
|
71 | to cover it.
|
72 |
|
73 | ## License
|
74 |
|
75 | MIT © [Ben Briggs](http://beneb.info)
|
76 |
|
77 | [ci]: https://travis-ci.org/ben-eb/postcss-convert-values
|
78 | [colormin]: https://github.com/ben-eb/postcss-colormin
|
79 | [deps]: https://gemnasium.com/ben-eb/postcss-convert-values
|
80 | [npm]: http://badge.fury.io/js/postcss-convert-values
|
81 | [postcss]: https://github.com/postcss/postcss
|
82 |
|
83 | [csstricks]: https://css-tricks.com/the-lengths-of-css/
|