@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
@@ -1,37 +1,55 @@
1
1
  "use strict";
2
2
 
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _react2 = require("@storybook/react");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.Standard = exports.CustomSize = exports.All = void 0;
6
7
 
7
- var _stories = require("../../stories");
8
+ var _react = _interopRequireDefault(require("react"));
8
9
 
9
10
  var _ = require(".");
10
11
 
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
 
13
- var stories = (0, _react2.storiesOf)('UI/Icon', module);
14
- stories.addDecorator((0, _stories.getWrapperDecorator)());
15
- stories.add('default', function () {
16
- return /*#__PURE__*/_react["default"].createElement(_.Icon, {
17
- glyph: _.Icon.ICONS.ARROW
18
- });
19
- });
20
- stories.add('with size', function () {
21
- return /*#__PURE__*/_react["default"].createElement(_.Icon, {
22
- glyph: _.Icon.ICONS.ARROW,
23
- size: _.Icon.SIZE_LARGE
24
- });
25
- });
26
- stories.add('all', function () {
14
+ var _default = {
15
+ title: 'UI/Icon',
16
+ component: _.Icon
17
+ };
18
+ exports["default"] = _default;
19
+
20
+ var Template = function Template(args) {
21
+ return /*#__PURE__*/_react["default"].createElement(_.Icon, args);
22
+ };
23
+
24
+ var Standard = Template.bind();
25
+ exports.Standard = Standard;
26
+ Standard.args = {
27
+ glyph: _.Icon.ICONS.ARROW
28
+ };
29
+ var CustomSize = Template.bind();
30
+ exports.CustomSize = CustomSize;
31
+ CustomSize.args = {
32
+ glyph: _.Icon.ICONS.ARROW,
33
+ size: _.Icon.SIZE_LARGE
34
+ };
35
+
36
+ var All = function All() {
27
37
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, Object.values(_.Icon.ICONS).map(function (glyph) {
28
- return /*#__PURE__*/_react["default"].createElement("span", {
38
+ return /*#__PURE__*/_react["default"].createElement("div", {
29
39
  style: {
30
- margin: '0.3rem'
40
+ display: 'inline-block',
41
+ padding: '1rem',
42
+ textAlign: 'center'
31
43
  }
32
44
  }, /*#__PURE__*/_react["default"].createElement(_.Icon, {
33
45
  glyph: glyph,
34
46
  key: glyph
35
- }));
47
+ }), /*#__PURE__*/_react["default"].createElement("code", {
48
+ style: {
49
+ display: 'block'
50
+ }
51
+ }, glyph));
36
52
  }));
37
- });
53
+ };
54
+
55
+ exports.All = All;
@@ -20,9 +20,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
20
20
 
21
21
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
22
22
 
23
- 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; }
23
+ 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; }
24
24
 
25
- 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; }
25
+ 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; }
26
26
 
27
27
  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; }
28
28
 
@@ -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
@@ -35,7 +35,7 @@ var Popover = function Popover(_ref) {
35
35
  children = _ref.children;
36
36
  var popover = (0, _Popover.usePopoverState)({
37
37
  baseId: process.env.NODE_ENV === 'test' && 'id-test',
38
- gutter: 24,
38
+ gutter: 12,
39
39
  modal: true,
40
40
  placement: 'top'
41
41
  });
@@ -64,7 +64,7 @@ var Popover = function Popover(_ref) {
64
64
  }), /*#__PURE__*/_react["default"].createElement(_Popover.PopoverArrow, _extends({
65
65
  className: _popoverModule["default"].arrow
66
66
  }, popover, {
67
- size: 24
67
+ size: 16
68
68
  })), typeof children === 'function' ? children({
69
69
  popoverToggle: popover.toggle
70
70
  }) : children, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
@@ -23,7 +23,8 @@
23
23
  }
24
24
 
25
25
  .popover {
26
- padding: var(--space-xsmall) var(--space-large) var(--space-xsmall) var(--space-small);
26
+ padding: var(--space-small) var(--space-large) var(--space-small) var(--space-small);
27
+ border-radius: var(--radius-small);
27
28
  max-width: 360px;
28
29
  outline: none;
29
30
  filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
@@ -17,9 +17,9 @@ var _excluded = ["className", "isTabActive"];
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
19
 
20
- 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; }
20
+ 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; }
21
21
 
