@flodesk/grain 10.8.4 → 10.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/box2.js +454 -0
- package/es/components/index.js +1 -0
- package/es/styles/index.js +2 -1
- package/es/styles/utilities.js +108 -0
- package/es/types.js +4 -2
- package/es/utilities/helpers.js +162 -0
- package/es/utilities/responsive.js +3 -0
- package/es/utilities/styles.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import "core-js/modules/es.object.keys.js";
|
|
2
|
+
import "core-js/modules/es.array.index-of.js";
|
|
3
|
+
import "core-js/modules/es.symbol.js";
|
|
4
|
+
import "core-js/modules/es.object.define-property.js";
|
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
|
6
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
7
|
+
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
8
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
9
|
+
import "core-js/modules/es.object.assign.js";
|
|
10
|
+
var _excluded = ["all", "color", "colorHover", "backgroundColor", "backgroundColorHover", "borderColorHover", "borderSide", "width", "minWidth", "maxWidth", "height", "minHeight", "maxHeight", "radius", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "paddingX", "paddingY", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "marginX", "marginY", "position", "top", "bottom", "left", "right", "shadow", "shadowHover", "overflow", "overflowX", "overflowY", "aspectRatio", "zIndex", "tag", "opacity", "opacityHover", "order", "alignSelf", "flex", "transition", "transitionHover", "cursor", "children", "className", "style"];
|
|
11
|
+
|
|
12
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
|
|
20
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
+
|
|
22
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
|
+
|
|
24
|
+
import "core-js/modules/es.object.to-string.js";
|
|
25
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
26
|
+
import "core-js/modules/es.array.concat.js";
|
|
27
|
+
import "core-js/modules/es.array.includes.js";
|
|
28
|
+
import "core-js/modules/es.string.includes.js";
|
|
29
|
+
import "core-js/modules/es.string.trim.js";
|
|
30
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
31
|
+
import "core-js/modules/es.string.replace.js";
|
|
32
|
+
import { getColor, getShadow, getSpace, isObject, isSpaceVar, propNameToShorthand, getDimension, isColorVar, getRadius, isNumber } from '../utilities';
|
|
33
|
+
import React, { forwardRef } from 'react';
|
|
34
|
+
import { overflows, types } from '../types';
|
|
35
|
+
import PropTypes from 'prop-types';
|
|
36
|
+
import { vars } from '../variables';
|
|
37
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
38
|
+
|
|
39
|
+
var generateSpaceStyles = function generateSpaceStyles(_ref) {
|
|
40
|
+
var spaceProps = _ref.spaceProps;
|
|
41
|
+
var styles = {};
|
|
42
|
+
var classNames = [];
|
|
43
|
+
spaceProps.forEach(function (_ref2) {
|
|
44
|
+
var property = _ref2.property,
|
|
45
|
+
value = _ref2.value;
|
|
46
|
+
|
|
47
|
+
if (isObject(value)) {
|
|
48
|
+
var defaultValue = value.default,
|
|
49
|
+
mobile = value.mobile,
|
|
50
|
+
tablet = value.tablet;
|
|
51
|
+
styles["--".concat(propNameToShorthand(property), "-dft")] = getSpace(defaultValue);
|
|
52
|
+
styles["--".concat(propNameToShorthand(property), "-mbl")] = getSpace(mobile);
|
|
53
|
+
styles["--".concat(propNameToShorthand(property), "-tbl")] = getSpace(tablet);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (isSpaceVar(value)) {
|
|
57
|
+
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
58
|
+
} else {
|
|
59
|
+
styles["--".concat(propNameToShorthand(property))] = getSpace(value);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
className: classNames.join(' '),
|
|
64
|
+
style: styles
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var generateOrderStyles = function generateOrderStyles(_ref3) {
|
|
69
|
+
var order = _ref3.order;
|
|
70
|
+
var styles = {};
|
|
71
|
+
var property = 'order';
|
|
72
|
+
|
|
73
|
+
if (isObject(order)) {
|
|
74
|
+
var defaultValue = order.default,
|
|
75
|
+
mobile = order.mobile,
|
|
76
|
+
tablet = order.tablet;
|
|
77
|
+
styles["--".concat(propNameToShorthand(property), "-dft")] = defaultValue;
|
|
78
|
+
styles["--".concat(propNameToShorthand(property), "-mbl")] = mobile;
|
|
79
|
+
styles["--".concat(propNameToShorthand(property), "-tbl")] = tablet;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isNumber(order)) {
|
|
83
|
+
styles[property] = order;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return styles;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
var generateDimentionStyles = function generateDimentionStyles(_ref4) {
|
|
90
|
+
var dimentionsProps = _ref4.dimentionsProps;
|
|
91
|
+
var styles = {};
|
|
92
|
+
dimentionsProps.forEach(function (_ref5) {
|
|
93
|
+
var property = _ref5.property,
|
|
94
|
+
value = _ref5.value;
|
|
95
|
+
|
|
96
|
+
if (isObject(value)) {
|
|
97
|
+
var defaultValue = value.default,
|
|
98
|
+
mobile = value.mobile,
|
|
99
|
+
tablet = value.tablet;
|
|
100
|
+
styles["--".concat(propNameToShorthand(property), "-dft")] = getDimension(defaultValue);
|
|
101
|
+
styles["--".concat(propNameToShorthand(property), "-mbl")] = getDimension(mobile);
|
|
102
|
+
styles["--".concat(propNameToShorthand(property), "-tbl")] = getDimension(tablet);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
styles["--".concat(propNameToShorthand(property))] = getDimension(value);
|
|
107
|
+
});
|
|
108
|
+
return styles;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var generateColorStyles = function generateColorStyles(_ref6) {
|
|
112
|
+
var colorProps = _ref6.colorProps;
|
|
113
|
+
var styles = {};
|
|
114
|
+
var classNames = [];
|
|
115
|
+
colorProps.forEach(function (_ref7) {
|
|
116
|
+
var property = _ref7.property,
|
|
117
|
+
value = _ref7.value;
|
|
118
|
+
|
|
119
|
+
if (isColorVar(value)) {
|
|
120
|
+
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
121
|
+
} else {
|
|
122
|
+
styles["--".concat(propNameToShorthand(property))] = getColor(value);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
className: classNames.join(' '),
|
|
127
|
+
style: styles
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var genereateShadowStyles = function genereateShadowStyles(_ref8) {
|
|
132
|
+
var shadowProps = _ref8.shadowProps;
|
|
133
|
+
var styles = {};
|
|
134
|
+
var classNames = [];
|
|
135
|
+
shadowProps.forEach(function (_ref9) {
|
|
136
|
+
var property = _ref9.property,
|
|
137
|
+
value = _ref9.value;
|
|
138
|
+
|
|
139
|
+
if (value in vars.shadows) {
|
|
140
|
+
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
141
|
+
} else {
|
|
142
|
+
styles["--".concat(propNameToShorthand(property))] = getShadow(value);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
className: classNames.join(' '),
|
|
147
|
+
style: styles
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
var generateRadiusStyles = function generateRadiusStyles(_ref10) {
|
|
152
|
+
var radiusProps = _ref10.radiusProps;
|
|
153
|
+
var styles = {};
|
|
154
|
+
var classNames = [];
|
|
155
|
+
radiusProps.forEach(function (_ref11) {
|
|
156
|
+
var property = _ref11.property,
|
|
157
|
+
value = _ref11.value;
|
|
158
|
+
|
|
159
|
+
if (value in vars.radii) {
|
|
160
|
+
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
161
|
+
} else {
|
|
162
|
+
styles["--".concat(propNameToShorthand(property))] = getRadius(value);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
className: classNames.join(' '),
|
|
167
|
+
style: styles
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var generateZIndexStyles = function generateZIndexStyles(_ref12) {
|
|
172
|
+
var zIndex = _ref12.zIndex;
|
|
173
|
+
var styles = {};
|
|
174
|
+
styles["zIndex"] = zIndex;
|
|
175
|
+
return styles;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
var generatePositionStyles = function generatePositionStyles(_ref13) {
|
|
179
|
+
var position = _ref13.position;
|
|
180
|
+
|
|
181
|
+
if (position) {
|
|
182
|
+
return "".concat(propNameToShorthand('position'), "-").concat(position);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
var generateOverflowStyles = function generateOverflowStyles(_ref14) {
|
|
187
|
+
var overflowProps = _ref14.overflowProps;
|
|
188
|
+
var classNames = [];
|
|
189
|
+
overflowProps.forEach(function (_ref15) {
|
|
190
|
+
var property = _ref15.property,
|
|
191
|
+
value = _ref15.value;
|
|
192
|
+
|
|
193
|
+
if (overflows.includes(value)) {
|
|
194
|
+
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return classNames.join(' ');
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export var Box2 = /*#__PURE__*/forwardRef(function (_ref16, ref) {
|
|
201
|
+
var all = _ref16.all,
|
|
202
|
+
color = _ref16.color,
|
|
203
|
+
colorHover = _ref16.colorHover,
|
|
204
|
+
backgroundColor = _ref16.backgroundColor,
|
|
205
|
+
backgroundColorHover = _ref16.backgroundColorHover,
|
|
206
|
+
borderColorHover = _ref16.borderColorHover,
|
|
207
|
+
borderSide = _ref16.borderSide,
|
|
208
|
+
width = _ref16.width,
|
|
209
|
+
minWidth = _ref16.minWidth,
|
|
210
|
+
maxWidth = _ref16.maxWidth,
|
|
211
|
+
height = _ref16.height,
|
|
212
|
+
minHeight = _ref16.minHeight,
|
|
213
|
+
maxHeight = _ref16.maxHeight,
|
|
214
|
+
radius = _ref16.radius,
|
|
215
|
+
padding = _ref16.padding,
|
|
216
|
+
paddingTop = _ref16.paddingTop,
|
|
217
|
+
paddingBottom = _ref16.paddingBottom,
|
|
218
|
+
paddingLeft = _ref16.paddingLeft,
|
|
219
|
+
paddingRight = _ref16.paddingRight,
|
|
220
|
+
paddingX = _ref16.paddingX,
|
|
221
|
+
paddingY = _ref16.paddingY,
|
|
222
|
+
margin = _ref16.margin,
|
|
223
|
+
marginTop = _ref16.marginTop,
|
|
224
|
+
marginBottom = _ref16.marginBottom,
|
|
225
|
+
marginLeft = _ref16.marginLeft,
|
|
226
|
+
marginRight = _ref16.marginRight,
|
|
227
|
+
marginX = _ref16.marginX,
|
|
228
|
+
marginY = _ref16.marginY,
|
|
229
|
+
position = _ref16.position,
|
|
230
|
+
top = _ref16.top,
|
|
231
|
+
bottom = _ref16.bottom,
|
|
232
|
+
left = _ref16.left,
|
|
233
|
+
right = _ref16.right,
|
|
234
|
+
shadow = _ref16.shadow,
|
|
235
|
+
shadowHover = _ref16.shadowHover,
|
|
236
|
+
overflow = _ref16.overflow,
|
|
237
|
+
overflowX = _ref16.overflowX,
|
|
238
|
+
overflowY = _ref16.overflowY,
|
|
239
|
+
aspectRatio = _ref16.aspectRatio,
|
|
240
|
+
zIndex = _ref16.zIndex,
|
|
241
|
+
_ref16$tag = _ref16.tag,
|
|
242
|
+
tag = _ref16$tag === void 0 ? 'div' : _ref16$tag,
|
|
243
|
+
opacity = _ref16.opacity,
|
|
244
|
+
opacityHover = _ref16.opacityHover,
|
|
245
|
+
order = _ref16.order,
|
|
246
|
+
alignSelf = _ref16.alignSelf,
|
|
247
|
+
flex = _ref16.flex,
|
|
248
|
+
transition = _ref16.transition,
|
|
249
|
+
transitionHover = _ref16.transitionHover,
|
|
250
|
+
cursor = _ref16.cursor,
|
|
251
|
+
children = _ref16.children,
|
|
252
|
+
className = _ref16.className,
|
|
253
|
+
style = _ref16.style,
|
|
254
|
+
otherProps = _objectWithoutProperties(_ref16, _excluded);
|
|
255
|
+
|
|
256
|
+
var spaceProps = [{
|
|
257
|
+
property: 'padding',
|
|
258
|
+
value: padding
|
|
259
|
+
}, {
|
|
260
|
+
property: 'paddingTop',
|
|
261
|
+
value: paddingTop
|
|
262
|
+
}, {
|
|
263
|
+
property: 'paddingBottom',
|
|
264
|
+
value: paddingBottom
|
|
265
|
+
}, {
|
|
266
|
+
property: 'paddingLeft',
|
|
267
|
+
value: paddingLeft
|
|
268
|
+
}, {
|
|
269
|
+
property: 'paddingRight',
|
|
270
|
+
value: paddingRight
|
|
271
|
+
}, {
|
|
272
|
+
property: 'paddingX',
|
|
273
|
+
value: paddingX
|
|
274
|
+
}, {
|
|
275
|
+
property: 'paddingY',
|
|
276
|
+
value: paddingY
|
|
277
|
+
}, {
|
|
278
|
+
property: 'margin',
|
|
279
|
+
value: margin
|
|
280
|
+
}, {
|
|
281
|
+
property: 'marginTop',
|
|
282
|
+
value: marginTop
|
|
283
|
+
}, {
|
|
284
|
+
property: 'marginBottom',
|
|
285
|
+
value: marginBottom
|
|
286
|
+
}, {
|
|
287
|
+
property: 'marginLeft',
|
|
288
|
+
value: marginLeft
|
|
289
|
+
}, {
|
|
290
|
+
property: 'marginRight',
|
|
291
|
+
value: marginRight
|
|
292
|
+
}, {
|
|
293
|
+
property: 'marginX',
|
|
294
|
+
value: marginX
|
|
295
|
+
}, {
|
|
296
|
+
property: 'marginY',
|
|
297
|
+
value: marginY
|
|
298
|
+
}, {
|
|
299
|
+
property: 'top',
|
|
300
|
+
value: top
|
|
301
|
+
}, {
|
|
302
|
+
property: 'bottom',
|
|
303
|
+
value: bottom
|
|
304
|
+
}, {
|
|
305
|
+
property: 'left',
|
|
306
|
+
value: left
|
|
307
|
+
}, {
|
|
308
|
+
property: 'right',
|
|
309
|
+
value: right
|
|
310
|
+
}];
|
|
311
|
+
var dimentionsProps = [{
|
|
312
|
+
property: 'width',
|
|
313
|
+
value: width
|
|
314
|
+
}, {
|
|
315
|
+
property: 'minWidth',
|
|
316
|
+
value: minWidth
|
|
317
|
+
}, {
|
|
318
|
+
property: 'maxWidth',
|
|
319
|
+
value: maxWidth
|
|
320
|
+
}, {
|
|
321
|
+
property: 'height',
|
|
322
|
+
value: height
|
|
323
|
+
}, {
|
|
324
|
+
property: 'minHeight',
|
|
325
|
+
value: minHeight
|
|
326
|
+
}, {
|
|
327
|
+
property: 'maxHeight',
|
|
328
|
+
value: maxHeight
|
|
329
|
+
}];
|
|
330
|
+
var colorProps = [{
|
|
331
|
+
property: 'color',
|
|
332
|
+
value: color
|
|
333
|
+
}, {
|
|
334
|
+
property: 'colorHover',
|
|
335
|
+
value: colorHover
|
|
336
|
+
}, {
|
|
337
|
+
property: 'backgroundColor',
|
|
338
|
+
value: backgroundColor
|
|
339
|
+
}, {
|
|
340
|
+
property: 'backgroundColorHover',
|
|
341
|
+
value: backgroundColorHover
|
|
342
|
+
}];
|
|
343
|
+
var shadowProps = [{
|
|
344
|
+
property: 'shadow',
|
|
345
|
+
value: shadow
|
|
346
|
+
}, {
|
|
347
|
+
property: 'shadowHover',
|
|
348
|
+
value: shadowHover
|
|
349
|
+
}];
|
|
350
|
+
var radiusProps = [{
|
|
351
|
+
property: 'radius',
|
|
352
|
+
value: radius
|
|
353
|
+
}];
|
|
354
|
+
var overflowProps = [{
|
|
355
|
+
property: 'overflow',
|
|
356
|
+
value: overflow
|
|
357
|
+
}, {
|
|
358
|
+
property: 'overflowX',
|
|
359
|
+
value: overflowX
|
|
360
|
+
}, {
|
|
361
|
+
property: 'overflowY',
|
|
362
|
+
value: overflowY
|
|
363
|
+
}];
|
|
364
|
+
|
|
365
|
+
var styles = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, generateDimentionStyles({
|
|
366
|
+
dimentionsProps: dimentionsProps
|
|
367
|
+
})), generateSpaceStyles({
|
|
368
|
+
spaceProps: spaceProps
|
|
369
|
+
}).style), generateColorStyles({
|
|
370
|
+
colorProps: colorProps
|
|
371
|
+
}).style), genereateShadowStyles({
|
|
372
|
+
shadowProps: shadowProps
|
|
373
|
+
}).style), generateRadiusStyles({
|
|
374
|
+
radiusProps: radiusProps
|
|
375
|
+
}).style), generateOrderStyles({
|
|
376
|
+
order: order
|
|
377
|
+
})), generateZIndexStyles({
|
|
378
|
+
zIndex: zIndex
|
|
379
|
+
}));
|
|
380
|
+
|
|
381
|
+
var propClassname = className ? className : '';
|
|
382
|
+
var classNames = [generateSpaceStyles({
|
|
383
|
+
spaceProps: spaceProps
|
|
384
|
+
}).className, generateColorStyles({
|
|
385
|
+
colorProps: colorProps
|
|
386
|
+
}).className, genereateShadowStyles({
|
|
387
|
+
shadowProps: shadowProps
|
|
388
|
+
}).className, generateRadiusStyles({
|
|
389
|
+
radiusProps: radiusProps
|
|
390
|
+
}).className, generatePositionStyles({
|
|
391
|
+
position: position
|
|
392
|
+
}), generateOverflowStyles({
|
|
393
|
+
overflowProps: overflowProps
|
|
394
|
+
}), propClassname].join(' ').replace(/\s+/g, ' ').trim();
|
|
395
|
+
return ___EmotionJSX("div", _extends({
|
|
396
|
+
ref: ref,
|
|
397
|
+
as: tag,
|
|
398
|
+
style: styles,
|
|
399
|
+
className: classNames
|
|
400
|
+
}, otherProps), children);
|
|
401
|
+
});
|
|
402
|
+
Box2.propTypes = {
|
|
403
|
+
all: PropTypes.string,
|
|
404
|
+
color: types.color,
|
|
405
|
+
colorHover: types.color,
|
|
406
|
+
backgroundColor: types.color,
|
|
407
|
+
backgroundColorHover: types.color,
|
|
408
|
+
borderSide: types.side,
|
|
409
|
+
borderWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
410
|
+
borderColor: types.color,
|
|
411
|
+
borderColorHover: types.color,
|
|
412
|
+
width: types.responsiveDimension,
|
|
413
|
+
minWidth: types.responsiveDimension,
|
|
414
|
+
maxWidth: types.responsiveDimension,
|
|
415
|
+
height: types.responsiveDimension,
|
|
416
|
+
minHeight: types.responsiveDimension,
|
|
417
|
+
maxHeight: types.responsiveDimension,
|
|
418
|
+
radius: types.radius,
|
|
419
|
+
shadow: types.shadow,
|
|
420
|
+
shadowHover: types.shadow,
|
|
421
|
+
padding: types.responsiveSpace,
|
|
422
|
+
paddingTop: types.responsiveSpace,
|
|
423
|
+
paddingBottom: types.responsiveSpace,
|
|
424
|
+
paddingLeft: types.responsiveSpace,
|
|
425
|
+
paddingRight: types.responsiveSpace,
|
|
426
|
+
paddingX: types.responsiveSpace,
|
|
427
|
+
paddingY: types.responsiveSpace,
|
|
428
|
+
margin: types.responsiveSpace,
|
|
429
|
+
marginTop: types.responsiveSpace,
|
|
430
|
+
marginBottom: types.responsiveSpace,
|
|
431
|
+
marginLeft: types.responsiveSpace,
|
|
432
|
+
marginRight: types.responsiveSpace,
|
|
433
|
+
marginX: types.responsiveSpace,
|
|
434
|
+
marginY: types.responsiveSpace,
|
|
435
|
+
position: types.position,
|
|
436
|
+
top: types.responsiveSpace,
|
|
437
|
+
bottom: types.responsiveSpace,
|
|
438
|
+
left: types.responsiveSpace,
|
|
439
|
+
right: types.responsiveSpace,
|
|
440
|
+
overflow: types.overflow,
|
|
441
|
+
overflowX: types.overflow,
|
|
442
|
+
overflowY: types.overflow,
|
|
443
|
+
aspectRatio: PropTypes.string,
|
|
444
|
+
zIndex: types.zIndex,
|
|
445
|
+
opacity: PropTypes.string,
|
|
446
|
+
opacityHover: PropTypes.string,
|
|
447
|
+
order: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
448
|
+
alignSelf: types.alignSelf,
|
|
449
|
+
flex: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
450
|
+
transition: types.transition,
|
|
451
|
+
transitionHover: types.transition,
|
|
452
|
+
cursor: types.cursor,
|
|
453
|
+
tag: PropTypes.string
|
|
454
|
+
};
|
package/es/components/index.js
CHANGED
package/es/styles/index.js
CHANGED
|
@@ -2,4 +2,5 @@ import variables from './variables';
|
|
|
2
2
|
import colors from './colors';
|
|
3
3
|
import shadows from './shadows';
|
|
4
4
|
import base from './base';
|
|
5
|
-
|
|
5
|
+
import utilities from './utilities';
|
|
6
|
+
export default [variables, colors, shadows, base, utilities].join('\n');
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import "core-js/modules/es.object.keys.js";
|
|
2
|
+
import "core-js/modules/es.object.to-string.js";
|
|
3
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
4
|
+
import "core-js/modules/es.array.concat.js";
|
|
5
|
+
import { overflows, positions } from '../types';
|
|
6
|
+
import { propertyToShorthand, getSpace, getColor, getShadow, getRadius } from '../utilities';
|
|
7
|
+
import { vars } from '../variables';
|
|
8
|
+
var spaces = Object.keys(vars.spaces);
|
|
9
|
+
var colors = Object.keys(vars.colors);
|
|
10
|
+
var shadows = Object.keys(vars.shadows);
|
|
11
|
+
var radii = Object.keys(vars.radii);
|
|
12
|
+
var spaceProperties = ['padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', 'padding-inline', 'padding-block', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'margin-inline', 'margin-block', 'top', 'bottom', 'left', 'right', 'width', 'height', 'min-width', 'max-width', 'min-height', 'max-height'];
|
|
13
|
+
var colorProperties = ['color', 'background-color'];
|
|
14
|
+
|
|
15
|
+
function generateCSS() {
|
|
16
|
+
var css = '';
|
|
17
|
+
spaces.forEach(function (space) {
|
|
18
|
+
spaceProperties.forEach(function (property) {
|
|
19
|
+
css += "\n .".concat(propertyToShorthand(property), "-").concat(space, " {\n ").concat(property, ": ").concat(getSpace(space), "\n }");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
colors.forEach(function (color) {
|
|
23
|
+
colorProperties.forEach(function (property) {
|
|
24
|
+
css += "\n .".concat(propertyToShorthand(property), "-").concat(color, " {\n ").concat(property, ": ").concat(getColor(color), "\n }");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
[].concat(spaceProperties, colorProperties).forEach(function (property) {
|
|
28
|
+
css += "\n [style*=\"--".concat(propertyToShorthand(property), ":\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), ")\n }");
|
|
29
|
+
});
|
|
30
|
+
return css;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var generateHoverCSS = function generateHoverCSS() {
|
|
34
|
+
var css = '';
|
|
35
|
+
colors.forEach(function (color) {
|
|
36
|
+
colorProperties.forEach(function (property) {
|
|
37
|
+
css += "\n .".concat(propertyToShorthand(property), "-hover-").concat(color, ":hover {\n ").concat(property, ": ").concat(getColor(color), "\n }\n ");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
colorProperties.forEach(function (property) {
|
|
41
|
+
css += "\n [style*=\"--".concat(propertyToShorthand(property), "-hover\"]:hover {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-hover)\n }\n ");
|
|
42
|
+
});
|
|
43
|
+
return css;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var generateResponsiveCSS = function generateResponsiveCSS() {
|
|
47
|
+
var css = '';
|
|
48
|
+
spaceProperties.forEach(function (property) {
|
|
49
|
+
css += "\n [style*=\"--".concat(propertyToShorthand(property), "-dft\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-dft)\n }\n @media (max-width: 1169px) {\n [style*=\"--").concat(propertyToShorthand(property), "-tbl\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-tbl);\n }\n }\n @media (max-width: 767px) {\n [style*=\"--").concat(propertyToShorthand(property), "-mbl\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-mbl);\n }\n }\n ");
|
|
50
|
+
});
|
|
51
|
+
return css;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var generateShadowCSS = function generateShadowCSS() {
|
|
55
|
+
var css = '';
|
|
56
|
+
var property = 'box-shadow';
|
|
57
|
+
shadows.forEach(function (shadow) {
|
|
58
|
+
css += "\n .".concat(propertyToShorthand(property), "-").concat(shadow, " {\n ").concat(property, ": ").concat(getShadow(shadow), "\n }\n .").concat(propertyToShorthand(property), "-hover-").concat(shadow, ":hover {\n ").concat(property, ": ").concat(getShadow(shadow), "\n }\n ");
|
|
59
|
+
css += "\n [style*=\"--".concat(propertyToShorthand(property), "\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), ")\n }\n [style*=\"--").concat(propertyToShorthand(property), "-hover\"]:hover {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-hover)\n }\n ");
|
|
60
|
+
});
|
|
61
|
+
return css;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var generateRadiiCSS = function generateRadiiCSS() {
|
|
65
|
+
var css = '';
|
|
66
|
+
var property = 'border-radius';
|
|
67
|
+
radii.forEach(function (radius) {
|
|
68
|
+
css += "\n .".concat(propertyToShorthand(property), "-").concat(radius, " {\n ").concat(property, ": ").concat(getRadius(radius), "\n }\n ");
|
|
69
|
+
css += "\n [style*=\"--".concat(propertyToShorthand(property), "\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), ")\n }\n ");
|
|
70
|
+
});
|
|
71
|
+
return css;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var generateOrderCSS = function generateOrderCSS() {
|
|
75
|
+
var css = '';
|
|
76
|
+
var property = 'order';
|
|
77
|
+
css += "\n [style*=\"--".concat(propertyToShorthand(property), "-dft\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-dft)\n }\n @media (max-width: 1169px) {\n [style*=\"--").concat(propertyToShorthand(property), "-tbl\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-tbl);\n }\n }\n @media (max-width: 767px) {\n [style*=\"--").concat(propertyToShorthand(property), "-mbl\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-mbl);\n }\n }\n ");
|
|
78
|
+
return css;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var generatePositionCSS = function generatePositionCSS() {
|
|
82
|
+
var css = '';
|
|
83
|
+
var property = 'position';
|
|
84
|
+
positions.forEach(function (value) {
|
|
85
|
+
css += "\n .".concat(propertyToShorthand(property), "-").concat(value, " {\n ").concat(property, ": ").concat(value, "\n }\n ");
|
|
86
|
+
});
|
|
87
|
+
return css;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var generateOverflowCSS = function generateOverflowCSS() {
|
|
91
|
+
var css = '';
|
|
92
|
+
var property = 'overflow';
|
|
93
|
+
overflows.forEach(function (value) {
|
|
94
|
+
css += "\n .".concat(propertyToShorthand(property), "-").concat(value, " {\n ").concat(property, ": ").concat(value, "\n }\n ");
|
|
95
|
+
});
|
|
96
|
+
return css;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var css = generateCSS();
|
|
100
|
+
var hoverCSS = generateHoverCSS();
|
|
101
|
+
var responsiveCSS = generateResponsiveCSS();
|
|
102
|
+
var shadowCSS = generateShadowCSS();
|
|
103
|
+
var radiiCSS = generateRadiiCSS();
|
|
104
|
+
var orderCSS = generateOrderCSS();
|
|
105
|
+
var positionCSS = generatePositionCSS();
|
|
106
|
+
var overflowCSS = generateOverflowCSS();
|
|
107
|
+
var utilities = "\n ".concat(css, ";\n ").concat(hoverCSS, ";\n ").concat(responsiveCSS, ";\n ").concat(shadowCSS, ";\n ").concat(radiiCSS, ";\n ").concat(orderCSS, ";\n ").concat(positionCSS, ";\n ").concat(overflowCSS, ";\n");
|
|
108
|
+
export default utilities;
|
package/es/types.js
CHANGED
|
@@ -17,6 +17,8 @@ export var autoFlows = directions;
|
|
|
17
17
|
export var flexDirections = directions;
|
|
18
18
|
export var alignSelfs = [].concat(axisAlignments, ['baseline']);
|
|
19
19
|
export var flexWraps = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
20
|
+
export var overflows = ['visible', 'hidden', 'scroll', 'auto'];
|
|
21
|
+
export var positions = ['static', 'relative', 'fixed', 'absolute', 'sticky'];
|
|
20
22
|
export var types = {
|
|
21
23
|
color: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.colors)), PropTypes.string]),
|
|
22
24
|
responsiveSpace: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.spaces)), PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
@@ -25,12 +27,12 @@ export var types = {
|
|
|
25
27
|
side: PropTypes.oneOf(['all', 'left', 'right', 'top', 'bottom', 'x', 'y']),
|
|
26
28
|
radius: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.radii)), PropTypes.string, PropTypes.number]),
|
|
27
29
|
shadow: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.shadows)), PropTypes.string]),
|
|
28
|
-
position: PropTypes.oneOf(
|
|
30
|
+
position: PropTypes.oneOf(positions),
|
|
29
31
|
responsiveTextSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.texts)), PropTypes.string, PropTypes.object]),
|
|
30
32
|
responsiveTextAlign: PropTypes.oneOfType([PropTypes.oneOf(['left', 'center', 'right']), PropTypes.string, PropTypes.object]),
|
|
31
33
|
iconSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.icons)), PropTypes.number, PropTypes.string]),
|
|
32
34
|
weight: PropTypes.oneOf(Object.keys(vars.weights)),
|
|
33
|
-
overflow: PropTypes.oneOf(
|
|
35
|
+
overflow: PropTypes.oneOf(overflows),
|
|
34
36
|
textTag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'label']),
|
|
35
37
|
textDisplay: PropTypes.oneOf(['block', 'inline-block', 'inline']),
|
|
36
38
|
responsiveColumns: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
package/es/utilities/helpers.js
CHANGED
|
@@ -3,6 +3,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
3
3
|
import "core-js/modules/es.array.concat.js";
|
|
4
4
|
import "core-js/modules/es.object.to-string.js";
|
|
5
5
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
6
|
+
import "core-js/modules/es.array.find.js";
|
|
6
7
|
import "core-js/modules/es.symbol.js";
|
|
7
8
|
import "core-js/modules/es.symbol.description.js";
|
|
8
9
|
import "core-js/modules/es.symbol.iterator.js";
|
|
@@ -44,4 +45,165 @@ export var mergeRefs = function mergeRefs(refs) {
|
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
};
|
|
48
|
+
};
|
|
49
|
+
var shortHandProps = [{
|
|
50
|
+
propName: 'padding',
|
|
51
|
+
property: 'padding',
|
|
52
|
+
value: 'p'
|
|
53
|
+
}, {
|
|
54
|
+
propName: 'paddingTop',
|
|
55
|
+
property: 'padding-top',
|
|
56
|
+
value: 'pt'
|
|
57
|
+
}, {
|
|
58
|
+
propName: 'paddingBottom',
|
|
59
|
+
property: 'padding-bottom',
|
|
60
|
+
value: 'pb'
|
|
61
|
+
}, {
|
|
62
|
+
propName: 'paddingLeft',
|
|
63
|
+
property: 'padding-left',
|
|
64
|
+
value: 'pl'
|
|
65
|
+
}, {
|
|
66
|
+
propName: 'paddingRight',
|
|
67
|
+
property: 'padding-right',
|
|
68
|
+
value: 'pr'
|
|
69
|
+
}, {
|
|
70
|
+
propName: 'paddingX',
|
|
71
|
+
property: 'padding-inline',
|
|
72
|
+
value: 'px'
|
|
73
|
+
}, {
|
|
74
|
+
propName: 'paddingY',
|
|
75
|
+
property: 'padding-block',
|
|
76
|
+
value: 'py'
|
|
77
|
+
}, {
|
|
78
|
+
propName: 'margin',
|
|
79
|
+
property: 'margin',
|
|
80
|
+
value: 'm'
|
|
81
|
+
}, {
|
|
82
|
+
propName: 'marginTop',
|
|
83
|
+
property: 'margin-top',
|
|
84
|
+
value: 'mt'
|
|
85
|
+
}, {
|
|
86
|
+
propName: 'marginBottom',
|
|
87
|
+
property: 'margin-bottom',
|
|
88
|
+
value: 'mb'
|
|
89
|
+
}, {
|
|
90
|
+
propName: 'marginLeft',
|
|
91
|
+
property: 'margin-left',
|
|
92
|
+
value: 'ml'
|
|
93
|
+
}, {
|
|
94
|
+
propName: 'marginRight',
|
|
95
|
+
property: 'margin-right',
|
|
96
|
+
value: 'mr'
|
|
97
|
+
}, {
|
|
98
|
+
propName: 'marginX',
|
|
99
|
+
property: 'margin-inline',
|
|
100
|
+
value: 'mx'
|
|
101
|
+
}, {
|
|
102
|
+
propName: 'marginY',
|
|
103
|
+
property: 'margin-block',
|
|
104
|
+
value: 'my'
|
|
105
|
+
}, {
|
|
106
|
+
propName: 'top',
|
|
107
|
+
property: 'top',
|
|
108
|
+
value: 't'
|
|
109
|
+
}, {
|
|
110
|
+
propName: 'bottom',
|
|
111
|
+
property: 'bottom',
|
|
112
|
+
value: 'b'
|
|
113
|
+
}, {
|
|
114
|
+
propName: 'left',
|
|
115
|
+
property: 'left',
|
|
116
|
+
value: 'l'
|
|
117
|
+
}, {
|
|
118
|
+
propName: 'right',
|
|
119
|
+
property: 'right',
|
|
120
|
+
value: 'r'
|
|
121
|
+
}, {
|
|
122
|
+
propName: 'width',
|
|
123
|
+
property: 'width',
|
|
124
|
+
value: 'w'
|
|
125
|
+
}, {
|
|
126
|
+
propName: 'height',
|
|
127
|
+
property: 'height',
|
|
128
|
+
value: 'h'
|
|
129
|
+
}, {
|
|
130
|
+
propName: 'minWidth',
|
|
131
|
+
property: 'min-width',
|
|
132
|
+
value: 'min-w'
|
|
133
|
+
}, {
|
|
134
|
+
propName: 'maxWidth',
|
|
135
|
+
property: 'max-width',
|
|
136
|
+
value: 'max-w'
|
|
137
|
+
}, {
|
|
138
|
+
propName: 'minHeight',
|
|
139
|
+
property: 'min-height',
|
|
140
|
+
value: 'min-h'
|
|
141
|
+
}, {
|
|
142
|
+
propName: 'maxHeight',
|
|
143
|
+
property: 'max-height',
|
|
144
|
+
value: 'max-h'
|
|
145
|
+
}, {
|
|
146
|
+
propName: 'color',
|
|
147
|
+
property: 'color',
|
|
148
|
+
value: 'c'
|
|
149
|
+
}, {
|
|
150
|
+
propName: 'colorHover',
|
|
151
|
+
property: 'color',
|
|
152
|
+
value: 'c-hover'
|
|
153
|
+
}, {
|
|
154
|
+
propName: 'backgroundColor',
|
|
155
|
+
property: 'background-color',
|
|
156
|
+
value: 'bgc'
|
|
157
|
+
}, {
|
|
158
|
+
propName: 'backgroundColorHover',
|
|
159
|
+
property: 'background-color',
|
|
160
|
+
value: 'bgc-hover'
|
|
161
|
+
}, {
|
|
162
|
+
propName: 'shadow',
|
|
163
|
+
property: 'box-shadow',
|
|
164
|
+
value: 'sh'
|
|
165
|
+
}, {
|
|
166
|
+
propName: 'shadowHover',
|
|
167
|
+
property: 'box-shadow',
|
|
168
|
+
value: 'sh-hover'
|
|
169
|
+
}, {
|
|
170
|
+
propName: 'radius',
|
|
171
|
+
property: 'border-radius',
|
|
172
|
+
value: 'rad'
|
|
173
|
+
}, {
|
|
174
|
+
propName: 'order',
|
|
175
|
+
property: 'order',
|
|
176
|
+
value: 'order'
|
|
177
|
+
}, {
|
|
178
|
+
propName: 'position',
|
|
179
|
+
property: 'position',
|
|
180
|
+
value: 'pos'
|
|
181
|
+
}, {
|
|
182
|
+
propName: 'overflow',
|
|
183
|
+
property: 'overflow',
|
|
184
|
+
value: 'ovf'
|
|
185
|
+
}, {
|
|
186
|
+
propName: 'overflowX',
|
|
187
|
+
property: 'overflow-x',
|
|
188
|
+
value: 'ovf-x'
|
|
189
|
+
}, {
|
|
190
|
+
propName: 'overflowY',
|
|
191
|
+
property: 'overflow-y',
|
|
192
|
+
value: 'ovf-y'
|
|
193
|
+
}];
|
|
194
|
+
export var propertyToShorthand = function propertyToShorthand(property) {
|
|
195
|
+
var _shortHandProps$find;
|
|
196
|
+
|
|
197
|
+
return (_shortHandProps$find = shortHandProps.find(function (_ref) {
|
|
198
|
+
var prop = _ref.property;
|
|
199
|
+
return prop === property;
|
|
200
|
+
})) === null || _shortHandProps$find === void 0 ? void 0 : _shortHandProps$find.value;
|
|
201
|
+
};
|
|
202
|
+
export var propNameToShorthand = function propNameToShorthand(propName) {
|
|
203
|
+
var _shortHandProps$find2;
|
|
204
|
+
|
|
205
|
+
return (_shortHandProps$find2 = shortHandProps.find(function (_ref2) {
|
|
206
|
+
var prop = _ref2.propName;
|
|
207
|
+
return prop === propName;
|
|
208
|
+
})) === null || _shortHandProps$find2 === void 0 ? void 0 : _shortHandProps$find2.value;
|
|
47
209
|
};
|
|
@@ -61,6 +61,9 @@ export var getDimension = function getDimension(dimension) {
|
|
|
61
61
|
if (isString(dimension)) return dimension;
|
|
62
62
|
if (isNumber(dimension)) return u(dimension);
|
|
63
63
|
};
|
|
64
|
+
export var isSpaceVar = function isSpaceVar(space) {
|
|
65
|
+
return space in vars.spaces || space in vars.spaceUtils;
|
|
66
|
+
};
|
|
64
67
|
export var getSpace = function getSpace(space) {
|
|
65
68
|
if (space in vars.spaceUtils) {
|
|
66
69
|
return getCssVar(varInfo.spaceUtils.name, space);
|
package/es/utilities/styles.js
CHANGED
|
@@ -3,6 +3,9 @@ import "core-js/modules/es.array.map.js";
|
|
|
3
3
|
import { getCssVar, isNumber, isString, u } from '.';
|
|
4
4
|
import { vars, varInfo } from '../variables';
|
|
5
5
|
import { getDimension } from './responsive';
|
|
6
|
+
export var isColorVar = function isColorVar(color) {
|
|
7
|
+
return color in vars.colorUtils || color in vars.colors;
|
|
8
|
+
};
|
|
6
9
|
export var getColor = function getColor(color) {
|
|
7
10
|
if (color in vars.colorUtils) {
|
|
8
11
|
return getCssVar(varInfo.colorUtils.name, color);
|