@flodesk/grain 2.1.0 → 2.2.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/box/index.js +64 -17
- package/es/styles/base.css +6 -0
- package/es/types/index.js +8 -5
- package/es/utilities/index.js +12 -7
- package/es/variables/index.js +64 -35
- package/package.json +1 -1
|
@@ -1,35 +1,60 @@
|
|
|
1
1
|
import "core-js/modules/es.array.slice.js";
|
|
2
2
|
import "core-js/modules/es.object.freeze.js";
|
|
3
3
|
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
7
|
+
var _excluded = ["children", "color", "backgroundColor", "borderSide", "borderWidth", "borderColor", "width", "height", "radius", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "paddingX", "paddingY", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "marginX", "marginY", "position", "top", "bottom", "left", "right"];
|
|
4
8
|
|
|
5
9
|
var _templateObject;
|
|
6
10
|
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
7
15
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
8
16
|
|
|
9
|
-
import
|
|
10
|
-
import
|
|
17
|
+
import "core-js/modules/es.array.concat.js";
|
|
18
|
+
import "core-js/modules/es.object.assign.js";
|
|
19
|
+
import { getBorder, getColor, getRadius, getSpace } from '../../utilities';
|
|
11
20
|
import React from "react";
|
|
12
|
-
import { cssVars } from '../../variables';
|
|
13
21
|
import styled from "@emotion/styled";
|
|
14
22
|
import { types } from '../../types';
|
|
15
|
-
|
|
23
|
+
|
|
24
|
+
var getSpaceCss = function getSpaceCss(propertyName, propertyValue) {
|
|
25
|
+
if (propertyValue || propertyValue === 0) {
|
|
26
|
+
return "".concat(propertyName, ": ").concat(getSpace(propertyValue));
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n \n ", ";\n ", ";\n ", ";\n ", ";\n \n ", ";\n ", ";\n ", ";\n ", ";\n \n ", ";\n ", ";\n ", ";\n ", ";\n \n ", ";\n \n color: ", ";\n background-color: ", ";\n width: ", ";\n height: ", ";\n border-radius: ", ";\n"])), function (p) {
|
|
16
31
|
return getBorder(p.borderSide, p.borderWidth, p.borderColor);
|
|
17
32
|
}, function (p) {
|
|
18
|
-
return
|
|
33
|
+
return getSpaceCss('padding-top', p.paddingTop);
|
|
34
|
+
}, function (p) {
|
|
35
|
+
return getSpaceCss('padding-bottom', p.paddingBottom);
|
|
19
36
|
}, function (p) {
|
|
20
|
-
return
|
|
37
|
+
return getSpaceCss('padding-left', p.paddingLeft);
|
|
21
38
|
}, function (p) {
|
|
22
|
-
return
|
|
39
|
+
return getSpaceCss('padding-right', p.paddingRight);
|
|
23
40
|
}, function (p) {
|
|
24
|
-
return
|
|
41
|
+
return getSpaceCss('margin-top', p.marginTop);
|
|
25
42
|
}, function (p) {
|
|
26
|
-
return
|
|
43
|
+
return getSpaceCss('margin-bottom', p.marginBottom);
|
|
27
44
|
}, function (p) {
|
|
28
|
-
return
|
|
45
|
+
return getSpaceCss('margin-left', p.marginLeft);
|
|
29
46
|
}, function (p) {
|
|
30
|
-
return
|
|
47
|
+
return getSpaceCss('margin-right', p.marginRight);
|
|
31
48
|
}, function (p) {
|
|
32
|
-
return
|
|
49
|
+
return getSpaceCss('top', p.top);
|
|
50
|
+
}, function (p) {
|
|
51
|
+
return getSpaceCss('bottom', p.bottom);
|
|
52
|
+
}, function (p) {
|
|
53
|
+
return getSpaceCss('left', p.left);
|
|
54
|
+
}, function (p) {
|
|
55
|
+
return getSpaceCss('right', p.right);
|
|
56
|
+
}, function (p) {
|
|
57
|
+
return p.position && "position: ".concat(p.position);
|
|
33
58
|
}, function (p) {
|
|
34
59
|
return getColor(p.color);
|
|
35
60
|
}, function (p) {
|
|
@@ -38,6 +63,8 @@ var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLi
|
|
|
38
63
|
return getSpace(p.width);
|
|
39
64
|
}, function (p) {
|
|
40
65
|
return getSpace(p.height);
|
|
66
|
+
}, function (p) {
|
|
67
|
+
return getRadius(p.radius);
|
|
41
68
|
});
|
|
42
69
|
export var Box = function Box(_ref) {
|
|
43
70
|
var children = _ref.children,
|
|
@@ -48,6 +75,7 @@ export var Box = function Box(_ref) {
|
|
|
48
75
|
borderColor = _ref.borderColor,
|
|
49
76
|
width = _ref.width,
|
|
50
77
|
height = _ref.height,
|
|
78
|
+
radius = _ref.radius,
|
|
51
79
|
padding = _ref.padding,
|
|
52
80
|
paddingTop = _ref.paddingTop,
|
|
53
81
|
paddingBottom = _ref.paddingBottom,
|
|
@@ -61,8 +89,15 @@ export var Box = function Box(_ref) {
|
|
|
61
89
|
marginLeft = _ref.marginLeft,
|
|
62
90
|
marginRight = _ref.marginRight,
|
|
63
91
|
marginX = _ref.marginX,
|
|
64
|
-
marginY = _ref.marginY
|
|
65
|
-
|
|
92
|
+
marginY = _ref.marginY,
|
|
93
|
+
position = _ref.position,
|
|
94
|
+
top = _ref.top,
|
|
95
|
+
bottom = _ref.bottom,
|
|
96
|
+
left = _ref.left,
|
|
97
|
+
right = _ref.right,
|
|
98
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
66
101
|
backgroundColor: backgroundColor,
|
|
67
102
|
color: color,
|
|
68
103
|
borderSide: borderSide,
|
|
@@ -70,6 +105,7 @@ export var Box = function Box(_ref) {
|
|
|
70
105
|
borderColor: borderColor,
|
|
71
106
|
width: width,
|
|
72
107
|
height: height,
|
|
108
|
+
radius: radius,
|
|
73
109
|
paddingTop: padding || paddingY || paddingTop,
|
|
74
110
|
paddingBottom: padding || paddingY || paddingBottom,
|
|
75
111
|
paddingLeft: padding || paddingX || paddingLeft,
|
|
@@ -77,14 +113,20 @@ export var Box = function Box(_ref) {
|
|
|
77
113
|
marginTop: margin || marginY || marginTop,
|
|
78
114
|
marginBottom: margin || marginY || marginBottom,
|
|
79
115
|
marginLeft: margin || marginX || marginLeft,
|
|
80
|
-
marginRight: margin || marginX || marginRight
|
|
81
|
-
|
|
116
|
+
marginRight: margin || marginX || marginRight,
|
|
117
|
+
position: position,
|
|
118
|
+
top: top,
|
|
119
|
+
bottom: bottom,
|
|
120
|
+
left: left,
|
|
121
|
+
right: right
|
|
122
|
+
}, props), children);
|
|
82
123
|
};
|
|
83
124
|
Box.propTypes = {
|
|
84
125
|
color: types.color,
|
|
85
126
|
borderSide: types.side,
|
|
86
127
|
width: types.space,
|
|
87
128
|
height: types.space,
|
|
129
|
+
radius: types.radius,
|
|
88
130
|
padding: types.space,
|
|
89
131
|
paddingTop: types.space,
|
|
90
132
|
paddingBottom: types.space,
|
|
@@ -98,5 +140,10 @@ Box.propTypes = {
|
|
|
98
140
|
marginLeft: types.space,
|
|
99
141
|
marginRight: types.space,
|
|
100
142
|
marginX: types.space,
|
|
101
|
-
marginY: types.space
|
|
143
|
+
marginY: types.space,
|
|
144
|
+
position: types.position,
|
|
145
|
+
top: types.space,
|
|
146
|
+
bottom: types.space,
|
|
147
|
+
left: types.space,
|
|
148
|
+
right: types.space
|
|
102
149
|
};
|
package/es/styles/base.css
CHANGED
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
--grn-space-xxl: calc(var(--grn-unit) * 7);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
:root {
|
|
29
|
+
--grn-radius-s: calc(var(--grn-unit) / 2);
|
|
30
|
+
--grn-radius-m: calc(var(--grn-unit) / 1.33);
|
|
31
|
+
--grn-radius-l: calc(var(--grn-unit) * 1.25);
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
:root {
|
|
29
35
|
--grey8-HSL: 0 0% 7%;
|
|
30
36
|
|
package/es/types/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import "core-js/modules/es.object.keys.js";
|
|
1
2
|
import PropTypes from "prop-types";
|
|
2
|
-
import {
|
|
3
|
+
import { vars } from "../variables";
|
|
3
4
|
export var types = {
|
|
4
|
-
color: PropTypes.oneOfType([PropTypes.oneOf(
|
|
5
|
-
space: PropTypes.oneOfType([PropTypes.oneOf(
|
|
5
|
+
color: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.colors)), PropTypes.string]),
|
|
6
|
+
space: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.spaces)), PropTypes.number, PropTypes.string]),
|
|
6
7
|
side: PropTypes.oneOf(["all", "left", "right", "top", "bottom", "x", "y"]),
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
radius: PropTypes.oneOf(["s", "m", "l"]),
|
|
9
|
+
position: PropTypes.oneOf(["static", "relative", "fixed", "absolute", "sticky"]),
|
|
10
|
+
textSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.textSizes)), PropTypes.number, PropTypes.string]),
|
|
11
|
+
weight: PropTypes.oneOf(Object.keys(vars.weights))
|
|
9
12
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import "core-js/modules/es.array.concat.js";
|
|
2
|
-
import "
|
|
3
|
-
import "core-js/modules/es.string.includes.js";
|
|
4
|
-
import { cssVars, grnPrefix } from "../variables";
|
|
2
|
+
import { grnPrefix, vars } from "../variables";
|
|
5
3
|
export var getCssVarCore = function getCssVarCore(type, value) {
|
|
6
4
|
return "".concat(grnPrefix).concat(type, "-").concat(value);
|
|
7
5
|
};
|
|
@@ -14,35 +12,42 @@ var u = function u(amount) {
|
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export var getColor = function getColor(color) {
|
|
17
|
-
if (
|
|
15
|
+
if (color in vars.colors) {
|
|
18
16
|
return getCssVar("color", color);
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
return color;
|
|
22
20
|
};
|
|
23
21
|
export var getTextSize = function getTextSize(size) {
|
|
24
|
-
if (
|
|
22
|
+
if (size in vars.textSizes) {
|
|
25
23
|
return getCssVar("text", size);
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
return size;
|
|
29
27
|
};
|
|
30
28
|
export var getWeight = function getWeight(weight) {
|
|
31
|
-
if (
|
|
29
|
+
if (weight in vars.weights) {
|
|
32
30
|
return getCssVar("weight", weight);
|
|
33
31
|
}
|
|
34
32
|
};
|
|
33
|
+
export var getRadius = function getRadius(radius) {
|
|
34
|
+
if (radius in vars.radiuses) {
|
|
35
|
+
return getCssVar("radius", radius);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
35
38
|
export var getSpace = function getSpace(space) {
|
|
36
39
|
if (isNaN(space)) {
|
|
37
|
-
if (
|
|
40
|
+
if (space in vars.spaces) {
|
|
38
41
|
return getCssVar("space", space);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
return space;
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
if (space === 0) return space;
|
|
44
48
|
return u(space);
|
|
45
49
|
};
|
|
50
|
+
console.log("getSpace", getSpace(0));
|
|
46
51
|
export var getBorder = function getBorder(borderSide) {
|
|
47
52
|
var borderWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "1px";
|
|
48
53
|
var borderColor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "border";
|
package/es/variables/index.js
CHANGED
|
@@ -1,41 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
-
|
|
13
|
-
import "core-js/modules/es.array.reverse.js";
|
|
14
|
-
import "core-js/modules/es.array.concat.js";
|
|
1
|
+
import "core-js/modules/es.object.define-property.js";
|
|
2
|
+
import "core-js/modules/es.object.keys.js";
|
|
15
3
|
import "core-js/modules/es.symbol.js";
|
|
16
|
-
import "core-js/modules/es.
|
|
4
|
+
import "core-js/modules/es.array.filter.js";
|
|
17
5
|
import "core-js/modules/es.object.to-string.js";
|
|
18
|
-
import "core-js/modules/es.
|
|
19
|
-
import "core-js/modules/
|
|
20
|
-
import "core-js/modules/es.
|
|
21
|
-
import "core-js/modules/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var greysArray = [];
|
|
6
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
7
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
8
|
+
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
9
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
greysArray.push("grey" + step);
|
|
30
|
-
}
|
|
15
|
+
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; }
|
|
31
16
|
|
|
32
17
|
export var grnPrefix = "--grn-";
|
|
33
|
-
export var greys =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
export var greys = {
|
|
19
|
+
grey8: "grey8",
|
|
20
|
+
grey7: "grey7",
|
|
21
|
+
grey6: "grey6",
|
|
22
|
+
grey5: "grey5",
|
|
23
|
+
grey4: "grey4",
|
|
24
|
+
grey3: "grey3",
|
|
25
|
+
grey2: "grey2",
|
|
26
|
+
grey1: "grey1"
|
|
27
|
+
};
|
|
28
|
+
export var semanticColors = {
|
|
29
|
+
body: "body",
|
|
30
|
+
bodyDimmed: "bodyDimmed",
|
|
31
|
+
accent: "accent",
|
|
32
|
+
backgroundSecondary: "backgroundSecondary",
|
|
33
|
+
background: "background",
|
|
34
|
+
overlay: "overlay",
|
|
35
|
+
border: "border",
|
|
36
|
+
selection: "selection",
|
|
37
|
+
danger: "danger"
|
|
38
|
+
};
|
|
39
|
+
export var baseColors = {
|
|
40
|
+
blue: "blue",
|
|
41
|
+
red: "red"
|
|
42
|
+
};
|
|
43
|
+
export var vars = {
|
|
44
|
+
textSizes: {
|
|
45
|
+
s: "s",
|
|
46
|
+
m: "m",
|
|
47
|
+
l: "l",
|
|
48
|
+
xl: "xl",
|
|
49
|
+
xxl: "xxl"
|
|
50
|
+
},
|
|
51
|
+
spaces: {
|
|
52
|
+
xs: "xs",
|
|
53
|
+
s: "s",
|
|
54
|
+
m: "m",
|
|
55
|
+
l: "l",
|
|
56
|
+
xl: "xl",
|
|
57
|
+
xxl: "xxl"
|
|
58
|
+
},
|
|
59
|
+
weights: {
|
|
60
|
+
normal: "normal",
|
|
61
|
+
medium: "medium",
|
|
62
|
+
semiBold: "semiBold"
|
|
63
|
+
},
|
|
64
|
+
radiuses: {
|
|
65
|
+
s: "s",
|
|
66
|
+
m: "m",
|
|
67
|
+
l: "l"
|
|
68
|
+
},
|
|
69
|
+
colors: _objectSpread(_objectSpread(_objectSpread({}, greys), baseColors), semanticColors)
|
|
41
70
|
};
|