@bundle-stats/ui 3.2.1 → 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.
Files changed (121) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/lib/app/app.js +31 -6
  3. package/lib/app/app.stories.js +31 -3
  4. package/lib/assets/icons/alert-circle.svg +1 -0
  5. package/lib/assets/icons/arrow-right-circle.svg +1 -0
  6. package/lib/assets/icons/check-circle.svg +1 -0
  7. package/lib/assets/icons/close.svg +1 -1
  8. package/lib/assets/icons.svg +50 -1
  9. package/lib/components/browsertime-table/browsertime-table.js +1 -1
  10. package/lib/components/browsertime-table/browsertime-table.stories.js +1 -1
  11. package/lib/components/budget-info/budget-info.js +80 -0
  12. package/lib/components/budget-info/budget-info.module.css +40 -0
  13. package/lib/components/budget-info/budget-info.stories.js +44 -0
  14. package/lib/components/budget-info/index.js +18 -0
  15. package/lib/components/budget-insights/budget-insights.js +200 -0
  16. package/lib/components/budget-insights/budget-insights.module.css +53 -0
  17. package/lib/components/budget-insights/budget-insights.stories.js +104 -0
  18. package/lib/components/budget-insights/index.js +18 -0
  19. package/lib/components/bundle-assets/bundle-assets.js +3 -3
  20. package/lib/components/bundle-assets/bundle-assets.utils.js +2 -2
  21. package/lib/components/bundle-assets/index.js +3 -3
  22. package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
  23. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +44 -8
  24. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  25. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +58 -43
  26. package/lib/components/bundle-modules/bundle-modules.js +3 -3
  27. package/lib/components/bundle-modules/bundle-modules.utils.js +2 -2
  28. package/lib/components/bundle-modules/index.js +3 -3
  29. package/lib/components/bundle-packages/bundle-packages.js +1 -1
  30. package/lib/components/bundle-packages/bundle-packages.utils.js +2 -2
  31. package/lib/components/bundle-packages/index.js +1 -1
  32. package/lib/components/index.js +8 -0
  33. package/lib/components/lighthouse-table/lighthouse-table.js +1 -1
  34. package/lib/components/metrics-table/metrics-table.js +1 -1
  35. package/lib/components/metrics-table-search/metrics-table-search.js +1 -1
  36. package/lib/components/metrics-table-search/metrics-table-search.stories.js +1 -1
  37. package/lib/components/summary/summary.js +40 -62
  38. package/lib/components/summary/summary.module.css +31 -14
  39. package/lib/components/summary/summary.stories.js +29 -0
  40. package/lib/components/summary-item/summary-item.js +30 -13
  41. package/lib/components/summary-item/summary-item.module.css +18 -9
  42. package/lib/components/summary-item/summary-item.stories.js +67 -52
  43. package/lib/constants.js +6 -6
  44. package/lib/css/variables.css +15 -11
  45. package/lib/hooks/search-params.js +2 -2
  46. package/lib/query-state.js +1 -1
  47. package/lib/stories/wrapper.js +2 -2
  48. package/lib/ui/alert/alert.js +13 -3
  49. package/lib/ui/filters/filters.container.js +5 -5
  50. package/lib/ui/filters/filters.js +2 -2
  51. package/lib/ui/filters/filters.stories.js +3 -3
  52. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +3 -3
  53. package/lib/ui/icon/icon.js +3 -0
  54. package/lib/ui/icon/icon.stories.js +40 -22
  55. package/lib/ui/panels/panels.js +2 -2
  56. package/lib/ui/popover/popover.js +3 -3
  57. package/lib/ui/popover/popover.module.css +2 -1
  58. package/lib/ui/tabs/tabs.js +2 -2
  59. package/lib/ui/tooltip/tooltip.module.css +1 -0
  60. package/lib/utils.js +2 -2
  61. package/lib-esm/app/app.js +57 -31
  62. package/lib-esm/app/app.stories.js +29 -1
  63. package/lib-esm/assets/icons/alert-circle.svg +1 -0
  64. package/lib-esm/assets/icons/arrow-right-circle.svg +1 -0
  65. package/lib-esm/assets/icons/check-circle.svg +1 -0
  66. package/lib-esm/assets/icons/close.svg +1 -1
  67. package/lib-esm/assets/icons.svg +50 -1
  68. package/lib-esm/components/budget-info/budget-info.js +58 -0
  69. package/lib-esm/components/budget-info/budget-info.module.css +40 -0
  70. package/lib-esm/components/budget-info/budget-info.stories.js +30 -0
  71. package/lib-esm/components/budget-info/index.js +1 -0
  72. package/lib-esm/components/budget-insights/budget-insights.js +148 -0
  73. package/lib-esm/components/budget-insights/budget-insights.module.css +53 -0
  74. package/lib-esm/components/budget-insights/budget-insights.stories.js +84 -0
  75. package/lib-esm/components/budget-insights/index.js +1 -0
  76. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +23 -7
  77. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  78. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +46 -21
  79. package/lib-esm/components/index.js +1 -0
  80. package/lib-esm/components/summary/summary.js +26 -45
  81. package/lib-esm/components/summary/summary.module.css +31 -14
  82. package/lib-esm/components/summary/summary.stories.js +27 -0
  83. package/lib-esm/components/summary-item/summary-item.js +28 -12
  84. package/lib-esm/components/summary-item/summary-item.module.css +18 -9
  85. package/lib-esm/components/summary-item/summary-item.stories.js +52 -42
  86. package/lib-esm/constants.js +4 -4
  87. package/lib-esm/css/variables.css +15 -11
  88. package/lib-esm/ui/alert/alert.js +6 -3
  89. package/lib-esm/ui/filters/filters.container.js +39 -41
  90. package/lib-esm/ui/icon/icon.js +3 -0
  91. package/lib-esm/ui/icon/icon.stories.js +22 -11
  92. package/lib-esm/ui/popover/popover.js +2 -2
  93. package/lib-esm/ui/popover/popover.module.css +2 -1
  94. package/lib-esm/ui/tooltip/tooltip.module.css +1 -0
  95. package/package.json +15 -15
  96. package/src/app/app.jsx +24 -8
  97. package/src/assets/icons/alert-circle.svg +1 -0
  98. package/src/assets/icons/arrow-right-circle.svg +1 -0
  99. package/src/assets/icons/check-circle.svg +1 -0
  100. package/src/assets/icons/close.svg +1 -1
  101. package/src/assets/icons.svg +50 -1
  102. package/src/components/budget-info/budget-info.jsx +65 -0
  103. package/src/components/budget-info/budget-info.module.css +40 -0
  104. package/src/components/budget-info/index.js +1 -0
  105. package/src/components/budget-insights/budget-insights.jsx +157 -0
  106. package/src/components/budget-insights/budget-insights.module.css +53 -0
  107. package/src/components/budget-insights/index.js +1 -0
  108. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +27 -13
  109. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  110. package/src/components/index.js +1 -0
  111. package/src/components/summary/summary.jsx +26 -44
  112. package/src/components/summary/summary.module.css +31 -14
  113. package/src/components/summary-item/summary-item.jsx +26 -24
  114. package/src/components/summary-item/summary-item.module.css +18 -9
  115. package/src/constants.js +7 -7
  116. package/src/css/variables.css +15 -11
  117. package/src/ui/alert/alert.jsx +7 -2
  118. package/src/ui/icon/icon.jsx +3 -0
  119. package/src/ui/popover/popover.jsx +3 -3
  120. package/src/ui/popover/popover.module.css +2 -1
  121. package/src/ui/tooltip/tooltip.module.css +1 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
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
+
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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **ui:** Alert - allow to override props ([4d52999](https://github.com/relative-ci/bundle-stats/commit/4d52999e80427f95bac30d0123cc149566b54282))
23
+
24
+
25
+ ### Features
26
+
27
+ * App - add BudgetInsights ([4068e33](https://github.com/relative-ci/bundle-stats/commit/4068e334465f6eb624b92790da11306d711718f6))
28
+ * **ui:** App - pass budgets info to Summary ([102a4c1](https://github.com/relative-ci/bundle-stats/commit/102a4c1b4a8ab445c1a39ba8d19fba88b0c259d5))
29
+ * **ui:** BudgetInsights component ([4458395](https://github.com/relative-ci/bundle-stats/commit/44583958a83458285b896c5564b03df0960fb992))
30
+ * **ui:** BundleAssetsTotalsTable - add budgets ([b2fa86e](https://github.com/relative-ci/bundle-stats/commit/b2fa86eb1ec2ad1e4ea183a4f4dee2eefa4cfddc))
31
+ * **ui:** Icon - add check-circle icon ([1bc3707](https://github.com/relative-ci/bundle-stats/commit/1bc3707a868ca216da5b9e500ba0536d0163b168))
32
+ * **ui:** Icon - alert-circle icon ([9ae82bc](https://github.com/relative-ci/bundle-stats/commit/9ae82bcac0ff55511eafb158322b571e09a4de60))
33
+ * **ui:** SummaryItem - budgets ([591bb41](https://github.com/relative-ci/bundle-stats/commit/591bb414f7aa93c2e1f4208f1dfedffa037e5225))
34
+
35
+
36
+ ### Performance Improvements
37
+
38
+ * **ui:** BundleAssetsTotalsTable - use memo / callback ([22ec007](https://github.com/relative-ci/bundle-stats/commit/22ec00772b1b27d19d89a106fbcf93ac49b3d57e))
39
+
40
+
41
+
42
+
43
+
44
+ ## [3.2.2](https://github.com/relative-ci/bundle-stats/compare/v3.2.1...v3.2.2) (2021-12-08)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * **ui:** Icons sprite - no prefix ([b0cd04f](https://github.com/relative-ci/bundle-stats/commit/b0cd04f7f11b9a76cc98d6edf0b306ba2d89ea1b))
50
+ * **ui:** SummaryItem - remove unused styles ([f9cb800](https://github.com/relative-ci/bundle-stats/commit/f9cb800515aa943b6e932f056fbd8a8887b00791))
51
+
52
+
53
+ ### Features
54
+
55
+ * **ui:** Icon - add arrow-right-circle ([4c58204](https://github.com/relative-ci/bundle-stats/commit/4c582045fb4aa25c717204a8eafb562679266583))
56
+ * **ui:** Summary - use read more icon to navigate ([71578bd](https://github.com/relative-ci/bundle-stats/commit/71578bd0679504d7290087368ce592e8ad81036e))
57
+
58
+
59
+
60
+
61
+
6
62
  ## [3.2.1](https://github.com/relative-ci/bundle-stats/compare/v3.2.0...v3.2.1) (2021-11-23)
7
63
 
8
64
 
package/lib/app/app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -23,6 +23,8 @@ var _container = require("../ui/container");
23
23
 
24
24
  var _duplicatePackagesWarning = require("../components/duplicate-packages-warning");
25
25
 
26
+ var _budgetInsights = require("../components/budget-insights");
27
+
26
28
  var _summary = require("../components/summary");
27
29
 
28
30
  var _bundleAssets = require("../components/bundle-assets");
@@ -114,6 +116,8 @@ Layout.defaultProps = {
114
116
  };
115
117
 
116
118
  var AppComponent = function AppComponent(_ref2) {
119
+ var _insights$webpack;
120
+
117
121
  var version = _ref2.version,
118
122
  jobs = _ref2.jobs;
119
123
 
@@ -140,7 +144,13 @@ var AppComponent = function AppComponent(_ref2) {
140
144
  }, _i18n["default"].NO_DATA)));
141
145
  }
142
146
 
143
- var duplicatePackagesCount = jobs[0].summary.webpack.duplicatePackagesCount;
147
+ var _useMemo = (0, _react.useMemo)(function () {
148
+ return jobs[0];
149
+ }, jobs),
150
+ summary = _useMemo.summary,
151
+ insights = _useMemo.insights;
152
+
153
+ var duplicatePackagesCount = summary.webpack.duplicatePackagesCount;
144
154
  var duplicatePackagesInsights = Boolean(duplicatePackagesCount.current || duplicatePackagesCount.baseline);
145
155
  return /*#__PURE__*/_react["default"].createElement(Layout, {
146
156
  jobs: jobs,
@@ -150,7 +160,8 @@ var AppComponent = function AppComponent(_ref2) {
150
160
  }, /*#__PURE__*/_react["default"].createElement(_summary.Summary, {
151
161
  size: "large",
152
162
  keys: _constants.METRICS_WEBPACK_GENERAL,
153
- data: jobs[0].summary,
163
+ data: summary,
164
+ budgets: insights === null || insights === void 0 ? void 0 : (_insights$webpack = insights.webpack) === null || _insights$webpack === void 0 ? void 0 : _insights$webpack.budgets,
154
165
  showSummaryItemDelta: jobs.length !== 1
155
166
  })), /*#__PURE__*/_react["default"].createElement(_container.Container, {
156
167
  className: _appModule["default"].tabsContainer
@@ -178,12 +189,15 @@ var AppComponent = function AppComponent(_ref2) {
178
189
  exact: true,
179
190
  path: _constants.URLS.ASSETS,
180
191
  render: function render(_ref3) {
192
+ var _insights$webpack2;
193
+
181
194
  var location = _ref3.location;
182
195
  return /*#__PURE__*/_react["default"].createElement(_container.Container, null, /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
183
196
  space: "medium"
184
197
  }, /*#__PURE__*/_react["default"].createElement(_summary.Summary, {
185
198
  keys: _constants.METRICS_WEBPACK_ASSETS,
186
- data: jobs[0].summary,
199
+ data: summary,
200
+ budgets: insights === null || insights === void 0 ? void 0 : (_insights$webpack2 = insights.webpack) === null || _insights$webpack2 === void 0 ? void 0 : _insights$webpack2.budgets,
187
201
  showSummaryItemDelta: jobs.length !== 1
188
202
  }), /*#__PURE__*/_react["default"].createElement(_box.Box, {
189
203
  outline: true
@@ -198,11 +212,14 @@ var AppComponent = function AppComponent(_ref2) {
198
212
  exact: true,
199
213
  path: _constants.URLS.MODULES,
200
214
  render: function render() {
215
+ var _insights$webpack3;
216
+
201
217
  return /*#__PURE__*/_react["default"].createElement(_container.Container, null, /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
202
218
  space: "medium"
203
219
  }, /*#__PURE__*/_react["default"].createElement(_summary.Summary, {
204
220
  keys: _constants.METRICS_WEBPACK_MODULES,
205
- data: jobs[0].summary,
221
+ data: summary,
222
+ budgets: insights === null || insights === void 0 ? void 0 : (_insights$webpack3 = insights.webpack) === null || _insights$webpack3 === void 0 ? void 0 : _insights$webpack3.budgets,
206
223
  showSummaryItemDelta: jobs.length !== 1
207
224
  }), /*#__PURE__*/_react["default"].createElement(_box.Box, {
208
225
  outline: true
@@ -215,12 +232,15 @@ var AppComponent = function AppComponent(_ref2) {
215
232
  exact: true,
216
233
  path: _constants.URLS.PACKAGES,
217
234
  render: function render(_ref4) {
235
+ var _insights$webpack4;
236
+
218
237
  var location = _ref4.location;
219
238
  return /*#__PURE__*/_react["default"].createElement(_container.Container, null, /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
220
239
  space: "medium"
221
240
  }, /*#__PURE__*/_react["default"].createElement(_summary.Summary, {
222
241
  keys: _constants.METRICS_WEBPACK_PACKAGES,
223
- data: jobs[0].summary,
242
+ data: summary,
243
+ budgets: insights === null || insights === void 0 ? void 0 : (_insights$webpack4 = insights.webpack) === null || _insights$webpack4 === void 0 ? void 0 : _insights$webpack4.budgets,
224
244
  showSummaryItemDelta: jobs.length !== 1
225
245
  }), /*#__PURE__*/_react["default"].createElement(_box.Box, {
226
246
  outline: true
@@ -235,11 +255,16 @@ var AppComponent = function AppComponent(_ref2) {
235
255
  exact: true,
236
256
  path: _constants.URLS.OVERVIEW,
237
257
  render: function render() {
258
+ var _insights$webpack5;
259
+
238
260
  return /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
239
261
  space: "large"
240
262
  }, duplicatePackagesInsights && /*#__PURE__*/_react["default"].createElement(_container.Container, null, /*#__PURE__*/_react["default"].createElement(_duplicatePackagesWarning.DuplicatePackagesWarning, {
241
263
  duplicatePackagesCount: duplicatePackagesCount,
242
264
  showDelta: jobs.length > 1
265
+ })), (insights === null || insights === void 0 ? void 0 : (_insights$webpack5 = insights.webpack) === null || _insights$webpack5 === void 0 ? void 0 : _insights$webpack5.budgets) && /*#__PURE__*/_react["default"].createElement(_container.Container, null, /*#__PURE__*/_react["default"].createElement(_budgetInsights.BudgetInsights, {
266
+ source: "webpack",
267
+ budgets: insights.webpack.budgets
243
268
  })), /*#__PURE__*/_react["default"].createElement(_container.Container, null, /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
244
269
  space: "small"
245
270
  }, /*#__PURE__*/_react["default"].createElement(_totalSizeTypeTitle.TotalSizeTypeTitle, null), /*#__PURE__*/_react["default"].createElement(_bundleAssetsTotalsChartBars.BundleAssetsTotalsChartBars, {
@@ -26,9 +26,9 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
26
26
 
27
27
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
28
 
29
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
29
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
30
30
 
31
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
32
32
 
33
33
  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; }
34
34
 
@@ -44,7 +44,35 @@ var BASELINE_SOURCE = {
44
44
  hash: _jobBaseline["default"].hash
45
45
  }, _jobBaseline["default"].rawData.webpack)
46
46
  };
47
- var JOBS = (0, _utils.createJobs)([CURRENT_SOURCE, BASELINE_SOURCE]);
47
+ var JOBS = (0, _utils.createJobs)([CURRENT_SOURCE, BASELINE_SOURCE], {
48
+ webpack: {
49
+ budgets: [{
50
+ metric: 'totalSizeByTypeALL',
51
+ value: 2 * 1024 * 1024
52
+ }, {
53
+ metric: 'totalInitialSizeJS',
54
+ value: 512 * 1024
55
+ }, {
56
+ metric: 'totalInitialSizeCSS',
57
+ value: 50 * 1024
58
+ }, {
59
+ metric: 'chunkCount',
60
+ value: 50
61
+ }, {
62
+ metric: 'moduleCount',
63
+ value: 2000
64
+ }, {
65
+ metric: 'duplicatePackagesCount',
66
+ value: 5
67
+ }, {
68
+ metric: 'sizes.totalSizeByTypeJS',
69
+ value: 2 * 1024 * 1024
70
+ }, {
71
+ metric: 'sizes.totalSizeByTypeCSS',
72
+ value: 20 * 1024
73
+ }]
74
+ }
75
+ });
48
76
  var NO_BASELINE_JOBS = (0, _utils.createJobs)([CURRENT_SOURCE]);
49
77
  var MULTIPLE_JOBS = (0, _utils.createJobs)([CURRENT_SOURCE, BASELINE_SOURCE, {
50
78
  webpack: _objectSpread(_objectSpread({
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right-circle"><circle cx="12" cy="12" r="10"></circle><polyline points="12 16 16 12 12 8"></polyline><line x1="8" y1="12" x2="16" y2="12"></line></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-circle"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>
@@ -1 +1,50 @@
1
- <svg width="16" height="16"><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="afeather afeather-arrow-down" id="arrow" xmlns="http://www.w3.org/2000/svg"><path d="M12 5v14M19 12l-7 7-7-7"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="bfeather bfeather-x-circle" id="cancel" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10"/><path d="M15 9l-6 6M9 9l6 6"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="cfeather cfeather-clock" id="clock" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="dfeather dfeather-x" id="close" xmlns="http://www.w3.org/2000/svg"><path d="M18 6L6 18M6 6l12 12"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="efeather efeather-git-commit" id="commit" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="4"/><path d="M1.05 12H7M17.01 12h5.95"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="ffeather ffeather-bar-chart" id="filter" xmlns="http://www.w3.org/2000/svg"><path d="M12 20V10M18 20V4M6 20v-4"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="gfeather gfeather-help-circle" id="help" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3M12 17h.01"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="hfeather hfeather-menu" id="menu" xmlns="http://www.w3.org/2000/svg"><path d="M3 12h18M3 6h18M3 18h18"/></symbol><symbol viewBox="0 0 24 24" fill="currentColor" id="sort" xmlns="http://www.w3.org/2000/svg"><path d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"/><path d="M0 0h24v24H0z" fill="none"/></symbol><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="jfeather jfeather-alert-triangle" id="warning" xmlns="http://www.w3.org/2000/svg"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0zM12 9v4M12 17h.01"/></symbol></svg>
1
+ <svg width="16" height="16">
2
+ <symbol fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle" viewBox="0 0 24 24" id="alert-circle" xmlns="http://www.w3.org/2000/svg">
3
+ <circle cx="12" cy="12" r="10"/>
4
+ <path d="M12 8v4M12 16h.01"/>
5
+ </symbol>
6
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-down" id="arrow" xmlns="http://www.w3.org/2000/svg">
7
+ <path d="M12 5v14M19 12l-7 7-7-7"/>
8
+ </symbol>
9
+ <symbol fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right-circle" viewBox="0 0 24 24" id="arrow-right-circle" xmlns="http://www.w3.org/2000/svg">
10
+ <circle cx="12" cy="12" r="10"/>
11
+ <path d="M12 16l4-4-4-4M8 12h8"/>
12
+ </symbol>
13
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-circle" id="cancel" xmlns="http://www.w3.org/2000/svg">
14
+ <circle cx="12" cy="12" r="10"/>
15
+ <path d="M15 9l-6 6M9 9l6 6"/>
16
+ </symbol>
17
+ <symbol fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle" viewBox="0 0 24 24" id="check-circle" xmlns="http://www.w3.org/2000/svg">
18
+ <path d="M22 11.08V12a10 10 0 11-5.93-9.14"/>
19
+ <path d="M22 4L12 14.01l-3-3"/>
20
+ </symbol>
21
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock" id="clock" xmlns="http://www.w3.org/2000/svg">
22
+ <circle cx="12" cy="12" r="10"/>
23
+ <path d="M12 6v6l4 2"/>
24
+ </symbol>
25
+ <symbol fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-circle" viewBox="0 0 24 24" id="close" xmlns="http://www.w3.org/2000/svg">
26
+ <circle cx="12" cy="12" r="10"/>
27
+ <path d="M15 9l-6 6M9 9l6 6"/>
28
+ </symbol>
29
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-commit" id="commit" xmlns="http://www.w3.org/2000/svg">
30
+ <circle cx="12" cy="12" r="4"/>
31
+ <path d="M1.05 12H7M17.01 12h5.95"/>
32
+ </symbol>
33
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bar-chart" id="filter" xmlns="http://www.w3.org/2000/svg">
34
+ <path d="M12 20V10M18 20V4M6 20v-4"/>
35
+ </symbol>
36
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-help-circle" id="help" xmlns="http://www.w3.org/2000/svg">
37
+ <circle cx="12" cy="12" r="10"/>
38
+ <path d="M9.09 9a3 3 0 015.83 1c0 2-3 3-3 3M12 17h.01"/>
39
+ </symbol>
40
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu" id="menu" xmlns="http://www.w3.org/2000/svg">
41
+ <path d="M3 12h18M3 6h18M3 18h18"/>
42
+ </symbol>
43
+ <symbol viewBox="0 0 24 24" fill="currentColor" id="sort" xmlns="http://www.w3.org/2000/svg">
44
+ <path d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"/>
45
+ <path d="M0 0h24v24H0z" fill="none"/>
46
+ </symbol>
47
+ <symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-triangle" id="warning" xmlns="http://www.w3.org/2000/svg">
48
+ <path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0zM12 9v4M12 17h.01"/>
49
+ </symbol>
50
+ </svg>
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
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
4
 
5
5
  var _react = _interopRequireDefault(require("react"));
6
6
 
@@ -0,0 +1,80 @@
1
+ "use strict";
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
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.BudgetInfo = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ var _utils = require("@bundle-stats/utils");
17
+
18
+ var budgetsInsightsTransformer = _interopRequireWildcard(require("@bundle-stats/utils/lib-esm/transformers/budgets-insights"));
19
+
20
+ var _icon = require("../../ui/icon");
21
+
22
+ var _tooltip = require("../../ui/tooltip");
23
+
24
+ var _budgetInfoModule = _interopRequireDefault(require("./budget-info.module.css"));
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
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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
+
47
+ var BudgetInfo = function BudgetInfo(_ref) {
48
+ var _ref$className = _ref.className,
49
+ className = _ref$className === void 0 ? '' : _ref$className,
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;
58
+ return /*#__PURE__*/_react["default"].createElement(_tooltip.Tooltip, {
59
+ className: rootClassName,
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 ")
61
+ }, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
62
+ className: _budgetInfoModule["default"].icon,
63
+ glyph: glyph,
64
+ size: "medium"
65
+ }));
66
+ };
67
+
68
+ exports.BudgetInfo = BudgetInfo;
69
+ BudgetInfo.propTypes = {
70
+ metricId: _propTypes["default"].string.isRequired,
71
+ budgetInsight: _propTypes["default"].shape({
72
+ currentValue: _propTypes["default"].number,
73
+ budgetValue: _propTypes["default"].number,
74
+ failed: _propTypes["default"].bool
75
+ }).isRequired,
76
+ className: _propTypes["default"].string
77
+ };
78
+ BudgetInfo.defaultProps = {
79
+ className: ''
80
+ };
@@ -0,0 +1,40 @@
1
+ .root {
2
+ display: inline-block;
3
+ line-height: 1em;
4
+ }
5
+
6
+ /* Budget error */
7
+ .error .icon {
8
+ color: var(--color-danger);
9
+ }
10
+
11
+ .error .icon:hover,
12
+ .error .icon:focus,
13
+ .error .icon:active
14
+ {
15
+ color: var(--color-danger-light);
16
+ }
17
+
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
+ {
27
+ color: var(--color-success-light);
28
+ }
29
+
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
38
+ {
39
+ color: var(--color-warning);
40
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _react2 = require("@storybook/react");
6
+
7
+ var _stories = require("../../stories");
8
+
9
+ var _ = require(".");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+
13
+ var stories = (0, _react2.storiesOf)('Components/BudgetInfo', module);
14
+ stories.addDecorator((0, _stories.getWrapperDecorator)());
15
+ stories.add('default', function () {
16
+ return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
17
+ metricId: "webpack.assetCount",
18
+ budgetInsight: {
19
+ budgetValue: 300,
20
+ currentValue: 250,
21
+ failed: false
22
+ }
23
+ });
24
+ });
25
+ stories.add('error', function () {
26
+ return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
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
42
+ }
43
+ });
44
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _budgetInfo = require("./budget-info");
8
+
9
+ Object.keys(_budgetInfo).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _budgetInfo[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _budgetInfo[key];
16
+ }
17
+ });
18
+ });