@sb1/ffe-grid-react 11.1.8 → 12.0.1

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/Grid.js CHANGED
@@ -1,47 +1,29 @@
1
- var _excluded = ["children", "className", "condensed", "element", "topPadding"];
2
-
1
+ var _excluded = ["children", "className", "gap", "element"];
3
2
  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); }
4
-
3
+ 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; }
5
4
  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; }
6
-
7
5
  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; }
8
-
9
6
  import React from 'react';
10
7
  import classNames from 'classnames';
11
- import { bool, node, string } from 'prop-types';
8
+ import { node, string, oneOf } from 'prop-types';
12
9
  export default function Grid(_ref) {
13
10
  var children = _ref.children,
14
- className = _ref.className,
15
- condensed = _ref.condensed,
16
- element = _ref.element,
17
- topPadding = _ref.topPadding,
18
- rest = _objectWithoutProperties(_ref, _excluded);
19
-
11
+ className = _ref.className,
12
+ gap = _ref.gap,
13
+ element = _ref.element,
14
+ rest = _objectWithoutProperties(_ref, _excluded);
20
15
  var Element = element || 'div';
21
16
  return /*#__PURE__*/React.createElement(Element, _extends({
22
- className: classNames(className, 'ffe-grid', {
23
- 'ffe-grid--condensed': condensed
24
- }, {
25
- 'ffe-grid--no-top-padding': !topPadding
26
- })
17
+ className: classNames(className, 'ffe-grid', _defineProperty({}, "ffe-grid--gap-".concat(gap), gap))
27
18
  }, rest), children);
28
19
  }
29
- Grid.defaultProps = {
30
- topPadding: true
31
- };
32
20
  Grid.propTypes = {
33
21
  /** Any children of a Grid must be a GridRow */
34
22
  children: node,
35
-
36
23
  /** Any extra classes are attached to the root node, in addition to ffe-grid classes */
37
24
  className: string,
38
-
39
- /** For a more compact grid */
40
- condensed: bool,
41
-
25
+ /** Specify the internal gutter of the grid */
26
+ gap: oneOf(['none', '2xs', 'xs', 'sm', 'md', 'lg']),
42
27
  /** Specify the DOM element being used to create the Grid */
43
- element: string,
44
-
45
- /** Add top padding */
46
- topPadding: bool
28
+ element: string
47
29
  };
package/es/GridCol.js CHANGED
@@ -1,63 +1,40 @@
1
- var _excluded = ["bottomPadding", "children", "className", "element", "lg", "md", "sm"];
2
-
1
+ var _excluded = ["children", "className", "element", "lg", "md", "sm"];
3
2
  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); }
4
-
5
3
  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; }
6
-
7
4
  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; }
8
-
9
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
6
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12
-
13
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
-
15
8
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
16
-
17
9
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
-
19
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
20
-
21
11
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
22
-
23
12
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
-
25
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
-
27
14
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
-
29
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; }
30
-
31
16
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
32
-
33
17
  import React, { Component, createRef } from 'react';
34
18
  import { bool, node, number, oneOf, oneOfType, shape, string } from 'prop-types';
35
19
  import classNames from 'classnames';
36
20
  import backgroundColors, { removedColors } from './background-colors';
37
-
38
21
  function camelCaseToDashCase(str) {
39
22
  return str.split('').reduce(function (previous, current) {
40
23
  return /[A-Z]/.test(current) ? "".concat(previous, "-").concat(current.toLowerCase()) : "".concat(previous).concat(current);
41
24
  });
42
25
  }
43
-
44
- var MODIFIER_LIST = ['around', 'background', 'between', 'bottom', 'center', 'end', 'horizontal', 'middle', 'reverse', 'start', 'centerText', 'top'];
45
-
26
+ var MODIFIER_LIST = ['background', 'centerText', 'center'];
46
27
  var sizeClasses = function sizeClasses(size, def) {
47
28
  var _classNames;
48
-
49
29
  switch (_typeof(def)) {
50
30
  case 'undefined':
51
31
  return '';
52
-
53
32
  case 'object':
54
33
  return classNames((_classNames = {}, _defineProperty(_classNames, "ffe-grid__col--".concat(size, "-").concat(def.cols), def.cols || def.cols === 0), _defineProperty(_classNames, "ffe-grid__col--".concat(size, "-offset-").concat(def.offset), def.offset || def.offset === 0), _classNames));
55
-
56
34
  default:
57
35
  return "ffe-grid__col--".concat(size, "-").concat(def);
58
36
  }
59
37
  };
