@bundle-stats/ui 3.3.0-alpha.1 → 3.3.0-beta.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 (240) hide show
  1. package/CHANGELOG.md +65 -13
  2. package/lib/app/app.js +124 -104
  3. package/lib/app/app.module.css +11 -4
  4. package/lib/app/app.stories.js +1 -22
  5. package/lib/app/header/header.js +1 -10
  6. package/lib/assets/icons.svg +0 -8
  7. package/lib/components/asset-info/asset-info.module.css +1 -0
  8. package/lib/components/bundle-assets/bundle-assets.js +104 -52
  9. package/lib/components/bundle-assets/bundle-assets.module.css +24 -26
  10. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +16 -42
  11. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  12. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
  13. package/lib/components/bundle-modules/bundle-modules.js +68 -68
  14. package/lib/components/bundle-modules/bundle-modules.module.css +11 -2
  15. package/lib/components/bundle-modules/bundle-modules.utils.js +14 -10
  16. package/lib/components/bundle-modules/index.js +4 -4
  17. package/lib/components/bundle-packages/bundle-packages.js +100 -44
  18. package/lib/components/bundle-packages/bundle-packages.module.css +17 -21
  19. package/lib/components/delta/delta.module.css +1 -0
  20. package/lib/components/index.js +0 -8
  21. package/lib/components/job-header/job-header.js +3 -1
  22. package/lib/components/job-header/job-header.module.css +6 -8
  23. package/lib/components/jobs-header/jobs-header.module.css +5 -0
  24. package/lib/components/metrics-table/metrics-table.js +72 -59
  25. package/lib/components/metrics-table/metrics-table.module.css +18 -7
  26. package/lib/components/metrics-table-search/metrics-table-search.module.css +5 -4
  27. package/lib/components/metrics-table-title/metrics-table-title.js +9 -7
  28. package/lib/components/metrics-table-title/metrics-table-title.module.css +2 -0
  29. package/lib/components/module-info/module-info.js +2 -2
  30. package/lib/components/module-info/module-info.module.css +1 -0
  31. package/lib/components/summary/summary.js +7 -12
  32. package/lib/components/summary/summary.module.css +1 -1
  33. package/lib/components/summary/summary.stories.js +0 -29
  34. package/lib/components/summary-item/summary-item.js +18 -38
  35. package/lib/components/summary-item/summary-item.module.css +1 -34
  36. package/lib/components/summary-item/summary-item.stories.js +53 -51
  37. package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
  38. package/lib/constants.js +4 -4
  39. package/lib/css/default.css +14 -3
  40. package/lib/css/variables.css +17 -17
  41. package/lib/hooks/search-params.js +31 -31
  42. package/lib/layout/box/box.module.css +9 -0
  43. package/lib/layout/footer/footer.module.css +1 -1
  44. package/lib/layout/index.js +8 -0
  45. package/lib/layout/separator.js +48 -0
  46. package/lib/layout/separator.module.css +5 -0
  47. package/lib/ui/alert/alert.js +3 -13
  48. package/lib/ui/dropdown/dropdown.js +21 -26
  49. package/lib/ui/dropdown/dropdown.module.css +11 -12
  50. package/lib/ui/dropdown/dropdown.stories.js +2 -9
  51. package/lib/ui/empty-set/empty-set.js +5 -4
  52. package/lib/ui/empty-set/empty-set.module.css +2 -2
  53. package/lib/ui/filters/filters.container.js +1 -1
  54. package/lib/ui/filters/filters.js +22 -7
  55. package/lib/ui/filters/filters.module.css +3 -3
  56. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +1 -1
  57. package/lib/ui/hover-card/hover-card.js +102 -0
  58. package/lib/ui/hover-card/hover-card.module.css +29 -0
  59. package/lib/ui/hover-card/hover-card.stories.js +56 -0
  60. package/lib/{components/budget-info → ui/hover-card}/index.js +4 -4
  61. package/lib/ui/icon/icon.js +6 -8
  62. package/lib/ui/icon/icon.module.css +1 -0
  63. package/lib/ui/index.js +8 -8
  64. package/lib/ui/table/table.js +5 -74
  65. package/lib/ui/table/table.module.css +41 -25
  66. package/lib/ui/table/table.stories.js +1 -1
  67. package/lib/ui/{popover → tag}/index.js +4 -4
  68. package/lib/ui/tag/tag.js +72 -0
  69. package/lib/ui/tag/tag.module.css +55 -0
  70. package/lib/ui/tag/tag.stories.js +38 -0
  71. package/lib/ui/tooltip/tooltip.js +10 -9
  72. package/lib/ui/tooltip/tooltip.module.css +2 -1
  73. package/lib-esm/app/app.js +119 -103
  74. package/lib-esm/app/app.module.css +11 -4
  75. package/lib-esm/app/app.stories.js +1 -22
  76. package/lib-esm/app/header/header.js +1 -9
  77. package/lib-esm/assets/icons.svg +0 -8
  78. package/lib-esm/components/asset-info/asset-info.module.css +1 -0
  79. package/lib-esm/components/bundle-assets/bundle-assets.js +97 -56
  80. package/lib-esm/components/bundle-assets/bundle-assets.module.css +24 -26
  81. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +13 -26
  82. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  83. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
  84. package/lib-esm/components/bundle-modules/bundle-modules.js +50 -51
  85. package/lib-esm/components/bundle-modules/bundle-modules.module.css +11 -2
  86. package/lib-esm/components/bundle-modules/bundle-modules.utils.js +14 -6
  87. package/lib-esm/components/bundle-modules/index.js +5 -3
  88. package/lib-esm/components/bundle-packages/bundle-packages.js +88 -41
  89. package/lib-esm/components/bundle-packages/bundle-packages.module.css +17 -21
  90. package/lib-esm/components/delta/delta.module.css +1 -0
  91. package/lib-esm/components/index.js +0 -1
  92. package/lib-esm/components/job-header/job-header.js +2 -1
  93. package/lib-esm/components/job-header/job-header.module.css +6 -8
  94. package/lib-esm/components/jobs-header/jobs-header.module.css +5 -0
  95. package/lib-esm/components/metrics-table/metrics-table.js +61 -53
  96. package/lib-esm/components/metrics-table/metrics-table.module.css +18 -7
  97. package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +5 -4
  98. package/lib-esm/components/metrics-table-title/metrics-table-title.js +8 -7
  99. package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +2 -0
  100. package/lib-esm/components/module-info/module-info.js +2 -2
  101. package/lib-esm/components/module-info/module-info.module.css +1 -0
  102. package/lib-esm/components/summary/summary.js +7 -11
  103. package/lib-esm/components/summary/summary.module.css +1 -1
  104. package/lib-esm/components/summary/summary.stories.js +0 -27
  105. package/lib-esm/components/summary-item/summary-item.js +16 -36
  106. package/lib-esm/components/summary-item/summary-item.module.css +1 -34
  107. package/lib-esm/components/summary-item/summary-item.stories.js +38 -50
  108. package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
  109. package/lib-esm/constants.js +4 -4
  110. package/lib-esm/css/default.css +14 -3
  111. package/lib-esm/css/variables.css +17 -17
  112. package/lib-esm/hooks/search-params.js +27 -28
  113. package/lib-esm/layout/box/box.module.css +9 -0
  114. package/lib-esm/layout/footer/footer.module.css +1 -1
  115. package/lib-esm/layout/index.js +1 -0
  116. package/lib-esm/layout/separator.js +28 -0
  117. package/lib-esm/layout/separator.module.css +5 -0
  118. package/lib-esm/ui/alert/alert.js +3 -6
  119. package/lib-esm/ui/dropdown/dropdown.js +20 -25
  120. package/lib-esm/ui/dropdown/dropdown.module.css +11 -12
  121. package/lib-esm/ui/dropdown/dropdown.stories.js +2 -7
  122. package/lib-esm/ui/empty-set/empty-set.js +4 -4
  123. package/lib-esm/ui/empty-set/empty-set.module.css +2 -2
  124. package/lib-esm/ui/filters/filters.js +20 -5
  125. package/lib-esm/ui/filters/filters.module.css +3 -3
  126. package/lib-esm/ui/hover-card/hover-card.js +83 -0
  127. package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
  128. package/lib-esm/ui/hover-card/hover-card.stories.js +35 -0
  129. package/lib-esm/ui/hover-card/index.js +1 -0
  130. package/lib-esm/ui/icon/icon.js +3 -5
  131. package/lib-esm/ui/icon/icon.module.css +1 -0
  132. package/lib-esm/ui/index.js +1 -1
  133. package/lib-esm/ui/table/table.js +5 -65
  134. package/lib-esm/ui/table/table.module.css +41 -25
  135. package/lib-esm/ui/table/table.stories.js +1 -1
  136. package/lib-esm/ui/tag/index.js +1 -0
  137. package/lib-esm/ui/tag/tag.js +45 -0
  138. package/lib-esm/ui/tag/tag.module.css +55 -0
  139. package/lib-esm/ui/tag/tag.stories.js +23 -0
  140. package/lib-esm/ui/tooltip/tooltip.js +10 -9
  141. package/lib-esm/ui/tooltip/tooltip.module.css +2 -1
  142. package/package.json +33 -31
  143. package/src/app/app.jsx +135 -145
  144. package/src/app/app.module.css +11 -4
  145. package/src/app/header/header.jsx +0 -10
  146. package/src/assets/icons.svg +0 -8
  147. package/src/components/asset-info/asset-info.module.css +1 -0
  148. package/src/components/bundle-assets/bundle-assets.jsx +85 -31
  149. package/src/components/bundle-assets/bundle-assets.module.css +24 -26
  150. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -25
  151. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  152. package/src/components/bundle-modules/bundle-modules.jsx +53 -36
  153. package/src/components/bundle-modules/bundle-modules.module.css +11 -2
  154. package/src/components/bundle-modules/bundle-modules.utils.js +16 -4
  155. package/src/components/bundle-modules/index.jsx +3 -0
  156. package/src/components/bundle-packages/bundle-packages.jsx +89 -39
  157. package/src/components/bundle-packages/bundle-packages.module.css +17 -21
  158. package/src/components/delta/delta.module.css +1 -0
  159. package/src/components/index.js +0 -1
  160. package/src/components/job-header/job-header.jsx +2 -1
  161. package/src/components/job-header/job-header.module.css +6 -8
  162. package/src/components/jobs-header/jobs-header.module.css +5 -0
  163. package/src/components/metrics-table/metrics-table.jsx +53 -44
  164. package/src/components/metrics-table/metrics-table.module.css +18 -7
  165. package/src/components/metrics-table-search/metrics-table-search.module.css +5 -4
  166. package/src/components/metrics-table-title/metrics-table-title.jsx +20 -21
  167. package/src/components/metrics-table-title/metrics-table-title.module.css +2 -0
  168. package/src/components/module-info/module-info.jsx +3 -7
  169. package/src/components/module-info/module-info.module.css +1 -0
  170. package/src/components/summary/summary.jsx +7 -8
  171. package/src/components/summary/summary.module.css +1 -1
  172. package/src/components/summary-item/summary-item.jsx +23 -40
  173. package/src/components/summary-item/summary-item.module.css +1 -34
  174. package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
  175. package/src/constants.js +11 -7
  176. package/src/css/default.css +14 -3
  177. package/src/css/variables.css +17 -17
  178. package/src/hooks/search-params.js +42 -33
  179. package/src/layout/box/box.module.css +9 -0
  180. package/src/layout/footer/footer.module.css +1 -1
  181. package/src/layout/index.js +1 -0
  182. package/src/layout/separator.jsx +25 -0
  183. package/src/layout/separator.module.css +5 -0
  184. package/src/ui/alert/alert.jsx +2 -7
  185. package/src/ui/dropdown/dropdown.jsx +16 -22
  186. package/src/ui/dropdown/dropdown.module.css +11 -12
  187. package/src/ui/empty-set/empty-set.jsx +25 -21
  188. package/src/ui/empty-set/empty-set.module.css +2 -2
  189. package/src/ui/filters/filters.jsx +64 -53
  190. package/src/ui/filters/filters.module.css +3 -3
  191. package/src/ui/hover-card/hover-card.jsx +73 -0
  192. package/src/ui/hover-card/hover-card.module.css +29 -0
  193. package/src/ui/hover-card/index.js +1 -0
  194. package/src/ui/icon/icon.jsx +11 -9
  195. package/src/ui/icon/icon.module.css +1 -0
  196. package/src/ui/index.js +1 -1
  197. package/src/ui/table/table.jsx +5 -52
  198. package/src/ui/table/table.module.css +41 -25
  199. package/src/ui/tag/index.js +1 -0
  200. package/src/ui/tag/tag.jsx +49 -0
  201. package/src/ui/tag/tag.module.css +55 -0
  202. package/src/ui/tooltip/tooltip.jsx +10 -14
  203. package/src/ui/tooltip/tooltip.module.css +2 -1
  204. package/lib/assets/icons/alert-circle.svg +0 -1
  205. package/lib/assets/icons/check-circle.svg +0 -1
  206. package/lib/components/budget-info/budget-info.js +0 -80
  207. package/lib/components/budget-info/budget-info.module.css +0 -40
  208. package/lib/components/budget-info/budget-info.stories.js +0 -44
  209. package/lib/components/budget-insights/budget-insights.js +0 -200
  210. package/lib/components/budget-insights/budget-insights.module.css +0 -53
  211. package/lib/components/budget-insights/budget-insights.stories.js +0 -104
  212. package/lib/components/budget-insights/index.js +0 -18
  213. package/lib/ui/popover/popover.js +0 -92
  214. package/lib/ui/popover/popover.module.css +0 -66
  215. package/lib/ui/popover/popover.stories.js +0 -26
  216. package/lib-esm/assets/icons/alert-circle.svg +0 -1
  217. package/lib-esm/assets/icons/check-circle.svg +0 -1
  218. package/lib-esm/components/budget-info/budget-info.js +0 -58
  219. package/lib-esm/components/budget-info/budget-info.module.css +0 -40
  220. package/lib-esm/components/budget-info/budget-info.stories.js +0 -30
  221. package/lib-esm/components/budget-info/index.js +0 -1
  222. package/lib-esm/components/budget-insights/budget-insights.js +0 -148
  223. package/lib-esm/components/budget-insights/budget-insights.module.css +0 -53
  224. package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -84
  225. package/lib-esm/components/budget-insights/index.js +0 -1
  226. package/lib-esm/ui/popover/index.js +0 -1
  227. package/lib-esm/ui/popover/popover.js +0 -71
  228. package/lib-esm/ui/popover/popover.module.css +0 -66
  229. package/lib-esm/ui/popover/popover.stories.js +0 -14
  230. package/src/assets/icons/alert-circle.svg +0 -1
  231. package/src/assets/icons/check-circle.svg +0 -1
  232. package/src/components/budget-info/budget-info.jsx +0 -65
  233. package/src/components/budget-info/budget-info.module.css +0 -40
  234. package/src/components/budget-info/index.js +0 -1
  235. package/src/components/budget-insights/budget-insights.jsx +0 -157
  236. package/src/components/budget-insights/budget-insights.module.css +0 -53
  237. package/src/components/budget-insights/index.js +0 -1
  238. package/src/ui/popover/index.js +0 -1
  239. package/src/ui/popover/popover.jsx +0 -79
  240. package/src/ui/popover/popover.module.css +0 -66
