UNPKG

1.91 kBMarkdownView Raw
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
7With [npm](https://npmjs.org/package/postcss-convert-values) do:
8
9```
10npm install postcss-convert-values --save
11```
12
13## Example
14
15This plugin reduces CSS size by converting values to use different units
16where possible; for example, `500ms` can be represented as `.5s`. You can
17read more about these units in [this article][csstricks].
18
19### Input
20
21```css
22h1 {
23 font-size: 16px;
24 width: 0em
25}
26```
27
28### Output
29
30```css
31h1 {
32 font-size: 1pc;
33 width: 0
34}
35```
36
37Note that this plugin only covers conversions for duration and absolute length
38values. For color conversions, use [postcss-colormin][colormin].
39
40## API
41
42### convertValues([options])
43
44#### options
45
46##### length
47
48Type: `boolean`
49Default: `true`
50
51Pass `false` to disable conversion from `px` to other absolute length units,
52such as `pc` & `pt` & vice versa.
53
54##### time
55
56Type: `boolean`
57Default: `true`
58
59Pass `false` to disable conversion from `ms` to `s` & vice versa.
60
61##### angle
62
63Type: `boolean`
64Default: `true`
65
66Pass `false` to disable conversion from `deg` to `turn` & vice versa.
67
68## Contributing
69
70Pull requests are welcome. If you add functionality, then please add unit tests
71to cover it.
72
73## License
74
75MIT © [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/