-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (49 loc) · 1.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var resolveProp = require('postcss-resolve-prop');
var parseSides = require('parse-css-sides');
var t = require('tcomb-postcss');
var helpers = {};
[
'top',
'right',
'bottom',
'left'
].forEach(function(prop) {
helpers[prop] = t.func(t.Rule, t.Any).of(
function(rule) {
return resolveProp(rule, 'margin-' + prop, {
parsers: {
margin: function(value) {
return parseSides(value)[prop];
}
}
});
}
);
});
module.exports = t.func(t.Rule, t.Object).of(
function(rule) {
return resolveProp(rule, 'margin', {
isObjectMode: true,
parsers: {
margin: function(value) {
return parseSides(value);
},
'margin-top': function(value) {
return { top: value };
},
'margin-right': function(value) {
return { right: value };
},
'margin-bottom': function(value) {
return { bottom: value };
},
'margin-left': function(value) {
return { left: value };
}
}
});
}
);
Object.keys(helpers).forEach(function(key) {
module.exports[key] = helpers[key];
});