@flodesk/grain 2.19.1 → 2.19.4

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.
@@ -23,18 +23,16 @@ var _styled = _interopRequireDefault(require("@emotion/styled"));
23
23
 
24
24
  var _types = require("../types");
25
25
 
26
- var _box = require("./box");
27
-
28
26
  var _excluded = ["children", "gap", "columns", "autoFlow", "justifyItems", "alignItems", "justifyContent", "alignContent", "placeItems", "placeContent"];
29
27
 
30
28
  var _templateObject;
31
29
 
32
30
  var __jsx = _react.default.createElement;
33
31
 
34
- var Wrapper = _styled.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: grid;\n ", ";\n justify-content: start;\n align-items: center;\n gap: ", ";\n grid-template-columns: ", ";\n justify-items: ", ";\n align-items: ", ";\n justify-content: ", ";\n align-content: ", ";\n place-items: ", ";\n place-content: ", ";\n"])), function (p) {
32
+ var Wrapper = _styled.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: grid;\n ", ";\n ", ";\n grid-template-columns: ", ";\n justify-items: ", ";\n align-items: ", ";\n justify-content: ", ";\n align-content: ", ";\n place-items: ", ";\n place-content: ", ";\n"])), function (p) {
35
33
  return !p.columns && "grid-auto-flow: ".concat(p.autoFlow);
