@bundle-stats/ui 3.4.0-alpha.5 → 4.0.0-alpha.7

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 (143) hide show
  1. package/lib/app/app.js +6 -21
  2. package/lib/app/app.stories.js +1 -22
  3. package/lib/assets/icons.svg +0 -8
  4. package/lib/components/asset-info/asset-info.js +1 -1
  5. package/lib/components/bundle-assets/bundle-assets.js +1 -1
  6. package/lib/components/bundle-assets/index.js +1 -1
  7. package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
  8. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +8 -44
  9. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  10. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
  11. package/lib/components/bundle-modules/bundle-modules.js +1 -1
  12. package/lib/components/bundle-modules/index.js +1 -1
  13. package/lib/components/bundle-packages/bundle-packages.js +1 -1
  14. package/lib/components/bundle-packages/index.js +1 -1
  15. package/lib/components/component-link.js +1 -1
  16. package/lib/components/index.js +0 -8
  17. package/lib/components/job-meta/job-meta.js +1 -1
  18. package/lib/components/job-name/job-name.js +1 -1
  19. package/lib/components/metrics-table/metrics-table.js +1 -1
  20. package/lib/components/metrics-table-options/metrics-table-options.js +1 -1
  21. package/lib/components/module-info/module-info.js +1 -1
  22. package/lib/components/summary/summary.js +13 -24
  23. package/lib/components/summary/summary.module.css +1 -45
  24. package/lib/components/summary/summary.stories.js +1 -30
  25. package/lib/components/summary-item/summary-item.js +14 -37
  26. package/lib/components/summary-item/summary-item.module.css +25 -13
  27. package/lib/components/summary-item/summary-item.stories.js +53 -51
  28. package/lib/constants.js +4 -4
  29. package/lib/layout/box/box.js +1 -1
  30. package/lib/layout/flex-stack/flex-stack.js +1 -1
  31. package/lib/layout/footer/footer.js +1 -1
  32. package/lib/layout/separator.js +1 -1
  33. package/lib/layout/stack/stack.js +1 -1
  34. package/lib/query-state.js +1 -1
  35. package/lib/ui/alert/alert.js +3 -13
  36. package/lib/ui/container/container.js +1 -1
  37. package/lib/ui/filters/filters.container.js +3 -3
  38. package/lib/ui/filters/filters.js +1 -1
  39. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +2 -2
  40. package/lib/ui/hover-card/hover-card.js +8 -2
  41. package/lib/ui/hover-card/hover-card.stories.js +1 -1
  42. package/lib/ui/icon/icon.js +1 -3
  43. package/lib/ui/input/input.js +1 -1
  44. package/lib/ui/loader/loader.js +1 -1
  45. package/lib/ui/logo/logo.js +1 -1
  46. package/lib/ui/panels/panels.js +1 -1
  47. package/lib/ui/skeleton/skeleton.js +1 -1
  48. package/lib/ui/sort-dropdown/sort-dropdown.js +1 -1
  49. package/lib/ui/tag/tag.js +1 -1
  50. package/lib/ui/tooltip/tooltip.js +1 -1
  51. package/lib-esm/app/app.js +6 -20
  52. package/lib-esm/app/app.stories.js +1 -22
  53. package/lib-esm/assets/icons.svg +0 -8
  54. package/lib-esm/components/asset-info/asset-info.js +1 -1
  55. package/lib-esm/components/bundle-assets/bundle-assets.js +1 -1
  56. package/lib-esm/components/bundle-assets/bundle-assets.utils.js +1 -0
  57. package/lib-esm/components/bundle-assets/index.js +1 -1
  58. package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
  59. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +8 -25
  60. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  61. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
  62. package/lib-esm/components/bundle-modules/bundle-modules.js +1 -1
  63. package/lib-esm/components/bundle-modules/index.js +1 -1
  64. package/lib-esm/components/bundle-packages/bundle-packages.js +1 -1
  65. package/lib-esm/components/bundle-packages/bundle-packages.utils.js +1 -0
  66. package/lib-esm/components/bundle-packages/index.js +1 -1
  67. package/lib-esm/components/component-link.js +1 -1
  68. package/lib-esm/components/index.js +0 -1
  69. package/lib-esm/components/job-meta/job-meta.js +1 -1
  70. package/lib-esm/components/job-name/job-name.js +1 -1
  71. package/lib-esm/components/metrics-table/metrics-table.js +1 -1
  72. package/lib-esm/components/metrics-table-options/metrics-table-options.js +1 -1
  73. package/lib-esm/components/module-info/module-info.js +1 -1
  74. package/lib-esm/components/summary/summary.js +14 -22
  75. package/lib-esm/components/summary/summary.module.css +1 -45
  76. package/lib-esm/components/summary/summary.stories.js +1 -28
  77. package/lib-esm/components/summary-item/summary-item.js +11 -33
  78. package/lib-esm/components/summary-item/summary-item.module.css +25 -13
  79. package/lib-esm/components/summary-item/summary-item.stories.js +38 -50
  80. package/lib-esm/constants.js +4 -4
  81. package/lib-esm/layout/box/box.js +1 -1
  82. package/lib-esm/layout/flex-stack/flex-stack.js +1 -1
  83. package/lib-esm/layout/footer/footer.js +1 -1
  84. package/lib-esm/layout/separator.js +1 -1
  85. package/lib-esm/layout/stack/stack.js +1 -1
  86. package/lib-esm/query-state.js +1 -1
  87. package/lib-esm/ui/alert/alert.js +3 -6
  88. package/lib-esm/ui/container/container.js +1 -1
  89. package/lib-esm/ui/filters/filters.container.js +1 -1
  90. package/lib-esm/ui/filters/filters.js +2 -1
  91. package/lib-esm/ui/hover-card/hover-card.js +8 -2
  92. package/lib-esm/ui/hover-card/hover-card.stories.js +1 -1
  93. package/lib-esm/ui/icon/icon.js +1 -3
  94. package/lib-esm/ui/input/input.js +1 -1
  95. package/lib-esm/ui/loader/loader.js +1 -1
  96. package/lib-esm/ui/logo/logo.js +1 -1
  97. package/lib-esm/ui/panels/panels.js +1 -1
  98. package/lib-esm/ui/skeleton/skeleton.js +1 -1
  99. package/lib-esm/ui/sort-dropdown/sort-dropdown.js +1 -1
  100. package/lib-esm/ui/tag/tag.js +1 -1
  101. package/lib-esm/ui/tooltip/tooltip.js +1 -1
  102. package/package.json +26 -26
  103. package/src/app/app.jsx +5 -12
  104. package/src/assets/icons.svg +0 -8
  105. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -27
  106. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  107. package/src/components/index.js +0 -1
  108. package/src/components/summary/summary.jsx +19 -24
  109. package/src/components/summary/summary.module.css +1 -45
  110. package/src/components/summary-item/summary-item.jsx +10 -23
  111. package/src/components/summary-item/summary-item.module.css +25 -13
  112. package/src/constants.js +11 -7
  113. package/src/ui/alert/alert.jsx +2 -7
  114. package/src/ui/hover-card/hover-card.jsx +5 -0
  115. package/src/ui/icon/icon.jsx +0 -2
  116. package/lib/assets/icons/alert-circle.svg +0 -1
  117. package/lib/assets/icons/check-circle.svg +0 -1
  118. package/lib/components/budget-info/budget-info.js +0 -80
  119. package/lib/components/budget-info/budget-info.module.css +0 -40
  120. package/lib/components/budget-info/budget-info.stories.js +0 -44
  121. package/lib/components/budget-info/index.js +0 -18
  122. package/lib/components/budget-insights/budget-insights.js +0 -200
  123. package/lib/components/budget-insights/budget-insights.module.css +0 -53
  124. package/lib/components/budget-insights/budget-insights.stories.js +0 -104
  125. package/lib/components/budget-insights/index.js +0 -18
  126. package/lib-esm/assets/icons/alert-circle.svg +0 -1
  127. package/lib-esm/assets/icons/check-circle.svg +0 -1
  128. package/lib-esm/components/budget-info/budget-info.js +0 -58
  129. package/lib-esm/components/budget-info/budget-info.module.css +0 -40
  130. package/lib-esm/components/budget-info/budget-info.stories.js +0 -30
  131. package/lib-esm/components/budget-info/index.js +0 -1
  132. package/lib-esm/components/budget-insights/budget-insights.js +0 -148
  133. package/lib-esm/components/budget-insights/budget-insights.module.css +0 -53
  134. package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -84
  135. package/lib-esm/components/budget-insights/index.js +0 -1
  136. package/src/assets/icons/alert-circle.svg +0 -1
  137. package/src/assets/icons/check-circle.svg +0 -1
  138. package/src/components/budget-info/budget-info.jsx +0 -65
  139. package/src/components/budget-info/budget-info.module.css +0 -40
  140. package/src/components/budget-info/index.js +0 -1
  141. package/src/components/budget-insights/budget-insights.jsx +0 -157
  142. package/src/components/budget-insights/budget-insights.module.css +0 -53
  143. package/src/components/budget-insights/index.js +0 -1
