@sis-cc/dotstatsuite-visions 7.12.2 → 7.13.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.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import * as R from 'ramda';
2
3
  import cx from 'classnames';
3
4
  import PropTypes from 'prop-types';
4
5
  import { makeStyles } from '@material-ui/core/styles';
@@ -19,13 +20,12 @@ var useStyles = makeStyles(function (theme) {
19
20
  height: ' 48px',
20
21
  borderStyle: 'solid',
21
22
  borderWidth: '5px',
22
- borderColor: theme.palette.primary.main,
23
- borderBottomColor: 'transparent',
24
23
  borderRadius: '50%',
25
24
  display: 'inline-block',
26
25
  boxSizing: 'border-box',
27
26
  animation: '$rotate 1s linear infinite',
28
- margin: theme.spacing(2)
27
+ margin: theme.spacing(2),
28
+ borderBottomColor: 'transparent !important'
29
29
  },
30
30
  '@keyframes rotate': {
31
31
  '0%': {
@@ -36,8 +36,13 @@ var useStyles = makeStyles(function (theme) {
36
36
  }
37
37
  },
38
38
  warning: {
39
- borderColor: theme.palette.warning.main,
40
- borderBottomColor: 'transparent'
39
+ borderColor: theme.palette.warning.main
40
+ },
41
+ primaryColor: {
42
+ borderColor: theme.palette.primary.main
43
+ },
44
+ secondaryColor: {
45
+ borderColor: theme.palette.secondary.main
41
46
  }
42
47
  };
43
48
  });
