@bundle-stats/ui 3.2.1-beta.9 → 3.3.0-alpha.0

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 (124) hide show
  1. package/CHANGELOG.md +47 -1
  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 +53 -0
  12. package/lib/components/budget-info/budget-info.module.css +28 -0
  13. package/lib/components/budget-info/budget-info.stories.js +42 -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 +45 -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/lighthouse-table/lighthouse-table.js +1 -1
  33. package/lib/components/metrics-table/metrics-table.js +1 -1
  34. package/lib/components/metrics-table-search/metrics-table-search.js +1 -1
  35. package/lib/components/metrics-table-search/metrics-table-search.stories.js +1 -1
  36. package/lib/components/summary/summary.js +40 -62
  37. package/lib/components/summary/summary.module.css +31 -14
  38. package/lib/components/summary/summary.stories.js +29 -0
  39. package/lib/components/summary-item/summary-item.js +30 -13
  40. package/lib/components/summary-item/summary-item.module.css +18 -9
  41. package/lib/components/summary-item/summary-item.stories.js +67 -52
  42. package/lib/constants.js +6 -6
  43. package/lib/css/variables.css +15 -11
  44. package/lib/hooks/search-params.js +2 -2
  45. package/lib/layout/box/box.js +2 -2
  46. package/lib/layout/stack/stack.js +13 -3
  47. package/lib/query-state.js +1 -1
  48. package/lib/stories/wrapper.js +2 -2
  49. package/lib/ui/alert/alert.js +13 -3
  50. package/lib/ui/filters/filters.container.js +5 -5
  51. package/lib/ui/filters/filters.js +2 -2
  52. package/lib/ui/filters/filters.stories.js +3 -3
  53. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +3 -3
  54. package/lib/ui/icon/icon.js +3 -0
  55. package/lib/ui/icon/icon.stories.js +40 -22
  56. package/lib/ui/panels/panels.js +2 -2
  57. package/lib/ui/popover/popover.js +3 -3
  58. package/lib/ui/popover/popover.module.css +2 -1
  59. package/lib/ui/tabs/tabs.js +2 -2
  60. package/lib/ui/tooltip/tooltip.module.css +1 -0
  61. package/lib/utils.js +2 -2
  62. package/lib-esm/app/app.js +57 -31
  63. package/lib-esm/app/app.stories.js +29 -1
  64. package/lib-esm/assets/icons/alert-circle.svg +1 -0
  65. package/lib-esm/assets/icons/arrow-right-circle.svg +1 -0
  66. package/lib-esm/assets/icons/check-circle.svg +1 -0
  67. package/lib-esm/assets/icons/close.svg +1 -1
  68. package/lib-esm/assets/icons.svg +50 -1
  69. package/lib-esm/components/budget-info/budget-info.js +37 -0
  70. package/lib-esm/components/budget-info/budget-info.module.css +28 -0
  71. package/lib-esm/components/budget-info/budget-info.stories.js +26 -0
  72. package/lib-esm/components/budget-info/index.js +1 -0
  73. package/lib-esm/components/budget-insights/budget-insights.js +147 -0
  74. package/lib-esm/components/budget-insights/budget-insights.module.css +53 -0
  75. package/lib-esm/components/budget-insights/budget-insights.stories.js +84 -0
  76. package/lib-esm/components/budget-insights/index.js +1 -0
  77. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +24 -7
  78. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  79. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +46 -21
  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/layout/box/box.js +2 -2
  89. package/lib-esm/layout/stack/stack.js +6 -3
  90. package/lib-esm/ui/alert/alert.js +6 -3
  91. package/lib-esm/ui/filters/filters.container.js +39 -41
  92. package/lib-esm/ui/icon/icon.js +3 -0
  93. package/lib-esm/ui/icon/icon.stories.js +22 -11
  94. package/lib-esm/ui/popover/popover.js +2 -2
  95. package/lib-esm/ui/popover/popover.module.css +2 -1
  96. package/lib-esm/ui/tooltip/tooltip.module.css +1 -0
  97. package/package.json +15 -15
  98. package/src/app/app.jsx +24 -8
  99. package/src/assets/icons/alert-circle.svg +1 -0
  100. package/src/assets/icons/arrow-right-circle.svg +1 -0
  101. package/src/assets/icons/check-circle.svg +1 -0
  102. package/src/assets/icons/close.svg +1 -1
  103. package/src/assets/icons.svg +50 -1
  104. package/src/components/budget-info/budget-info.jsx +49 -0
  105. package/src/components/budget-info/budget-info.module.css +28 -0
  106. package/src/components/budget-info/index.js +1 -0
  107. package/src/components/budget-insights/budget-insights.jsx +152 -0
  108. package/src/components/budget-insights/budget-insights.module.css +53 -0
  109. package/src/components/budget-insights/index.js +1 -0
  110. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +28 -13
  111. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  112. package/src/components/summary/summary.jsx +26 -44
  113. package/src/components/summary/summary.module.css +31 -14
  114. package/src/components/summary-item/summary-item.jsx +26 -24
  115. package/src/components/summary-item/summary-item.module.css +18 -9
  116. package/src/constants.js +7 -7
  117. package/src/css/variables.css +15 -11
  118. package/src/layout/box/box.jsx +1 -1
  119. package/src/layout/stack/stack.jsx +2 -2
  120. package/src/ui/alert/alert.jsx +7 -2
  121. package/src/ui/icon/icon.jsx +3 -0
  122. package/src/ui/popover/popover.jsx +3 -3
  123. package/src/ui/popover/popover.module.css +2 -1
  124. package/src/ui/tooltip/tooltip.module.css +1 -0
