@plusscommunities/pluss-core-web 1.4.20 → 1.4.21
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/dist/index.cjs.js +61 -0
- package/dist/index.esm.js +61 -0
- package/dist/index.umd.js +62 -4
- package/package.json +4 -1
- package/src/components/StatBox.js +49 -0
- package/src/components/index.js +1 -0
package/dist/index.cjs.js
CHANGED
|
@@ -32,6 +32,9 @@ var reactCsv = require('react-csv');
|
|
|
32
32
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
33
33
|
var reactColor = require('react-color');
|
|
34
34
|
var tinycolor = require('tinycolor2');
|
|
35
|
+
var reactRouterDom = require('react-router-dom');
|
|
36
|
+
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
37
|
+
var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
35
38
|
|
|
36
39
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
37
40
|
|
|
@@ -11547,6 +11550,63 @@ var ColourPicker = /*#__PURE__*/function (_Component) {
|
|
|
11547
11550
|
return ColourPicker;
|
|
11548
11551
|
}(React.Component);
|
|
11549
11552
|
|
|
11553
|
+
var StatBox = function StatBox(_ref) {
|
|
11554
|
+
var title = _ref.title,
|
|
11555
|
+
icon = _ref.icon,
|
|
11556
|
+
value = _ref.value,
|
|
11557
|
+
previousValue = _ref.previousValue,
|
|
11558
|
+
prevText = _ref.prevText,
|
|
11559
|
+
viewGraphLink = _ref.viewGraphLink,
|
|
11560
|
+
isLoading = _ref.isLoading;
|
|
11561
|
+
var change = (value / previousValue - 1) * 100;
|
|
11562
|
+
|
|
11563
|
+
if (isNaN(change)) {
|
|
11564
|
+
change = 0;
|
|
11565
|
+
}
|
|
11566
|
+
|
|
11567
|
+
if (!isFinite(change)) {
|
|
11568
|
+
change = 100;
|
|
11569
|
+
}
|
|
11570
|
+
|
|
11571
|
+
change = parseInt(change);
|
|
11572
|
+
var opacity = isLoading ? 0 : 1;
|
|
11573
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
11574
|
+
className: "dashboardBox dashboardBox-stats dashboardBox-inline".concat(change > 0 ? ' dashboardBox-stats-positive' : '').concat(change < 0 ? ' dashboardBox-stats-negative' : '')
|
|
11575
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
11576
|
+
className: "dashboardBox-stats_title"
|
|
11577
|
+
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11578
|
+
type: "h6"
|
|
11579
|
+
}, title)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
11580
|
+
className: "dashboardBox-stats_mid",
|
|
11581
|
+
style: {
|
|
11582
|
+
opacity: opacity
|
|
11583
|
+
}
|
|
11584
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
11585
|
+
className: "dashboardBox-stats_icon",
|
|
11586
|
+
icon: icon
|
|
11587
|
+
}), /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11588
|
+
type: "h2",
|
|
11589
|
+
className: "dashboardBox-stats_count"
|
|
11590
|
+
}, value), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
11591
|
+
className: "dashboardBox-stats_change"
|
|
11592
|
+
}, change === 0 ? 'No change' : "".concat(change, "% ").concat(change < 0 ? '↓' : '↑'))), /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11593
|
+
type: "help",
|
|
11594
|
+
style: {
|
|
11595
|
+
opacity: opacity
|
|
11596
|
+
}
|
|
11597
|
+
}, "Compared to ", prevText), viewGraphLink && /*#__PURE__*/React__default['default'].createElement(reactRouterDom.Link, {
|
|
11598
|
+
to: "".concat(viewGraphLink, "&title=").concat(title)
|
|
11599
|
+
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11600
|
+
type: "h5-noUpper",
|
|
11601
|
+
className: "text-link marginTop-10"
|
|
11602
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
11603
|
+
icon: freeSolidSvgIcons.faChartLine,
|
|
11604
|
+
style: {
|
|
11605
|
+
marginRight: 4
|
|
11606
|
+
}
|
|
11607
|
+
}), "View Graph")));
|
|
11608
|
+
};
|
|
11609
|
+
|
|
11550
11610
|
var index = /*#__PURE__*/Object.freeze({
|
|
11551
11611
|
__proto__: null,
|
|
11552
11612
|
AddButton: AddButton,
|
|
@@ -11589,6 +11649,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
11589
11649
|
ExportCsvPopup: ExportCsvPopup,
|
|
11590
11650
|
InputGroup: InputGroup,
|
|
11591
11651
|
ColourPicker: ColourPicker,
|
|
11652
|
+
StatBox: StatBox,
|
|
11592
11653
|
Tabs: Tabs
|
|
11593
11654
|
});
|
|
11594
11655
|
|
package/dist/index.esm.js
CHANGED
|
@@ -28,6 +28,9 @@ import { CSVLink } from 'react-csv';
|
|
|
28
28
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
29
29
|
import { ChromePicker } from 'react-color';
|
|
30
30
|
import tinycolor from 'tinycolor2';
|
|
31
|
+
import { Link } from 'react-router-dom';
|
|
32
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
33
|
+
import { faChartLine } from '@fortawesome/free-solid-svg-icons';
|
|
31
34
|
|
|
32
35
|
var CoreConfig = {
|
|
33
36
|
env: {
|
|
@@ -11517,6 +11520,63 @@ var ColourPicker = /*#__PURE__*/function (_Component) {
|
|
|
11517
11520
|
return ColourPicker;
|
|
11518
11521
|
}(Component);
|
|
11519
11522
|
|
|
11523
|
+
var StatBox = function StatBox(_ref) {
|
|
11524
|
+
var title = _ref.title,
|
|
11525
|
+
icon = _ref.icon,
|
|
11526
|
+
value = _ref.value,
|
|
11527
|
+
previousValue = _ref.previousValue,
|
|
11528
|
+
prevText = _ref.prevText,
|
|
11529
|
+
viewGraphLink = _ref.viewGraphLink,
|
|
11530
|
+
isLoading = _ref.isLoading;
|
|
11531
|
+
var change = (value / previousValue - 1) * 100;
|
|
11532
|
+
|
|
11533
|
+
if (isNaN(change)) {
|
|
11534
|
+
change = 0;
|
|
11535
|
+
}
|
|
11536
|
+
|
|
11537
|
+
if (!isFinite(change)) {
|
|
11538
|
+
change = 100;
|
|
11539
|
+
}
|
|
11540
|
+
|
|
11541
|
+
change = parseInt(change);
|
|
11542
|
+
var opacity = isLoading ? 0 : 1;
|
|
11543
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
11544
|
+
className: "dashboardBox dashboardBox-stats dashboardBox-inline".concat(change > 0 ? ' dashboardBox-stats-positive' : '').concat(change < 0 ? ' dashboardBox-stats-negative' : '')
|
|
11545
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
11546
|
+
className: "dashboardBox-stats_title"
|
|
11547
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
11548
|
+
type: "h6"
|
|
11549
|
+
}, title)), /*#__PURE__*/React.createElement("div", {
|
|
11550
|
+
className: "dashboardBox-stats_mid",
|
|
11551
|
+
style: {
|
|
11552
|
+
opacity: opacity
|
|
11553
|
+
}
|
|
11554
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
11555
|
+
className: "dashboardBox-stats_icon",
|
|
11556
|
+
icon: icon
|
|
11557
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
11558
|
+
type: "h2",
|
|
11559
|
+
className: "dashboardBox-stats_count"
|
|
11560
|
+
}, value), /*#__PURE__*/React.createElement("p", {
|
|
11561
|
+
className: "dashboardBox-stats_change"
|
|
11562
|
+
}, change === 0 ? 'No change' : "".concat(change, "% ").concat(change < 0 ? '↓' : '↑'))), /*#__PURE__*/React.createElement(Text, {
|
|
11563
|
+
type: "help",
|
|
11564
|
+
style: {
|
|
11565
|
+
opacity: opacity
|
|
11566
|
+
}
|
|
11567
|
+
}, "Compared to ", prevText), viewGraphLink && /*#__PURE__*/React.createElement(Link, {
|
|
11568
|
+
to: "".concat(viewGraphLink, "&title=").concat(title)
|
|
11569
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
11570
|
+
type: "h5-noUpper",
|
|
11571
|
+
className: "text-link marginTop-10"
|
|
11572
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
11573
|
+
icon: faChartLine,
|
|
11574
|
+
style: {
|
|
11575
|
+
marginRight: 4
|
|
11576
|
+
}
|
|
11577
|
+
}), "View Graph")));
|
|
11578
|
+
};
|
|
11579
|
+
|
|
11520
11580
|
var index = /*#__PURE__*/Object.freeze({
|
|
11521
11581
|
__proto__: null,
|
|
11522
11582
|
AddButton: AddButton,
|
|
@@ -11559,6 +11619,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
11559
11619
|
ExportCsvPopup: ExportCsvPopup,
|
|
11560
11620
|
InputGroup: InputGroup,
|
|
11561
11621
|
ColourPicker: ColourPicker,
|
|
11622
|
+
StatBox: StatBox,
|
|
11562
11623
|
Tabs: Tabs
|
|
11563
11624
|
});
|
|
11564
11625
|
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator'), require('lodash'), require('axios'), require('aws-amplify'), require('@babel/runtime/helpers/defineProperty'), require('moment'), require('react'), require('jquery'), require('js-cookie'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('react-fontawesome'), require('@babel/runtime/helpers/extends'), require('@babel/runtime/helpers/assertThisInitialized'), require('react-redux'), require('react-textarea-autosize'), require('@babel/runtime/helpers/toConsumableArray'), require('@babel/runtime/helpers/typeof'), require('react-dropzone'), require('react-router'), require('react-bootstrap'), require('@crello/react-lottie'), require('react-csv'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-color'), require('tinycolor2')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', 'aws-amplify', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', 'react-fontawesome', '@babel/runtime/helpers/extends', '@babel/runtime/helpers/assertThisInitialized', 'react-redux', 'react-textarea-autosize', '@babel/runtime/helpers/toConsumableArray', '@babel/runtime/helpers/typeof', 'react-dropzone', 'react-router', 'react-bootstrap', '@crello/react-lottie', 'react-csv', '@babel/runtime/helpers/objectWithoutProperties', 'react-color', 'tinycolor2'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global.awsAmplify, global._defineProperty, global.moment, global.React, global.$, global.Cookies, global._classCallCheck, global._createClass, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global.FontAwesome, global._extends, global._assertThisInitialized, global.reactRedux, global.Textarea, global._toConsumableArray, global._typeof, global.Dropzone, global.reactRouter, global.reactBootstrap, global.reactLottie, global.reactCsv, global._objectWithoutProperties, global.reactColor, global.tinycolor));
|
|
5
|
-
}(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios, awsAmplify, _defineProperty, moment, React, $, Cookies, _classCallCheck, _createClass, _inherits, _possibleConstructorReturn, _getPrototypeOf, FontAwesome, _extends, _assertThisInitialized, reactRedux, Textarea, _toConsumableArray, _typeof, Dropzone, reactRouter, reactBootstrap, reactLottie, reactCsv, _objectWithoutProperties, reactColor, tinycolor) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator'), require('lodash'), require('axios'), require('aws-amplify'), require('@babel/runtime/helpers/defineProperty'), require('moment'), require('react'), require('jquery'), require('js-cookie'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('react-fontawesome'), require('@babel/runtime/helpers/extends'), require('@babel/runtime/helpers/assertThisInitialized'), require('react-redux'), require('react-textarea-autosize'), require('@babel/runtime/helpers/toConsumableArray'), require('@babel/runtime/helpers/typeof'), require('react-dropzone'), require('react-router'), require('react-bootstrap'), require('@crello/react-lottie'), require('react-csv'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-color'), require('tinycolor2'), require('react-router-dom'), require('@fortawesome/react-fontawesome'), require('@fortawesome/free-solid-svg-icons')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', 'aws-amplify', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', 'react-fontawesome', '@babel/runtime/helpers/extends', '@babel/runtime/helpers/assertThisInitialized', 'react-redux', 'react-textarea-autosize', '@babel/runtime/helpers/toConsumableArray', '@babel/runtime/helpers/typeof', 'react-dropzone', 'react-router', 'react-bootstrap', '@crello/react-lottie', 'react-csv', '@babel/runtime/helpers/objectWithoutProperties', 'react-color', 'tinycolor2', 'react-router-dom', '@fortawesome/react-fontawesome', '@fortawesome/free-solid-svg-icons'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global.awsAmplify, global._defineProperty, global.moment, global.React, global.$, global.Cookies, global._classCallCheck, global._createClass, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global.FontAwesome, global._extends, global._assertThisInitialized, global.reactRedux, global.Textarea, global._toConsumableArray, global._typeof, global.Dropzone, global.reactRouter, global.reactBootstrap, global.reactLottie, global.reactCsv, global._objectWithoutProperties, global.reactColor, global.tinycolor, global.reactRouterDom, global.reactFontawesome, global.freeSolidSvgIcons));
|
|
5
|
+
}(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios, awsAmplify, _defineProperty, moment, React, $, Cookies, _classCallCheck, _createClass, _inherits, _possibleConstructorReturn, _getPrototypeOf, FontAwesome, _extends, _assertThisInitialized, reactRedux, Textarea, _toConsumableArray, _typeof, Dropzone, reactRouter, reactBootstrap, reactLottie, reactCsv, _objectWithoutProperties, reactColor, tinycolor, reactRouterDom, reactFontawesome, freeSolidSvgIcons) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -11518,6 +11518,63 @@
|
|
|
11518
11518
|
return ColourPicker;
|
|
11519
11519
|
}(React.Component);
|
|
11520
11520
|
|
|
11521
|
+
var StatBox = function StatBox(_ref) {
|
|
11522
|
+
var title = _ref.title,
|
|
11523
|
+
icon = _ref.icon,
|
|
11524
|
+
value = _ref.value,
|
|
11525
|
+
previousValue = _ref.previousValue,
|
|
11526
|
+
prevText = _ref.prevText,
|
|
11527
|
+
viewGraphLink = _ref.viewGraphLink,
|
|
11528
|
+
isLoading = _ref.isLoading;
|
|
11529
|
+
var change = (value / previousValue - 1) * 100;
|
|
11530
|
+
|
|
11531
|
+
if (isNaN(change)) {
|
|
11532
|
+
change = 0;
|
|
11533
|
+
}
|
|
11534
|
+
|
|
11535
|
+
if (!isFinite(change)) {
|
|
11536
|
+
change = 100;
|
|
11537
|
+
}
|
|
11538
|
+
|
|
11539
|
+
change = parseInt(change);
|
|
11540
|
+
var opacity = isLoading ? 0 : 1;
|
|
11541
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
11542
|
+
className: "dashboardBox dashboardBox-stats dashboardBox-inline".concat(change > 0 ? ' dashboardBox-stats-positive' : '').concat(change < 0 ? ' dashboardBox-stats-negative' : '')
|
|
11543
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
11544
|
+
className: "dashboardBox-stats_title"
|
|
11545
|
+
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11546
|
+
type: "h6"
|
|
11547
|
+
}, title)), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
11548
|
+
className: "dashboardBox-stats_mid",
|
|
11549
|
+
style: {
|
|
11550
|
+
opacity: opacity
|
|
11551
|
+
}
|
|
11552
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
11553
|
+
className: "dashboardBox-stats_icon",
|
|
11554
|
+
icon: icon
|
|
11555
|
+
}), /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11556
|
+
type: "h2",
|
|
11557
|
+
className: "dashboardBox-stats_count"
|
|
11558
|
+
}, value), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
11559
|
+
className: "dashboardBox-stats_change"
|
|
11560
|
+
}, change === 0 ? 'No change' : "".concat(change, "% ").concat(change < 0 ? '↓' : '↑'))), /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11561
|
+
type: "help",
|
|
11562
|
+
style: {
|
|
11563
|
+
opacity: opacity
|
|
11564
|
+
}
|
|
11565
|
+
}, "Compared to ", prevText), viewGraphLink && /*#__PURE__*/React__default['default'].createElement(reactRouterDom.Link, {
|
|
11566
|
+
to: "".concat(viewGraphLink, "&title=").concat(title)
|
|
11567
|
+
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
11568
|
+
type: "h5-noUpper",
|
|
11569
|
+
className: "text-link marginTop-10"
|
|
11570
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
11571
|
+
icon: freeSolidSvgIcons.faChartLine,
|
|
11572
|
+
style: {
|
|
11573
|
+
marginRight: 4
|
|
11574
|
+
}
|
|
11575
|
+
}), "View Graph")));
|
|
11576
|
+
};
|
|
11577
|
+
|
|
11521
11578
|
var index = /*#__PURE__*/Object.freeze({
|
|
11522
11579
|
__proto__: null,
|
|
11523
11580
|
AddButton: AddButton,
|
|
@@ -11560,6 +11617,7 @@
|
|
|
11560
11617
|
ExportCsvPopup: ExportCsvPopup,
|
|
11561
11618
|
InputGroup: InputGroup,
|
|
11562
11619
|
ColourPicker: ColourPicker,
|
|
11620
|
+
StatBox: StatBox,
|
|
11563
11621
|
Tabs: Tabs
|
|
11564
11622
|
});
|
|
11565
11623
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-core-web",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.21",
|
|
4
4
|
"description": "Core extension package for Pluss Communities platform",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.14.0",
|
|
32
|
+
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
33
|
+
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
|
34
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
32
35
|
"jquery": "^3.2.1",
|
|
33
36
|
"js-cookie": "^2.2.0",
|
|
34
37
|
"lodash": "^4.17.4",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
4
|
+
import { faChartLine } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
|
|
7
|
+
// StatBox Component
|
|
8
|
+
const StatBox = ({ title, icon, value, previousValue, prevText, viewGraphLink, isLoading }) => {
|
|
9
|
+
let change = (value / previousValue - 1) * 100;
|
|
10
|
+
if (isNaN(change)) {
|
|
11
|
+
change = 0;
|
|
12
|
+
}
|
|
13
|
+
if (!isFinite(change)) {
|
|
14
|
+
change = 100;
|
|
15
|
+
}
|
|
16
|
+
change = parseInt(change);
|
|
17
|
+
const opacity = isLoading ? 0 : 1;
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={`dashboardBox dashboardBox-stats dashboardBox-inline${change > 0 ? ' dashboardBox-stats-positive' : ''}${
|
|
21
|
+
change < 0 ? ' dashboardBox-stats-negative' : ''
|
|
22
|
+
}`}
|
|
23
|
+
>
|
|
24
|
+
<div className="dashboardBox-stats_title">
|
|
25
|
+
<Text type="h6">{title}</Text>
|
|
26
|
+
</div>
|
|
27
|
+
<div className="dashboardBox-stats_mid" style={{ opacity }}>
|
|
28
|
+
<FontAwesomeIcon className="dashboardBox-stats_icon" icon={icon} />
|
|
29
|
+
<Text type="h2" className="dashboardBox-stats_count">
|
|
30
|
+
{value}
|
|
31
|
+
</Text>
|
|
32
|
+
<p className="dashboardBox-stats_change">{change === 0 ? 'No change' : `${change}% ${change < 0 ? '↓' : '↑'}`}</p>
|
|
33
|
+
</div>
|
|
34
|
+
<Text type="help" style={{ opacity }}>
|
|
35
|
+
Compared to {prevText}
|
|
36
|
+
</Text>
|
|
37
|
+
{viewGraphLink && (
|
|
38
|
+
<Link to={`${viewGraphLink}&title=${title}`}>
|
|
39
|
+
<Text type="h5-noUpper" className="text-link marginTop-10">
|
|
40
|
+
<FontAwesomeIcon icon={faChartLine} style={{ marginRight: 4 }} />
|
|
41
|
+
View Graph
|
|
42
|
+
</Text>
|
|
43
|
+
</Link>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { StatBox };
|