60
-
61
38
  var modifiers = function modifiers(props) {
62
39
  return Object.keys(props).filter(function (key) {
63
40
  return MODIFIER_LIST.indexOf(key) !== -1 && !!props[key];
@@ -65,55 +42,43 @@ var modifiers = function modifiers(props) {
65
42
  return "ffe-grid__col--".concat(camelCaseToDashCase(key));
66
43
  }).join(' ');
67
44
  };
68
-
69
45
  var backgroundClass = function backgroundClass(_ref) {
70
46
  var background = _ref.background;
71
-
72
47
  if (!background) {
73
48
  return null;
74
49
  }
75
-
76
50
  if (removedColors.includes(background)) {
77
51
  throw new Error("Support for the ".concat(background, " background on <GridCol> has been removed, please see the CHANGELOG"));
78
52
  }
79
-
80
53
  return backgroundColors.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
81
54
  };
82
-
83
55
  var GridCol = /*#__PURE__*/function (_Component) {
84
56
  _inherits(GridCol, _Component);
85
-
86
57
  var _super = _createSuper(GridCol);
87
-
88
58
  function GridCol() {
89
59
  var _this;
90
-
91
60
  _classCallCheck(this, GridCol);
92
-
93
61
  _this = _super.call(this);
94
62
  _this.ref = /*#__PURE__*/createRef();
95
63
  return _this;
96
64
  }
97
-
98
65
  _createClass(GridCol, [{
99
66
  key: "render",
100
67
  value: function render() {
101
68
  var _this$props = this.props,
102
- bottomPadding = _this$props.bottomPadding,
103
- children = _this$props.children,
104
- className = _this$props.className,
105
- Element = _this$props.element,
106
- lg = _this$props.lg,
107
- md = _this$props.md,
108
- sm = _this$props.sm,
109
- rest = _objectWithoutProperties(_this$props, _excluded);
110
-
69
+ children = _this$props.children,
70
+ className = _this$props.className,
71
+ Element = _this$props.element,
72
+ lg = _this$props.lg,
73
+ md = _this$props.md,
74
+ sm = _this$props.sm,
75
+ rest = _objectWithoutProperties(_this$props, _excluded);
111
76
  Object.keys(rest).forEach(function (key) {
112
77
  if (MODIFIER_LIST.includes(key)) {
113
78
  delete rest[key];
114
79
  }
115
80
  });
116
- var classes = [className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), modifiers(this.props), backgroundClass(this.props), !bottomPadding ? 'ffe-grid__col--no-bottom-padding' : null].filter(function (x) {
81
+ var classes = ['ffe-grid__col', className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), modifiers(this.props), backgroundClass(this.props)].filter(function (x) {
117
82
  return x;
118
83
  }).join(' ');
119
84
  return /*#__PURE__*/React.createElement(Element, _extends({
@@ -122,99 +87,49 @@ var GridCol = /*#__PURE__*/function (_Component) {
122
87
  }, rest), children);
123
88
  }
124
89
  }]);
125
-
126
90
  return GridCol;
127
91
  }(Component);
128
-
129
92
  export { GridCol as default };
130
93
  GridCol.defaultProps = {
131
- bottomPadding: true,
132
94
  element: 'div'
133
95
  };
134
96
  GridCol.propTypes = {
135
97
  /** Supported background colors */
136
98
  background: oneOf(['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit']),
137
-
138
99
  /** Any extra classes are attached to the root node, in addition to ffe-grid__col classes */
139
100
  className: string,
140
-
141
101
  /** Specify the DOM element being used to create the GridCol */
142
102
  element: node,
143
-
144
- /** Distribute remaining space around the content elements */
145
- around: bool,
146
-
147
- /** Distribute remaining space between the content elements */
148
- between: bool,
149
-
150
- /** Place content elements at the bottom of the column */
151
- bottom: bool,
152
-
153
- /** Center content horizontally */
154
- center: bool,
155
-
156
103
  /** Center text content horizontally */
157
104
  centerText: bool,
158
-
105
+ /** Center content vertically */
106
+ center: bool,
159
107
  /** The content of the column */
160
108
  children: node,
161
-
162
- /** Place content elements to the right of the column */
163
- end: bool,
164
-
165
- /** Layout column content horizontally and flip flex direction */
166
- horizontal: bool,
167
-
168
- /** Center content vertically */
169
- middle: bool,
170
-
171
- /** Add bottom padding */
172
- bottomPadding: bool,
173
-
174
- /** Reverse layout direction */
175
- reverse: bool,
176
-
177
- /** Place content elements to the left of the column */
178
- start: bool,
179
-
180
- /** Place content elements at the top of the column */
181
- top: bool,
182
-
183
109
  /** Size modifiers for small screen sizes */
184
- sm: oneOfType([
185
- /** Number of columns, 0-12 */
186
- number,
187
- /** Number of columns, 0-12 */
110
+ sm: oneOfType([/** Number of columns, 0-12 */
111
+ number, /** Number of columns, 0-12 */
188
112
  string, shape({
189
113
  /** Number of columns, 0-12 */
190
114
  cols: oneOfType([number, string]),
191
-
192
115
  /** Number of colums offset, 0-12 */
193
116
  offset: oneOfType([number, string])
194
117
  })]),
195
-
196
118
  /** Size modifiers for medium screen sizes */
197
- md: oneOfType([
198
- /** Number of columns, 0-12 */
199
- number,
200
- /** Number of columns, 0-12 */
119
+ md: oneOfType([/** Number of columns, 0-12 */
120
+ number, /** Number of columns, 0-12 */
201
121
  string, shape({
202
122
  /** Number of columns, 0-12 */
203
123
  cols: oneOfType([number, string]),
204
-
205
124
  /** Number of colums offset, 0-12 */
206
125
  offset: oneOfType([number, string])
207
126
  })]),
208
-
209
127
  /** Size modifiers for large screen sizes */
210
- lg: oneOfType([
211
- /** Number of columns, 0-12 */
212
- number,
213
- /** Number of columns, 0-12 */
128
+ lg: oneOfType([/** Number of columns, 0-12 */
129
+ number, /** Number of columns, 0-12 */
214
130
  string, shape({
215
131
  /** Number of columns, 0-12 */
216
132
  cols: oneOfType([number, string]),
217
-
218
133
  /** Number of colums offset, 0-12 */
219
134
  offset: oneOfType([number, string])
220
135
  })])
package/es/GridRow.js CHANGED
@@ -1,68 +1,41 @@
1
- var _excluded = ["background", "className", "children", "element", "reverse", "topPadding"];
2
-
1
+ var _excluded = ["background", "className", "children", "element", "padding", "margin"];
3
2
  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); }
4
-
5
3
  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; }
6
-
7
4
  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; }
8
-
9
5
  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; }
10
-
11
6
  import React from 'react';
12
- import { bool, node, oneOf, string } from 'prop-types';
7
+ import { node, oneOf, string } from 'prop-types';
13
8
  import classNames from 'classnames';
14
9
  import backgroundColors, { removedColors } from './background-colors';
15
10
  export default function GridRow(_ref) {
16
11
  var background = _ref.background,
17
- className = _ref.className,
18
- children = _ref.children,
19
- element = _ref.element,
20
- reverse = _ref.reverse,
21
- topPadding = _ref.topPadding,
22
- rest = _objectWithoutProperties(_ref, _excluded);
23
-
24
- var content = children;
12
+ className = _ref.className,
13
+ children = _ref.children,
14
+ element = _ref.element,
15
+ padding = _ref.padding,
16
+ margin = _ref.margin,
17
+ rest = _objectWithoutProperties(_ref, _excluded);
25
18
  var hasBackgroundColor = backgroundColors.includes(background);
26
19
  var hasRemovedColor = removedColors.includes(background);
27
-
28
- if (hasBackgroundColor) {
29
- content = /*#__PURE__*/React.createElement("div", {
30
- className: "ffe-grid__row-wrapper"
31
- }, children);
32
- }
33
-
34
20
  if (hasRemovedColor) {
35
21
  throw new Error("Support for the ".concat(background, " background on <GridRow> has been removed, please see the CHANGELOG"));
36
22
  }
37
-
38
23
  var Element = element || 'div';
39
24
  return /*#__PURE__*/React.createElement(Element, _extends({
40
- className: classNames(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), {
41
- 'ffe-grid__row--reverse': reverse
42
- }, {
43
- 'ffe-grid__row--top-padding': topPadding
44
- })
45
- }, rest), content);
25
+ className: classNames(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), _defineProperty({}, "ffe-grid__row--padding-".concat(padding), padding), _defineProperty({}, "ffe-grid__row--margin-".concat(margin), margin))
26
+ }, rest), children);
46
27
  }
