UNPKG

5.31 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = exports.transformRest = exports.atomicProps = void 0;
9
10var _objectSpread2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectSpread"));
11
12var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectWithoutProperties"));
13
14var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
15
16var _lodash = _interopRequireDefault(require("lodash.forown"));
17
18var atomicStyles = function atomicStyles(_ref) {
19 var spacing = _ref.spacing;
20 return {
21 light: {
22 fontWeight: 'lighter'
23 },
24 fontWeightNormal: {
25 fontWeight: 'normal'
26 },
27 bold: {
28 fontWeight: 500
29 },
30 bolder: {
31 fontWeight: 'bolder'
32 },
33 italic: {
34 fontStyle: 'italic'
35 },
36 noDecoration: {
37 textDecoration: 'none'
38 },
39 underline: {
40 textDecoration: 'underline'
41 },
42 m0: {
43 margin: 0
44 },
45 mv0: {
46 marginTop: 0,
47 marginBottom: 0
48 },
49 mh0: {
50 marginRight: 0,
51 marginLeft: 0
52 },
53 mt0: {
54 marginTop: 0
55 },
56 mr0: {
57 marginRight: 0
58 },
59 mb0: {
60 marginBottom: 0
61 },
62 ml0: {
63 marginLeft: 0
64 },
65 p0: {
66 padding: 0
67 },
68 pv0: {
69 paddingTop: 0,
70 paddingBottom: 0
71 },
72 ph0: {
73 paddingRight: 0,
74 paddingLeft: 0
75 },
76 pt0: {
77 paddingTop: 0
78 },
79 pr0: {
80 paddingRight: 0
81 },
82 pb0: {
83 paddingBottom: 0
84 },
85 pl0: {
86 paddingLeft: 0
87 },
88 m1: {
89 margin: spacing.unit
90 },
91 mv1: {
92 marginTop: spacing.unit,
93 marginBottom: spacing.unit
94 },
95 mh1: {
96 marginRight: spacing.unit,
97 marginLeft: spacing.unit
98 },
99 mt1: {
100 marginTop: spacing.unit
101 },
102 mr1: {
103 marginRight: spacing.unit
104 },
105 mb1: {
106 marginBottom: spacing.unit
107 },
108 ml1: {
109 marginLeft: spacing.unit
110 },
111 p1: {
112 padding: spacing.unit
113 },
114 pv1: {
115 paddingTop: spacing.unit,
116 paddingBottom: spacing.unit
117 },
118 ph1: {
119 paddingRight: spacing.unit,
120 paddingLeft: spacing.unit
121 },
122 pt1: {
123 paddingTop: spacing.unit
124 },
125 pr1: {
126 paddingRight: spacing.unit
127 },
128 pb1: {
129 paddingBottom: spacing.unit
130 },
131 pl1: {
132 paddingLeft: spacing.unit
133 },
134 m2: {
135 margin: spacing.unit * 2
136 },
137 mv2: {
138 marginTop: spacing.unit * 2,
139 marginBottom: spacing.unit * 2
140 },
141 mh2: {
142 marginRight: spacing.unit * 2,
143 marginLeft: spacing.unit * 2
144 },
145 mt2: {
146 marginTop: spacing.unit * 2
147 },
148 mr2: {
149 marginRight: spacing.unit * 2
150 },
151 mb2: {
152 marginBottom: spacing.unit * 2
153 },
154 ml2: {
155 marginLeft: spacing.unit * 2
156 },
157 p2: {
158 padding: spacing.unit * 2
159 },
160 pv2: {
161 paddingTop: spacing.unit * 2,
162 paddingBottom: spacing.unit * 2
163 },
164 ph2: {
165 paddingRight: spacing.unit * 2,
166 paddingLeft: spacing.unit * 2
167 },
168 pt2: {
169 paddingTop: spacing.unit * 2
170 },
171 pr2: {
172 paddingRight: spacing.unit * 2
173 },
174 pb2: {
175 paddingBottom: spacing.unit * 2
176 },
177 pl2: {
178 paddingLeft: spacing.unit * 2
179 },
180 m3: {
181 margin: spacing.unit * 3
182 },
183 mv3: {
184 marginTop: spacing.unit * 3,
185 marginBottom: spacing.unit * 3
186 },
187 mh3: {
188 marginRight: spacing.unit * 3,
189 marginLeft: spacing.unit * 3
190 },
191 mt3: {
192 marginTop: spacing.unit * 3
193 },
194 mr3: {
195 marginRight: spacing.unit * 3
196 },
197 mb3: {
198 marginBottom: spacing.unit * 3
199 },
200 ml3: {
201 marginLeft: spacing.unit * 3
202 },
203 p3: {
204 padding: spacing.unit * 3
205 },
206 pv3: {
207 paddingTop: spacing.unit * 3,
208 paddingBottom: spacing.unit * 3
209 },
210 ph3: {
211 paddingRight: spacing.unit * 3,
212 paddingLeft: spacing.unit * 3
213 },
214 pt3: {
215 paddingTop: spacing.unit * 3
216 },
217 pr3: {
218 paddingRight: spacing.unit * 3
219 },
220 pb3: {
221 paddingBottom: spacing.unit * 3
222 },
223 pl3: {
224 paddingLeft: spacing.unit * 3
225 }
226 };
227};
228
229var atomicProps = (0, _keys.default)(atomicStyles({
230 spacing: {
231 unit: 0
232 }
233}));
234exports.atomicProps = atomicProps;
235
236var transformRest = function transformRest(props) {
237 var _props = (0, _objectSpread2.default)({}, props),
238 userClassName = _props.className,
239 classes = _props.classes,
240 newProps = (0, _objectWithoutProperties2.default)(_props, ["className", "classes"]);
241
242 var newClassName = '';
243 (0, _lodash.default)(newProps, function (propValue, propName) {
244 var foundProp = atomicProps.find(function (x) {
245 return x === propName;
246 });
247
248 if (foundProp) {
249 newClassName = newClassName.concat(" ".concat(classes[propName]));
250 delete newProps[propName];
251 }
252 });
253
254 if (userClassName) {
255 newClassName = newClassName.concat(" ".concat(userClassName));
256 }
257
258 return (0, _objectSpread2.default)({
259 className: newClassName
260 }, newProps);
261};
262
263exports.transformRest = transformRest;
264var _default = atomicStyles;
265exports.default = _default;
\No newline at end of file