@bundle-stats/ui 3.3.0-alpha.0 → 3.3.0-alpha.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/CHANGELOG.md +11 -0
- package/lib/components/budget-info/budget-info.js +37 -10
- package/lib/components/budget-info/budget-info.module.css +25 -13
- package/lib/components/budget-info/budget-info.stories.js +21 -19
- package/lib/components/budget-insights/budget-insights.js +19 -19
- package/lib/components/budget-insights/budget-insights.stories.js +33 -33
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +2 -3
- package/lib/components/index.js +8 -0
- package/lib/components/summary/summary.js +1 -1
- package/lib/components/summary/summary.stories.js +12 -12
- package/lib/components/summary-item/summary-item.js +6 -6
- package/lib/components/summary-item/summary-item.stories.js +13 -13
- package/lib-esm/components/budget-info/budget-info.js +31 -10
- package/lib-esm/components/budget-info/budget-info.module.css +25 -13
- package/lib-esm/components/budget-info/budget-info.stories.js +19 -15
- package/lib-esm/components/budget-insights/budget-insights.js +21 -20
- package/lib-esm/components/budget-insights/budget-insights.stories.js +33 -33
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +2 -3
- package/lib-esm/components/index.js +1 -0
- package/lib-esm/components/summary/summary.js +1 -1
- package/lib-esm/components/summary/summary.stories.js +12 -12
- package/lib-esm/components/summary-item/summary-item.js +6 -6
- package/lib-esm/components/summary-item/summary-item.stories.js +10 -10
- package/package.json +3 -3
- package/src/components/budget-info/budget-info.jsx +32 -16
- package/src/components/budget-info/budget-info.module.css +25 -13
- package/src/components/budget-insights/budget-insights.jsx +20 -15
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +1 -2
- package/src/components/index.js +1 -0
- package/src/components/summary/summary.jsx +1 -1
- package/src/components/summary-item/summary-item.jsx +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.3.0-alpha.1](https://github.com/relative-ci/bundle-stats/compare/v3.3.0-alpha.0...v3.3.0-alpha.1) (2021-12-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **utils:** Budgets - take biggerIsBetter in consideration ([3df8abc](https://github.com/relative-ci/bundle-stats/commit/3df8abc2bcd27c8e56d62412749c6c9f2c02feba))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.3.0-alpha.0](https://github.com/relative-ci/bundle-stats/compare/v3.2.2...v3.3.0-alpha.0) (2021-12-17)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
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
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -11,41 +13,66 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
13
|
|
|
12
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
15
|
|
|
16
|
+
var _utils = require("@bundle-stats/utils");
|
|
17
|
+
|
|
18
|
+
var budgetsInsightsTransformer = _interopRequireWildcard(require("@bundle-stats/utils/lib-esm/transformers/budgets-insights"));
|
|
19
|
+
|
|
14
20
|
var _icon = require("../../ui/icon");
|
|
15
21
|
|
|
16
22
|
var _tooltip = require("../../ui/tooltip");
|
|
17
23
|
|
|
18
24
|
var _budgetInfoModule = _interopRequireDefault(require("./budget-info.module.css"));
|
|
19
25
|
|
|
26
|
+
var _INSIGHT_TYPE_MAP;
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
20
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
33
|
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
var INSIGHT_TYPE_MAP = (_INSIGHT_TYPE_MAP = {}, _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.SUCCESS, {
|
|
37
|
+
className: _budgetInfoModule["default"].success,
|
|
38
|
+
glyph: _icon.Icon.ICONS.CHECK_CIRCLE
|
|
39
|
+
}), _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.ERROR, {
|
|
40
|
+
className: _budgetInfoModule["default"].error,
|
|
41
|
+
glyph: _icon.Icon.ICONS.ALERT_CIRCLE
|
|
42
|
+
}), _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.WARNING, {
|
|
43
|
+
className: _budgetInfoModule["default"].warning,
|
|
44
|
+
glyph: _icon.Icon.ICONS.WARNING
|
|
45
|
+
}), _INSIGHT_TYPE_MAP);
|
|
46
|
+
|
|
22
47
|
var BudgetInfo = function BudgetInfo(_ref) {
|
|
23
48
|
var _ref$className = _ref.className,
|
|
24
49
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
50
|
+
metricId = _ref.metricId,
|
|
51
|
+
budgetInsight = _ref.budgetInsight;
|
|
52
|
+
var budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
|
|
53
|
+
var _INSIGHT_TYPE_MAP$bud = INSIGHT_TYPE_MAP[budgetInsightInfo.type],
|
|
54
|
+
insightTypeClassName = _INSIGHT_TYPE_MAP$bud.className,
|
|
55
|
+
glyph = _INSIGHT_TYPE_MAP$bud.glyph;
|
|
56
|
+
var rootClassName = (0, _classnames["default"])(_budgetInfoModule["default"].root, insightTypeClassName, className);
|
|
57
|
+
var messageData = budgetInsightInfo.message.data;
|
|
28
58
|
return /*#__PURE__*/_react["default"].createElement(_tooltip.Tooltip, {
|
|
29
59
|
className: rootClassName,
|
|
30
|
-
title: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null,
|
|
60
|
+
title: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, messageData.metricLabel), " value (", /*#__PURE__*/_react["default"].createElement("strong", null, messageData.currentValue), ") is ".concat(messageData.diffLabel, " "), /*#__PURE__*/_react["default"].createElement("strong", null, messageData.budgetValue), " budget ")
|
|
31
61
|
}, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
32
62
|
className: _budgetInfoModule["default"].icon,
|
|
33
|
-
glyph:
|
|
63
|
+
glyph: glyph,
|
|
34
64
|
size: "medium"
|
|
35
65
|
}));
|
|
36
66
|
};
|
|
37
67
|
|
|
38
68
|
exports.BudgetInfo = BudgetInfo;
|
|
39
69
|
BudgetInfo.propTypes = {
|
|
40
|
-
|
|
70
|
+
metricId: _propTypes["default"].string.isRequired,
|
|
71
|
+
budgetInsight: _propTypes["default"].shape({
|
|
41
72
|
currentValue: _propTypes["default"].number,
|
|
42
73
|
budgetValue: _propTypes["default"].number,
|
|
43
74
|
failed: _propTypes["default"].bool
|
|
44
75
|
}).isRequired,
|
|
45
|
-
metric: _propTypes["default"].shape({
|
|
46
|
-
label: _propTypes["default"].string,
|
|
47
|
-
formatter: _propTypes["default"].func
|
|
48
|
-
}).isRequired,
|
|
49
76
|
className: _propTypes["default"].string
|
|
50
77
|
};
|
|
51
78
|
BudgetInfo.defaultProps = {
|
|
@@ -3,26 +3,38 @@
|
|
|
3
3
|
line-height: 1em;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
/* Budget
|
|
7
|
-
.
|
|
8
|
-
color: var(--color-danger
|
|
6
|
+
/* Budget error */
|
|
7
|
+
.error .icon {
|
|
8
|
+
color: var(--color-danger);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
.
|
|
11
|
+
.error .icon:hover,
|
|
12
|
+
.error .icon:focus,
|
|
13
|
+
.error .icon:active
|
|
14
14
|
{
|
|
15
|
-
color: var(--color-danger);
|
|
15
|
+
color: var(--color-danger-light);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/* Budget
|
|
19
|
-
.
|
|
18
|
+
/* Budget success */
|
|
19
|
+
.success .icon {
|
|
20
|
+
color: var(--color-success);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.success .icon:hover,
|
|
24
|
+
.success .icon:focus,
|
|
25
|
+
.success .icon:active
|
|
26
|
+
{
|
|
20
27
|
color: var(--color-success-light);
|
|
21
28
|
}
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
30
|
+
/* Budget warning */
|
|
31
|
+
.warning .icon {
|
|
32
|
+
color: var(--color-warning-dark);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.warning .icon:hover,
|
|
36
|
+
.warning .icon:focus,
|
|
37
|
+
.warning .icon:active
|
|
26
38
|
{
|
|
27
|
-
color: var(--color-
|
|
39
|
+
color: var(--color-warning);
|
|
28
40
|
}
|
|
@@ -14,29 +14,31 @@ var stories = (0, _react2.storiesOf)('Components/BudgetInfo', module);
|
|
|
14
14
|
stories.addDecorator((0, _stories.getWrapperDecorator)());
|
|
15
15
|
stories.add('default', function () {
|
|
16
16
|
return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
metric: {
|
|
23
|
-
formatter: function formatter(v) {
|
|
24
|
-
return v;
|
|
25
|
-
}
|
|
17
|
+
metricId: "webpack.assetCount",
|
|
18
|
+
budgetInsight: {
|
|
19
|
+
budgetValue: 300,
|
|
20
|
+
currentValue: 250,
|
|
21
|
+
failed: false
|
|
26
22
|
}
|
|
27
23
|
});
|
|
28
24
|
});
|
|
29
|
-
stories.add('
|
|
25
|
+
stories.add('error', function () {
|
|
30
26
|
return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
metricId: "webpack.assetCount",
|
|
28
|
+
budgetInsight: {
|
|
29
|
+
budgetValue: 300,
|
|
30
|
+
currentValue: 350,
|
|
31
|
+
failed: true
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
stories.add('warning', function () {
|
|
36
|
+
return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
|
|
37
|
+
metricId: "webpack.assetCount",
|
|
38
|
+
budgetInsight: {
|
|
39
|
+
budgetValue: 300,
|
|
40
|
+
currentValue: 300,
|
|
41
|
+
failed: false
|
|
40
42
|
}
|
|
41
43
|
});
|
|
42
44
|
});
|
|
@@ -15,6 +15,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("@bundle-stats/utils");
|
|
17
17
|
|
|
18
|
+
var budgetsInsightsTransformer = _interopRequireWildcard(require("@bundle-stats/utils/lib-esm/transformers/budgets-insights"));
|
|
19
|
+
|
|
18
20
|
var _box = require("../../layout/box");
|
|
19
21
|
|
|
20
22
|
var _stack = require("../../layout/stack");
|
|
@@ -51,29 +53,27 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
51
53
|
|
|
52
54
|
var Budget = function Budget(props) {
|
|
53
55
|
var className = props.className,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
budgetValue = props.budgetValue;
|
|
58
|
-
var metric = (0, _utils.getGlobalMetricType)(metricKey);
|
|
56
|
+
metricId = props.metricId,
|
|
57
|
+
budgetInsight = props.budgetInsight,
|
|
58
|
+
CustomLink = props.CustomLink;
|
|
59
59
|
|
|
60
|
-
var componentLinkOptions = _utils.METRIC_COMPONENT_LINKS.get(
|
|
60
|
+
var componentLinkOptions = _utils.METRIC_COMPONENT_LINKS.get(metricId);
|
|
61
61
|
|
|
62
|
+
var budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
|
|
63
|
+
var messageData = budgetInsightInfo.message.data;
|
|
62
64
|
return /*#__PURE__*/_react["default"].createElement(CustomLink, _extends({
|
|
63
65
|
className: (0, _classnames["default"])(_budgetInsightsModule["default"].budget, className)
|
|
64
|
-
}, componentLinkOptions === null || componentLinkOptions === void 0 ? void 0 : componentLinkOptions.link), /*#__PURE__*/_react["default"].createElement("
|
|
65
|
-
className: _budgetInsightsModule["default"].budgetLabel
|
|
66
|
-
}, metric.label), " is ".concat(failed ? 'over' : 'under', " "), /*#__PURE__*/_react["default"].createElement("span", {
|
|
67
|
-
className: _budgetInsightsModule["default"].budgetValue
|
|
68
|
-
}, metric.formatter(budgetValue)), " budget");
|
|
66
|
+
}, componentLinkOptions === null || componentLinkOptions === void 0 ? void 0 : componentLinkOptions.link), /*#__PURE__*/_react["default"].createElement("strong", null, messageData.metricLabel), " value (", /*#__PURE__*/_react["default"].createElement("strong", null, messageData.currentValue), ") is ".concat(messageData.diffLabel, " "), /*#__PURE__*/_react["default"].createElement("strong", null, messageData.budgetValue), " budget ");
|
|
69
67
|
};
|
|
70
68
|
|
|
71
69
|
Budget.propTypes = {
|
|
72
70
|
className: _propTypes["default"].string,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
metricId: _propTypes["default"].string.isRequired,
|
|
72
|
+
budgetInsight: _propTypes["default"].shape({
|
|
73
|
+
currentValue: _propTypes["default"].number.isRequired,
|
|
74
|
+
budgetValue: _propTypes["default"].number.isRequired,
|
|
75
|
+
failed: _propTypes["default"].bool.isRequired
|
|
76
|
+
}).isRequired,
|
|
77
77
|
CustomLink: _propTypes["default"].elementType.isRequired
|
|
78
78
|
};
|
|
79
79
|
Budget.defaultProps = {
|
|
@@ -123,12 +123,12 @@ var BudgetsGroup = function BudgetsGroup(props) {
|
|
|
123
123
|
key = _ref2[0],
|
|
124
124
|
budget = _ref2[1];
|
|
125
125
|
|
|
126
|
-
return /*#__PURE__*/_react["default"].createElement(Budget,
|
|
126
|
+
return /*#__PURE__*/_react["default"].createElement(Budget, {
|
|
127
127
|
key: key,
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
metricId: "".concat(source, ".").concat(key),
|
|
129
|
+
budgetInsight: budget,
|
|
130
130
|
CustomLink: CustomLink
|
|
131
|
-
}
|
|
131
|
+
});
|
|
132
132
|
}))));
|
|
133
133
|
};
|
|
134
134
|
|
|
@@ -32,44 +32,44 @@ Default.args = {
|
|
|
32
32
|
source: 'webpack',
|
|
33
33
|
budgets: {
|
|
34
34
|
totalSizeByTypeALL: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
currentValue: 2097917,
|
|
36
|
+
budgetValue: 2097152,
|
|
37
|
+
failed: true
|
|
38
38
|
},
|
|
39
39
|
totalInitialSizeJS: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
currentValue: 1265645,
|
|
41
|
+
budgetValue: 524288,
|
|
42
|
+
failed: true
|
|
43
43
|
},
|
|
44
44
|
totalInitialSizeCSS: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
currentValue: 48866,
|
|
46
|
+
budgetValue: 51200,
|
|
47
|
+
failed: false
|
|
48
48
|
},
|
|
49
49
|
chunkCount: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
currentValue: 12,
|
|
51
|
+
budgetValue: 50,
|
|
52
|
+
failed: false
|
|
53
53
|
},
|
|
54
54
|
moduleCount: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
currentValue: 1059,
|
|
56
|
+
budgetValue: 2000,
|
|
57
|
+
failed: false
|
|
58
58
|
},
|
|
59
59
|
duplicatePackagesCount: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
currentValue: 13,
|
|
61
|
+
budgetValue: 5,
|
|
62
|
+
failed: true
|
|
63
63
|
},
|
|
64
64
|
'sizes.totalSizeByTypeJS': {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
currentValue: 1981470,
|
|
66
|
+
budgetValue: 2097152,
|
|
67
|
+
failed: false
|
|
68
68
|
},
|
|
69
69
|
'sizes.totalSizeByTypeCSS': {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
currentValue: 56091,
|
|
71
|
+
budgetValue: 20480,
|
|
72
|
+
failed: true
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
};
|
|
@@ -79,14 +79,14 @@ FailedBudgets.args = {
|
|
|
79
79
|
source: 'webpack',
|
|
80
80
|
budgets: {
|
|
81
81
|
totalSizeByTypeALL: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
currentValue: 2097917,
|
|
83
|
+
budgetValue: 2097152,
|
|
84
|
+
failed: true
|
|
85
85
|
},
|
|
86
86
|
totalInitialSizeJS: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
currentValue: 1265645,
|
|
88
|
+
budgetValue: 524288,
|
|
89
|
+
failed: true
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
};
|
|
@@ -96,9 +96,9 @@ SingleBudget.args = {
|
|
|
96
96
|
source: 'webpack',
|
|
97
97
|
budgets: {
|
|
98
98
|
totalInitialSizeJS: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
currentValue: 524288,
|
|
100
|
+
budgetValue: 1265645,
|
|
101
|
+
failed: false
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -72,7 +72,6 @@ var BundleAssetsTotalsTable = function BundleAssetsTotalsTable(_ref) {
|
|
|
72
72
|
|
|
73
73
|
var metricKey = metricSlugs.join('.');
|
|
74
74
|
var budget = (0, _get2["default"])(budgets, metricKey);
|
|
75
|
-
var metric = webpack.getMetricType(metricKey);
|
|
76
75
|
return /*#__PURE__*/_react["default"].createElement(CustomComponentLink, {
|
|
77
76
|
section: section,
|
|
78
77
|
title: title,
|
|
@@ -81,8 +80,8 @@ var BundleAssetsTotalsTable = function BundleAssetsTotalsTable(_ref) {
|
|
|
81
80
|
space: "xxsmall",
|
|
82
81
|
className: _bundleAssetsTotalsTableModule["default"].itemTitleText
|
|
83
82
|
}, /*#__PURE__*/_react["default"].createElement("span", null, item.label), budget && /*#__PURE__*/_react["default"].createElement(_budgetInfo.BudgetInfo, {
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
metricId: item.key,
|
|
84
|
+
budgetInsight: budget
|
|
86
85
|
})));
|
|
87
86
|
}, [CustomComponentLink]);
|
|
88
87
|
return /*#__PURE__*/_react["default"].createElement(_metricsTable.MetricsTable, {
|
package/lib/components/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "BrowsertimeTable", {
|
|
|
9
9
|
return _browsertimeTable.BrowsertimeTable;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "BudgetInsights", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _budgetInsights.BudgetInsights;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "BundleAssets", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function get() {
|
|
@@ -148,6 +154,8 @@ var _bundlePackages = require("./bundle-packages");
|
|
|
148
154
|
|
|
149
155
|
var _bundleModules = require("./bundle-modules");
|
|
150
156
|
|
|
157
|
+
var _budgetInsights = require("./budget-insights");
|
|
158
|
+
|
|
151
159
|
var _componentLink = require("./component-link");
|
|
152
160
|
|
|
153
161
|
var _duplicatePackagesWarning = require("./duplicate-packages-warning");
|
|
@@ -80,7 +80,7 @@ var Summary = function Summary(_ref) {
|
|
|
80
80
|
size: size,
|
|
81
81
|
id: metricId,
|
|
82
82
|
data: (0, _get2["default"])(data, metricId),
|
|
83
|
-
budget: (0, _get2["default"])(budgets,
|
|
83
|
+
budget: (0, _get2["default"])(budgets, metricId),
|
|
84
84
|
loading: loading,
|
|
85
85
|
showMetricDescription: true,
|
|
86
86
|
showDelta: showSummaryItemDelta && metricOptions.showDelta !== false
|
|
@@ -47,24 +47,24 @@ stories.add('budgets', function () {
|
|
|
47
47
|
budgets: {
|
|
48
48
|
webpack: {
|
|
49
49
|
totalSizeByTypeALL: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.totalSizeByTypeALL.current,
|
|
51
|
+
budgetValue: 1024 * 1024,
|
|
52
|
+
failed: false
|
|
53
53
|
},
|
|
54
54
|
totalInitialSizeJS: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.totalInitialSizeJS.current,
|
|
56
|
+
budgetValue: 512 * 1024,
|
|
57
|
+
failed: true
|
|
58
58
|
},
|
|
59
59
|
totalInitialSizeCSS: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.totalInitialSizeCSS.current,
|
|
61
|
+
budgetValue: 50 * 1024,
|
|
62
|
+
failed: false
|
|
63
63
|
},
|
|
64
64
|
chunkCount: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.chunkCount.current,
|
|
66
|
+
budgetValue: 50,
|
|
67
|
+
failed: false
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -103,8 +103,8 @@ var SummaryItem = function SummaryItem(_ref2) {
|
|
|
103
103
|
icon: "help"
|
|
104
104
|
}, /*#__PURE__*/_react["default"].createElement(MetricInfoPopover, metric)), budget && /*#__PURE__*/_react["default"].createElement(_budgetInfo.BudgetInfo, {
|
|
105
105
|
className: _summaryItemModule["default"].budgetInfo,
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
metricId: id,
|
|
107
|
+
budgetInsight: budget
|
|
108
108
|
})), !loading ? /*#__PURE__*/_react["default"].createElement(_stack.Stack, null, /*#__PURE__*/_react["default"].createElement(_metric.Metric, {
|
|
109
109
|
className: _summaryItemModule["default"].currentMetric,
|
|
110
110
|
value: current,
|
|
@@ -163,10 +163,10 @@ SummaryItem.propTypes = {
|
|
|
163
163
|
/** Show delta */
|
|
164
164
|
showDelta: _propTypes["default"].bool,
|
|
165
165
|
|
|
166
|
-
/** Budget data */
|
|
166
|
+
/** Budget insight data */
|
|
167
167
|
budget: _propTypes["default"].shape({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
currentBalue: _propTypes["default"].number,
|
|
169
|
+
budgetValue: _propTypes["default"].number,
|
|
170
|
+
failed: _propTypes["default"].bool
|
|
171
171
|
})
|
|
172
172
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] = exports.Standard = exports.SizeLarge = exports.ShowMetricDescription = exports.ShowDeltaFalse = exports.Loading = exports.
|
|
6
|
+
exports["default"] = exports.Standard = exports.SizeLarge = exports.ShowMetricDescription = exports.ShowDeltaFalse = exports.Loading = exports.BudgetSuccess = exports.BudgetError = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -53,24 +53,24 @@ exports.ShowDeltaFalse = ShowDeltaFalse;
|
|
|
53
53
|
ShowDeltaFalse.args = {
|
|
54
54
|
showDelta: false
|
|
55
55
|
};
|
|
56
|
-
var
|
|
57
|
-
exports.
|
|
58
|
-
|
|
56
|
+
var BudgetError = Template.bind();
|
|
57
|
+
exports.BudgetError = BudgetError;
|
|
58
|
+
BudgetError.args = {
|
|
59
59
|
showMetricDescription: true,
|
|
60
60
|
budget: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
currentValue: 120 * 1000,
|
|
62
|
+
budgetValue: 100 * 1000,
|
|
63
|
+
failed: true
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
var
|
|
67
|
-
exports.
|
|
68
|
-
|
|
66
|
+
var BudgetSuccess = Template.bind();
|
|
67
|
+
exports.BudgetSuccess = BudgetSuccess;
|
|
68
|
+
BudgetSuccess.args = {
|
|
69
69
|
showMetricDescription: true,
|
|
70
70
|
budget: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
currentValue: 120 * 1000,
|
|
72
|
+
budgetValue: 120 * 1024,
|
|
73
|
+
failed: false
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
var Loading = Template.bind();
|
|
@@ -1,35 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import { InsightType } from '@bundle-stats/utils';
|
|
5
|
+
import * as budgetsInsightsTransformer from '@bundle-stats/utils/lib-esm/transformers/budgets-insights';
|
|
4
6
|
import { Icon } from '../../ui/icon';
|
|
5
7
|
import { Tooltip } from '../../ui/tooltip';
|
|
6
8
|
import css from './budget-info.module.css';
|
|
9
|
+
const INSIGHT_TYPE_MAP = {
|
|
10
|
+
[InsightType.SUCCESS]: {
|
|
11
|
+
className: css.success,
|
|
12
|
+
glyph: Icon.ICONS.CHECK_CIRCLE
|
|
13
|
+
},
|
|
14
|
+
[InsightType.ERROR]: {
|
|
15
|
+
className: css.error,
|
|
16
|
+
glyph: Icon.ICONS.ALERT_CIRCLE
|
|
17
|
+
},
|
|
18
|
+
[InsightType.WARNING]: {
|
|
19
|
+
className: css.warning,
|
|
20
|
+
glyph: Icon.ICONS.WARNING
|
|
21
|
+
}
|
|
22
|
+
};
|
|
7
23
|
export const BudgetInfo = _ref => {
|
|
8
24
|
let {
|
|
9
25
|
className = '',
|
|
10
|
-
|
|
11
|
-
|
|
26
|
+
metricId,
|
|
27
|
+
budgetInsight
|
|
12
28
|
} = _ref;
|
|
13
|
-
const
|
|
29
|
+
const budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
|
|
30
|
+
const {
|
|
31
|
+
className: insightTypeClassName,
|
|
32
|
+
glyph
|
|
33
|
+
} = INSIGHT_TYPE_MAP[budgetInsightInfo.type];
|
|
34
|
+
const rootClassName = cx(css.root, insightTypeClassName, className);
|
|
35
|
+
const {
|
|
36
|
+
data: messageData
|
|
37
|
+
} = budgetInsightInfo.message;
|
|
14
38
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
15
39
|
className: rootClassName,
|
|
16
|
-
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("strong", null,
|
|
40
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("strong", null, messageData.metricLabel), ` value (`, /*#__PURE__*/React.createElement("strong", null, messageData.currentValue), `) is ${messageData.diffLabel} `, /*#__PURE__*/React.createElement("strong", null, messageData.budgetValue), ` budget `)
|
|
17
41
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
18
42
|
className: css.icon,
|
|
19
|
-
glyph:
|
|
43
|
+
glyph: glyph,
|
|
20
44
|
size: "medium"
|
|
21
45
|
}));
|
|
22
46
|
};
|
|
23
47
|
BudgetInfo.propTypes = {
|
|
24
|
-
|
|
48
|
+
metricId: PropTypes.string.isRequired,
|
|
49
|
+
budgetInsight: PropTypes.shape({
|
|
25
50
|
currentValue: PropTypes.number,
|
|
26
51
|
budgetValue: PropTypes.number,
|
|
27
52
|
failed: PropTypes.bool
|
|
28
53
|
}).isRequired,
|
|
29
|
-
metric: PropTypes.shape({
|
|
30
|
-
label: PropTypes.string,
|
|
31
|
-
formatter: PropTypes.func
|
|
32
|
-
}).isRequired,
|
|
33
54
|
className: PropTypes.string
|
|
34
55
|
};
|
|
35
56
|
BudgetInfo.defaultProps = {
|
|
@@ -3,26 +3,38 @@
|
|
|
3
3
|
line-height: 1em;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
/* Budget
|
|
7
|
-
.
|
|
8
|
-
color: var(--color-danger
|
|
6
|
+
/* Budget error */
|
|
7
|
+
.error .icon {
|
|
8
|
+
color: var(--color-danger);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
.
|
|
11
|
+
.error .icon:hover,
|
|
12
|
+
.error .icon:focus,
|
|
13
|
+
.error .icon:active
|
|
14
14
|
{
|
|
15
|
-
color: var(--color-danger);
|
|
15
|
+
color: var(--color-danger-light);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/* Budget
|
|
19
|
-
.
|
|
18
|
+
/* Budget success */
|
|
19
|
+
.success .icon {
|
|
20
|
+
color: var(--color-success);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.success .icon:hover,
|
|
24
|
+
.success .icon:focus,
|
|
25
|
+
.success .icon:active
|
|
26
|
+
{
|
|
20
27
|
color: var(--color-success-light);
|
|
21
28
|
}
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
30
|
+
/* Budget warning */
|
|
31
|
+
.warning .icon {
|
|
32
|
+
color: var(--color-warning-dark);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.warning .icon:hover,
|
|
36
|
+
.warning .icon:focus,
|
|
37
|
+
.warning .icon:active
|
|
26
38
|
{
|
|
27
|
-
color: var(--color-
|
|
39
|
+
color: var(--color-warning);
|
|
28
40
|
}
|