47
- GridRow.defaultProps = {
48
- topPadding: false
49
- };
50
28
  GridRow.propTypes = {
51
29
  /** Supported background colors */
52
30
  background: oneOf(['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit']),
53
-
31
+ /** Padding in the top and bottom of the row */
32
+ padding: oneOf(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
33
+ /** Margin in the top and bottom of the row */
34
+ margin: oneOf(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
54
35
  /** Any extra classes are attached to the root node, in addition to ffe-grid__row classes */
55
36
  className: string,
56
-
57
37
  /** All children of a `<GridRow />` must be `<GridCol />`. */
58
38
  children: node,
59
-
60
39
  /** Specify the DOM element being used to create the GridRow */
61
- element: string,
62
-
63
- /** If true, columns are reversed */
64
- reverse: bool,
65
-
66
- /** If true, row receives top padding. Useful for when you have background colored rows */
67
- topPadding: bool
40
+ element: string
68
41
  };
package/es/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export { default as Grid } from './Grid';
2
- export { default as InlineGrid } from './InlineGrid';
3
2
  export { default as GridRow } from './GridRow';
4
3
  export { default as GridCol } from './GridCol';
package/es/show-grid.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Grid, GridRow, GridCol } from '@sb1/ffe-grid-react';
3
3
  import { render } from 'react-dom';
4
-
5
4
  var createGridContainer = function createGridContainer() {
6
5
  var css = "\n .ffe-grid-react-debug__grid-content {\n background: #e1e1e1;\n height: 100vh;\n opacity: 0.6;\n width: 100%;\n }\n\n .ffe-grid-react-debug__grid-container {\n height: 100%;\n pointer-events: none;\n position: fixed;\n top: 0;\n z-index: 9999;\n width: 100%;\n }\n ";
7
6
  var style = document.createElement('style');
@@ -15,16 +14,13 @@ var createGridContainer = function createGridContainer() {
15
14
  document.body.appendChild(div);
16
15
  return div;
17
16
  };
18
-
19
17
  var showGrid = function showGrid() {
20
18
  var div = document.getElementById('gridView');
21
-
22
19
  if (div) {
23
20
  var styleDiv = document.getElementById('gridViewStyle');
24
21
  styleDiv.parentNode.removeChild(styleDiv);
25
22
  return div.parentNode.removeChild(div);
26
23
  }
27
-
28
24
  var grid = /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(GridRow, null, new Array(12).fill(null).map(function (_, index) {
29
25
  return /*#__PURE__*/React.createElement(GridCol, {
30
26
  lg: 1,
@@ -37,5 +33,4 @@ var showGrid = function showGrid() {
37
33
  })));
38
34
  render(grid, createGridContainer());
39
35
  };
40
-
41
36
  export default showGrid;
package/lib/Grid.js CHANGED
@@ -4,57 +4,33 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Grid;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _classnames = _interopRequireDefault(require("classnames"));
11
-
12
9
  var _propTypes = require("prop-types");
13
-
14
- var _excluded = ["children", "className", "condensed", "element", "topPadding"];
15
-
10
+ var _excluded = ["children", "className", "gap", "element"];
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
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); }
19
-
13
+ 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; }
20
14
  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
15
  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
16
  function Grid(_ref) {
25
17
  var children = _ref.children,
26
- className = _ref.className,
27
- condensed = _ref.condensed,
28
- element = _ref.element,
29
- topPadding = _ref.topPadding,
30
- rest = _objectWithoutProperties(_ref, _excluded);
31
-
18
+ className = _ref.className,
19
+ gap = _ref.gap,
20
+ element = _ref.element,
21
+ rest = _objectWithoutProperties(_ref, _excluded);
32
22
  var Element = element || 'div';
33
23
  return /*#__PURE__*/_react.default.createElement(Element, _extends({
34
- className: (0, _classnames.default)(className, 'ffe-grid', {
35
- 'ffe-grid--condensed': condensed
36
- }, {
37
- 'ffe-grid--no-top-padding': !topPadding
38
- })
24
+ className: (0, _classnames.default)(className, 'ffe-grid', _defineProperty({}, "ffe-grid--gap-".concat(gap), gap))
39
25
  }, rest), children);
40
26
  }
41
-
42
- Grid.defaultProps = {
43
- topPadding: true
44
- };
45
27
  Grid.propTypes = {
46
28
  /** Any children of a Grid must be a GridRow */
47
29
  children: _propTypes.node,
48
-
49
30
  /** Any extra classes are attached to the root node, in addition to ffe-grid classes */
50
31
  className: _propTypes.string,
51
-
52
- /** For a more compact grid */
53
- condensed: _propTypes.bool,
54
-
32
+ /** Specify the internal gutter of the grid */
33
+ gap: (0, _propTypes.oneOf)(['none', '2xs', 'xs', 'sm', 'md', 'lg']),
55
34
  /** Specify the DOM element being used to create the Grid */
56
- element: _propTypes.string,
57
-
58
- /** Add top padding */
59
- topPadding: _propTypes.bool
35
+ element: _propTypes.string
60
36
  };
package/lib/GridCol.js CHANGED
@@ -4,76 +4,46 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _propTypes = require("prop-types");
11
-
12
9
  var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
10
  var _backgroundColors = _interopRequireWildcard(require("./background-colors"));
15
-
16
- var _excluded = ["bottomPadding", "children", "className", "element", "lg", "md", "sm"];
17
-
11
+ var _excluded = ["children", "className", "element", "lg", "md", "sm"];
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
15
  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); }