22
- 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; }
22
+ 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; }
23
23
 
24
24
  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; }
25
25
 
@@ -12,6 +12,7 @@
12
12
 
13
13
  .tooltip {
14
14
  padding: var(--space-xxxsmall) var(--space-xxsmall);
15
+ border-radius: var(--radius-small);
15
16
  background: var(--color-light);
16
17
  color: var(--color-text);
17
18
  filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
package/lib/utils.js CHANGED
@@ -15,9 +15,9 @@ var _chartColors = _interopRequireDefault(require("./chart-colors.json"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
17
 
18
- 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; }
18
+ 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; }
19
19
 
20
- 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; }
20
+ 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; }
21
21
 
22
22
  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; }
23
23
 
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useEffect } from 'react';
3
+ import React, { useEffect, useMemo } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { HashRouter, NavLink, Route, Switch, useLocation } from 'react-router-dom';
6
6
  import { COMPONENT } from '@bundle-stats/utils';
@@ -8,6 +8,7 @@ import { METRICS_WEBPACK_ASSETS, METRICS_WEBPACK_GENERAL, METRICS_WEBPACK_MODULE
8
8
  import { Box } from '../layout/box';
9
9
  import { Container } from '../ui/container';
10
10
  import { DuplicatePackagesWarning } from '../components/duplicate-packages-warning';
11
+ import { BudgetInsights } from '../components/budget-insights';
11
12
  import { Summary } from '../components/summary';
12
13
  import { BundleAssets } from '../components/bundle-assets';
13
14
  import { BundleAssetsTotalsChartBars } from '../components/bundle-assets-totals-chart-bars';
@@ -61,6 +62,8 @@ Layout.defaultProps = {
61
62
  };
62
63
 
63
64
  const AppComponent = _ref2 => {
65
+ var _insights$webpack;
66
+
64
67
  let {
65
68
  version,
66
69
  jobs
@@ -77,9 +80,13 @@ const AppComponent = _ref2 => {
77
80
  }, I18N.NO_DATA)));
78
81
  }
79
82
 
83
+ const {
84
+ summary,
85
+ insights
86
+ } = useMemo(() => jobs[0], jobs);
80
87
  const {
81
88
  duplicatePackagesCount
82
- } = jobs[0].summary.webpack;
89
+ } = summary.webpack;
83
90
  const duplicatePackagesInsights = Boolean(duplicatePackagesCount.current || duplicatePackagesCount.baseline);
