@flodesk/grain 2.21.0 → 3.0.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/arrange.js +21 -21
- package/es/types.js +8 -5
- package/es/utilities/index.js +1 -1
- package/es/utilities/responsive.js +20 -0
- package/es/utilities/styles.js +1 -12
- package/package.json +1 -1
package/es/components/arrange.js
CHANGED
|
@@ -4,7 +4,7 @@ import "core-js/modules/es.object.define-properties.js";
|
|
|
4
4
|
import "core-js/modules/es.object.keys.js";
|
|
5
5
|
import "core-js/modules/es.array.index-of.js";
|
|
6
6
|
import "core-js/modules/es.symbol.js";
|
|
7
|
-
var _excluded = ["children", "gap", "
|
|
7
|
+
var _excluded = ["children", "gap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "autoFlow", "width", "height"];
|
|
8
8
|
|
|
9
9
|
var _templateObject;
|
|
10
10
|
|
|
@@ -16,16 +16,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
16
|
|
|
17
17
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { getResponsiveDimension, getResponsiveGridColumns, getResponsiveSpace } from '../utilities';
|
|
20
20
|
import React from 'react';
|
|
21
21
|
import styled from '@emotion/styled';
|
|
22
22
|
import { types } from '../types';
|
|
23
|
-
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: grid;\n ", ";\n ", ";\n
|
|
23
|
+
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: grid;\n ", ";\n ", ";\n ", ";\n justify-items: ", ";\n align-items: ", ";\n justify-content: ", ";\n align-content: ", ";\n ", ";\n ", ";\n"])), function (p) {
|
|
24
24
|
return !p.columns && "grid-auto-flow: ".concat(p.autoFlow);
|
|
25
25
|
}, function (p) {
|
|
26
26
|
return getResponsiveSpace('gap', p.gap);
|
|
27
27
|
}, function (p) {
|
|
28
|
-
return
|
|
28
|
+
return getResponsiveGridColumns(p.columns);
|
|
29
29
|
}, function (p) {
|
|
30
30
|
return p.justifyItems;
|
|
31
31
|
}, function (p) {
|
|
@@ -35,46 +35,46 @@ var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLi
|
|
|
35
35
|
}, function (p) {
|
|
36
36
|
return p.alignContent;
|
|
37
37
|
}, function (p) {
|
|
38
|
-
return p.
|
|
38
|
+
return getResponsiveDimension('width', p.width);
|
|
39
39
|
}, function (p) {
|
|
40
|
-
return p.
|
|
40
|
+
return getResponsiveDimension('height', p.height);
|
|
41
41
|
});
|
|
42
42
|
export var Arrange = function Arrange(_ref) {
|
|
43
43
|
var children = _ref.children,
|
|
44
44
|
gap = _ref.gap,
|
|
45
|
-
columns = _ref.columns,
|
|
46
|
-
_ref$autoFlow = _ref.autoFlow,
|
|
47
|
-
autoFlow = _ref$autoFlow === void 0 ? 'column' : _ref$autoFlow,
|
|
48
|
-
justifyItems = _ref.justifyItems,
|
|
49
45
|
_ref$alignItems = _ref.alignItems,
|
|
50
46
|
alignItems = _ref$alignItems === void 0 ? 'center' : _ref$alignItems,
|
|
47
|
+
justifyItems = _ref.justifyItems,
|
|
51
48
|
_ref$justifyContent = _ref.justifyContent,
|
|
52
49
|
justifyContent = _ref$justifyContent === void 0 ? 'start' : _ref$justifyContent,
|
|
53
50
|
alignContent = _ref.alignContent,
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
columns = _ref.columns,
|
|
52
|
+
_ref$autoFlow = _ref.autoFlow,
|
|
53
|
+
autoFlow = _ref$autoFlow === void 0 ? 'column' : _ref$autoFlow,
|
|
54
|
+
width = _ref.width,
|
|
55
|
+
height = _ref.height,
|
|
56
56
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
57
|
|
|
58
58
|
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
59
59
|
gap: gap,
|
|
60
60
|
columns: columns,
|
|
61
61
|
autoFlow: autoFlow,
|
|
62
|
-
justifyItems: justifyItems,
|
|
63
62
|
alignItems: alignItems,
|
|
63
|
+
justifyItems: justifyItems,
|
|
64
64
|
justifyContent: justifyContent,
|
|
65
65
|
alignContent: alignContent,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
width: width,
|
|
67
|
+
height: height
|
|
68
68
|
}, props), children);
|
|
69
69
|
};
|
|
70
70
|
Arrange.propTypes = {
|
|
71
71
|
gap: types.space,
|
|
72
72
|
columns: types.columns,
|
|
73
73
|
autoFlow: types.autoFlow,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
justifyContent: types.
|
|
77
|
-
alignContent: types.
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
alignItems: types.gridItemsAlignment,
|
|
75
|
+
justifyItems: types.gridItemsAlignment,
|
|
76
|
+
justifyContent: types.gridContentPosition,
|
|
77
|
+
alignContent: types.gridContentPosition,
|
|
78
|
+
width: types.dimension,
|
|
79
|
+
height: types.dimension
|
|
80
80
|
};
|
package/es/types.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import "core-js/modules/es.object.keys.js";
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { vars } from './variables';
|
|
4
|
+
export var gridContentPositions = ['start', 'end', 'center', 'stretch', 'space-around', 'space-between', 'space-evenly'];
|
|
5
|
+
export var gridItemsAlignments = ['start', 'end', 'center', 'stretch'];
|
|
6
|
+
export var autoFlows = ['column', 'row'];
|
|
4
7
|
export var types = {
|
|
5
8
|
color: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.colors)), PropTypes.string]),
|
|
6
9
|
space: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.spaces)), PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
7
10
|
dimension: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
8
11
|
side: PropTypes.oneOf(['all', 'left', 'right', 'top', 'bottom', 'x', 'y']),
|
|
9
|
-
radius: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.radii)), PropTypes.string]),
|
|
12
|
+
radius: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.radii)), PropTypes.string, PropTypes.number]),
|
|
10
13
|
shadow: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.shadows)), PropTypes.string]),
|
|
11
14
|
position: PropTypes.oneOf(['static', 'relative', 'fixed', 'absolute', 'sticky']),
|
|
12
15
|
textSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.texts)), PropTypes.string, PropTypes.object]),
|
|
@@ -15,9 +18,9 @@ export var types = {
|
|
|
15
18
|
textAlign: PropTypes.oneOf(['left', 'center', 'right']),
|
|
16
19
|
overflow: PropTypes.oneOf(['visible', 'hidden', 'scroll', 'auto']),
|
|
17
20
|
fieldSize: PropTypes.oneOf(['s', 'm']),
|
|
18
|
-
columns: PropTypes.oneOfType([PropTypes.
|
|
19
|
-
autoFlow: PropTypes.oneOf(
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
columns: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
22
|
+
autoFlow: PropTypes.oneOf(autoFlows),
|
|
23
|
+
gridItemsAlignment: PropTypes.oneOf(gridItemsAlignments),
|
|
24
|
+
gridContentPosition: PropTypes.oneOf(gridContentPositions),
|
|
22
25
|
icon: PropTypes.node
|
|
23
26
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { getDimension } from './responsive';
|
|
2
2
|
export { getResponsiveDimension } from './responsive';
|
|
3
|
+
export { getResponsiveGridColumns } from './responsive';
|
|
3
4
|
export { getColor } from './styles';
|
|
4
5
|
export { getShadow } from './styles';
|
|
5
6
|
export { getTextSize } from './responsive';
|
|
@@ -9,7 +10,6 @@ export { getRadius } from './styles';
|
|
|
9
10
|
export { getTransition } from './styles';
|
|
10
11
|
export { getResponsiveSpace } from './responsive';
|
|
11
12
|
export { getIconSize } from './styles';
|
|
12
|
-
export { getGridColumns } from './styles';
|
|
13
13
|
export { getBorder } from './styles';
|
|
14
14
|
export { isBrowser } from './helpers';
|
|
15
15
|
export { getCssVarCore } from './helpers';
|
|
@@ -104,4 +104,24 @@ export var getResponsiveTextSize = function getResponsiveTextSize(size) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
return "".concat(property, ": ").concat(getTextSize(size));
|
|
107
|
+
};
|
|
108
|
+
export var mapColumnsToMedia = function mapColumnsToMedia(property, obj) {
|
|
109
|
+
var declarations = Object.entries(obj).map(function (_ref3) {
|
|
110
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
111
|
+
breakpoint = _ref4[0],
|
|
112
|
+
value = _ref4[1];
|
|
113
|
+
|
|
114
|
+
return getMediaCss(breakpoint, property, value);
|
|
115
|
+
});
|
|
116
|
+
return declarations.join('');
|
|
117
|
+
};
|
|
118
|
+
export var getResponsiveGridColumns = function getResponsiveGridColumns(columns) {
|
|
119
|
+
if (!columns) return;
|
|
120
|
+
var property = 'grid-template-columns';
|
|
121
|
+
|
|
122
|
+
if (isObject(columns)) {
|
|
123
|
+
return mapColumnsToMedia(property, columns);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return "".concat(property, ": ").concat(columns);
|
|
107
127
|
};
|
package/es/utilities/styles.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "core-js/modules/es.array.map.js";
|
|
2
1
|
import "core-js/modules/es.array.concat.js";
|
|
2
|
+
import "core-js/modules/es.array.map.js";
|
|
3
3
|
import "core-js/modules/es.object.define-property.js";
|
|
4
4
|
import "core-js/modules/es.object.keys.js";
|
|
5
5
|
import "core-js/modules/es.symbol.js";
|
|
@@ -62,17 +62,6 @@ export var getIconSize = function getIconSize(size) {
|
|
|
62
62
|
|
|
63
63
|
return getDimension(size);
|
|
64
64
|
};
|
|
65
|
-
export var getGridColumns = function getGridColumns(columns) {
|
|
66
|
-
if (columns) {
|
|
67
|
-
if (isArray(columns)) {
|
|
68
|
-
return columns.map(function (column) {
|
|
69
|
-
return getDimension(column);
|
|
70
|
-
}).join(' ');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (isString(columns)) return columns;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
65
|
export var getBorder = function getBorder(borderSide, borderWidth, borderColor) {
|
|
77
66
|
var borderSides = {
|
|
78
67
|
all: ["top", "right", "bottom", "left"],
|