25
-
26
16
  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; }
27
-
28
17
  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; }
29
-
30
18
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
-
32
19
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
33
-
34
20
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
35
-
36
21
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
37
-
38
22
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
39
-
40
23
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
41
-
42
24
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
43
-
44
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
45
-
46
26
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
47
-
48
27
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
-
50
28
  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; }
51
-
52
29
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
53
-
54
30
  function camelCaseToDashCase(str) {
55
31
  return str.split('').reduce(function (previous, current) {
56
32
  return /[A-Z]/.test(current) ? "".concat(previous, "-").concat(current.toLowerCase()) : "".concat(previous).concat(current);
57
33
  });
58
34
  }
59
-
60
- var MODIFIER_LIST = ['around', 'background', 'between', 'bottom', 'center', 'end', 'horizontal', 'middle', 'reverse', 'start', 'centerText', 'top'];
61
-
35
+ var MODIFIER_LIST = ['background', 'centerText', 'center'];
62
36
  var sizeClasses = function sizeClasses(size, def) {
63
37
  var _classNames;
64
-
65
38
  switch (_typeof(def)) {
66
39
  case 'undefined':
67
40
  return '';
68
-
69
41
  case 'object':
70
42
  return (0, _classnames.default)((_classNames = {}, _defineProperty(_classNames, "ffe-grid__col--".concat(size, "-").concat(def.cols), def.cols || def.cols === 0), _defineProperty(_classNames, "ffe-grid__col--".concat(size, "-offset-").concat(def.offset), def.offset || def.offset === 0), _classNames));
71
-
72
43
  default:
73
44
  return "ffe-grid__col--".concat(size, "-").concat(def);
74
45
  }
75
46
  };
