Skip to content

Commit 129767f

Browse files
committed
add input-output example, close #19, thanks!
1 parent 56011ee commit 129767f

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ A plugin for [PostCSS](https://github.com/ai/postcss) that generates rem units f
88
Pixels are the easiest unit to use (*opinion*). The only issue with them is that they don't let browsers change the default font size of 16. This script converts every px value to a rem from the properties you choose to allow the browser to set the font size.
99

1010

11+
### Input/Output
12+
13+
*With the default settings, only font related properties are targeted.*
14+
15+
```css
16+
// input
17+
h1 {
18+
margin: 0 0 20px;
19+
font-size: 32px;
20+
line-height: 1.2;
21+
letter-spacing: 1px;
22+
}
23+
24+
// output
25+
h1 {
26+
margin: 0 0 20px;
27+
font-size: 2rem;
28+
line-height: 1.2;
29+
letter-spacing: 0.0625rem;
30+
}
31+
```
32+
1133
### Example
1234

1335
```js
@@ -51,11 +73,12 @@ Default:
5173
- `media_query` (Boolean) Allow px to be converted in media queries.
5274

5375

54-
### Use with gulp-postcss and autoprefixer-core
76+
### Use with gulp-postcss and autoprefixer
77+
5578
```js
5679
var gulp = require('gulp');
5780
var postcss = require('gulp-postcss');
58-
var autoprefixer = require('autoprefixer-core');
81+
var autoprefixer = require('autoprefixer');
5982
var pxtorem = require('postcss-pxtorem');
6083

6184
gulp.task('css', function () {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "postcss-pxtorem",
33
"description": "A CSS post-processor that converts px to rem.",
4-
"version": "3.1.0",
4+
"version": "3.1.1",
55
"author": "cuth",
66
"license": "MIT",
77
"repository": {

spec/pxtorem-spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ var css = '.rule { font-size: 15px }';
1212

1313
describe('pxtorem', function () {
1414

15+
it('should work on the readme example', function () {
16+
var input = 'h1 { margin: 0 0 20px; font-size: 32px; line-height: 1.2; letter-spacing: 1px; }';
17+
var output = 'h1 { margin: 0 0 20px; font-size: 2rem; line-height: 1.2; letter-spacing: 0.0625rem; }';
18+
var processed = postcss(pxtorem()).process(input).css;
19+
20+
expect(processed).toBe(output);
21+
});
22+
1523
it('should replace the px unit with rem', function () {
1624
var processed = postcss(pxtorem()).process(css).css;
1725
var expected = '.rule { font-size: 0.9375rem }';

0 commit comments

Comments
 (0)