This repository has been archived by the owner on Oct 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.js
81 lines (80 loc) · 1.91 KB
/
default.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module.exports = {
breakpoints: ['576px', '768px', '992px', '1200px'],
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
fontSizes: [12, 14, 16, 20, 24, 32, 48, 64, 72],
// Custom style props go in the props object
props: {
f: {
// Where to find values in theme
themeKey: 'fontSizes',
// Default unit if none specified
defaultUnit: 'px',
// Resulting css property
style: 'fontSize'
},
color: {
// Extend theme and add colors object
themeKey: 'colors',
style: 'color'
},
bg: {
themeKey: 'colors',
style: 'backgroundColor'
},
borderColor: {
themeKey: 'colors',
style: 'borderColor'
},
d: {
style: 'display'
},
p: {
themeKey: 'space',
defaultUnit: 'px',
style: 'padding',
// Directional variations
variations: {
pt: 'paddingTop',
pr: 'paddingRight',
pb: 'paddingBottom',
pl: 'paddingLeft',
px: ['paddingLeft', 'paddingRight'],
py: ['paddingTop', 'paddingBottom']
}
},
m: {
themeKey: 'space',
defaultUnit: 'px',
style: 'margin',
variations: {
mt: 'marginTop',
mr: 'marginRight',
mb: 'marginBottom',
ml: 'marginLeft',
mx: ['marginLeft', 'marginRight'],
my: ['marginTop', 'marginBottom']
}
},
h: {
style: 'height'
},
// Advanced width prop
w: {
// Style is a function instead of a string
style: function(value) {
let width = value;
// If less than 1 make it a fraction of 100% (1/3 = 33.33...%, etc)
// Nice for column widths (<Row><Col w={1/3}><Col w={2/3}></Row>)
if (isNumber(width) && width <= 1) {
width = width * 100 + '%';
}
return {
width: width
};
}
}
}
};
function isNumber(n) {
return typeof n === 'number' && !isNaN(n);
}