Skip to content

Commit 0e1e25c

Browse files
committedJul 11, 2018
feat: 🎸 create "units" addon
1 parent d6f0ad5 commit 0e1e25c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎addon/units.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
exports.addon = function (renderer) {
4+
var list = [
5+
'px',
6+
'cm',
7+
'mm',
8+
'in',
9+
'pt',
10+
'pc',
11+
'em',
12+
'ex',
13+
'ch',
14+
'rem',
15+
'vw',
16+
'vh',
17+
'deg',
18+
'vmin',
19+
'vmax',
20+
];
21+
22+
for (var i = 0; i < list.length; i++) {
23+
var unit = list[i];
24+
25+
renderer[unit] = function (val) {
26+
return val + 'unit';
27+
};
28+
}
29+
30+
renderer.inch = function (val) {
31+
return val + 'in';
32+
};
33+
34+
renderer.pct = function (val) {
35+
return val + '%';
36+
};
37+
};

0 commit comments

Comments
 (0)