@@ -9,9 +9,10 @@ import { Stack } from '../../layout/stack';
9
9
  import { FlexStack } from '../../layout/flex-stack';
10
10
  import { Metric } from '../metric';
11
11
  import { Delta } from '../delta';
12
+ import { BudgetInfo } from '../budget-info';
12
13
  import css from './summary-item.module.css';
13
14
 
14
- const MetricInfo = ({ description, url }) => {
15
+ const MetricInfoPopover = ({ description, url }) => {
15
16
  // Workaround cases where the parent is a link
16
17
  const readMoreOnClick = () => {
17
18
  window.open(url);
@@ -31,12 +32,12 @@ const MetricInfo = ({ description, url }) => {
31
32
  );
32
33
  };
33
34
 
34
- MetricInfo.propTypes = {
35
+ MetricInfoPopover.propTypes = {
35
36
  description: PropTypes.string.isRequired,
36
37
  url: PropTypes.string,
37
38
  };
38
39
 
39
- MetricInfo.defaultProps = {
40
+ MetricInfoPopover.defaultProps = {
40
41
  url: '',
41
42
  };
42
43
 
@@ -49,6 +50,7 @@ export const SummaryItem = ({
49
50
  loading,
50
51
  showDelta,
51
52
  showMetricDescription,
53
+ budget,
52
54
  ...props
53
55
  }) => {
54
56
  const { baseline, current } = data || { baseline: 0, current: 0 };
@@ -56,30 +58,24 @@ export const SummaryItem = ({
56
58
  const metric = getGlobalMetricType(id);
57
59
  const runInfo = getMetricRunInfo(metric, current, baseline);
58
60
  const showMetricDescriptionTooltip = showMetricDescription && metric?.description;
59
-
60
- const rootClassName = cx(
61
- css.root,
62
- className,
63
- css[size],
64
- showMetricDescription && css.showMetricDescription,
65
- showMetricDescriptionTooltip && css.showMetricDescription,
66
- showDelta && css.showDelta,
67
- );
61
+ const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
68
62
 
69
63
  return (
70
64
  <Stack space="xxsmall" as={Component} className={rootClassName} {...props}>
71
65
  <FlexStack as="h3" space="xxxsmall" className={css.title}>
72
- <span>{metric.label}</span>
66
+ <span className={css.titleLabel}>{metric.label}</span>
73
67
 
74
68
  {showMetricDescriptionTooltip && (
75
69
  <Popover className={css.icon} icon="help">
76
- <MetricInfo {...metric} />
70
+ <MetricInfoPopover {...metric} />
77
71
  </Popover>
78
72
  )}
73
+
74
+ {budget && <BudgetInfo className={css.budgetInfo} metric={metric} budget={budget} />}
79
75
  </FlexStack>
80
76
 
81
- <Stack>
82
- {!loading ? (
77
+ {!loading ? (
78
+ <Stack>
83
79
  <Metric
84
80
  className={css.currentMetric}
85
81
  value={current}
@@ -95,16 +91,14 @@ export const SummaryItem = ({
95
91
  />
96
92
  )}
97
93
  </Metric>
98
- ) : (
99
- <Skeleton className={cx(css.currentMetric, css.loading)} />
100
- )}
101
-
102
- {!loading ? (
103
94
  <Metric className={css.baselineMetric} value={baseline} formatter={metric.formatter} />
104
- ) : (
95
+ </Stack>
96
+ ) : (
97
+ <Stack>
98
+ <Skeleton className={cx(css.currentMetric, css.loading)} />
105
99
  <Skeleton className={cx(css.baselineMetric, css.loading)} />
106
- )}
107
- </Stack>
100
+ </Stack>
101
+ )}
108
102
  </Stack>
109
103
  );
110
104
  };
@@ -117,6 +111,7 @@ SummaryItem.defaultProps = {
117
111
  loading: false,
118
112
  showMetricDescription: false,
119
113
  showDelta: true,
114
+ budget: undefined,
120
115
  };
121
116
 
122
117
  SummaryItem.propTypes = {
@@ -143,4 +138,11 @@ SummaryItem.propTypes = {
143
138
 
144
139
  /** Show delta */
145
140
  showDelta: PropTypes.bool,
141
+
142
+ /** Budget data */
143
+ budget: PropTypes.shape({
144
+ value: PropTypes.number,
145
+ budget: PropTypes.number,
146
+ overBudget: PropTypes.bool,
147
+ }),
146
148
  };
@@ -1,5 +1,9 @@
1
+ .root {
2
+ position: relative;
3
+ padding-right: var(--space-xlarge);
4
+ }
5
+
1
6
  .title {
2
- margin: 0;
3
7
  color: var(--color-text-ultra-light);
4
8
  font-weight: bold;
5
9
  font-size: var(--size-xsmall);
@@ -8,6 +12,10 @@
8
12
  white-space: nowrap;
9
13
  }
10
14
 
15
+ .titleLabel {
16
+ flex: 0 0 auto;
17
+ }
18
+
11
19
  .readMoreBtn {
12
20
  appearance: none;
13
21
  padding: 0;
@@ -27,24 +35,30 @@
27
35
  text-decoration: none;
28
36
  }
29
37
 
38
+ .budgetInfo {
39
+ position: absolute;
40
+ right: 0;
41
+ top: 0;
42
+ }
43
+
30
44
  .currentMetric {
31
45
  display: block;
32
46
  color: var(--color-heading);
33
47
  font-size: var(--size-large);
34
- line-height: 1.3;
48
+ line-height: var(--space-medium);
35
49
  white-space: nowrap;
36
50
  font-weight: bold;
37
51
  }
38
52
 
39
53
  .delta {
40
- margin: var(--space-xxxsmall) 0 0;
41
54
  font-size: var(--size-small);
55
+ line-height: var(--space-medium);
42
56
  }
43
57
 
44
58
  .baselineMetric {
45
59
  color: var(--color-text-light);
46
60
  font-size: var(--size-small);
47
- line-height: 1.3;
61
+ line-height: var(--space-small);
48
62
  }
49
63
 
50
64
  /* Loading state */
@@ -60,9 +74,4 @@
60
74
  .large .currentMetric {
61
75
  font-size: var(--size-xxxlarge);
62
76
  line-height: var(--space-medium);
63
- min-height: var(--space-medium);
64
- }
65
-
66
- .large .baselineMetric {
67
- font-size: var(--size-medium);
68
77
  }
package/src/constants.js CHANGED
@@ -47,11 +47,11 @@ export const ASSETS_SIZES_FILE_TYPE_MAP = FILE_TYPES.reduce(
47
47
  );
48
48
 
49
49
  export const METRICS_WEBPACK_GENERAL = [
50
- 'webpack.totalSizeByTypeALL',
51
- 'webpack.totalInitialSizeJS',
52
- 'webpack.totalInitialSizeCSS',
53
- 'webpack.cacheInvalidation',
50
+ 'totalSizeByTypeALL',
51
+ 'totalInitialSizeJS',
52
+ 'totalInitialSizeCSS',
53
+ 'cacheInvalidation',
54
54
  ];
55
- export const METRICS_WEBPACK_ASSETS = ['webpack.assetCount', 'webpack.chunkCount'];
56
- export const METRICS_WEBPACK_MODULES = ['webpack.moduleCount'];
57
- export const METRICS_WEBPACK_PACKAGES = ['webpack.packageCount', 'webpack.duplicatePackagesCount'];
55
+ export const METRICS_WEBPACK_ASSETS = ['assetCount', 'chunkCount'];
56
+ export const METRICS_WEBPACK_MODULES = ['moduleCount'];
57
+ export const METRICS_WEBPACK_PACKAGES = ['packageCount', 'duplicatePackagesCount'];
@@ -27,20 +27,20 @@
27
27
 
28
28
  /*
29
29
  * Color scheme:
30
- * http://mcg.mbitson.com/#!?mcgpalette0=%23dd555e&mcgpalette1=%2363bf5e&mcgpalette2=%23f7e37d&mcgpalette3=%23484a4d&mcgpalette4=%233385d6&themename=mcgtheme
30
+ * http://mcg.mbitson.com/#!?mcgpalette0=%23dd555e&mcgpalette1=%2363bf5e&mcgpalette2=%23f7e37d&mcgpalette3=%23636568&mcgpalette4=%233385d6&themename=mcgtheme
31
31
  * https://coolors.co/3385d6-dd555e-63bf5e-f7e37d-192339
32
32
  */
33
33
  --color-gray-25: #fafafa;
34
- --color-gray-50: #e9e9ea;
35
- --color-gray-100: #c8c9ca;
36
- --color-gray-200: #a4a5a6;
37
- --color-gray-300: #7f8082;
38
- --color-gray-400: #636568;
39
- --color-gray-500: #484a4d;
40
- --color-gray-600: #414346;
41
- --color-gray-700: #383a3d;
42
- --color-gray-800: #303234;
43
- --color-gray-900: #212225;
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;
44
44
 
45
45
  --color-gray-ultra-light: var(--color-gray-200);
46
46
  --color-gray-light: var(--color-gray-300);
@@ -181,6 +181,10 @@
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);
187
+
184
188
  /** Layout */
185
189
  --max-width: 80rem;
186
190
  }
@@ -31,7 +31,7 @@ export const Box = (props) => {
31
31
  outline && css.outline,
32
32
  );
33
33
 
34
- return <Component className={rootClassName} {...restProps} />;
34
+ return <Component {...restProps} className={rootClassName} />;
35
35
  };
36
36
 
37
37
  Box.defaultProps = {
@@ -7,11 +7,11 @@ import { getRenderChildWithClassName } from '../../utils';
7
7
  import css from './stack.module.css';
8
8
 
9
9
  export const Stack = (props) => {
10
- const { as: Component, className, space, children } = props;
10
+ const { as: Component, className, space, children, ...restProps } = props;
11
11
  const rootClassName = cx(className, css.root, css[`space--${space}`]);
12
12
 
13
13
  return (
14
- <Component className={rootClassName}>
14
+ <Component {...restProps} className={rootClassName}>
15
15
  {React.Children.map(children, getRenderChildWithClassName(css.item))}
16
16
  </Component>
17
17
  );
@@ -6,10 +6,15 @@ import { Box } from '../../layout/box';
6
6
  import css from './alert.module.css';
7
7
 
8
8
  export const Alert = (props) => {
9
- const { className, kind, children } = props;
9
+ const { className, kind, children, ...restProps } = props;
10
10
 
11
11
  return (
12
- <Box padding={['xsmall', 'small']} outline className={cx(css.root, className, css[kind])}>
12
+ <Box
13
+ padding={['xsmall', 'small']}
14
+ outline
15
+ className={cx(css.root, className, css[kind])}
16
+ {...restProps}
17
+ >
13
18
  {children}
14
19
  </Box>
15
20
  );
@@ -5,10 +5,13 @@ import cx from 'classnames';
5
5
  import css from './icon.module.css';
6
6
 
7
7
  const ICONS = {
8
+ ALERT_CIRCLE: 'alert-circle',
8
9
  ARROW: 'arrow',
10
+ ARROW_RIGHT_CIRLCE: 'arrow-right-circle',
9
11
  CANCEL: 'cancel',
10
12
  CLOSE: 'close',
11
13
  CLOCK: 'clock',
14
+ CHECK_CIRCLE: 'check-circle',
12
15
  COMMIT: 'commit',
13
16
  FILTER: 'filter',
14
17
  HELP: 'help',
@@ -14,7 +14,7 @@ import css from './popover.module.css';
14
14
  export const Popover = ({ className, icon, label, ariaLabel, children }) => {
15
15
  const popover = usePopoverState({
16
16
  baseId: process.env.NODE_ENV === 'test' && 'id-test',
17
- gutter: 24,
17
+ gutter: 12,
18
18
  modal: true,
19
19
  placement: 'top',
20
20
  });
@@ -32,7 +32,7 @@ export const Popover = ({ className, icon, label, ariaLabel, children }) => {
32
32
  event.preventDefault();
33
33
  popover.toggle();
34
34
  },
35
- [popover]
35
+ [popover],
36
36
  );
37
37
 
38
38
  return (
@@ -47,7 +47,7 @@ export const Popover = ({ className, icon, label, ariaLabel, children }) => {
47
47
  {label && <span className={css.label}>{label}</span>}
48
48
  </UIPopoverDisclosure>
49
49
  <UIPopover className={css.popover} {...popover} tabIndex={0}>
50
- <UIPopoverArrow className={css.arrow} {...popover} size={24} />
50
+ <UIPopoverArrow className={css.arrow} {...popover} size={16} />
51
51
 
52
52
  {typeof children === 'function' ? children({ popoverToggle: popover.toggle }) : children}
53
53
 
@@ -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));
@@ -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));