Skip to content

Commit ae6e509

Browse files
author
James Kolce
committed
[ref: #8] Add pe unit to transform px to em
1 parent 9fe55be commit ae6e509

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

lib/compile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = (file) => {
99
return postcss([
1010
require('postcss-lh'),
1111
require('postcss-pr'),
12+
require('postcss-pe'),
1213
require('postcss-custom-media'),
1314
require('postcss-media-minmax'),
1415
require('autoprefixer')

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"postcss-custom-media": "^5.0.1",
2020
"postcss-lh": "^1.1.0",
2121
"postcss-media-minmax": "^2.1.2",
22+
"postcss-pe": "^1.0.0",
2223
"postcss-pr": "^1.0.0"
2324
},
2425
"devDependencies": {

test/fixtures/pxToEm/pxToEm.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
:root {
2+
font: 16px / 1.5 "Helvetica", "Arial", sans-serif;
3+
}
4+
5+
@media (max-width: 500px) {
6+
:root {
7+
font-size: 14px;
8+
}
9+
}
10+
11+
@media print {
12+
:root {
13+
font: 11pt / 1.3 "Georgia", "Times New Roman", "Times", serif;
14+
}
15+
}
16+
17+
section {
18+
margin-bottom: 1.5em;
19+
padding-top: 2em;
20+
}
21+
22+
.othersection {
23+
font-size: 3em;
24+
}
25+
26+
.othersection article {
27+
margin-top: 2em;
28+
}

test/fixtures/pxToEm/pxToEm.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
:root {
2+
font: 16px / 1.5 "Helvetica", "Arial", sans-serif;
3+
4+
@media (max-width: 500px) {
5+
font-size: 14px;
6+
}
7+
}
8+
9+
@media print {
10+
:root {
11+
font: 11pt / 1.3 "Georgia", "Times New Roman", "Times", serif;
12+
}
13+
}
14+
15+
section {
16+
margin-bottom: 24pe;
17+
padding-top: 32pe;
18+
}
19+
20+
.othersection {
21+
font-size: 48pe;
22+
}
23+
24+
.othersection article {
25+
margin-top: 96/48pe;
26+
}

test/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ test('units', (t) => {
3333
t.equal(
3434
actual('pxToRem'),
3535
expected('pxToRem'),
36-
'should be added');
36+
'should be transformed');
37+
38+
t.equal(
39+
actual('pxToEm'),
40+
expected('pxToEm'),
41+
'should be transformed');
3742

3843
t.end();
3944
});

0 commit comments

Comments
 (0)