@bundle-stats/ui 3.3.0-alpha.1 → 3.3.1-beta.12

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 +126 -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 +3 -11
  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 +105 -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 +121 -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 +3 -10
  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 +98 -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 +136 -146
  144. package/src/app/app.module.css +11 -4
  145. package/src/app/header/header.jsx +1 -11
  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
@@ -12,7 +12,8 @@ import styles from './metrics-table.module.css';
12
12
 
13
13
  const METRIC_TYPE_DATA = getGlobalMetricType(null, METRIC_TYPE_FILE_SIZE);
14
14
 
15
- const getRowsRunTotal = (rows, runIndex) => sum(rows.map((row) => get(row, `runs[${runIndex}].value`, 0)));
15
+ const getRowsRunTotal = (rows, runIndex) =>
16
+ sum(rows.map((row) => get(row, `runs[${runIndex}].value`, 0)));
16
17
 
17
18
  const getHeaderLabelCells = (rows) => (run, runIndex, runs) => {
18
19
  const isBaseline = runIndex === runs.length - 1;
@@ -102,46 +103,58 @@ const getHeaderRows = (runs, items, showHeaderSum, title) => [
102
103
  : []),
103
104
  ];
104
105
 
105
- const generateRowCells = (item, index, items) => {
106
- const isBaseline = index === items.length - 1;
106
+ const MetricsTableRow = ({ item, renderRowHeader }) => (
107
+ <Table.Tr className={cx(!item.changed && styles.unchanged)}>
108
+ <Table.Th className={styles.metricName}>{renderRowHeader(item)}</Table.Th>
107
109
 
108
- // eslint-disable-next-line react/destructuring-assignment
109
- if (!item || typeof item.value === 'undefined') {
110
- return ['-', ...(!isBaseline ? [''] : [])];
111
- }
110
+ {item.runs.map((run, index) => {
111
+ const isBaseline = index === item.runs.length - 1;
112
+ const valueClassName = cx(styles.value, !isBaseline && styles.current);
112
113
 
113
- const { displayValue, deltaPercentage, displayDeltaPercentage, deltaType } = item;
114
+ // Empty cells if no value
115
+ if (!run || typeof run.value === 'undefined') {
116
+ return (
117
+ <>
118
+ <Table.Td className={valueClassName}>-</Table.Td>
119
+ {!isBaseline && <Table.Td className={styles.delta} />}
120
+ </>
121
+ );
122
+ }
114
123
 
115
- const cells = [<Metric value={displayValue} />];
124
+ const { displayValue, deltaPercentage, displayDeltaPercentage, deltaType } = run;
116
125
 
117
- if (!isBaseline) {
118
- cells.push(
119
- typeof deltaPercentage === 'number' && (
120
- <Delta displayValue={displayDeltaPercentage} deltaType={deltaType} />
121
- ),
122
- );
123
- }
126
+ return (
127
+ <>
128
+ <Table.Td className={valueClassName}>
129
+ <Metric value={displayValue} />
130
+ </Table.Td>
131
+ {!isBaseline && typeof deltaPercentage === 'number' && (
132
+ <Table.Td className={styles.delta}>
133
+ <Delta displayValue={displayDeltaPercentage} deltaType={deltaType} />
134
+ </Table.Td>
135
+ )}
136
+ </>
137
+ );
138
+ })}
139
+ </Table.Tr>
140
+ );
124
141
 
125
- return cells;
142
+ MetricsTableRow.propTypes = {
143
+ item: PropTypes.shape({
144
+ changed: PropTypes.bool,
145
+ runs: PropTypes.arrayOf(
146
+ PropTypes.shape({
147
+ value: PropTypes.number,
148
+ displayValue: PropTypes.string,
149
+ deltaPercentage: PropTypes.number,
150
+ displayDeltaPercentage: PropTypes.string,
151
+ deltaType: PropTypes.string,
152
+ }),
153
+ ),
154
+ }).isRequired,
155
+ renderRowHeader: PropTypes.func.isRequired,
126
156
  };
127
157
 
128
- const getRows = (runs, items, renderRowHeader) =>
129
- items.map((item, index) => {
130
- const { changed } = item;
131
-
132
- return {
133
- key: item?.key || index,
134
- className: changed ? '' : styles.unchanged,
135
- cells: [
136
- // Metric name
137
- renderRowHeader(item),
138
-
139
- // Metric item values
140
- ...item.runs.map(generateRowCells).flat(),
141
- ],
142
- };
143
- });
144
-
145
158
  export const MetricsTable = ({
146
159
  className,
147
160
  renderRowHeader,
@@ -151,9 +164,11 @@ export const MetricsTable = ({
151
164
  showHeaderSum,
152
165
  headerRows,
153
166
  title,
167
+ ...restProps
154
168
  }) => {
155
169
  const { headers, columnClassNames } = useMemo(() => {
156
170
  const headerColumns = getHeaderRows(runs, items, showHeaderSum, title);
171
+
157
172
  return {
158
173
  headers: [...headerRows, ...headerColumns],
159
174
  // First header row has the column class names
@@ -161,8 +176,6 @@ export const MetricsTable = ({
161
176
  };
162
177
  }, [headerRows, runs, items, showHeaderSum, title]);
163
178
 
164
- const rows = useMemo(() => getRows(runs, items, renderRowHeader), [runs, items, renderRowHeader]);
165
-
166
179
  const rootClassName = cx(
167
180
  styles.root,
168
181
  className,
@@ -171,7 +184,7 @@ export const MetricsTable = ({
171
184
  );
172
185
 
173
186
  return (
174
- <Table className={rootClassName} compact>
187
+ <Table className={rootClassName} compact {...restProps}>
175
188
  <Table.THead>
176
189
  {headers.map((headerRow) => {
177
190
  const { cells, className: rowClassName } = headerRow.cells
@@ -188,13 +201,9 @@ export const MetricsTable = ({
188
201
  })}
189
202
  </Table.THead>
190
203
  <Table.TBody>
191
- {!isEmpty(rows) ? (
192
- rows.map(({ key, className: rowClassName, cells }) => (
193
- <Table.Tr key={key} className={rowClassName}>
194
- {cells.map((cell, index) => (
195
- <Table.Td className={columnClassNames[index]}>{cell}</Table.Td>
196
- ))}
197
- </Table.Tr>
204
+ {!isEmpty(items) ? (
205
+ items.map((item) => (
206
+ <MetricsTableRow key={item.key} item={item} renderRowHeader={renderRowHeader} />
198
207
  ))
199
208
  ) : (
200
209
  <Table.Tr>
@@ -1,11 +1,11 @@
1
- .jobName a {
1
+ .root a {
2
2
  color: inherit;
3
3
  text-decoration: none;
4
4
  }
5
5
 
6
- .jobName a:hover,
7
- .jobName a:active,
8
- .jobName a:focus {
6
+ .root a:hover,
7
+ .root a:active,
8
+ .root a:focus {
9
9
  color: var(--color-primary);
10
10
  text-decoration: underline;
11
11
  }
@@ -15,21 +15,31 @@
15
15
  width: 100%;
16
16
  }
17
17
 
18
- .value {
18
+ .root .value {
19
19
  padding-left: var(--space-large);
20
20
  text-align: right;
21
+ vertical-align: baseline;
21
22
  }
22
23
 
23
- .delta {
24
+ .root .delta {
24
25
  padding-left: 0;
25
26
  text-align: left;
26
27
  font-size: var(--size-xsmall);
28
+ vertical-align: baseline;
27
29
  }
28
30
 
29
- .value.current {
31
+ .root tbody .delta {
32
+ line-height: 1.6rem; /* baseline alignment with the value */
33
+ }
34
+
35
+ .root .value.current {
30
36
  padding-right: var(--space-xxsmall);
31
37
  }
32
38
 
39
+ .jobName {
40
+ white-space: nowrap;
41
+ }
42
+
33
43
  /* columns overrides for showHeaderSum */
34
44
  .showHeaderSum .headerRowColumns .value,
35
45
  .showHeaderSum .headerRowColumns .delta {
@@ -45,6 +55,7 @@
45
55
  }
46
56
 
47
57
  /** rows */
58
+ .multipleRuns .unchanged th,
48
59
  .multipleRuns .unchanged td {
49
60
  color: var(--color-text-light);
50
61
  }
@@ -5,6 +5,7 @@
5
5
  }
6
6
 
7
7
  .input {
8
+ border-radius: var(--radius-small);
8
9
  height: var(--space-large);
9
10
  border-color: var(--color-outline);
10
11
  }
@@ -21,12 +22,12 @@
21
22
  cursor: pointer;
22
23
  border-radius: 50%;
23
24
  position: absolute;
24
- right: 0;
25
+ right: 2px;
25
26
  top: 50%;
26
27
  transform: translateY(-50%);
27
- padding: var(--space-xxsmall);
28
- width: var(--space-large);
29
- height: var(--space-large);
28
+ padding: var(--space-xxxsmall);
29
+ width: var(--space-medium);
30
+ height: var(--space-medium);
30
31
  background: radial-gradient(var(--color-background) 50%, transparent);
31
32
  color: var(--color-text-ultra-light);
32
33
  transition: var(--transition-in);
@@ -5,7 +5,8 @@ import cx from 'classnames';
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 './metrics-table-title.module.css';
10
11
 
11
12
  export const MetricsTableTitle = (props) => {
@@ -13,26 +14,24 @@ export const MetricsTableTitle = (props) => {
13
14
  const rootClassName = cx(css.root, className);
14
15
 
15
16
  return (
16
- <Stack space="xxxsmall" className={rootClassName}>
17
- <FlexStack space="xxxsmall">
18
- <span>{title}</span>
19
- {info && <span className={css.info}>{info}</span>}
20
- {(popoverInfo || popoverHref) && (
21
- <Popover icon="help">
22
- <Stack space="xxxsmall">
23
- {popoverInfo && <p>{popoverInfo}</p>}
24
- {popoverHref && (
25
- <p>
26
- <a href={popoverHref} target="_blank" rel="noreferrer">
27
- {I18N.READ_MORE}
28
- </a>
29
- </p>
30
- )}
31
- </Stack>
32
- </Popover>
33
- )}
34
- </FlexStack>
35
- </Stack>
17
+ <FlexStack space="xxxsmall" className={rootClassName}>
18
+ <span>{title}</span>
19
+ {info && <span className={css.info}>{info}</span>}
20
+ {(popoverInfo || popoverHref) && (
21
+ <HoverCard label={<Icon glyph="help" />}>
22
+ <Stack space="xxxsmall">
23
+ {popoverInfo && <p>{popoverInfo}</p>}
24
+ {popoverHref && (
25
+ <p>
26
+ <a href={popoverHref} target="_blank" rel="noreferrer">
27
+ {I18N.READ_MORE}
28
+ </a>
29
+ </p>
30
+ )}
31
+ </Stack>
32
+ </HoverCard>
33
+ )}
34
+ </FlexStack>
36
35
  );
37
36
  };
38
37
 
@@ -1,5 +1,7 @@
1
1
  .root {
2
+ align-items: center;
2
3
  font-weight: bold;
4
+ line-height: var(--space-small);
3
5
  text-transform: uppercase;
4
6
  color: var(--color-text-light);
5
7
  }
@@ -20,7 +20,7 @@ export const ModuleInfo = (props) => {
20
20
  } = props;
21
21
 
22
22
  return (
23
- <Stack space="small" className={className}>
23
+ <Stack space="xsmall" className={className}>
24
24
  {item.runs.map((run, index) => {
25
25
  const TitleComponent = index !== 0 ? 'h4' : 'h3';
26
26
  const key = `module-info-${run?.name || index}-${index}`;
@@ -30,7 +30,7 @@ export const ModuleInfo = (props) => {
30
30
  <TitleComponent>{labels[index]}</TitleComponent>
31
31
  {index === 0 && !isEmpty(run?.chunkIds) && (
32
32
  <div className={css.chunks}>
33
- <strong className={css.chunksTitle}>Chunks:</strong>
33
+ <span className={css.chunksTitle}>Chunks:</span>
34
34
  {run.chunkIds.map((chunkId) => {
35
35
  const chunk = find(chunks, { id: chunkId });
36
36
 
@@ -51,11 +51,7 @@ export const ModuleInfo = (props) => {
51
51
  </div>
52
52
  )}
53
53
 
54
- <FileName
55
- className={css.fileName}
56
- as="code"
57
- name={run?.name || '-'}
58
- />
54
+ <FileName className={css.fileName} as="code" name={run?.name || '-'} />
59
55
  </Stack>
60
56
  );
61
57
  })}
@@ -15,6 +15,7 @@
15
15
  }
16
16
 
17
17
  .fileName {
18
+ max-width: 100%;
18
19
  padding: 2px;
19
20
  background: var(--color-highlight-warning);
20
21
  }
@@ -12,14 +12,11 @@ import { ComponentLink } from '../component-link';
12
12
  import { SummaryItem } from '../summary-item';
13
13
  import css from './summary.module.css';
14
14
 
15
- const getSourceMetricId = (fullMetricId) => fullMetricId.split('.').slice(1).join('.');
16
-
17
15
  export const Summary = ({
18
16
  className,
19
17
  size,
20
18
  keys,
21
19
  data,
22
- budgets,
23
20
  loading,
24
21
  showSummaryItemDelta,
25
22
  summaryItemLink: SummaryItemCustomLink,
@@ -27,14 +24,13 @@ export const Summary = ({
27
24
  <Box outline className={cx(css.root, className)}>
28
25
  <FlexStack className={css.items}>
29
26
  {Array.from(METRIC_COMPONENT_LINKS)
30
- .filter(([metricId]) => keys.includes(getSourceMetricId(metricId)))
27
+ .filter(([metricId]) => keys.includes(metricId))
31
28
  .map(([metricId, metricOptions]) => (
32
29
  <div key={metricId} className={css.item}>
33
30
  <SummaryItem
34
31
  size={size}
35
32
  id={metricId}
36
33
  data={get(data, metricId)}
37
- budget={get(budgets, metricId)}
38
34
  loading={loading}
39
35
  showMetricDescription
40
36
  showDelta={showSummaryItemDelta && metricOptions.showDelta !== false}
@@ -53,7 +49,6 @@ export const Summary = ({
53
49
  Summary.defaultProps = {
54
50
  className: '',
55
51
  data: null,
56
- budgets: null,
57
52
  loading: false,
58
53
  size: '',
59
54
  keys: METRICS_WEBPACK_GENERAL,
@@ -65,8 +60,12 @@ Summary.propTypes = {
65
60
  className: PropTypes.string,
66
61
  size: PropTypes.string,
67
62
  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
63
+ data: PropTypes.shape({
64
+ [PropTypes.string]: PropTypes.shape({
65
+ baseline: PropTypes.number,
66
+ current: PropTypes.number,
67
+ }),
68
+ }),
70
69
  loading: PropTypes.bool,
71
70
  showSummaryItemDelta: PropTypes.bool,
72
71
  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;
@@ -3,41 +3,34 @@ import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
5
5
 
6
- import { Popover } from '../../ui/popover';
6
+ import { HoverCard } from '../../ui/hover-card';
7
+ import { Icon } from '../../ui/icon';
7
8
  import { Skeleton } from '../../ui/skeleton';
8
9
  import { Stack } from '../../layout/stack';
9
10
  import { FlexStack } from '../../layout/flex-stack';
10
11
  import { Metric } from '../metric';
11
12
  import { Delta } from '../delta';
12
- import { BudgetInfo } from '../budget-info';
13
13
  import css from './summary-item.module.css';
14
14
 
15
- const MetricInfoPopover = ({ description, url }) => {
16
- // Workaround cases where the parent is a link
17
- const readMoreOnClick = () => {
18
- window.open(url);
19
- };
20
-
21
- return (
22
- <Stack space="xxxsmall">
23
- <p>{description}</p>
24
- {url && (
25
- <p>
26
- <button type="button" className={css.readMoreBtn} onClick={readMoreOnClick}>
27
- Read more
28
- </button>
29
- </p>
30
- )}
31
- </Stack>
32
- );
33
- };
34
-
35
- MetricInfoPopover.propTypes = {
15
+ const MetricInfo = ({ description, url }) => (
16
+ <Stack space="xxxsmall">
17
+ <p>{description}</p>
18
+ {url && (
19
+ <p>
20
+ <a href={url} className={css.readMoreLink}>
21
+ Read more
22
+ </a>
23
+ </p>
24
+ )}
25
+ </Stack>
26
+ );
27
+
28
+ MetricInfo.propTypes = {
36
29
  description: PropTypes.string.isRequired,
37
30
  url: PropTypes.string,
38
31
  };
39
32
 
40
- MetricInfoPopover.defaultProps = {
33
+ MetricInfo.defaultProps = {
41
34
  url: '',
42
35
  };
43
36
 
@@ -50,7 +43,6 @@ export const SummaryItem = ({
50
43
  loading,
51
44
  showDelta,
52
45
  showMetricDescription,
53
- budget,
54
46
  ...props
55
47
  }) => {
56
48
  const { baseline, current } = data || { baseline: 0, current: 0 };
@@ -58,20 +50,19 @@ export const SummaryItem = ({
58
50
  const metric = getGlobalMetricType(id);
59
51
  const runInfo = getMetricRunInfo(metric, current, baseline);
60
52
  const showMetricDescriptionTooltip = showMetricDescription && metric?.description;
53
+
61
54
  const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
62
55
 
63
56
  return (
64
- <Stack space="xxsmall" as={Component} className={rootClassName} {...props}>
57
+ <Stack space="xxxsmall" as={Component} className={rootClassName} {...props}>
65
58
  <FlexStack as="h3" space="xxxsmall" className={css.title}>
66
- <span className={css.titleLabel}>{metric.label}</span>
59
+ <span>{metric.label}</span>
67
60
 
68
61
  {showMetricDescriptionTooltip && (
69
- <Popover className={css.icon} icon="help">
70
- <MetricInfoPopover {...metric} />
71
- </Popover>
62
+ <HoverCard className={css.icon} label={<Icon glyph="help" />}>
63
+ <MetricInfo {...metric} />
64
+ </HoverCard>
72
65
  )}
73
-
74
- {budget && <BudgetInfo className={css.budgetInfo} metricId={id} budgetInsight={budget} />}
75
66
  </FlexStack>
76
67
 
77
68
  {!loading ? (
@@ -111,7 +102,6 @@ SummaryItem.defaultProps = {
111
102
  loading: false,
112
103
  showMetricDescription: false,
113
104
  showDelta: true,
114
- budget: undefined,
115
105
  };
116
106
 
117
107
  SummaryItem.propTypes = {
@@ -138,11 +128,4 @@ SummaryItem.propTypes = {
138
128
 
139
129
  /** Show delta */
140
130
  showDelta: PropTypes.bool,
141
-
142
- /** Budget insight data */
143
- budget: PropTypes.shape({
144
- currentBalue: PropTypes.number,
145
- budgetValue: PropTypes.number,
146
- failed: PropTypes.bool,
147
- }),
148
131
  };
@@ -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);
@@ -1,31 +1,28 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import cx from 'classnames'
3
+ import cx from 'classnames';
4
4
 
5
5
  import config from '../../config.json';
6
6
  import I18N from '../../i18n';
7
7
  import { FlexStack } from '../../layout/flex-stack';
8
8
  import { Stack } from '../../layout/stack';
9
- import { Popover } from '../../ui/popover';
9
+ import { Icon } from '../../ui/icon';
10
+ import { HoverCard } from '../../ui/hover-card';
10
11
  import css from './total-size-type-title.module.css';
11
12
 
12
13
  export const TotalSizeTypeTitle = ({ className }) => (
13
14
  <FlexStack space="xxxsmall" className={cx(css.title, className)}>
14
15
  <span>{I18N.ASSET_TOTALS}</span>
15
- <Popover icon="help">
16
+ <HoverCard label={<Icon glyph="help" />}>
16
17
  <Stack space="xxxsmall">
17
18
  <p>{I18N.ASSET_TOTALS_INFO}</p>
18
19
  <p>
19
- <a
20
- href={config.documentation.assets}
21
- target="_blank"
22
- rel="noreferrer"
23
- >
20
+ <a href={config.documentation.assets} target="_blank" rel="noreferrer">
24
21
  {I18N.READ_MORE}
25
22
  </a>
26
23
  </p>
27
24
  </Stack>
28
- </Popover>
25
+ </HoverCard>
29
26
  </FlexStack>
30
27
  );
31
28
 
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'];
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'];
@@ -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
  }