36
34
  }, function (p) {
37
- return (0, _utilities.getSpace)(p.gap);
35
+ return (0, _utilities.getSpace)('gap', p.gap);
38
36
  }, function (p) {
39
37
  return (0, _utilities.getGridColumns)(p.columns);
40
38
  }, function (p) {
@@ -23,54 +23,54 @@ var _styled = _interopRequireDefault(require("@emotion/styled"));
23
23
 
24
24
  var _types = require("../types");
25
25
 
26
- var _excluded = ["children", "color", "backgroundColor", "borderSide", "borderWidth", "borderColor", "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", "overflow", "aspectRatio"];
26
+ var _excluded = ["children", "color", "backgroundColor", "borderColor", "borderWidth", "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", "overflow", "aspectRatio"];
27
27
 
28
28
  var _templateObject;
29
29
 
30
30
  var __jsx = _react.default.createElement;
31
31
 
32
- var Wrapper = _styled.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n \n padding:", ";\n padding-top:", ";\n padding-bottom:", ";\n padding-left:", ";\n padding-right:", ";\n \n margin:", ";\n margin-top:", ";\n margin-bottom:", ";\n margin-left:", ";\n margin-right:", ";\n \n top:", ";\n bottom:", ";\n left:", ";\n right:", ";\n \n width: ", ";\n min-width: ", ";\n max-width: ", ";\n height: ", ";\n min-height: ", ";\n max-height: ", ";\n\n color: ", ";\n background-color: ", ";\n \n position: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n overflow: ", ";\n aspect-ratio: ", ";\n"])), function (p) {
32
+ var Wrapper = _styled.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n \n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\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 \n position: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n overflow: ", ";\n aspect-ratio: ", ";\n"])), function (p) {
33
33
  return (0, _utilities.getBorder)(p.borderSide, p.borderWidth, p.borderColor);
34
34
  }, function (p) {
35
- return (0, _utilities.getSpace)(p.padding);
35
+ return (0, _utilities.getSpace)('padding', p.padding);
36
36
  }, function (p) {
37
- return (0, _utilities.getSpace)(p.paddingTop);
37
+ return (0, _utilities.getSpace)('padding-top', p.paddingTop);
38
38
  }, function (p) {
39
- return (0, _utilities.getSpace)(p.paddingBottom);
39
+ return (0, _utilities.getSpace)('padding-bottom', p.paddingBottom);
40
40
  }, function (p) {
41
- return (0, _utilities.getSpace)(p.paddingLeft);
41
+ return (0, _utilities.getSpace)('padding-left', p.paddingLeft);
42
42
  }, function (p) {
43
- return (0, _utilities.getSpace)(p.paddingRight);
43
+ return (0, _utilities.getSpace)('padding-right', p.paddingRight);
44
44
  }, function (p) {
45
- return (0, _utilities.getSpace)(p.margin);
45
+ return (0, _utilities.getSpace)('margin', p.margin);
46
46
  }, function (p) {
47
- return (0, _utilities.getSpace)(p.marginTop);
47
+ return (0, _utilities.getSpace)('margin-top', p.marginTop);
48
48
  }, function (p) {
49
- return (0, _utilities.getSpace)(p.marginBottom);
49
+ return (0, _utilities.getSpace)('margin-bottom', p.marginBottom);
50
50
  }, function (p) {
51
- return (0, _utilities.getSpace)(p.marginLeft);
51
+ return (0, _utilities.getSpace)('margin-left', p.marginLeft);
52
52
  }, function (p) {
53
- return (0, _utilities.getSpace)(p.marginRight);
53
+ return (0, _utilities.getSpace)('margin-right', p.marginRight);
54
54
  }, function (p) {
55
- return (0, _utilities.getSpace)(p.top);
55
+ return (0, _utilities.getSpace)('top', p.top);
56
56
  }, function (p) {
57
- return (0, _utilities.getSpace)(p.bottom);
57
+ return (0, _utilities.getSpace)('bottom', p.bottom);
58
58
  }, function (p) {
59
- return (0, _utilities.getSpace)(p.left);
59
+ return (0, _utilities.getSpace)('left', p.left);
60
60
  }, function (p) {
61
- return (0, _utilities.getSpace)(p.right);
61
+ return (0, _utilities.getSpace)('right', p.right);
62
62
  }, function (p) {
63
- return (0, _utilities.getDimension)(p.width);
63
+ return (0, _utilities.getDimension)('width', p.width);
64
64
  }, function (p) {
65
- return (0, _utilities.getDimension)(p.minWidth);
65
+ return (0, _utilities.getDimension)('min-width', p.minWidth);
66
66
  }, function (p) {
67
- return (0, _utilities.getDimension)(p.maxWidth);
67
+ return (0, _utilities.getDimension)('max-width', p.maxWidth);
68
68
  }, function (p) {
69
- return (0, _utilities.getDimension)(p.height);
69
+ return (0, _utilities.getDimension)('height', p.height);
70
70
  }, function (p) {
71
- return (0, _utilities.getDimension)(p.minHeight);
71
+ return (0, _utilities.getDimension)('min-height', p.minHeight);
72
72
  }, function (p) {
73
- return (0, _utilities.getDimension)(p.maxHeight);
73
+ return (0, _utilities.getDimension)('max-height', p.maxHeight);
74
74
  }, function (p) {
75
75
  return (0, _utilities.getColor)(p.color);
76
76
  }, function (p) {
@@ -91,9 +91,11 @@ var Box = function Box(_ref) {
91
91
  var children = _ref.children,
92
92
  color = _ref.color,
93
93
  backgroundColor = _ref.backgroundColor,
94
+ _ref$borderColor = _ref.borderColor,
95
+ borderColor = _ref$borderColor === void 0 ? 'border' : _ref$borderColor,
96
+ _ref$borderWidth = _ref.borderWidth,
97
+ borderWidth = _ref$borderWidth === void 0 ? '1px' : _ref$borderWidth,
94
98
  borderSide = _ref.borderSide,
95
- borderWidth = _ref.borderWidth,
96
- borderColor = _ref.borderColor,
97
99
  width = _ref.width,
98
100
  minWidth = _ref.minWidth,
99
101
  maxWidth = _ref.maxWidth,
@@ -164,6 +166,51 @@ Box.__docgenInfo = {
164
166
  "methods": [],
165
167
  "displayName": "Box",
166
168
  "props": {
169
+ "borderColor": {
170
+ "defaultValue": {
171
+ "value": "'border'",
172
+ "computed": false
173
+ },
174
+ "type": {
175
+ "name": "union",
176
+ "value": [{
177
+ "name": "enum",
178
+ "value": [{
179
+ "value": "\"greys\"",
180
+ "computed": false
181
+ }, {
182
+ "value": "\"fades\"",
183
+ "computed": false
184
+ }, {
185
+ "value": "\"baseColors\"",
186
+ "computed": false
187
+ }, {
188
+ "value": "\"semanticColors\"",
189
+ "computed": false
190
+ }]
191
+ }, {
192
+ "name": "string"
193
+ }]
194
+ },
195
+ "required": false,
196
+ "description": ""
197
+ },
198
+ "borderWidth": {
199
+ "defaultValue": {
200
+ "value": "'1px'",
201
+ "computed": false
202
+ },
203
+ "type": {
204
+ "name": "union",
205
+ "value": [{
206
+ "name": "number"
207
+ }, {
208
+ "name": "string"
209
+ }]
210
+ },
211
+ "required": false,
212
+ "description": ""
213
+ },
167
214
  "color": {
168
215
  "type": {
169
216
  "name": "union",
@@ -243,43 +290,6 @@ Box.__docgenInfo = {
243
290
  "required": false,
244
291
  "description": ""
245
292
  },
246
- "borderWidth": {
247
- "type": {
248
- "name": "union",
249
- "value": [{
250
- "name": "number"
251
- }, {
252
- "name": "string"
253
- }]
254
- },
255
- "required": false,
256
- "description": ""
257
- },
258
- "borderColor": {
259
- "type": {
260
- "name": "union",
261
- "value": [{
262
- "name": "enum",
263
- "value": [{
264
- "value": "\"greys\"",
265
- "computed": false
266
- }, {
267
- "value": "\"fades\"",
268
- "computed": false
269
- }, {
270
- "value": "\"baseColors\"",
271
- "computed": false
272
- }, {
273
- "value": "\"semanticColors\"",
274
- "computed": false
275
- }]
276
- }, {
277
- "name": "string"
278
- }]
279
- },
280
- "required": false,
281
- "description": ""
282
- },
283
293
  "width": {
284
294
  "type": {
285
295
  "name": "union",
@@ -31,14 +31,14 @@ var _templateObject;
31
31
 
32
32
  var __jsx = _react.default.createElement;
33
33
 
34
- var Wrapper = _styled.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: block;\n width: ", ";\n color: ", ";\n \n svg {\n display: block;\n height: ", ";\n ", ";\n }\n"])), function (p) {
34
+ var Wrapper = _styled.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: block;\n width: ", ";\n color: ", ";\n \n svg {\n display: block;\n ", ";\n ", ";\n }\n"])), function (p) {
35
35
  return (0, _utilities.getColor)(p.color);
36
36
  }, function (p) {
37
37
  return (0, _utilities.getColor)(p.color);
38
38
  }, function (p) {
39
- return (0, _utilities.getIconSize)(p.size);
39
+ return (0, _utilities.getIconSize)('height', p.size);
40
40
  }, function (p) {
41
- return p.hasEvenBoundary && "width: ".concat((0, _utilities.getIconSize)(p.size));
41
+ return p.hasEvenBoundary && (0, _utilities.getIconSize)('width', p.size);
42
42
  });
43
43
 
44
44
  var Icon = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
@@ -29,7 +29,7 @@ var _templateObject;
29
29
 
30
30
  var __jsx = _react.default.createElement;
31
31
 
32
- var Wrapper = _styled.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: block;\n font-size: ", ";\n font-weight: ", ";\n color: ", ";\n text-align: ", ";\n \n ", ";\n ", ";\n ", ";\n"])), function (p) {
32
+ var Wrapper = _styled.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: block;\n ", ";\n font-weight: ", ";\n color: ", ";\n text-align: ", ";\n \n ", ";\n ", ";\n ", ";\n"])), function (p) {
33
33
  return (0, _utilities.getTextSize)(p.size);
34
34
  }, function (p) {
35
35
  return (0, _utilities.getWeight)(p.weight);
@@ -23,15 +23,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
23
23
  Object.defineProperty(exports, "__esModule", {
24
24
  value: true
25
25
  });
26
- exports.getBorder = exports.getGridColumns = exports.getIconSize = exports.getDimension = exports.getSpace = exports.getTransition = exports.getRadius = exports.getWeight = exports.getTextSize = exports.getShadow = exports.getColor = exports.getCssVar = exports.getCssVarCore = exports.isBrowser = void 0;
26
+ exports.getBorder = exports.getGridColumns = exports.getIconSize = exports.getSpace = exports.getDimension = exports.getTransition = exports.getRadius = exports.getWeight = exports.getTextSize = exports.getShadow = exports.getColor = exports.isObject = exports.isArray = exports.isString = exports.isNumber = exports.u = exports.getCssVar = exports.getCssVarCore = exports.isBrowser = void 0;
27
27
 
28
28
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
29
 
30
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
31
+
30
32
  require("core-js/modules/es.array.concat.js");
31
33
 
32
34
  require("core-js/modules/es.array.map.js");
33
35
 
34
- var _variables = require("./variables");
36
+ var _variables = require("../variables");
37
+
38
+ var _responsive = require("./responsive");
35
39
 
36
40
  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; }
37
41
 
@@ -56,20 +60,36 @@ var u = function u(amount) {
56
60
  return "calc(var(--grn-unit) * ".concat(amount, ")");
57
61
  };
58
62
 
63
+ exports.u = u;
64
+
59
65
  var isNumber = function isNumber(value) {
60
66
  return typeof value === "number";
61
67
  };
62
68
 
69
+ exports.isNumber = isNumber;
70
+
63
71
  var isString = function isString(value) {
64
72
  return typeof value === "string";
65
73
  };
66
74
 
75
+ exports.isString = isString;
76
+
67
77
  var isArray = function isArray(value) {
68
78
  return Array.isArray(value);
69
79
  };
70
80
 
81
+ exports.isArray = isArray;
82
+
83
+ var isObject = function isObject(value) {
84
+ return (0, _typeof2.default)(value) === "object";
85
+ };
86
+
87
+ exports.isObject = isObject;
88
+
89
+ var allColors = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, _variables.vars.colors.baseColors), _variables.vars.colors.greys), _variables.vars.colors.semanticColors), _variables.vars.colors.fades);
90
+
71
91
  var getColor = function getColor(color) {
72
- if (color in _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, _variables.vars.colors.baseColors), _variables.vars.colors.greys), _variables.vars.colors.semanticColors), _variables.vars.colors.fades)) {
92
+ if (color in allColors) {
73
93
  return getCssVar(_variables.varNames.color.prefix, color);
74
94
  }
75
95
 
@@ -89,13 +109,14 @@ var getShadow = function getShadow(shadow) {
89
109
  exports.getShadow = getShadow;
90
110
 
91
111
  var getTextSize = function getTextSize(size) {
112
+ var property = "font-size: ";
113
+
92
114
  if (size in _variables.vars.textSizes) {
93
- return getCssVar(_variables.varNames.textSize.prefix, size);
115
+ return property + getCssVar(_variables.varNames.textSize.prefix, size);
94
116
  }
95
117
 
96
- if (isString(size)) {
97
- return size;
98
- }
118
+ if (isString(size)) return property + size;
119
+ if (isObject(size)) return (0, _responsive.getMediaStyles)(property, size);
99
120
  };
100
121
 
101
122
  exports.getTextSize = getTextSize;
@@ -113,9 +134,7 @@ var getRadius = function getRadius(radius) {
113
134
  return getCssVar(_variables.varNames.radius.prefix, radius);
114
135
  }
115
136
 
116
- if (isString(radius)) {
117
- return radius;
118
- }
137
+ if (isString(radius)) return radius;
119
138
  };
120
139
 
121
140
  exports.getRadius = getRadius;
@@ -128,48 +147,32 @@ var getTransition = function getTransition(transition) {
128
147
 
129
148
  exports.getTransition = getTransition;
130
149
 
131
- var getSpace = function getSpace(space) {
132
- if (space === 0) return space;
150
+ var getDimension = function getDimension(property, dimension) {
151
+ var propertyName = property + ":";
152
+ if (dimension === 0) return propertyName + dimension;
153
+ if (isNumber(dimension)) return propertyName + u(dimension);
154
+ if (isString(dimension)) return propertyName + dimension;
155
+ if (isObject(dimension)) return (0, _responsive.getMediaStyles)(propertyName, dimension);
156
+ };
133
157
 
134
- if (isNumber(space)) {
135
- return u(space);
136
- }
158
+ exports.getDimension = getDimension;
137
159
 
160
+ var getSpace = function getSpace(property, space) {
138
161
  if (space in _variables.vars.spaces) {
139
- return getCssVar(_variables.varNames.space.prefix, space);
162
+ return "".concat(property, ": ").concat(getCssVar(_variables.varNames.space.prefix, space));
140
163
  }
141
164
 
142
- if (isString(space)) {
143
- return space;
144
- }
165
+ return getDimension(property, space);
145
166
  };
146
167
 
147
168
  exports.getSpace = getSpace;
148
169
 
149
- var getDimension = function getDimension(dimension) {
150
- if (dimension === 0) return dimension;
151
-
152
- if (isNumber(dimension)) {
153
- return u(dimension);
154
- }
155
-
156
- if (isString(dimension)) {
157
- return dimension;
158
- }
159
- };
160
-
161
- exports.getDimension = getDimension;
162
-
163
- var getIconSize = function getIconSize(size) {
164
- if (size === 0) return size;
165
-
170
+ var getIconSize = function getIconSize(property, size) {
166
171
  if (size in _variables.vars.iconSizes) {
167
- return getCssVar(_variables.varNames.iconSize.prefix, size);
172
+ return "".concat(property, ": ").concat(getCssVar(_variables.varNames.iconSize.prefix, size));
168
173
  }
169
174
 
170
- if (isNumber(size) || isString(size)) {
171
- return getDimension(size);
172
- }
175
+ return getDimension(property, size);
173
176
  };
174
177
 
175
178
  exports.getIconSize = getIconSize;
@@ -182,9 +185,7 @@ var getGridColumns = function getGridColumns(columns) {
182
185
  }).join(" ");
183
186
  }
184
187
 
185
- if (isString(columns)) {
186
- return columns;
187
- }
188
+ if (isString(columns)) return columns;
188
189
  }
189
190
  };