76
-
77
47
  var modifiers = function modifiers(props) {
78
48
  return Object.keys(props).filter(function (key) {
79
49
  return MODIFIER_LIST.indexOf(key) !== -1 && !!props[key];
@@ -81,55 +51,43 @@ var modifiers = function modifiers(props) {
81
51
  return "ffe-grid__col--".concat(camelCaseToDashCase(key));
82
52
  }).join(' ');
83
53
  };
84
-
85
54
  var backgroundClass = function backgroundClass(_ref) {
86
55
  var background = _ref.background;
87
-
88
56
  if (!background) {
89
57
  return null;
90
58
  }
91
-
92
59
  if (_backgroundColors.removedColors.includes(background)) {
93
60
  throw new Error("Support for the ".concat(background, " background on <GridCol> has been removed, please see the CHANGELOG"));
94
61
  }
95
-
96
62
  return _backgroundColors.default.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
97
63
  };
98
-
99
64
  var GridCol = /*#__PURE__*/function (_Component) {
100
65
  _inherits(GridCol, _Component);
101
-
102
66
  var _super = _createSuper(GridCol);
103
-
104
67
  function GridCol() {
105
68
  var _this;
106
-
107
69
  _classCallCheck(this, GridCol);
108
-
109
70
  _this = _super.call(this);
110
71
  _this.ref = /*#__PURE__*/(0, _react.createRef)();
111
72
  return _this;
112
73
  }
113
-
114
74
  _createClass(GridCol, [{
115
75
  key: "render",
116
76
  value: function render() {
117
77
  var _this$props = this.props,
118
- bottomPadding = _this$props.bottomPadding,
119
- children = _this$props.children,
120
- className = _this$props.className,
121
- Element = _this$props.element,
122
- lg = _this$props.lg,
123
- md = _this$props.md,
124
- sm = _this$props.sm,
125
- rest = _objectWithoutProperties(_this$props, _excluded);
126
-
78
+ children = _this$props.children,
79
+ className = _this$props.className,
80
+ Element = _this$props.element,
81
+ lg = _this$props.lg,
82
+ md = _this$props.md,
83
+ sm = _this$props.sm,
84
+ rest = _objectWithoutProperties(_this$props, _excluded);
127
85
  Object.keys(rest).forEach(function (key) {
128
86
  if (MODIFIER_LIST.includes(key)) {
129
87
  delete rest[key];
130
88
  }
131
89
  });
132
- var classes = [className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), modifiers(this.props), backgroundClass(this.props), !bottomPadding ? 'ffe-grid__col--no-bottom-padding' : null].filter(function (x) {
90
+ var classes = ['ffe-grid__col', className, sizeClasses('lg', lg), sizeClasses('md', md), sizeClasses('sm', !sm && !lg && !md ? 12 : sm), modifiers(this.props), backgroundClass(this.props)].filter(function (x) {
133
91
  return x;
134
92
  }).join(' ');
135
93
  return /*#__PURE__*/_react.default.createElement(Element, _extends({
@@ -138,99 +96,49 @@ var GridCol = /*#__PURE__*/function (_Component) {
138
96
  }, rest), children);
139
97
  }
140
98
  }]);
141
-
142
99
  return GridCol;
143
100
  }(_react.Component);
144
-
145
101
  exports.default = GridCol;
146
102
  GridCol.defaultProps = {
147
- bottomPadding: true,
148
103
  element: 'div'
149
104
  };
150
105
  GridCol.propTypes = {
151
106
  /** Supported background colors */
152
107
  background: (0, _propTypes.oneOf)(['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit']),
153
-
154
108
  /** Any extra classes are attached to the root node, in addition to ffe-grid__col classes */
155
109
  className: _propTypes.string,
156
-
157
110
  /** Specify the DOM element being used to create the GridCol */
158
111
  element: _propTypes.node,
159
-
160
- /** Distribute remaining space around the content elements */
161
- around: _propTypes.bool,
162
-
163
- /** Distribute remaining space between the content elements */
164
- between: _propTypes.bool,
165
-
166
- /** Place content elements at the bottom of the column */
167
- bottom: _propTypes.bool,
168
-
169
- /** Center content horizontally */
170
- center: _propTypes.bool,
171
-
172
112
  /** Center text content horizontally */
173
113
  centerText: _propTypes.bool,
174
-
114
+ /** Center content vertically */
115
+ center: _propTypes.bool,
175
116
  /** The content of the column */
176
117
  children: _propTypes.node,
177
-
178
- /** Place content elements to the right of the column */
179
- end: _propTypes.bool,
180
-
181
- /** Layout column content horizontally and flip flex direction */
182
- horizontal: _propTypes.bool,
183
-
184
- /** Center content vertically */
185
- middle: _propTypes.bool,
186
-
187
- /** Add bottom padding */
188
- bottomPadding: _propTypes.bool,
189
-
190
- /** Reverse layout direction */
191
- reverse: _propTypes.bool,
192
-
193
- /** Place content elements to the left of the column */
194
- start: _propTypes.bool,
195
-
196
- /** Place content elements at the top of the column */
197
- top: _propTypes.bool,
198
-
199
118
  /** Size modifiers for small screen sizes */
200
- sm: (0, _propTypes.oneOfType)([
201
- /** Number of columns, 0-12 */
202
- _propTypes.number,
203
- /** Number of columns, 0-12 */
119
+ sm: (0, _propTypes.oneOfType)([/** Number of columns, 0-12 */
120
+ _propTypes.number, /** Number of columns, 0-12 */
204
121
  _propTypes.string, (0, _propTypes.shape)({
205
122
  /** Number of columns, 0-12 */
206
123
  cols: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
207
-
208
124
  /** Number of colums offset, 0-12 */
209
125
  offset: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
210
126
  })]),
211
-
212
127
  /** Size modifiers for medium screen sizes */
213
- md: (0, _propTypes.oneOfType)([
214
- /** Number of columns, 0-12 */
215
- _propTypes.number,
216
- /** Number of columns, 0-12 */
128
+ md: (0, _propTypes.oneOfType)([/** Number of columns, 0-12 */
129
+ _propTypes.number, /** Number of columns, 0-12 */
217
130
  _propTypes.string, (0, _propTypes.shape)({
218
131
  /** Number of columns, 0-12 */
219
132
  cols: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
220
-
221
133
  /** Number of colums offset, 0-12 */
222
134
  offset: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
223
135
  })]),
224
-
225
136
  /** Size modifiers for large screen sizes */
226
- lg: (0, _propTypes.oneOfType)([
227
- /** Number of columns, 0-12 */
228
- _propTypes.number,
229
- /** Number of columns, 0-12 */
137
+ lg: (0, _propTypes.oneOfType)([/** Number of columns, 0-12 */
138
+ _propTypes.number, /** Number of columns, 0-12 */
230
139
  _propTypes.string, (0, _propTypes.shape)({
231
140
  /** Number of columns, 0-12 */
232
141
  cols: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
233
-
234
142
  /** Number of colums offset, 0-12 */
235
143
  offset: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
236
144
  })])
package/lib/GridRow.js CHANGED
@@ -1,90 +1,51 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = GridRow;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _propTypes = require("prop-types");
13
-
14
10
  var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
11
  var _backgroundColors = _interopRequireWildcard(require("./background-colors"));
17
-
18
- var _excluded = ["background", "className", "children", "element", "reverse", "topPadding"];
19
-
12
+ var _excluded = ["background", "className", "children", "element", "padding", "margin"];
20
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
16
  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); }
27
-
28
17
  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; }
29
-
30
18
  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; }
31
-
32
19
  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; }
33
-
34
20
  function GridRow(_ref) {
35
21
  var background = _ref.background,
36
- className = _ref.className,
37
- children = _ref.children,
38
- element = _ref.element,
39
- reverse = _ref.reverse,
40
- topPadding = _ref.topPadding,
41
- rest = _objectWithoutProperties(_ref, _excluded);
42
-
43
- var content = children;
44
-
22
+ className = _ref.className,
23
+ children = _ref.children,
24
+ element = _ref.element,
25
+ padding = _ref.padding,
26
+ margin = _ref.margin,
27
+ rest = _objectWithoutProperties(_ref, _excluded);
45
28
  var hasBackgroundColor = _backgroundColors.default.includes(background);
46
-
47
29
  var hasRemovedColor = _backgroundColors.removedColors.includes(background);
48
-
49
- if (hasBackgroundColor) {
50
- content = /*#__PURE__*/_react.default.createElement("div", {
51
- className: "ffe-grid__row-wrapper"
52
- }, children);
53
- }
54
-
55
30
  if (hasRemovedColor) {
56
31
  throw new Error("Support for the ".concat(background, " background on <GridRow> has been removed, please see the CHANGELOG"));
57
32
  }
58
-
59
33
  var Element = element || 'div';
60
34
  return /*#__PURE__*/_react.default.createElement(Element, _extends({
61
- className: (0, _classnames.default)(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), {
62
- 'ffe-grid__row--reverse': reverse
63
- }, {
64
- 'ffe-grid__row--top-padding': topPadding
65
- })
66
- }, rest), content);
35
+ className: (0, _classnames.default)(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), _defineProperty({}, "ffe-grid__row--padding-".concat(padding), padding), _defineProperty({}, "ffe-grid__row--margin-".concat(margin), margin))
36
+ }, rest), children);
67
37
  }