84
91
  return /*#__PURE__*/React.createElement(Layout, {
85
92
  jobs: jobs,
@@ -89,7 +96,8 @@ const AppComponent = _ref2 => {
89
96
  }, /*#__PURE__*/React.createElement(Summary, {
90
97
  size: "large",
91
98
  keys: METRICS_WEBPACK_GENERAL,
92
- data: jobs[0].summary,
99
+ data: summary,
100
+ budgets: insights == null ? void 0 : (_insights$webpack = insights.webpack) == null ? void 0 : _insights$webpack.budgets,
93
101
  showSummaryItemDelta: jobs.length !== 1
94
102
  })), /*#__PURE__*/React.createElement(Container, {
95
103
  className: css.tabsContainer
@@ -117,6 +125,8 @@ const AppComponent = _ref2 => {
117
125
  exact: true,
118
126
  path: URLS.ASSETS,
119
127
  render: _ref3 => {
128
+ var _insights$webpack2;
129
+
120
130
  let {
121
131
  location
122
132
  } = _ref3;
@@ -124,7 +134,8 @@ const AppComponent = _ref2 => {
124
134
  space: "medium"
125
135
  }, /*#__PURE__*/React.createElement(Summary, {
126
136
  keys: METRICS_WEBPACK_ASSETS,
127
- data: jobs[0].summary,
137
+ data: summary,
138
+ budgets: insights == null ? void 0 : (_insights$webpack2 = insights.webpack) == null ? void 0 : _insights$webpack2.budgets,
128
139
  showSummaryItemDelta: jobs.length !== 1
129
140
  }), /*#__PURE__*/React.createElement(Box, {
130
141
  outline: true
@@ -138,22 +149,29 @@ const AppComponent = _ref2 => {
138
149
  }), /*#__PURE__*/React.createElement(Route, {
139
150
  exact: true,
140
151
  path: URLS.MODULES,
141
- render: () => /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Stack, {
142
- space: "medium"
143
- }, /*#__PURE__*/React.createElement(Summary, {
144
- keys: METRICS_WEBPACK_MODULES,
145
- data: jobs[0].summary,
146
- showSummaryItemDelta: jobs.length !== 1
147
- }), /*#__PURE__*/React.createElement(Box, {
148
- outline: true
149
- }, /*#__PURE__*/React.createElement(BundleModules, _extends({
150
- jobs: jobs,
151
- setState: bundleModulesSetState
152
- }, bundleModulesState)))))
152
+ render: () => {
153
+ var _insights$webpack3;
154
+
155
+ return /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Stack, {
156
+ space: "medium"
157
+ }, /*#__PURE__*/React.createElement(Summary, {
158
+ keys: METRICS_WEBPACK_MODULES,
159
+ data: summary,
160
+ budgets: insights == null ? void 0 : (_insights$webpack3 = insights.webpack) == null ? void 0 : _insights$webpack3.budgets,
161
+ showSummaryItemDelta: jobs.length !== 1
162
+ }), /*#__PURE__*/React.createElement(Box, {
163
+ outline: true
164
+ }, /*#__PURE__*/React.createElement(BundleModules, _extends({
165
+ jobs: jobs,
166
+ setState: bundleModulesSetState
167
+ }, bundleModulesState)))));
168
+ }
153
169
  }), /*#__PURE__*/React.createElement(Route, {
154
170
  exact: true,
155
171
  path: URLS.PACKAGES,
156
172
  render: _ref4 => {
173
+ var _insights$webpack4;
174
+
157
175
  let {
158
176
  location
159
177
  } = _ref4;
@@ -161,7 +179,8 @@ const AppComponent = _ref2 => {
161
179
  space: "medium"
162
180
  }, /*#__PURE__*/React.createElement(Summary, {
163
181
  keys: METRICS_WEBPACK_PACKAGES,
164
- data: jobs[0].summary,
182
+ data: summary,
183
+ budgets: insights == null ? void 0 : (_insights$webpack4 = insights.webpack) == null ? void 0 : _insights$webpack4.budgets,
165
184
  showSummaryItemDelta: jobs.length !== 1
166
185
  }), /*#__PURE__*/React.createElement(Box, {
167
186
  outline: true
@@ -175,20 +194,27 @@ const AppComponent = _ref2 => {
175
194
  }), /*#__PURE__*/React.createElement(Route, {
176
195
  exact: true,
177
196
  path: URLS.OVERVIEW,
178
- render: () => /*#__PURE__*/React.createElement(Stack, {
179
- space: "large"
180
- }, duplicatePackagesInsights && /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(DuplicatePackagesWarning, {
181
- duplicatePackagesCount: duplicatePackagesCount,
182
- showDelta: jobs.length > 1
183
- })), /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Stack, {
184
- space: "small"
185
- }, /*#__PURE__*/React.createElement(TotalSizeTypeTitle, null), /*#__PURE__*/React.createElement(BundleAssetsTotalsChartBars, {
186
- jobs: jobs
187
- }), /*#__PURE__*/React.createElement(Box, {
188
- outline: true
189
- }, /*#__PURE__*/React.createElement(BundleAssetsTotalsTable, {
190
- jobs: jobs
191
- })))))
197
+ render: () => {
198
+ var _insights$webpack5;
199
+
200
+ return /*#__PURE__*/React.createElement(Stack, {
201
+ space: "large"
202
+ }, duplicatePackagesInsights && /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(DuplicatePackagesWarning, {
203
+ duplicatePackagesCount: duplicatePackagesCount,
204
+ showDelta: jobs.length > 1
205
+ })), (insights == null ? void 0 : (_insights$webpack5 = insights.webpack) == null ? void 0 : _insights$webpack5.budgets) && /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(BudgetInsights, {
206
+ source: "webpack",
207
+ budgets: insights.webpack.budgets
208
+ })), /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Stack, {
209
+ space: "small"
210
+ }, /*#__PURE__*/React.createElement(TotalSizeTypeTitle, null), /*#__PURE__*/React.createElement(BundleAssetsTotalsChartBars, {
211
+ jobs: jobs
212
+ }), /*#__PURE__*/React.createElement(Box, {
213
+ outline: true
214
+ }, /*#__PURE__*/React.createElement(BundleAssetsTotalsTable, {
215
+ jobs: jobs
216
+ })))));
217
+ }
192
218
  }))));