190
191
 
@@ -193,19 +194,20 @@ exports.getGridColumns = getGridColumns;
193
194
  var getBorder = function getBorder(borderSide) {
194
195
  var borderWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "1px";
195
196
  var borderColor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "border";
196
- var w = getSpace(borderWidth);
197
- var borderSideStyles = {
198
- x: "0 ".concat(w),
199
- y: "".concat(w, " 0"),
200
- all: "".concat(w),
201
- top: "".concat(w, " 0 0 0"),
202
- right: "0 ".concat(w, " 0 0"),
203
- bottom: "0 0 ".concat(w, " 0"),
204
- left: "0 0 0 ".concat(w)
197
+ var borderSides = {
198
+ all: ["top", "right", "bottom", "left"],
199
+ x: ["right", "left"],
200
+ y: ["top", "bottom"],
201
+ top: ["top"],
202
+ right: ["right"],
203
+ bottom: ["bottom"],
204
+ left: ["left"]
205
205
  };
206
206
 
207
- if (borderSide in borderSideStyles) {
208
- return "\n border-style: solid;\n border-width: ".concat(borderSideStyles[borderSide], ";\n border-color: ").concat(getColor(borderColor), ";\n ");
207
+ if (borderSide in borderSides) {
208
+ return "\n ".concat(borderSides[borderSide].map(function (side) {
209
+ return "border-".concat(side, "-style: solid");
210
+ }).join(";"), ";\n\n border-color: ").concat(getColor(borderColor), ";\n ").concat(getDimension("border-width", borderWidth), ";\n ");
209
211
  }
210
212
  };
211
213
 
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.getMediaStyles = void 0;
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ require("core-js/modules/es.array.map.js");
15
+
16
+ require("core-js/modules/es.object.entries.js");
17
+
18
+ require("core-js/modules/es.array.concat.js");
19
+
20
+ var getMediaStyles = function getMediaStyles(property, obj) {
21
+ var declarations = Object.entries(obj).map(function (_ref) {
22
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
23
+ key = _ref2[0],
24
+ value = _ref2[1];
25
+
26
+ return "\n @media (min-width: ".concat(key, ") {\n ").concat(property, " ").concat(value, ";\n }\n ");
27
+ });
28
+ return declarations.join("");
29
+ };
30
+
31
+ exports.getMediaStyles = getMediaStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "2.19.1",
3
+ "version": "2.19.4",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",