68
-
69
- GridRow.defaultProps = {
70
- topPadding: false
71
- };
72
38
  GridRow.propTypes = {
73
39
  /** Supported background colors */
74
40
  background: (0, _propTypes.oneOf)(['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit']),
75
-
41
+ /** Padding in the top and bottom of the row */
42
+ padding: (0, _propTypes.oneOf)(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
43
+ /** Margin in the top and bottom of the row */
44
+ margin: (0, _propTypes.oneOf)(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
76
45
  /** Any extra classes are attached to the root node, in addition to ffe-grid__row classes */
77
46
  className: _propTypes.string,
78
-
79
47
  /** All children of a `<GridRow />` must be `<GridCol />`. */
80
48
  children: _propTypes.node,
81
-
82
49
  /** Specify the DOM element being used to create the GridRow */
83
- element: _propTypes.string,
84
-
85
- /** If true, columns are reversed */
86
- reverse: _propTypes.bool,
87
-
88
- /** If true, row receives top padding. Useful for when you have background colored rows */
89
- topPadding: _propTypes.bool
50
+ element: _propTypes.string
90
51
  };
package/lib/index.js CHANGED
@@ -21,19 +21,7 @@ Object.defineProperty(exports, "GridRow", {
21
21
  return _GridRow.default;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "InlineGrid", {
25
- enumerable: true,
26
- get: function get() {
27
- return _InlineGrid.default;
28
- }
29
- });
30
-
31
24
  var _Grid = _interopRequireDefault(require("./Grid"));
32
-
33
- var _InlineGrid = _interopRequireDefault(require("./InlineGrid"));
34
-
35
25
  var _GridRow = _interopRequireDefault(require("./GridRow"));
36
-
37
26
  var _GridCol = _interopRequireDefault(require("./GridCol"));
38
-
39
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/lib/show-grid.js CHANGED
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _ffeGridReact = require("@sb1/ffe-grid-react");
11
-
12
9
  var _reactDom = require("react-dom");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  var createGridContainer = function createGridContainer() {
17
12
  var css = "\n .ffe-grid-react-debug__grid-content {\n background: #e1e1e1;\n height: 100vh;\n opacity: 0.6;\n width: 100%;\n }\n\n .ffe-grid-react-debug__grid-container {\n height: 100%;\n pointer-events: none;\n position: fixed;\n top: 0;\n z-index: 9999;\n width: 100%;\n }\n ";
18
13
  var style = document.createElement('style');
@@ -26,16 +21,13 @@ var createGridContainer = function createGridContainer() {
26
21
  document.body.appendChild(div);
27
22
  return div;
28
23
  };
29
-
30
24
  var showGrid = function showGrid() {
31
25
  var div = document.getElementById('gridView');
32
-
33
26
  if (div) {
34
27
  var styleDiv = document.getElementById('gridViewStyle');
35
28
  styleDiv.parentNode.removeChild(styleDiv);
36
29
  return div.parentNode.removeChild(div);
37
30
  }
38
-
39
31
  var grid = /*#__PURE__*/_react.default.createElement(_ffeGridReact.Grid, null, /*#__PURE__*/_react.default.createElement(_ffeGridReact.GridRow, null, new Array(12).fill(null).map(function (_, index) {
40
32
  return /*#__PURE__*/_react.default.createElement(_ffeGridReact.GridCol, {
41
33
  lg: 1,
@@ -46,9 +38,7 @@ var showGrid = function showGrid() {
46
38
  className: "ffe-grid-react-debug__grid-content"
47
39
  }));
48
40
  })));
49
-
50
41
  (0, _reactDom.render)(grid, createGridContainer());
51
42
  };
52
-
53
43
  var _default = showGrid;
54
44
  exports.default = _default;
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
- "name": "@sb1/ffe-grid-react",
3
- "version": "11.1.8",
4
- "license": "MIT",
5
- "author": "SpareBank1",
6
- "files": [
7
- "lib",
8
- "es",
9
- "types"
10
- ],
11
- "main": "lib/index.js",
12
- "module": "es/index.js",
13
- "types": "types/index.d.ts",
14
- "sideEffects": false,
15
- "repository": {
16
- "type": "git",
17
- "url": "ssh://git@github.com:SpareBank1/designsystem.git"
18
- },
19
- "scripts": {
20
- "build": "ffe-buildtool babel",
21
- "watch": "ffe-buildtool babel-watch",
22
- "lint": "eslint src",
23
- "test": "ffe-buildtool jest",
24
- "test:watch": "ffe-buildtool jest --watch"
25
- },
26
- "dependencies": {
27
- "classnames": "^2.3.1"
28
- },
29
- "devDependencies": {
30
- "@sb1/ffe-buildtool": "^0.4.1",
31
- "react": "^16.9.0",
32
- "react-dom": "^16.9.0"
33
- },
34
- "peerDependencies": {
35
- "@sb1/ffe-grid": "*",
36
- "react": ">=16.9.0"
37
- },
38
- "publishConfig": {
39
- "access": "public"
40
- },
41
- "gitHead": "20645a84ff31b513ef2568a7eefbed950f7e1c40"
2
+ "name": "@sb1/ffe-grid-react",
3
+ "version": "12.0.1",
4
+ "license": "MIT",
5
+ "author": "SpareBank1",
6
+ "files": [
7
+ "lib",
8
+ "es",
9
+ "types"
10
+ ],
11
+ "main": "lib/index.js",
12
+ "module": "es/index.js",
13
+ "types": "types/index.d.ts",
14
+ "sideEffects": false,
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "ssh://git@github.com:SpareBank1/designsystem.git"
18
+ },
19
+ "scripts": {
20
+ "build": "ffe-buildtool babel",
21
+ "watch": "ffe-buildtool babel-watch",
22
+ "lint": "eslint src",
23
+ "test": "ffe-buildtool jest",
24
+ "test:watch": "ffe-buildtool jest --watch"
25
+ },
26
+ "dependencies": {
27
+ "classnames": "^2.3.1"
28
+ },
29
+ "devDependencies": {
30
+ "@sb1/ffe-buildtool": "^0.4.1",
31
+ "react": "^16.9.0",
32
+ "react-dom": "^16.9.0"
33
+ },
34
+ "peerDependencies": {
35
+ "@sb1/ffe-grid": "*",
36
+ "react": ">=16.9.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "gitHead": "783ef6b80058399af45613836f5903635ba30ea5"
42
42
  }
package/types/index.d.ts CHANGED
@@ -1,17 +1,12 @@
1
1
  import * as React from 'react';
2
2
 
3
- export interface GridProps extends React.HTMLAttributes<HTMLElement> {
4
- children: React.ReactNode;
5
- className?: string;
6
- condensed?: boolean;
7
- element?: string;
8
- topPadding?: boolean;
9
- }
3
+ type Gap = 'none' | '2xs' | 'xs' | 'md' | 'lg';
10
4
 
11
- export interface InlineGridProps extends React.HTMLAttributes<HTMLElement> {
5
+ export interface GridProps extends React.HTMLAttributes<HTMLElement> {
12
6
  children: React.ReactNode;
13
7
  className?: string;
14
8
  element?: string;
9
+ gap?: Gap;
15
10
  }
16
11
 
17
12
  type BackgroundColors =
@@ -26,13 +21,37 @@ type BackgroundColors =
26
21
  | 'fjell'
27
22
  | 'hvit';
28
23
 
24
+ type Margin =
25
+ | '2xs'
26
+ | 'xs'
27
+ | 'sm'
28
+ | 'md'
29
+ | 'lg'
30
+ | 'xl'
31
+ | '2xl'
32
+ | '3xl'
33
+ | '4xl'
34
+ | '5xl';
35
+
36
+ type Padding =
37
+ | '2xs'
38
+ | 'xs'
39
+ | 'sm'
40
+ | 'md'
41
+ | 'lg'
42
+ | 'xl'
43
+ | '2xl'
44
+ | '3xl'
45
+ | '4xl'
46
+ | '5xl';
47
+
29
48
  export interface GridRowProps extends React.HTMLAttributes<HTMLElement> {
30
49
  background?: BackgroundColors;
31
50
  children: React.ReactNode;
32
51
  className?: string;
33
52
  element?: string;
34
- reverse?: boolean;
35
- topPadding?: boolean;
53
+ padding?: Padding;
54
+ margin?: Margin;
36
55
  }
37
56
 
38
57
  type ColumnsRange = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
@@ -47,24 +66,13 @@ export interface GridColProps extends React.HTMLAttributes<HTMLElement> {
47
66
  children?: React.ReactNode;
48
67
  className?: string;
49
68
  element?: React.ReactNode;
50
- around?: boolean;
51
- between?: boolean;
52
- bottom?: boolean;
53
69
  center?: boolean;
54
70
  centerText?: boolean;
55
- end?: boolean;
56
- horizontal?: boolean;
57
- middle?: boolean;
58
- bottomPadding?: boolean;
59
- reverse?: boolean;
60
- start?: boolean;
61
- top?: boolean;
62
71
  sm?: ColumnsRange | string | GridColSize;
63
72
  md?: ColumnsRange | string | GridColSize;
64
73
  lg?: ColumnsRange | string | GridColSize;
65
74
  }
66
75
 
67
76
  declare class Grid extends React.Component<GridProps, any> {}
68
- declare class InlineGrid extends React.Component<InlineGridProps, any> {}
69
77
  declare class GridRow extends React.Component<GridRowProps, any> {}
70
78
  declare class GridCol extends React.Component<GridColProps, any> {}
package/es/InlineGrid.js DELETED
@@ -1,33 +0,0 @@
1
- var _excluded = ["className", "element"];
2
-
3
- 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); }
4
-
5
- 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; }
6
-
7
- 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; }
8
-
9
- import React from 'react';
10
- import classNames from 'classnames';
11
- import { node, string } from 'prop-types';
12
- export default function InlineGrid(_ref) {
13
- var className = _ref.className,
14
- Element = _ref.element,
15
- rest = _objectWithoutProperties(_ref, _excluded);
16
-
17
- return /*#__PURE__*/React.createElement(Element, _extends({
18
- className: classNames(className, 'ffe-grid', 'ffe-grid--inline')
19
- }, rest));
20
- }
21
- InlineGrid.propTypes = {
22
- /** Any children of a InlineGrid must be a GridRow */
23
- children: node,
24
-
25
- /** Any extra classes are attached to the root node, in addition to ffe-grid classes */
26
- className: string,
27
-
28
- /** Specify the DOM element being used to create the Grid */
29
- element: string
30
- };
31
- InlineGrid.defaultProps = {
32
- element: 'div'
33
- };
package/lib/InlineGrid.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = InlineGrid;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
-
12
- var _propTypes = require("prop-types");
13
-
14
- var _excluded = ["className", "element"];
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- 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); }
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
- function InlineGrid(_ref) {
25
- var className = _ref.className,
26
- Element = _ref.element,
27
- rest = _objectWithoutProperties(_ref, _excluded);
28
-
29
- return /*#__PURE__*/_react.default.createElement(Element, _extends({
30
- className: (0, _classnames.default)(className, 'ffe-grid', 'ffe-grid--inline')
31
- }, rest));
32
- }
33
-
34
- InlineGrid.propTypes = {
35
- /** Any children of a InlineGrid must be a GridRow */
36
- children: _propTypes.node,
37
-
38
- /** Any extra classes are attached to the root node, in addition to ffe-grid classes */
39
- className: _propTypes.string,
40
-
41
- /** Specify the DOM element being used to create the Grid */
42
- element: _propTypes.string
43
- };
44
- InlineGrid.defaultProps = {
45
- element: 'div'
46
- };