package/src/app/app.jsx CHANGED
@@ -13,7 +13,6 @@ import {
13
13
  import { Box } from '../layout/box';
14
14
  import { Container } from '../ui/container';
15
15
  import { DuplicatePackagesWarning } from '../components/duplicate-packages-warning';
16
- import { BudgetInsights } from '../components/budget-insights';
17
16
  import { Summary } from '../components/summary';
18
17
  import { BundleAssets } from '../components/bundle-assets';
19
18
  import { BundleAssetsTotalsChartBars } from '../components/bundle-assets-totals-chart-bars';
@@ -78,13 +77,10 @@ const OverviewContent = () => {
78
77
  <Stack space="medium">
79
78
  {duplicatePackagesInsights && (
80
79
  <Container>
81
- <Stack space="small">
82
- <DuplicatePackagesWarning
83
- duplicatePackagesCount={duplicatePackagesCount}
84
- showDelta={jobs.length > 1}
85
- />
86
- <BudgetInsights source="webpack" budgets={jobs[0].insights?.webpack?.budgets} />
87
- </Stack>
80
+ <DuplicatePackagesWarning
81
+ duplicatePackagesCount={duplicatePackagesCount}
82
+ showDelta={jobs.length > 1}
83
+ />
88
84
  </Container>
89
85
  )}
90
86
  <Container>
@@ -108,7 +104,6 @@ const AssetsContent = () => {
108
104
  <Summary
109
105
  keys={METRICS_WEBPACK_ASSETS}
110
106
  data={jobs?.[0]?.summary}
111
- budgets={jobs[0].insights?.webpack?.budgets}
112
107
  showSummaryItemDelta={jobs?.length !== 1}
113
108
  />
114
109
  <Box outline>
@@ -131,7 +126,6 @@ const ModulesContent = () => {
131
126
  <Summary
132
127
  keys={METRICS_WEBPACK_MODULES}
133
128
  data={jobs?.[0]?.summary}
134
- budgets={jobs[0].insights?.webpack?.budgets}
135
129
  showSummaryItemDelta={jobs?.length !== 1}
136
130
  />
137
131
  <Box outline>
@@ -154,7 +148,6 @@ const PackagesContent = () => {
154
148
  <Summary
155
149
  keys={METRICS_WEBPACK_PACKAGES}
156
150
  data={jobs?.[0]?.summary}
157
- budgets={jobs[0].insights?.webpack?.budgets}
158
151
  showSummaryItemDelta={jobs?.length !== 1}
159
152
  />
160
153
  <Box outline>
@@ -184,10 +177,10 @@ const AppComponent = ({ version, jobs }) => {
184
177
  size="large"
185
178
  keys={METRICS_WEBPACK_GENERAL}
186
179
  data={jobs[0].summary}
187
- budgets={jobs[0].insights?.webpack?.budgets}
188
180
  showSummaryItemDelta={jobs.length !== 1}
189
181
  />
190
182
  </Container>
183
+
191
184
  <Container className={css.tabsContainer}>
192
185
  <Tabs className={css.tabs}>
193
186
  <NavLink exact to={URLS.OVERVIEW} activeClassName={css.tabActive}>
@@ -1,8 +1,4 @@
1
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
2
  <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
3
  <path d="M12 5v14M19 12l-7 7-7-7"/>
8
4
  </symbol>
@@ -14,10 +10,6 @@
14
10
  <circle cx="12" cy="12" r="10"/>
15
11
  <path d="M15 9l-6 6M9 9l6 6"/>
16
12
  </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
13
  <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
14
  <circle cx="12" cy="12" r="10"/>
23
15
  <path d="M12 6v6l4 2"/>
@@ -1,15 +1,11 @@
1
- import React, { useCallback, useMemo } from 'react';
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { get } from 'lodash';
4
3
  import { getBundleAssetsFileTypeComponentLink } from '@bundle-stats/utils';
5
4
  import * as webpack from '@bundle-stats/utils/lib-esm/webpack';
6
5
 
7
6
  import { ASSETS_SIZES_FILE_TYPE_MAP } from '../../constants';
8
- import { FlexStack } from '../../layout/flex-stack';
9
7
  import { MetricsTable } from '../metrics-table';
10
8
  import { ComponentLink } from '../component-link';
11
- import { BudgetInfo } from '../budget-info';
12
- import css from './bundle-assets-totals-table.module.css';
13
9
 
14
10
  export const BundleAssetsTotalsTable = ({
15
11
  className,
@@ -17,28 +13,18 @@ export const BundleAssetsTotalsTable = ({
17
13
  customComponentLink: CustomComponentLink,
18
14
  ...restProps
19
15
  }) => {
20
- const items = useMemo(() => webpack.compareBySection.sizes(jobs), [jobs]);
21
- const budgets = jobs[0].insights?.webpack?.budgets;
22
-
23
- const renderRowHeader = useCallback(
24
- (item) => {
25
- const fileType = ASSETS_SIZES_FILE_TYPE_MAP[item.key];
26
- const { section, title, params } = getBundleAssetsFileTypeComponentLink(fileType, item.label);
27
- const [_, ...metricSlugs] = item.key.split('.');
28
- const metricKey = metricSlugs.join('.');
29
- const budget = get(budgets, metricKey);
30
-
31
- return (
32
- <CustomComponentLink section={section} title={title} params={params}>
33
- <FlexStack space="xxsmall" className={css.itemTitleText}>
34
- <span>{item.label}</span>
35
- {budget && <BudgetInfo metricId={item.key} budgetInsight={budget} />}
36
- </FlexStack>
37
- </CustomComponentLink>
38
- );
39
- },
40
- [CustomComponentLink],
41
- );
16
+ const items = webpack.compareBySection.sizes(jobs);
17
+
18
+ const renderRowHeader = (item) => {
19
+ const fileType = ASSETS_SIZES_FILE_TYPE_MAP[item.key];
20
+ const { section, title, params } = getBundleAssetsFileTypeComponentLink(fileType, item.label);
21
+
22
+ return (
23
+ <CustomComponentLink section={section} title={title} params={params}>
24
+ {item.label}
25
+ </CustomComponentLink>
26
+ );
27
+ };
42
28
 
43
29
  return (
44
30
  <MetricsTable
@@ -1,3 +1,3 @@
1
- .itemTitleText {
2
- align-items: center;
1
+ .title {
2
+ color: var(--color-text-light);
3
3
  }
@@ -4,7 +4,6 @@ export { BundleAssetsTotalsTable } from './bundle-assets-totals-table';
4
4
  export { BundleAssetsTotalsChartBars } from './bundle-assets-totals-chart-bars';
5
5
  export { BundlePackages } from './bundle-packages';
6
6
  export { BundleModules } from './bundle-modules';
7
- export { BudgetInsights } from './budget-insights';
8
7
  export { ComponentLink } from './component-link';
9
8
  export { DuplicatePackagesWarning } from './duplicate-packages-warning';
10
9
  export { Delta } from './delta';
@@ -5,21 +5,17 @@ import { get } from 'lodash';
5
5
  import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
6
6
 
7
7
  import { METRICS_WEBPACK_GENERAL } from '../../constants';
8
- import { Icon } from '../../ui/icon';
9
8
  import { Box } from '../../layout/box';
10
9
  import { FlexStack } from '../../layout/flex-stack';
11
10
  import { ComponentLink } from '../component-link';
12
11
  import { SummaryItem } from '../summary-item';
13
12
  import css from './summary.module.css';
14
13
 
15
- const getSourceMetricId = (fullMetricId) => fullMetricId.split('.').slice(1).join('.');
16
-
17
14
  export const Summary = ({
18
15
  className,
19
16
  size,
20
17
  keys,
21
18
  data,
22
- budgets,
23
19
  loading,
24
20
  showSummaryItemDelta,
25
21
  summaryItemLink: SummaryItemCustomLink,
@@ -27,24 +23,20 @@ export const Summary = ({
27
23
  <Box outline className={cx(css.root, className)}>
28
24
  <FlexStack className={css.items}>
29
25
  {Array.from(METRIC_COMPONENT_LINKS)
30
- .filter(([metricId]) => keys.includes(getSourceMetricId(metricId)))
26
+ .filter(([metricId]) => keys.includes(metricId))
31
27
  .map(([metricId, metricOptions]) => (
32
- <div key={metricId} className={css.item}>
33
- <SummaryItem
34
- size={size}
35
- id={metricId}
36
- data={get(data, metricId)}
37
- budget={get(budgets, getSourceMetricId(metricId))}
38
- loading={loading}
39
- showMetricDescription
40
- showDelta={showSummaryItemDelta && metricOptions.showDelta !== false}
41
- />
42
- {!loading && (
43
- <SummaryItemCustomLink {...metricOptions.link} className={css.readMore}>
44
- <Icon className={css.readMoreIcon} glyph={Icon.ICONS.ARROW_RIGHT_CIRLCE} />
45
- </SummaryItemCustomLink>
46
- )}
47
- </div>
28
+ <SummaryItem
29
+ key={metricId}
30
+ className={css.item}
31
+ as={SummaryItemCustomLink}
32
+ {...metricOptions.link}
33
+ size={size}
34
+ id={metricId}
35
+ data={get(data, metricId)}
36
+ loading={loading}
37
+ showMetricDescription
38
+ showDelta={showSummaryItemDelta && metricOptions.showDelta !== false}
39
+ />
48
40
  ))}
49
41
  </FlexStack>
50
42
  </Box>
@@ -53,7 +45,6 @@ export const Summary = ({
53
45
  Summary.defaultProps = {
54
46
  className: '',
55
47
  data: null,
56
- budgets: null,
57
48
  loading: false,
58
49
  size: '',
59
50
  keys: METRICS_WEBPACK_GENERAL,
@@ -65,8 +56,12 @@ Summary.propTypes = {
65
56
  className: PropTypes.string,
66
57
  size: PropTypes.string,
67
58
  keys: PropTypes.arrayOf(PropTypes.string),
68
- data: PropTypes.object, // eslint-disable-line react/forbid-prop-types
69
- budgets: PropTypes.object, // eslint-disable-line react/forbid-prop-types
59
+ data: PropTypes.shape({
60
+ [PropTypes.string]: PropTypes.shape({
61
+ baseline: PropTypes.number,
62
+ current: PropTypes.number,
63
+ }),
64
+ }),
70
65
  loading: PropTypes.bool,
71
66
  showSummaryItemDelta: PropTypes.bool,
72
67
  summaryItemLink: PropTypes.elementType,
@@ -6,49 +6,5 @@
6
6
  .item {
7
7
  padding: var(--space-small);
8
8
  flex: 1 0 25%; /* force equal sizes */
9
- position: relative;
10
- z-index: 1;
11
- }
12
-
13
- .item::before {
14
- content: '';
15
- display: block;
16
- width: 1px;
17
- position: absolute;
18
- left: -1px;
19
- top: var(--space-small);
20
- bottom: var(--space-small);
21
- background: var(--color-outline);
22
- }
23
-
24
- .readMore {
25
- display: block;
26
- position: absolute;
27
- right: 0;
28
- bottom: 0;
29
- padding: var(--space-small);
30
- color: var(--color-text-ultra-light);
31
- transition: var(--transition-out);
32
- }
33
-
34
- .readMore:hover,
35
- .readMore:focus {
36
- color: var(--color-primary);
37
- transition: var(--transition-in);
38
- }
39
-
40
- .readMoreIcon {
41
- display: block;
42
- }
43
-
44
- /** hover state */
45
- .readMore {
46
- opacity: 0;
47
- }
48
-
49
- .item:hover .readMore,
50
- .item:active .readMore,
51
- .item:focus .readMore {
52
- opacity: 1;
53
- transition: var(--transition-in);
9
+ text-decoration: none;
54
10
  }
@@ -4,13 +4,10 @@ import cx from 'classnames';
4
4
  import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
5
5
 
6
6
  import { HoverCard } from '../../ui/hover-card';
7
- import { Icon } from '../../ui/icon';
8
7
  import { Skeleton } from '../../ui/skeleton';
9
8
  import { Stack } from '../../layout/stack';
10
- import { FlexStack } from '../../layout/flex-stack';
11
9
  import { Metric } from '../metric';
12
10
  import { Delta } from '../delta';
13
- import { BudgetInfo } from '../budget-info';
14
11
  import css from './summary-item.module.css';
15
12
 
16
13
  const MetricInfo = ({ description, url }) => (
@@ -18,9 +15,9 @@ const MetricInfo = ({ description, url }) => (
18
15
  <p>{description}</p>
19
16
  {url && (
20
17
  <p>
21
- <a href={url} className={css.readMoreLink}>
18
+ <button type="button" onClick={() => window.open(url)} className={css.readMoreLink}>
22
19
  Read more
23
- </a>
20
+ </button>
24
21
  </p>
25
22
  )}
26
23
  </Stack>
@@ -44,7 +41,6 @@ export const SummaryItem = ({
44
41
  loading,
45
42
  showDelta,
46
43
  showMetricDescription,
47
- budget,
48
44
  ...props
49
45
  }) => {
50
46
  const { baseline, current } = data || { baseline: 0, current: 0 };
@@ -52,21 +48,20 @@ export const SummaryItem = ({
52
48
  const metric = getGlobalMetricType(id);
53
49
  const runInfo = getMetricRunInfo(metric, current, baseline);
54
50
  const showMetricDescriptionTooltip = showMetricDescription && metric?.description;
51
+
55
52
  const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
56
53
 
57
54
  return (
58
- <Stack space="xxxsmall" as={Component} className={rootClassName} {...props}>
59
- <FlexStack as="h3" space="xxxsmall" className={css.title}>
60
- <span className={css.titleLabel}>{metric.label}</span>
61
-
62
- {showMetricDescriptionTooltip && (
63
- <HoverCard className={css.icon} label={<Icon glyph="help" />}>
55
+ <Stack space="xxsmall" as={Component} className={rootClassName} {...props}>
56
+ <h3 className={css.title}>
57
+ {showMetricDescriptionTooltip ? (
58
+ <HoverCard label={metric.label}>
64
59
  <MetricInfo {...metric} />
65
60
  </HoverCard>
61
+ ) : (
62
+ metric.label
66
63
  )}
67
-
68
- {budget && <BudgetInfo className={css.budgetInfo} metricId={id} budgetInsight={budget} />}
69
- </FlexStack>
64
+ </h3>
70
65
 
71
66
  {!loading ? (
72
67
  <Stack>
@@ -105,7 +100,6 @@ SummaryItem.defaultProps = {
105
100
  loading: false,
106
101
  showMetricDescription: false,
107
102
  showDelta: true,
108
- budget: undefined,
109
103
  };
110
104
 
111
105
  SummaryItem.propTypes = {
@@ -132,11 +126,4 @@ SummaryItem.propTypes = {
132
126
 
133
127
  /** Show delta */
134
128
  showDelta: PropTypes.bool,
135
-
136
- /** Budget insight data */
137
- budget: PropTypes.shape({
138
- currentBalue: PropTypes.number,
139
- budgetValue: PropTypes.number,
140
- failed: PropTypes.bool,
141
- }),
142
129
  };
@@ -1,24 +1,12 @@
1
- .root {
2
- position: relative;
3
- padding-right: var(--space-xlarge);
4
- }
5
-
6
1
  .title {
7
- align-items: center;
8
2
  color: var(--color-text-ultra-light);
9
3
  font-weight: bold;
10
4
  font-size: var(--size-xsmall);
11
- line-height: var(--space-small);
5
+ line-height: 1;
12
6
  text-transform: uppercase;
13
7
  white-space: nowrap;
14
8
  }
15
9
 
16
- .budgetInfo {
17
- position: absolute;
18
- right: 0;
19
- top: 0;
20
- }
21
-
22
10
  .currentMetric {
23
11
  display: block;
24
12
  color: var(--color-heading);
@@ -39,6 +27,30 @@
39
27
  line-height: var(--space-small);
40
28
  }
41
29
 
30
+ .readMoreLink {
31
+ appearance: none;
32
+ background: none;
33
+ margin: 0;
34
+ border: 0;
35
+ padding: 0;
36
+ color: var(--color-primary);
37
+ text-decoration: underline;
38
+ cursor: pointer;
39
+ }
40
+
41
+ .readMoreLink:hover,
42
+ .readMoreLink:active,
43
+ .readMoreLink:focus {
44
+ color: var(--color-primary-dark);
45
+ text-decoration: none;
46
+ }
47
+
48
+ /* Hover state */
49
+ .root:hover .title {
50
+ color: var(--color-text-light);
51
+ }
52
+
53
+
42
54
  /* Loading state */
43
55
  .loading.currentMetric {
44
56
  width: 8em;
package/src/constants.js CHANGED
@@ -47,11 +47,15 @@ export const ASSETS_SIZES_FILE_TYPE_MAP = FILE_TYPES.reduce(
47
47
  );
48
48
 
49
49
  export const METRICS_WEBPACK_GENERAL = [
50
- 'totalSizeByTypeALL',
51
- 'totalInitialSizeJS',
52
- 'totalInitialSizeCSS',
53
- 'cacheInvalidation',
50
+ 'webpack.totalSizeByTypeALL',
51
+ 'webpack.totalInitialSizeJS',
52
+ 'webpack.totalInitialSizeCSS',
53
+ 'webpack.cacheInvalidation',
54
54
  ];
55
- export const METRICS_WEBPACK_ASSETS = ['assetCount', 'chunkCount'];
56
- export const METRICS_WEBPACK_MODULES = ['moduleCount', 'duplicateModulesCount', 'duplicateCode'];
57
- export const METRICS_WEBPACK_PACKAGES = ['packageCount', 'duplicatePackagesCount'];
55
+ export const METRICS_WEBPACK_ASSETS = ['webpack.assetCount', 'webpack.chunkCount'];
56
+ export const METRICS_WEBPACK_MODULES = [
57
+ 'webpack.moduleCount',
58
+ 'webpack.duplicateModulesCount',
59
+ 'webpack.duplicateCode',
60
+ ];
61
+ export const METRICS_WEBPACK_PACKAGES = ['webpack.packageCount', 'webpack.duplicatePackagesCount'];
@@ -6,15 +6,10 @@ 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, ...restProps } = props;
9
+ const { className, kind, children } = props;
10
10
 
11
11
  return (
12
- <Box
13
- padding={['xsmall', 'small']}
14
- outline
15
- className={cx(css.root, className, css[kind])}
16
- {...restProps}
17
- >
12
+ <Box padding={['xsmall', 'small']} outline className={cx(css.root, className, css[kind])}>
18
13
  {children}
19
14
  </Box>
20
15
  );
@@ -31,6 +31,10 @@ export const HoverCard = (props) => {
31
31
  // Fallback to span if no href
32
32
  const Component = resolveComponent(as, href);
33
33
 
34
+ const handleOnClick = (event) => {
35
+ event.preventDefault();
36
+ };
37
+
34
38
  return (
35
39
  <div className={cx(css.root, className)}>
36
40
  <HovercardAnchor state={state} href={href} className={css.anchor} as={Component}>
@@ -41,6 +45,7 @@ export const HoverCard = (props) => {
41
45
  state={state}
42
46
  className={cx(css.hoverCard, hoverCardClassName)}
43
47
  style={{ zIndex: 10000 }}
48
+ onClick={handleOnClick}
44
49
  >
45
50
  <HovercardArrow size={24} />
46
51
  {typeof children === 'function' ? children({ close: state.hide }) : children}
@@ -5,13 +5,11 @@ import cx from 'classnames';
5
5
  import css from './icon.module.css';
6
6
 
7
7
  const ICONS = {
8
- ALERT_CIRCLE: 'alert-circle',
9
8
  ARROW: 'arrow',
10
9
  ARROW_RIGHT_CIRLCE: 'arrow-right-circle',
11
10
  CANCEL: 'cancel',
12
11
  CLOSE: 'close',
13
12
  CLOCK: 'clock',
14
- CHECK_CIRCLE: 'check-circle',
15
13
  COMMIT: 'commit',
16
14
  FILTER: 'filter',
17
15
  HELP: 'help',
@@ -1 +0,0 @@
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>
@@ -1 +0,0 @@
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,80 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.BudgetInfo = void 0;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _utils = require("@bundle-stats/utils");
17
-
18
- var budgetsInsightsTransformer = _interopRequireWildcard(require("@bundle-stats/utils/lib-esm/transformers/budgets-insights"));
19
-
20
- var _icon = require("../../ui/icon");
21
-
22
- var _tooltip = require("../../ui/tooltip");
23
-
24
- var _budgetInfoModule = _interopRequireDefault(require("./budget-info.module.css"));
25
-
26
- var _INSIGHT_TYPE_MAP;
27
-
28
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
-
30
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
-
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
-
34
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
- var INSIGHT_TYPE_MAP = (_INSIGHT_TYPE_MAP = {}, _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.SUCCESS, {
37
- className: _budgetInfoModule["default"].success,
38
- glyph: _icon.Icon.ICONS.CHECK_CIRCLE
39
- }), _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.ERROR, {
40
- className: _budgetInfoModule["default"].error,
41
- glyph: _icon.Icon.ICONS.ALERT_CIRCLE
42
- }), _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.WARNING, {
43
- className: _budgetInfoModule["default"].warning,
44
- glyph: _icon.Icon.ICONS.WARNING
45
- }), _INSIGHT_TYPE_MAP);
46
-
47
- var BudgetInfo = function BudgetInfo(_ref) {
48
- var _ref$className = _ref.className,
49
- className = _ref$className === void 0 ? '' : _ref$className,
50
- metricId = _ref.metricId,
51
- budgetInsight = _ref.budgetInsight;
52
- var budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
53
- var _INSIGHT_TYPE_MAP$bud = INSIGHT_TYPE_MAP[budgetInsightInfo.type],
54
- insightTypeClassName = _INSIGHT_TYPE_MAP$bud.className,
55
- glyph = _INSIGHT_TYPE_MAP$bud.glyph;
56
- var rootClassName = (0, _classnames["default"])(_budgetInfoModule["default"].root, insightTypeClassName, className);
57
- var messageData = budgetInsightInfo.message.data;
58
- return /*#__PURE__*/_react["default"].createElement(_tooltip.Tooltip, {
59
- className: rootClassName,
60
- title: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, messageData.metricLabel), " value (", /*#__PURE__*/_react["default"].createElement("strong", null, messageData.currentValue), ") is ".concat(messageData.diffLabel, " "), /*#__PURE__*/_react["default"].createElement("strong", null, messageData.budgetValue), " budget ")
61
- }, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
62
- className: _budgetInfoModule["default"].icon,
63
- glyph: glyph,
64
- size: "medium"
65
- }));
66
- };
67
-
68
- exports.BudgetInfo = BudgetInfo;
69
- BudgetInfo.propTypes = {
70
- metricId: _propTypes["default"].string.isRequired,
71
- budgetInsight: _propTypes["default"].shape({
72
- currentValue: _propTypes["default"].number,
73
- budgetValue: _propTypes["default"].number,
74
- failed: _propTypes["default"].bool
75
- }).isRequired,
76
- className: _propTypes["default"].string
77
- };
78
- BudgetInfo.defaultProps = {
79
- className: ''
80
- };
@@ -1,40 +0,0 @@
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
- }