Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit dd46efa

Browse files
committed
Add rem fallback
Close #31
1 parent eddce29 commit dd46efa

File tree

8 files changed

+37
-3
lines changed

8 files changed

+37
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cssnext({
2929
- Added: `url` option: non absolute url() are now rebased according to `from` (and `to` options if provided). Enabled by default.
3030
- Added: `compress` option now accept CSSWring options directly.
3131
- Added: `browsers` option can enable or disable features and is propagated to autoprefixer
32+
- Added: px fallback for `rem` unit
3233

3334
# 0.6.6 - 2014-12-22
3435

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Follow [@cssnext on Twitter](https://twitter.com/cssnext) to get latest news & j
5959
([](https://github.com/postcss/postcss-font-variant)),
6060
* [filter](http://www.w3.org/TR/filter-effects/) properties
6161
([](https://github.com/iamvdo/pleeease-filters))
62-
62+
* [rem](http://www.w3.org/TR/css3-values/#rem-unit) units
63+
([](https://github.com/robwierzbowski/node-pixrem))
6364

6465
### Bonus features
6566

@@ -248,6 +249,7 @@ Here are all available features:
248249
- `colorRebeccapurple`
249250
- `fontVariant`
250251
- `filter`
252+
- `rem`
251253
- `autoprefixer`
252254

253255
_Note: order is important to get everything working correctly._

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var caniuseFeaturesMap = {
2323
// colorFunction:[null],
2424
// fontVariant: [null],
2525
// filter: [null], // @todo can be done using a callback, this is only used for Firefox < 35
26+
rem: ["rem"],
2627
// autoprefixer: [null] // will always be null since autoprefixer does the same game as we do
2728
}
2829

@@ -40,6 +41,7 @@ var features = {
4041
colorFunction: function(options) { return require("postcss-color-function")(options)},
4142
fontVariant: function(options) { return require("postcss-font-variant")(options)},
4243
filter: function(options) { return require("pleeease-filters")(options)},
44+
rem: function(options) { return require("pixrem")(options)},
4345
autoprefixer: function(options) { return require("autoprefixer-core")(options).postcss}
4446
}
4547

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"exit": "^0.1.2",
3636
"node-watch": "^0.3.4",
3737
"object-assign": "^2.0.0",
38+
"pixrem": "^1.1.0",
3839
"pleeease-filters": "^1.0.0",
3940
"postcss": "^4.0.2",
4041
"postcss-calc": "^4.0.0",

test/fixtures/cases/example.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
}
77

88
/* custom media queries */
9-
@custom-media --viewport-medium (width <= 50rem);
9+
@custom-media --viewport-medium (width <= 50em);
1010

1111
/* some var() & calc() */
1212
body {
@@ -20,6 +20,7 @@ body {
2020
/* custom media query usage */
2121
@media (--viewport-medium) {
2222
body { font-size: calc(var(--fontSize) * 1.2); }
23+
/* no need for px here since browsers that supports media queries support rem already */
2324
}
2425

2526
/* custom selectors */

test/fixtures/cases/example.expected.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
body {
77
color: rgba(18, 52, 86, 0.47059);
88

9+
font-size: 16px;
10+
911
font-size: 1rem;
12+
line-height: 24px;
1013
line-height: 1.5rem;
1114
padding: calc(0.5rem + 1px);
1215
}
1316

1417
/* custom media query usage */
15-
@media (max-width: 50rem) {
18+
@media (max-width: 50em) {
1619
body { font-size: 1.2rem; }
20+
/* no need for px here since browsers that supports media queries support rem already */
1721
}
1822

1923
/* custom selectors */

test/fixtures/features/rem.css

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.sky {
2+
margin: 2.5rem 2px 3em 100%;
3+
color: blue;
4+
}
5+
6+
@media screen and (min-width: 20rem) {
7+
.leaf {
8+
margin-bottom: 1.333rem;
9+
font-size: 1.5rem;
10+
}
11+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.sky {
2+
margin: 40px 2px 3em 100%;
3+
margin: 2.5rem 2px 3em 100%;
4+
color: blue;
5+
}
6+
7+
@media screen and (min-width: 20rem) {
8+
.leaf {
9+
margin-bottom: 1.333rem;
10+
font-size: 1.5rem;
11+
}
12+
}

0 commit comments

Comments
 (0)