@@ -47,14 +52,20 @@ var Loading = function Loading(_ref) {
47
52
 
48
53
  var message = _ref.message,
49
54
  _ref$isWarning = _ref.isWarning,
50
- isWarning = _ref$isWarning === undefined ? false : _ref$isWarning;
55
+ isWarning = _ref$isWarning === undefined ? false : _ref$isWarning,
56
+ _ref$variant = _ref.variant,
57
+ variant = _ref$variant === undefined ? 'primary' : _ref$variant,
58
+ color = _ref.color;
51
59
 
52
60
  var classes = useStyles();
53
61
 
54
62
  return React.createElement(
55
63
  'div',
56
64
  { className: classes.root },
57
- React.createElement('div', { className: cx(classes.circularProgress, (_cx = {}, _cx[classes.warning] = isWarning, _cx)) }),
65
+ React.createElement('div', {
66
+ style: { color: R.isNil(color) ? undefined : color },
67
+ className: cx(classes.circularProgress, (_cx = {}, _cx[classes[variant + 'Color']] = !R.isNil(variant) && R.isNil(color) && !isWarning, _cx[classes.warning] = isWarning, _cx))
68
+ }),
58
69
  React.createElement(
59
70
  Typography,
60
71
  { variant: 'subtitle1', noWrap: true, align: 'center' },
@@ -65,6 +76,8 @@ var Loading = function Loading(_ref) {
65
76
 
66
77
  Loading.propTypes = process.env.NODE_ENV !== "production" ? {
67
78
  message: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
79
+ variant: PropTypes.string,
80
+ color: PropTypes.string,
68
81
  isWarning: PropTypes.bool
69
82
  } : {};
70
83
 
@@ -1,14 +1,24 @@
1
1
  /**
2
2
  * Loading component is a basic placeholder to use when retrieving things.
3
+ * There are four way to use it:
4
+ * 1. Loading with message
5
+ * 2. Loading with message and variant (primary|secondary) (default: primary)
6
+ * 3. Loading with message and color (second priority color)
7
+ * 4. Loading with warning (top priority color)
8
+ *
3
9
  *
4
10
  * @memberOf VISIONS
5
11
  * @name Loading
6
12
  * @tag component
7
13
  * @api public
8
14
  * @props
9
- * message: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
10
- * @theme
11
- * // no custom theme there
15
+ * Loading.propTypes = {
16
+ * message: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
17
+ * variant: PropTypes.string,
18
+ * color: PropTypes.string,
19
+ * isWarning: PropTypes.bool,
20
+ * };
21
+
12
22
  */
13
23
 
14
24
  export { default } from './Loading';
@@ -6,6 +6,10 @@ var _react = require('react');
6
6
 
7
7
  var _react2 = _interopRequireDefault(_react);
8
8
 
9
+ var _ramda = require('ramda');
10
+
11
+ var R = _interopRequireWildcard(_ramda);
12
+
9
13
  var _classnames = require('classnames');
10
14
 
11
15
  var _classnames2 = _interopRequireDefault(_classnames);
@@ -20,6 +24,8 @@ var _Typography = require('@material-ui/core/Typography');
20
24
 
21
25
  var _Typography2 = _interopRequireDefault(_Typography);
22
26
 
27
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
28
+
23
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
30
 
25
31
  var useStyles = (0, _styles.makeStyles)(function (theme) {
@@ -37,13 +43,12 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
37
43
  height: ' 48px',
38
44
  borderStyle: 'solid',
39
45
  borderWidth: '5px',
40
- borderColor: theme.palette.primary.main,
41
- borderBottomColor: 'transparent',
42
46
  borderRadius: '50%',
43
47
  display: 'inline-block',
44
48
  boxSizing: 'border-box',
45
49
  animation: '$rotate 1s linear infinite',
46
- margin: theme.spacing(2)
50
+ margin: theme.spacing(2),
51
+ borderBottomColor: 'transparent !important'
47
52
  },
48
53
  '@keyframes rotate': {
49
54
  '0%': {
@@ -54,8 +59,13 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
54
59
  }
55
60
  },
56
61
  warning: {
57
- borderColor: theme.palette.warning.main,
58
- borderBottomColor: 'transparent'
62
+ borderColor: theme.palette.warning.main
63
+ },
64
+ primaryColor: {
65
+ borderColor: theme.palette.primary.main
66
+ },
67
+ secondaryColor: {
68
+ borderColor: theme.palette.secondary.main
59
69
  }
60
70
  };
61
71
  });
@@ -65,14 +75,20 @@ var Loading = function Loading(_ref) {
65
75
 
66
76
  var message = _ref.message,
67
77
  _ref$isWarning = _ref.isWarning,
68
- isWarning = _ref$isWarning === undefined ? false : _ref$isWarning;
78
+ isWarning = _ref$isWarning === undefined ? false : _ref$isWarning,
79
+ _ref$variant = _ref.variant,
80
+ variant = _ref$variant === undefined ? 'primary' : _ref$variant,
81
+ color = _ref.color;
69
82
 
70
83
  var classes = useStyles();
71
84
 
72
85
  return _react2.default.createElement(
73
86
  'div',
74
87
  { className: classes.root },
75
- _react2.default.createElement('div', { className: (0, _classnames2.default)(classes.circularProgress, (_cx = {}, _cx[classes.warning] = isWarning, _cx)) }),
88
+ _react2.default.createElement('div', {
89
+ style: { color: R.isNil(color) ? undefined : color },
90
+ className: (0, _classnames2.default)(classes.circularProgress, (_cx = {}, _cx[classes[variant + 'Color']] = !R.isNil(variant) && R.isNil(color) && !isWarning, _cx[classes.warning] = isWarning, _cx))
91
+ }),
76
92
  _react2.default.createElement(
77
93
  _Typography2.default,
78
94
  { variant: 'subtitle1', noWrap: true, align: 'center' },
@@ -83,6 +99,8 @@ var Loading = function Loading(_ref) {
83
99
 
84
100
  Loading.propTypes = process.env.NODE_ENV !== "production" ? {
85
101
  message: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
102
+ variant: _propTypes2.default.string,
103
+ color: _propTypes2.default.string,
86
104
  isWarning: _propTypes2.default.bool
87
105
  } : {};
88
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-visions",
3
- "version": "7.12.2",
3
+ "version": "7.13.0",
4
4
  "description": "Library of visual components",
5
5
  "author": "OECD",
6
6
  "homepage": "https://visions-qa.siscc.org/#o",