@sb1/ffe-grid-react 13.0.7 → 13.1.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/GridCol.js +2 -3
- package/es/GridRow.js +9 -5
- package/es/background-colors.js +2 -1
- package/lib/GridCol.js +5 -6
- package/lib/GridRow.js +10 -8
- package/lib/background-colors.js +3 -2
- package/package.json +3 -3
- package/types/index.d.ts +3 -0
package/es/GridCol.js
CHANGED
|
@@ -19,7 +19,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
19
19
|
import React, { Component, createRef } from 'react';
|
|
20
20
|
import { bool, node, number, oneOf, oneOfType, shape, string } from 'prop-types';
|
|
21
21
|
import classNames from 'classnames';
|
|
22
|
-
import backgroundColors,
|
|
22
|
+
import { backgroundColors, removedColors } from './background-colors';
|
|
23
23
|
function camelCaseToDashCase(str) {
|
|
24
24
|
return str.split('').reduce(function (previous, current) {
|
|
25
25
|
return /[A-Z]/.test(current) ? "".concat(previous, "-").concat(current.toLowerCase()) : "".concat(previous).concat(current);
|
|
@@ -27,12 +27,11 @@ function camelCaseToDashCase(str) {
|
|
|
27
27
|
}
|
|
28
28
|
var MODIFIER_LIST = ['background', 'centerText', 'center'];
|
|
29
29
|
var sizeClasses = function sizeClasses(size, def) {
|
|
30
|
-
var _classNames;
|
|
31
30
|
switch (_typeof(def)) {
|
|
32
31
|
case 'undefined':
|
|
33
32
|
return '';
|
|
34
33
|
case 'object':
|
|
35
|
-
return classNames((
|
|
34
|
+
return classNames(_defineProperty(_defineProperty({}, "ffe-grid__col--".concat(size, "-").concat(def.cols), def.cols || def.cols === 0), "ffe-grid__col--".concat(size, "-offset-").concat(def.offset), def.offset || def.offset === 0));
|
|
36
35
|
default:
|
|
37
36
|
return "ffe-grid__col--".concat(size, "-").concat(def);
|
|
38
37
|
}
|
package/es/GridRow.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["background", "className", "children", "element", "padding", "margin"];
|
|
2
|
+
var _excluded = ["background", "backgroundDark", "className", "children", "element", "padding", "margin"];
|
|
3
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
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
@@ -9,9 +9,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { node, oneOf, string } from 'prop-types';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
|
-
import backgroundColors,
|
|
12
|
+
import { backgroundColors, backgroundDarkColors, removedColors } from './background-colors';
|
|
13
13
|
export default function GridRow(_ref) {
|
|
14
14
|
var background = _ref.background,
|
|
15
|
+
backgroundDark = _ref.backgroundDark,
|
|
15
16
|
className = _ref.className,
|
|
16
17
|
children = _ref.children,
|
|
17
18
|
element = _ref.element,
|
|
@@ -19,8 +20,9 @@ export default function GridRow(_ref) {
|
|
|
19
20
|
margin = _ref.margin,
|
|
20
21
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
21
22
|
var hasBackgroundColor = backgroundColors.includes(background);
|
|
23
|
+
var hasBackgroundDarkColor = backgroundDarkColors.includes(backgroundDark);
|
|
22
24
|
var hasRemovedColor = removedColors.includes(background);
|
|
23
|
-
var content = hasBackgroundColor ? /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
var content = hasBackgroundColor || hasBackgroundDarkColor ? /*#__PURE__*/React.createElement("div", {
|
|
24
26
|
className: "ffe-grid__row-wrapper"
|
|
25
27
|
}, children) : children;
|
|
26
28
|
if (hasRemovedColor) {
|
|
@@ -28,12 +30,14 @@ export default function GridRow(_ref) {
|
|
|
28
30
|
}
|
|
29
31
|
var Element = element || 'div';
|
|
30
32
|
return /*#__PURE__*/React.createElement(Element, _extends({
|
|
31
|
-
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))
|
|
33
|
+
className: classNames(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), _defineProperty({}, "ffe-grid__row--bg-dark-".concat(backgroundDark), hasBackgroundDarkColor), _defineProperty({}, "ffe-grid__row--padding-".concat(padding), padding), _defineProperty({}, "ffe-grid__row--margin-".concat(margin), margin))
|
|
32
34
|
}, rest), content);
|
|
33
35
|
}
|
|
34
36
|
GridRow.propTypes = {
|
|
35
37
|
/** Supported background colors */
|
|
36
|
-
background: oneOf(
|
|
38
|
+
background: oneOf(backgroundColors),
|
|
39
|
+
/** Supported dark background colors */
|
|
40
|
+
backgroundDark: oneOf(backgroundDarkColors),
|
|
37
41
|
/** Padding in the top and bottom of the row */
|
|
38
42
|
padding: oneOf(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
|
|
39
43
|
/** Margin in the top and bottom of the row */
|
package/es/background-colors.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var backgroundColors = ['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit'];
|
|
2
|
+
export var backgroundDarkColors = ['svart', 'natt', 'koksgraa'];
|
|
2
3
|
export var removedColors = ['blue-cobalt', 'blue-royal', 'purple-magenta', 'blue-ice', 'blue-pale', 'green-mint', 'grey-cloud', 'grey-warm', 'orange-salmon', 'red', 'blue-sky', 'white'];
|
package/lib/GridCol.js
CHANGED
|
@@ -7,11 +7,11 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _backgroundColors =
|
|
10
|
+
var _backgroundColors = require("./background-colors");
|
|
11
11
|
var _excluded = ["children", "className", "element", "lg", "md", "sm"];
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function _getRequireWildcardCache(
|
|
14
|
-
function _interopRequireWildcard(
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
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); }
|
|
16
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; }
|
|
17
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; }
|
|
@@ -36,12 +36,11 @@ function camelCaseToDashCase(str) {
|
|
|
36
36
|
}
|
|
37
37
|
var MODIFIER_LIST = ['background', 'centerText', 'center'];
|
|
38
38
|
var sizeClasses = function sizeClasses(size, def) {
|
|
39
|
-
var _classNames;
|
|
40
39
|
switch (_typeof(def)) {
|
|
41
40
|
case 'undefined':
|
|
42
41
|
return '';
|
|
43
42
|
case 'object':
|
|
44
|
-
return (0, _classnames.default)((
|
|
43
|
+
return (0, _classnames.default)(_defineProperty(_defineProperty({}, "ffe-grid__col--".concat(size, "-").concat(def.cols), def.cols || def.cols === 0), "ffe-grid__col--".concat(size, "-offset-").concat(def.offset), def.offset || def.offset === 0));
|
|
45
44
|
default:
|
|
46
45
|
return "ffe-grid__col--".concat(size, "-").concat(def);
|
|
47
46
|
}
|
|
@@ -61,7 +60,7 @@ var backgroundClass = function backgroundClass(_ref) {
|
|
|
61
60
|
if (_backgroundColors.removedColors.includes(background)) {
|
|
62
61
|
throw new Error("Support for the ".concat(background, " background on <GridCol> has been removed, please see the CHANGELOG"));
|
|
63
62
|
}
|
|
64
|
-
return _backgroundColors.
|
|
63
|
+
return _backgroundColors.backgroundColors.includes(background) ? "ffe-grid__col--bg-".concat(background) : null;
|
|
65
64
|
};
|
|
66
65
|
var GridCol = exports.default = /*#__PURE__*/function (_Component) {
|
|
67
66
|
_inherits(GridCol, _Component);
|
package/lib/GridRow.js
CHANGED
|
@@ -8,10 +8,8 @@ exports.default = GridRow;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = require("prop-types");
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _backgroundColors =
|
|
12
|
-
var _excluded = ["background", "className", "children", "element", "padding", "margin"];
|
|
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); }
|
|
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; }
|
|
11
|
+
var _backgroundColors = require("./background-colors");
|
|
12
|
+
var _excluded = ["background", "backgroundDark", "className", "children", "element", "padding", "margin"];
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
14
|
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); }
|
|
17
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -21,15 +19,17 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
21
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; }
|
|
22
20
|
function GridRow(_ref) {
|
|
23
21
|
var background = _ref.background,
|
|
22
|
+
backgroundDark = _ref.backgroundDark,
|
|
24
23
|
className = _ref.className,
|
|
25
24
|
children = _ref.children,
|
|
26
25
|
element = _ref.element,
|
|
27
26
|
padding = _ref.padding,
|
|
28
27
|
margin = _ref.margin,
|
|
29
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
-
var hasBackgroundColor = _backgroundColors.
|
|
29
|
+
var hasBackgroundColor = _backgroundColors.backgroundColors.includes(background);
|
|
30
|
+
var hasBackgroundDarkColor = _backgroundColors.backgroundDarkColors.includes(backgroundDark);
|
|
31
31
|
var hasRemovedColor = _backgroundColors.removedColors.includes(background);
|
|
32
|
-
var content = hasBackgroundColor ? /*#__PURE__*/_react.default.createElement("div", {
|
|
32
|
+
var content = hasBackgroundColor || hasBackgroundDarkColor ? /*#__PURE__*/_react.default.createElement("div", {
|
|
33
33
|
className: "ffe-grid__row-wrapper"
|
|
34
34
|
}, children) : children;
|
|
35
35
|
if (hasRemovedColor) {
|
|
@@ -37,12 +37,14 @@ function GridRow(_ref) {
|
|
|
37
37
|
}
|
|
38
38
|
var Element = element || 'div';
|
|
39
39
|
return /*#__PURE__*/_react.default.createElement(Element, _extends({
|
|
40
|
-
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))
|
|
40
|
+
className: (0, _classnames.default)(className, 'ffe-grid__row', _defineProperty({}, "ffe-grid__row--bg-".concat(background), hasBackgroundColor), _defineProperty({}, "ffe-grid__row--bg-dark-".concat(backgroundDark), hasBackgroundDarkColor), _defineProperty({}, "ffe-grid__row--padding-".concat(padding), padding), _defineProperty({}, "ffe-grid__row--margin-".concat(margin), margin))
|
|
41
41
|
}, rest), content);
|
|
42
42
|
}
|
|
43
43
|
GridRow.propTypes = {
|
|
44
44
|
/** Supported background colors */
|
|
45
|
-
background: (0, _propTypes.oneOf)(
|
|
45
|
+
background: (0, _propTypes.oneOf)(_backgroundColors.backgroundColors),
|
|
46
|
+
/** Supported dark background colors */
|
|
47
|
+
backgroundDark: (0, _propTypes.oneOf)(_backgroundColors.backgroundDarkColors),
|
|
46
48
|
/** Padding in the top and bottom of the row */
|
|
47
49
|
padding: (0, _propTypes.oneOf)(['2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl']),
|
|
48
50
|
/** Margin in the top and bottom of the row */
|
package/lib/background-colors.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.removedColors = exports.
|
|
7
|
-
var
|
|
6
|
+
exports.removedColors = exports.backgroundDarkColors = exports.backgroundColors = void 0;
|
|
7
|
+
var backgroundColors = exports.backgroundColors = ['frost-30', 'sand', 'sand-70', 'sand-30', 'syrin-70', 'syrin-30', 'vann', 'vann-30', 'fjell', 'hvit'];
|
|
8
|
+
var backgroundDarkColors = exports.backgroundDarkColors = ['svart', 'natt', 'koksgraa'];
|
|
8
9
|
var removedColors = exports.removedColors = ['blue-cobalt', 'blue-royal', 'purple-magenta', 'blue-ice', 'blue-pale', 'green-mint', 'grey-cloud', 'grey-warm', 'orange-salmon', 'red', 'blue-sky', 'white'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-grid-react",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "SpareBank1",
|
|
6
6
|
"files": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test:watch": "ffe-buildtool jest --watch"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sb1/ffe-grid": "^14.0
|
|
27
|
+
"@sb1/ffe-grid": "^14.1.0",
|
|
28
28
|
"classnames": "^2.3.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "f8ef90c54a8eaf40fcfaa20b5b66ea5b1e0ed62d"
|
|
42
42
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ type BackgroundColors =
|
|
|
21
21
|
| 'fjell'
|
|
22
22
|
| 'hvit';
|
|
23
23
|
|
|
24
|
+
type BackgroundDarkColors = 'svart' | 'natt' | 'koksgraa';
|
|
25
|
+
|
|
24
26
|
type Margin =
|
|
25
27
|
| '2xs'
|
|
26
28
|
| 'xs'
|
|
@@ -47,6 +49,7 @@ type Padding =
|
|
|
47
49
|
|
|
48
50
|
export interface GridRowProps extends React.ComponentProps<'div'> {
|
|
49
51
|
background?: BackgroundColors;
|
|
52
|
+
backgroundDark?: BackgroundDarkColors;
|
|
50
53
|
children: React.ReactNode;
|
|
51
54
|
className?: string;
|
|
52
55
|
element?: string;
|