@@ -13,16 +13,12 @@ import { FlexStack } from '../../layout/flex-stack';
13
13
  import { ComponentLink } from '../component-link';
14
14
  import { SummaryItem } from '../summary-item';
15
15
  import css from './summary.module.css';
16
-
17
- const getSourceMetricId = fullMetricId => fullMetricId.split('.').slice(1).join('.');
18
-
19
16
  export const Summary = _ref => {
20
17
  let {
21
18
  className,
22
19
  size,
23
20
  keys,
24
21
  data,
25
- budgets,
26
22
  loading,
27
23
  showSummaryItemDelta,
28
24
  summaryItemLink: SummaryItemCustomLink
@@ -34,7 +30,7 @@ export const Summary = _ref => {
34
30
  className: css.items
35
31
  }, Array.from(METRIC_COMPONENT_LINKS).filter(_ref2 => {
36
32
  let [metricId] = _ref2;
37
- return keys.includes(getSourceMetricId(metricId));
33
+ return keys.includes(metricId);
38
34
  }).map(_ref3 => {
39
35
  let [metricId, metricOptions] = _ref3;
40
36
  return /*#__PURE__*/React.createElement("div", {
@@ -44,7 +40,6 @@ export const Summary = _ref => {
44
40
  size: size,
45
41
  id: metricId,
46
42
  data: _get(data, metricId),
47
- budget: _get(budgets, metricId),
48
43
  loading: loading,
49
44
  showMetricDescription: true,
50
45
  showDelta: showSummaryItemDelta && metricOptions.showDelta !== false
@@ -59,7 +54,6 @@ export const Summary = _ref => {
59
54
  Summary.defaultProps = {
60
55
  className: '',
61
56
  data: null,
62
- budgets: null,
63
57
  loading: false,
64
58
  size: '',
65
59
  keys: METRICS_WEBPACK_GENERAL,
@@ -70,10 +64,12 @@ Summary.propTypes = {
70
64
  className: PropTypes.string,
71
65
  size: PropTypes.string,
72
66
  keys: PropTypes.arrayOf(PropTypes.string),
73
- data: PropTypes.object,
74
- // eslint-disable-line react/forbid-prop-types
75
- budgets: PropTypes.object,
76
- // eslint-disable-line react/forbid-prop-types
67
+ data: PropTypes.shape({
68
+ [PropTypes.string]: PropTypes.shape({
69
+ baseline: PropTypes.number,
70
+ current: PropTypes.number
71
+ })
72
+ }),
77
73
  loading: PropTypes.bool,
78
74
  showSummaryItemDelta: PropTypes.bool,
79
75
  summaryItemLink: PropTypes.elementType
@@ -4,7 +4,7 @@
4
4
  }
5
5
 
6
6
  .item {
7
- padding: var(--space-small);
7
+ padding: var(--space-small) var(--space-xxlarge) var(--space-small) var(--space-small);
8
8
  flex: 1 0 25%; /* force equal sizes */
9
9
  position: relative;
10
10
  z-index: 1;
@@ -21,33 +21,6 @@ stories.addDecorator(getWrapperDecorator());
21
21
  stories.add('default', () => /*#__PURE__*/React.createElement(Summary, {
22
22
  data: MULTIPLE_JOBS[0].summary
23
23
  }));
24
- stories.add('budgets', () => /*#__PURE__*/React.createElement(Summary, {
25
- data: MULTIPLE_JOBS[0].summary,
26
- budgets: {
27
- webpack: {
28
- totalSizeByTypeALL: {
29
- currentValue: MULTIPLE_JOBS[0].summary.webpack.totalSizeByTypeALL.current,
30
- budgetValue: 1024 * 1024,
31
- failed: false
32
- },
33
- totalInitialSizeJS: {
34
- currentValue: MULTIPLE_JOBS[0].summary.webpack.totalInitialSizeJS.current,
35
- budgetValue: 512 * 1024,
36
- failed: true
37
- },
38
- totalInitialSizeCSS: {
39
- currentValue: MULTIPLE_JOBS[0].summary.webpack.totalInitialSizeCSS.current,
40
- budgetValue: 50 * 1024,
41
- failed: false
42
- },
43
- chunkCount: {
44
- currentValue: MULTIPLE_JOBS[0].summary.webpack.chunkCount.current,
45
- budgetValue: 50,
46
- failed: false
47
- }
48
- }
49
- }
50
- }));
51
24
  stories.add('custom keys', () => /*#__PURE__*/React.createElement(Summary, {
52
25
  keys: METRICS_WEBPACK_ASSETS,
53
26
  data: MULTIPLE_JOBS[0].summary
@@ -4,40 +4,33 @@ import React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import cx from 'classnames';
6
6
  import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
7
- import { Popover } from '../../ui/popover';
7
+ import { HoverCard } from '../../ui/hover-card';
8
+ import { Icon } from '../../ui/icon';
8
9
  import { Skeleton } from '../../ui/skeleton';
9
10
  import { Stack } from '../../layout/stack';
10
11
  import { FlexStack } from '../../layout/flex-stack';
11
12
  import { Metric } from '../metric';
12
13
  import { Delta } from '../delta';
13
- import { BudgetInfo } from '../budget-info';
14
14
  import css from './summary-item.module.css';
15
15
 
16
- const MetricInfoPopover = _ref => {
16
+ const MetricInfo = _ref => {
17
17
  let {
18
18
  description,
19
19
  url
20
20
  } = _ref;
21
-
22
- // Workaround cases where the parent is a link
23
- const readMoreOnClick = () => {
24
- window.open(url);
25
- };
26
-
27
21
  return /*#__PURE__*/React.createElement(Stack, {
28
22
  space: "xxxsmall"
29
- }, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", {
30
- type: "button",
31
- className: css.readMoreBtn,
32
- onClick: readMoreOnClick
23
+ }, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("a", {
24
+ href: url,
25
+ className: css.readMoreLink
33
26
  }, "Read more")));
34
27
  };
35
28
 
36
- MetricInfoPopover.propTypes = {
29
+ MetricInfo.propTypes = {
37
30
  description: PropTypes.string.isRequired,
38
31
  url: PropTypes.string
39
32
  };
40
- MetricInfoPopover.defaultProps = {
33
+ MetricInfo.defaultProps = {
41
34
  url: ''
42
35
  };
43
36
  export const SummaryItem = _ref2 => {
@@ -50,7 +43,6 @@ export const SummaryItem = _ref2 => {
50
43
  loading,
51
44
  showDelta,
52
45
  showMetricDescription,
53
- budget,
54
46
  ...props
55
47
  } = _ref2;
56
48
  const {
@@ -65,23 +57,19 @@ export const SummaryItem = _ref2 => {
65
57
  const showMetricDescriptionTooltip = showMetricDescription && (metric == null ? void 0 : metric.description);
66
58
  const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
67
59
  return /*#__PURE__*/React.createElement(Stack, _extends({
68
- space: "xxsmall",
60
+ space: "xxxsmall",
69
61
  as: Component,
70
62
  className: rootClassName
71
63
  }, props), /*#__PURE__*/React.createElement(FlexStack, {
72
64
  as: "h3",
73
65
  space: "xxxsmall",
74
66
  className: css.title
75
- }, /*#__PURE__*/React.createElement("span", {
76
- className: css.titleLabel
77
- }, metric.label), showMetricDescriptionTooltip && /*#__PURE__*/React.createElement(Popover, {
67
+ }, /*#__PURE__*/React.createElement("span", null, metric.label), showMetricDescriptionTooltip && /*#__PURE__*/React.createElement(HoverCard, {
78
68
  className: css.icon,
79
- icon: "help"
80
- }, /*#__PURE__*/React.createElement(MetricInfoPopover, metric)), budget && /*#__PURE__*/React.createElement(BudgetInfo, {
81
- className: css.budgetInfo,
82
- metricId: id,
83
- budgetInsight: budget
84
- })), !loading ? /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Metric, {
69
+ label: /*#__PURE__*/React.createElement(Icon, {
70
+ glyph: "help"
71
+ })
72
+ }, /*#__PURE__*/React.createElement(MetricInfo, metric))), !loading ? /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Metric, {
85
73
  className: css.currentMetric,
86
74
  value: current,
87
75
  formatter: metric.formatter,
@@ -108,8 +96,7 @@ SummaryItem.defaultProps = {
108
96
  size: 'medium',
109
97
  loading: false,
110
98
  showMetricDescription: false,
111
- showDelta: true,
112
- budget: undefined
99
+ showDelta: true
113
100
  };
114
101
  SummaryItem.propTypes = {
115
102
  /** Adopted child class name */
@@ -135,12 +122,5 @@ SummaryItem.propTypes = {
135
122
  showMetricDescription: PropTypes.bool,
136
123
 
137
124
  /** Show delta */
138
- showDelta: PropTypes.bool,
139
-
140
- /** Budget insight data */
141
- budget: PropTypes.shape({
142
- currentBalue: PropTypes.number,
143
- budgetValue: PropTypes.number,
144
- failed: PropTypes.bool
145
- })
125
+ showDelta: PropTypes.bool
146
126
  };
@@ -1,9 +1,5 @@
1
- .root {
2
- position: relative;
3
- padding-right: var(--space-xlarge);
4
- }
5
-
6
1
  .title {
2
+ align-items: center;
7
3
  color: var(--color-text-ultra-light);
8
4
  font-weight: bold;
9
5
  font-size: var(--size-xsmall);
@@ -12,35 +8,6 @@
12
8
  white-space: nowrap;
13
9
  }
14
10
 
15
- .titleLabel {
16
- flex: 0 0 auto;
17
- }
18
-
19
- .readMoreBtn {
20
- appearance: none;
21
- padding: 0;
22
- border: 0;
23
- background: none;
24
- cursor: pointer;
25
- /* simulate link */
26
- color: var(--color-primary);
27
- text-decoration: underline;
28
- line-height: var(--space-small);
29
- }
30
-
31
- .readMoreBtn:hover,
32
- .readMoreBtn:active,
33
- .readMoreBtn:focus {
34
- color: var(--color-primary-dark);
35
- text-decoration: none;
36
- }
37
-
38
- .budgetInfo {
39
- position: absolute;
40
- right: 0;
41
- top: 0;
42
- }
43
-
44
11
  .currentMetric {
45
12
  display: block;
46
13
  color: var(--color-heading);
@@ -2,56 +2,44 @@ import React from 'react';
2
2
  import { SummaryItem } from './summary-item';
3
3
  export default {
4
4
  title: 'Components/SummaryItem',
5
- component: SummaryItem,
6
- decorators: [Story => /*#__PURE__*/React.createElement("div", {
7
- style: {
8
- maxWidth: '320px'
9
- }
10
- }, /*#__PURE__*/React.createElement(Story, null))],
11
- args: {
12
- loading: false,
13
- id: 'webpack.totalSizeByTypeALL',
14
- data: {
15
- current: 120 * 1000,
16
- baseline: 100 * 1000
17
- }
18
- }
19
- };
20
-
21
- const Template = args => /*#__PURE__*/React.createElement(SummaryItem, args);
22
-
23
- export const Standard = Template.bind();
24
- export const SizeLarge = Template.bind();
25
- SizeLarge.args = {
26
- size: 'large'
27
- };
28
- export const ShowMetricDescription = Template.bind();
29
- ShowMetricDescription.args = {
30
- showMetricDescription: true
31
- };
32
- export const ShowDeltaFalse = Template.bind();
33
- ShowDeltaFalse.args = {
34
- showDelta: false
5
+ component: SummaryItem
35
6
  };
36
- export const BudgetError = Template.bind();
37
- BudgetError.args = {
38
- showMetricDescription: true,
39
- budget: {
40
- currentValue: 120 * 1000,
41
- budgetValue: 100 * 1000,
42
- failed: true
7
+ export const Standard = () => /*#__PURE__*/React.createElement(SummaryItem, {
8
+ loading: false,
9
+ id: "webpack.totalSizeByTypeALL",
10
+ data: {
11
+ current: 120 * 1000,
12
+ baseline: 100 * 1000
43
13
  }
44
- };
45
- export const BudgetSuccess = Template.bind();
46
- BudgetSuccess.args = {
47
- showMetricDescription: true,
48
- budget: {
49
- currentValue: 120 * 1000,
50
- budgetValue: 120 * 1024,
51
- failed: false
14
+ });
15
+ export const SizeLarge = () => /*#__PURE__*/React.createElement(SummaryItem, {
16
+ size: "large",
17
+ loading: false,
18
+ id: "webpack.totalSizeByTypeALL",
19
+ data: {
20
+ current: 120 * 1000,
21
+ baseline: 100 * 1000
52
22
  }
53
- };
54
- export const Loading = Template.bind();
55
- Loading.args = {
56
- loading: true
57
- };
23
+ });
24
+ export const ShowMetricDescription = () => /*#__PURE__*/React.createElement(SummaryItem, {
25
+ loading: false,
26
+ id: "webpack.totalSizeByTypeALL",
27
+ data: {
28
+ current: 120 * 1000,
29
+ baseline: 100 * 1000
30
+ },
31
+ showMetricDescription: true
32
+ });
33
+ export const ShowDeltaFalse = () => /*#__PURE__*/React.createElement(SummaryItem, {
34
+ loading: false,
35
+ id: "webpack.totalSizeByTypeALL",
36
+ data: {
37
+ current: 120 * 1000,
38
+ baseline: 0
39
+ },
40
+ showDelta: false
41
+ });
42
+ export const Loading = () => /*#__PURE__*/React.createElement(SummaryItem, {
43
+ loading: true,
44
+ id: "webpack.totalSizeByTypeALL"
45
+ });
@@ -5,7 +5,8 @@ import config from '../../config.json';
5
5
  import I18N from '../../i18n';
6
6
  import { FlexStack } from '../../layout/flex-stack';
7
7
  import { Stack } from '../../layout/stack';
8
- import { Popover } from '../../ui/popover';
8
+ import { Icon } from '../../ui/icon';
9
+ import { HoverCard } from '../../ui/hover-card';
9
10
  import css from './total-size-type-title.module.css';
10
11
  export const TotalSizeTypeTitle = _ref => {
11
12
  let {
@@ -14,8 +15,10 @@ export const TotalSizeTypeTitle = _ref => {
14
15
  return /*#__PURE__*/React.createElement(FlexStack, {
15
16
  space: "xxxsmall",
16
17
  className: cx(css.title, className)
17
- }, /*#__PURE__*/React.createElement("span", null, I18N.ASSET_TOTALS), /*#__PURE__*/React.createElement(Popover, {
18
- icon: "help"
18
+ }, /*#__PURE__*/React.createElement("span", null, I18N.ASSET_TOTALS), /*#__PURE__*/React.createElement(HoverCard, {
19
+ label: /*#__PURE__*/React.createElement(Icon, {
20
+ glyph: "help"
21
+ })
19
22
  }, /*#__PURE__*/React.createElement(Stack, {
20
23
  space: "xxxsmall"
21
24
  }, /*#__PURE__*/React.createElement("p", null, I18N.ASSET_TOTALS_INFO), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("a", {
@@ -25,7 +25,7 @@ export const SECTION_URLS = {
25
25
  export const ASSETS_SIZES_FILE_TYPE_MAP = FILE_TYPES.reduce((agg, fileType) => ({ ...agg,
26
26
  [`webpack.sizes.totalSizeByType${fileType}`]: fileType
27
27
  }), {});
28
- export const METRICS_WEBPACK_GENERAL = ['totalSizeByTypeALL', 'totalInitialSizeJS', 'totalInitialSizeCSS', 'cacheInvalidation'];
29
- export const METRICS_WEBPACK_ASSETS = ['assetCount', 'chunkCount'];
30
- export const METRICS_WEBPACK_MODULES = ['moduleCount'];
31
- export const METRICS_WEBPACK_PACKAGES = ['packageCount', 'duplicatePackagesCount'];
28
+ export const METRICS_WEBPACK_GENERAL = ['webpack.totalSizeByTypeALL', 'webpack.totalInitialSizeJS', 'webpack.totalInitialSizeCSS', 'webpack.cacheInvalidation'];
29
+ export const METRICS_WEBPACK_ASSETS = ['webpack.assetCount', 'webpack.chunkCount'];
30
+ export const METRICS_WEBPACK_MODULES = ['webpack.moduleCount', 'webpack.duplicateModulesCount', 'webpack.duplicateCode'];
31
+ export const METRICS_WEBPACK_PACKAGES = ['webpack.packageCount', 'webpack.duplicatePackagesCount'];
@@ -1,18 +1,29 @@
1
+ @import url("~modern-css-reset/dist/reset.css");
2
+
1
3
  :root {
2
4
  --chart-height: 180px;
3
5
  }
4
6
 
7
+ /** modern-css-reset updates */
8
+ pre,
9
+ ul,
10
+ ol,
11
+ button {
12
+ margin: 0;
13
+ }
14
+
5
15
  html {
16
+ font-family: var(--font-family);
6
17
  font-size: 81.25%;
7
- line-height: 1.8461;
18
+ line-height: 1.6;
8
19
  }
9
20
 
10
21
  body {
22
+ background: var(--color-background);
11
23
  color: var(--color-text);
12
24
  }
13
25
 
14
- h1, h2, h3, h4, h5 {
15
- margin-bottom: var(--space-small);
26
+ h1, h2, h3, h4, h5, h6 {
16
27
  color: var(--color-heading);
17
28
  font-weight: 500;
18
29
  }
@@ -23,30 +23,30 @@
23
23
  --size-xxlarge: 1.424rem;
24
24
  --size-xxxlarge: 1.602rem;
25
25
 
26
- --line-height: var(--space-medium);
26
+ --line-height: 1.6em;
27
27
 
28
28
  /*
29
29
  * Color scheme:
30
- * http://mcg.mbitson.com/#!?mcgpalette0=%23dd555e&mcgpalette1=%2363bf5e&mcgpalette2=%23f7e37d&mcgpalette3=%23636568&mcgpalette4=%233385d6&themename=mcgtheme
31
30
  * https://coolors.co/3385d6-dd555e-63bf5e-f7e37d-192339
31
+ * http://mcg.mbitson.com/#!?mcgpalette0=%23dd555e&mcgpalette1=%2363bf5e&mcgpalette2=%23f7e37d&mcgpalette3=%235b5d60&mcgpalette4=%233385d6&themename=mcgtheme
32
32
  */
33
33
  --color-gray-25: #fafafa;
34
- --color-gray-50: #eceded;
35
- --color-gray-100: #d0d1d2;
36
- --color-gray-200: #b1b2b4;
37
- --color-gray-300: #929395;
38
- --color-gray-400: #7a7c7f;
39
- --color-gray-500: #636568;
40
- --color-gray-600: #5b5d60;
41
- --color-gray-700: #515355;
42
- --color-gray-800: #47494b;
43
- --color-gray-900: #35373a;
34
+ --color-gray-50: #e4e4e5;
35
+ --color-gray-100: #cececf;
36
+ --color-gray-200: #adaeb0;
37
+ --color-gray-300: #8c8e90;
38
+ --color-gray-400: #747578;
39
+ --color-gray-500: #5b5d60;
40
+ --color-gray-600: #535558;
41
+ --color-gray-700: #494b4e;
42
+ --color-gray-800: #404144;
43
+ --color-gray-900: #2f3033;
44
44
 
45
45
  --color-gray-ultra-light: var(--color-gray-200);
46
46
  --color-gray-light: var(--color-gray-300);
47
47
  --color-gray: var(--color-gray-500);
48
- --color-gray-dark: var(--color-gray-700);
49
- --color-gray-ultra-dark: var(--color-gray-900);
48
+ --color-gray-dark: var(--color-gray-600);
49
+ --color-gray-ultra-dark: var(--color-gray-700);
50
50
 
51
51
  --color-red-25: #fdf5f6;
52
52
  --color-red-50: #fbebec;
@@ -181,9 +181,9 @@
181
181
  --layer-high: 1000;
182
182
  --layer-xhigh: 10000;
183
183
 
184
- --radius-small: var(--space-xxxsmall);
185
- --radius-medium: var(--space-xxsmall);
186
- --radius-large: var(--space-small);
184
+ --radius-small: 3px;
185
+ --radius-medium: var(--space-xxxsmall);
186
+ --radius-large: var(--space-xxsmall);
187
187
 
188
188
  /** Layout */
189
189
  --max-width: 80rem;
@@ -6,9 +6,11 @@ const ACTION_SET_SEARCH = 'SET_SEARCH';
6
6
  const ACTION_RESET_DEFAULT = 'RESET_DEFAULT';
7
7
  const ACTION_RESET_ALL = 'RESET_ALL';
8
8
  const ACTION_SET = 'SET';
9
+ const SEARCH_DEFAULT = '';
10
+ const SEARCH_DEFAULT_PATTERN = /.*/;
9
11
 
10
12
  const getSearchPattern = search => {
11
- let searchPattern = /.*/;
13
+ let searchPattern = SEARCH_DEFAULT_PATTERN;
12
14
 
13
15
  if (!search || !search.trim()) {
14
16
  return searchPattern;
@@ -39,49 +41,46 @@ const getSearchReducer = _ref => {
39
41
  switch (type) {
40
42
  case ACTION_SET_FILTERS:
41
43
  {
42
- setParentState({
44
+ const newState = {
43
45
  filters: payload,
44
46
  search: state.search
45
- });
46
- return { ...state,
47
- filters: payload
48
47
  };
48
+ setParentState(newState);
49
+ return newState;
49
50
  }
50
51
 
51
52
  case ACTION_SET_SEARCH:
52
53
  {
53
- setParentState({
54
+ const newState = {
54
55
  filters: state.filters,
55
56
  search: payload
56
- });
57
- return { ...state,
58
- search: payload,
57
+ };
58
+ setParentState(newState);
59
+ return { ...newState,
59
60
  searchPattern: getSearchPattern(payload)
60
61
  };
61
62
  }
62
63
 
63
64
  case ACTION_RESET_DEFAULT:
64
65
  {
65
- setParentState({
66
- filters: defaultFilters,
67
- search: ''
68
- });
69
- return {
66
+ const newState = {
70
67
  filters: defaultFilters,
71
- search: '',
68
+ search: SEARCH_DEFAULT
69
+ };
70
+ setParentState(newState);
71
+ return { ...newState,
72
72
  searchPattern: getSearchPattern()
73
73
  };
74
74
  }
75
75
 
76
76
  case ACTION_RESET_ALL:
77
77
  {
78
- setParentState({
78
+ const newState = {
79
79
  filters: allEntriesFilters,
80
- search: ''
81
- });
82
- return {
83
- filters: allEntriesFilters,
84
- search: '',
80
+ search: SEARCH_DEFAULT
81
+ };
82
+ setParentState(newState);
83
+ return { ...newState,
85
84
  searchPattern: getSearchPattern()
86
85
  };
87
86
  }
@@ -104,7 +103,7 @@ export const generateState = (filters, search) => ({
104
103
  });
105
104
  export const useSearchParams = _ref2 => {
106
105
  let {
107
- search: parentSearch,
106
+ search: parentSearch = SEARCH_DEFAULT,
108
107
  filters: parentFilters,
109
108
  defaultFilters,
110
109
  allEntriesFilters,
@@ -124,7 +123,7 @@ export const useSearchParams = _ref2 => {
124
123
 
125
124
  useLayoutEffect(() => {
126
125
  // Run a deep comparison to prevent circular setState triggering
127
- if (parentSearch === search || _isEqual(parentFilters, filters)) {
126
+ if (parentSearch === search && _isEqual(initialFilters, filters)) {
128
127
  return;
129
128
  }
130
129
 
@@ -132,7 +131,7 @@ export const useSearchParams = _ref2 => {
132
131
  type: ACTION_SET,
133
132
  payload: generateState(initialFilters, parentSearch)
134
133
  });
135
- }, [search, filters, parentFilters, parentSearch]);
134
+ }, [dispatch, search, filters, parentSearch, initialFilters]);
136
135
  /** Callbacks */
137
136
 
138
137
  const handleUpdateSearch = useCallback(newValue => {
@@ -140,23 +139,23 @@ export const useSearchParams = _ref2 => {
140
139
  type: ACTION_SET_SEARCH,
141
140
  payload: newValue
142
141
  });
143
- }, []);
142
+ }, [dispatch]);
144
143
  const handleUpdateFilters = useCallback(newFilters => {
145
144
  dispatch({
146
145
  type: ACTION_SET_FILTERS,
147
146
  payload: newFilters
148
147
  });
149
- }, []);
148
+ }, [dispatch]);
150
149
  const handleResetFilters = useCallback(() => {
151
150
  dispatch({
152
151
  type: ACTION_RESET_DEFAULT
153
152
  });
154
- }, []);
153
+ }, [dispatch]);
155
154
  const handleResetAllFilters = useCallback(() => {
156
155
  dispatch({
157
156
  type: ACTION_RESET_ALL
158
157
  });
159
- }, []);
158
+ }, [dispatch]);
160
159
  return {
161
160
  search,
162
161
  searchPattern,
@@ -4,6 +4,15 @@
4
4
 
5
5
  .outline {
6
6
  border: 1px solid var(--color-outline);
7
+ border-radius: var(--radius-medium);
8
+ }
9
+
10
+ .outline > :first-child {
11
+ border-radius: var(--radius-medium) var(--radius-medium) 0 0;
12
+ }
13
+
14
+ .outline > :last-child {
15
+ border-radius: 0 0 var(--radius-medium) var(--radius-medium);
7
16
  }
8
17
 
9
18
  .padding-xxxsmall {
@@ -3,7 +3,7 @@
3
3
  }
4
4
 
5
5
  .inner {
6
- border-top: 2px solid var(--color-outline);
6
+ border-top: 1px solid var(--color-outline);
7
7
  }
8
8
 
9
9
  .navItem {
@@ -1,6 +1,7 @@
1
1
  export { Box } from './box';
2
2
  export { Footer } from './footer';
3
3
  export { Header } from './header';
4
+ export { Separator } from './separator';
4
5
  export { SubHeader } from './sub-header';
5
6
  export { Stack } from './stack';
6
7
  export { FlexStack } from './flex-stack';
@@ -0,0 +1,28 @@
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
+
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import cx from 'classnames';
6
+ import css from './separator.module.css';
7
+ const propTypes = {
8
+ className: PropTypes.string
9
+ };
10
+ const defaultProps = {
11
+ className: ''
12
+ };
13
+ /**
14
+ * @param {PropTypes.InferProps<typeof propTypes>} props
15
+ * @return {React.FunctionComponentElement}
16
+ */
17
+
18
+ export const Separator = props => {
19
+ const {
20
+ className,
21
+ ...restProps
22
+ } = props;
23
+ return /*#__PURE__*/React.createElement("div", _extends({
24
+ className: cx(css.root, className)
25
+ }, restProps));
26
+ };
27
+ Separator.propTypes = propTypes;
28
+ Separator.defaultProps = defaultProps;