193
219
  };
194
220
 
@@ -24,7 +24,35 @@ const BASELINE_SOURCE = {
24
24
  ...baselineData.rawData.webpack
25
25
  }
26
26
  };
27
- const JOBS = createJobs([CURRENT_SOURCE, BASELINE_SOURCE]);
27
+ const JOBS = createJobs([CURRENT_SOURCE, BASELINE_SOURCE], {
28
+ webpack: {
29
+ budgets: [{
30
+ metric: 'totalSizeByTypeALL',
31
+ value: 2 * 1024 * 1024
32
+ }, {
33
+ metric: 'totalInitialSizeJS',
34
+ value: 512 * 1024
35
+ }, {
36
+ metric: 'totalInitialSizeCSS',
37
+ value: 50 * 1024
38
+ }, {
39
+ metric: 'chunkCount',
40
+ value: 50
41
+ }, {
42
+ metric: 'moduleCount',
43
+ value: 2000
44
+ }, {
45
+ metric: 'duplicatePackagesCount',
46
+ value: 5
47
+ }, {
48
+ metric: 'sizes.totalSizeByTypeJS',
49
+ value: 2 * 1024 * 1024
50
+ }, {
51
+ metric: 'sizes.totalSizeByTypeCSS',
52
+ value: 20 * 1024
53
+ }]
54
+ }
55
+ });
28
56
  const NO_BASELINE_JOBS = createJobs([CURRENT_SOURCE]);
29
57
  const MULTIPLE_JOBS = createJobs([CURRENT_SOURCE, BASELINE_SOURCE, {
30
58
  webpack: {
@@ -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>
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
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';
6
+ import { Icon } from '../../ui/icon';
7
+ import { Tooltip } from '../../ui/tooltip';
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
+ };
23
+ export const BudgetInfo = _ref => {
24
+ let {
25
+ className = '',
26
+ metricId,
27
+ budgetInsight
28
+ } = _ref;
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;
38
+ return /*#__PURE__*/React.createElement(Tooltip, {
39
+ className: rootClassName,
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 `)
41
+ }, /*#__PURE__*/React.createElement(Icon, {
42
+ className: css.icon,
43
+ glyph: glyph,
44
+ size: "medium"
45
+ }));
46
+ };
47
+ BudgetInfo.propTypes = {
48
+ metricId: PropTypes.string.isRequired,
49
+ budgetInsight: PropTypes.shape({
50
+ currentValue: PropTypes.number,
51
+ budgetValue: PropTypes.number,
52
+ failed: PropTypes.bool
53
+ }).isRequired,
54
+ className: PropTypes.string
55
+ };
56
+ BudgetInfo.defaultProps = {
57
+ className: ''
58
+ };
@@ -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,30 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { getWrapperDecorator } from '../../stories';
4
+ import { BudgetInfo } from '.';
5
+ const stories = storiesOf('Components/BudgetInfo', module);
6
+ stories.addDecorator(getWrapperDecorator());
7
+ stories.add('default', () => /*#__PURE__*/React.createElement(BudgetInfo, {
8
+ metricId: "webpack.assetCount",
9
+ budgetInsight: {
10
+ budgetValue: 300,
11
+ currentValue: 250,
12
+ failed: false
13
+ }
14
+ }));
15
+ stories.add('error', () => /*#__PURE__*/React.createElement(BudgetInfo, {
16
+ metricId: "webpack.assetCount",
17
+ budgetInsight: {
18
+ budgetValue: 300,
19
+ currentValue: 350,
20
+ failed: true
21
+ }
22
+ }));
23
+ stories.add('warning', () => /*#__PURE__*/React.createElement(BudgetInfo, {
24
+ metricId: "webpack.assetCount",
25
+ budgetInsight: {
26
+ budgetValue: 300,
27
+ currentValue: 300,
28
+ failed: false
29
+ }
30
+ }));
@@ -0,0 +1 @@
1
+ export * from './budget-info';