@bundle-stats/ui 4.13.0-beta.11 → 4.13.0-beta.13
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.
- package/lib/components/bundle-assets-totals/bundle-assets-totals.js +4 -4
- package/lib/components/bundle-assets-totals/bundle-assets-totals.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.js +25 -25
- package/lib/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.module.css +28 -23
- package/lib/css/variables.css +1 -0
- package/lib/layout/box/box.module.css +4 -2
- package/lib/ui/table/table.module.css +30 -0
- package/lib/ui/tag/tag.module.css +3 -3
- package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.js +4 -4
- package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.js +25 -25
- package/lib-esm/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.module.css +28 -23
- package/lib-esm/css/variables.css +1 -0
- package/lib-esm/layout/box/box.module.css +4 -2
- package/lib-esm/ui/table/table.module.css +30 -0
- package/lib-esm/ui/tag/tag.module.css +3 -3
- package/package.json +4 -4
- package/src/components/bundle-assets-totals/bundle-assets-totals.jsx +27 -22
- package/src/components/metrics-treemap/metrics-treemap.module.css +28 -23
- package/src/components/metrics-treemap/metrics-treemap.tsx +45 -45
- package/src/css/variables.css +1 -0
- package/src/layout/box/box.module.css +4 -2
- package/src/ui/table/table.module.css +30 -0
- package/src/ui/tag/tag.module.css +3 -3
|
@@ -29,7 +29,7 @@ const VERTICAL_SPACING = 4;
|
|
|
29
29
|
const LINE_HEIGHT = 16;
|
|
30
30
|
const LINE_HEIGHT_SMALL = 13.3;
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function resolveTileSizeDisplay(width: number, height: number): TileSizeDisplay {
|
|
33
33
|
if (
|
|
34
34
|
height > PADDING_TOP + PADDING_BOTTOM + VERTICAL_SPACING + LINE_HEIGHT * 2 &&
|
|
35
35
|
width > PADDING_LEFT + PADDING_RIGHT + 128
|
|
@@ -47,19 +47,19 @@ function resolveLeafSizeDisplay(width: number, height: number): TileSizeDisplay
|
|
|
47
47
|
return 'minimal';
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
interface
|
|
50
|
+
interface TileTooltipContentProps {
|
|
51
51
|
item: ReportMetricRow;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const
|
|
54
|
+
const TileTooltipContent = (props: TileTooltipContentProps) => {
|
|
55
55
|
const { item } = props;
|
|
56
56
|
|
|
57
57
|
const currentRun = item.runs[0] as MetricRunInfo;
|
|
58
58
|
const baselineRun = item.runs[item.runs.length - 1] as MetricRunInfoBaseline;
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
|
-
<Stack space="small" className={css.
|
|
62
|
-
<h3 className={css.
|
|
61
|
+
<Stack space="small" className={css.tileTooltipContent}>
|
|
62
|
+
<h3 className={css.tileTooltipContentTitle}>
|
|
63
63
|
<FileName as="code" name={item.label} />
|
|
64
64
|
</h3>
|
|
65
65
|
<RunInfo
|
|
@@ -72,21 +72,21 @@ const LeafTooltipContent = (props: LeafTooltipContentProps) => {
|
|
|
72
72
|
);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
interface
|
|
75
|
+
interface TileContentProps {
|
|
76
76
|
sizeDisplay: 'minimal' | 'small' | 'default';
|
|
77
77
|
item: ReportMetricRow;
|
|
78
78
|
runInfo: MetricRunInfo;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const
|
|
81
|
+
const TileContent = forwardRef((props: TileContentProps, ref: React.Ref<HTMLDivElement>) => {
|
|
82
82
|
const { sizeDisplay, item, runInfo } = props;
|
|
83
83
|
|
|
84
84
|
if (sizeDisplay === 'minimal') {
|
|
85
|
-
return <div className={css.
|
|
85
|
+
return <div className={css.tileContent} ref={ref} />;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
<div className={css.
|
|
89
|
+
<div className={css.tileContent} ref={ref}>
|
|
90
90
|
<FileName as="p" className={css.leadContentLabel} name={item.label} />
|
|
91
91
|
{sizeDisplay !== 'small' && (
|
|
92
92
|
<p className={css.leadContentValue}>
|
|
@@ -102,7 +102,7 @@ const LeafContent = forwardRef((props: LeafContentProps, ref: React.Ref<HTMLDivE
|
|
|
102
102
|
);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
const
|
|
105
|
+
const TileContentWithTooltip = (props: TileContentProps & { parentRef: RefObject<Element> }) => {
|
|
106
106
|
const { sizeDisplay, item, runInfo, parentRef } = props;
|
|
107
107
|
|
|
108
108
|
const pointer = useMouseHovered(parentRef, { whenHovered: true });
|
|
@@ -131,12 +131,12 @@ const LeafContentWithTooltip = (props: LeafContentProps & { parentRef: RefObject
|
|
|
131
131
|
|
|
132
132
|
return (
|
|
133
133
|
<>
|
|
134
|
-
<TooltipAnchor state={tooltipState} className={css.
|
|
135
|
-
<
|
|
134
|
+
<TooltipAnchor state={tooltipState} className={css.tileContentTooltipAnchor}>
|
|
135
|
+
<TileContent sizeDisplay={sizeDisplay} item={item} runInfo={runInfo} />
|
|
136
136
|
</TooltipAnchor>
|
|
137
137
|
<Tooltip state={tooltipState} className={css.tooltip}>
|
|
138
|
-
<TooltipArrow state={tooltipState} size={16} className={css.
|
|
139
|
-
<
|
|
138
|
+
<TooltipArrow state={tooltipState} size={16} className={css.tileTooltipArrow} />
|
|
139
|
+
<TileTooltipContent item={item} />
|
|
140
140
|
</Tooltip>
|
|
141
141
|
</>
|
|
142
142
|
);
|
|
@@ -155,7 +155,7 @@ interface RootTree {
|
|
|
155
155
|
children: Array<TreeNode>;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
interface
|
|
158
|
+
interface TileProps {
|
|
159
159
|
left: number;
|
|
160
160
|
top: number;
|
|
161
161
|
width: number;
|
|
@@ -164,42 +164,42 @@ interface LeafProps {
|
|
|
164
164
|
onClick?: (id: string) => void;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
const
|
|
167
|
+
const Tile = (props: TileProps) => {
|
|
168
168
|
const { left, top, width, height, data, onClick } = props;
|
|
169
169
|
|
|
170
170
|
const { item } = data;
|
|
171
171
|
const runInfo = item.runs?.[0] as MetricRunInfo;
|
|
172
172
|
|
|
173
|
-
const sizeDisplay = useMemo(() =>
|
|
173
|
+
const sizeDisplay = useMemo(() => resolveTileSizeDisplay(width, height), [width, height]);
|
|
174
174
|
const handleOnClick = useCallback(() => onClick?.(item.key), [item.key, onClick]);
|
|
175
175
|
|
|
176
|
-
const
|
|
177
|
-
const hover = useHoverDirty(
|
|
176
|
+
const contentRef = useRef<HTMLButtonElement>(null);
|
|
177
|
+
const hover = useHoverDirty(contentRef);
|
|
178
178
|
|
|
179
|
-
const
|
|
180
|
-
css.
|
|
181
|
-
css[`
|
|
182
|
-
sizeDisplay === 'small' && css.
|
|
183
|
-
left === 0 && css.
|
|
179
|
+
const className = cx(
|
|
180
|
+
css.tile,
|
|
181
|
+
css[`tile-${runInfo.deltaType}`],
|
|
182
|
+
sizeDisplay === 'small' && css.tileSmall,
|
|
183
|
+
left === 0 && css.tileFirstCol,
|
|
184
184
|
);
|
|
185
185
|
|
|
186
186
|
return (
|
|
187
187
|
<button
|
|
188
188
|
type="button"
|
|
189
189
|
onClick={handleOnClick}
|
|
190
|
-
ref={
|
|
190
|
+
ref={contentRef}
|
|
191
191
|
style={{ left, top, width, height }}
|
|
192
|
-
className={
|
|
192
|
+
className={className}
|
|
193
193
|
>
|
|
194
194
|
{hover ? (
|
|
195
|
-
<
|
|
195
|
+
<TileContentWithTooltip
|
|
196
196
|
sizeDisplay={sizeDisplay}
|
|
197
197
|
item={item}
|
|
198
198
|
runInfo={runInfo}
|
|
199
|
-
parentRef={
|
|
199
|
+
parentRef={contentRef}
|
|
200
200
|
/>
|
|
201
201
|
) : (
|
|
202
|
-
<
|
|
202
|
+
<TileContent sizeDisplay={sizeDisplay} item={item} runInfo={runInfo} />
|
|
203
203
|
)}
|
|
204
204
|
</button>
|
|
205
205
|
);
|
|
@@ -217,8 +217,8 @@ function useMetricsTreemapHierarchy(params: UseMetricsTreemapHierarchyParams) {
|
|
|
217
217
|
const treemapHierarchy = useMemo(() => {
|
|
218
218
|
const children = items.map((item) => {
|
|
219
219
|
/**
|
|
220
|
-
* Set
|
|
221
|
-
* display the impact of deleted
|
|
220
|
+
* Set tile value to the largest run value to allow to
|
|
221
|
+
* display the impact of deleted/new entries
|
|
222
222
|
*/
|
|
223
223
|
const values = item.runs.map((run) => run?.value || 0);
|
|
224
224
|
const value = Math.max(...values);
|
|
@@ -245,7 +245,7 @@ function useMetricsTreemapHierarchy(params: UseMetricsTreemapHierarchyParams) {
|
|
|
245
245
|
return customHierarchy;
|
|
246
246
|
}, [items]);
|
|
247
247
|
|
|
248
|
-
const
|
|
248
|
+
const tiles = useMemo(() => {
|
|
249
249
|
const createTremapLayout = treemap()
|
|
250
250
|
.size([width, height])
|
|
251
251
|
.tile(treemapSquarify.ratio(SQUARIFY_RATIO))
|
|
@@ -254,10 +254,10 @@ function useMetricsTreemapHierarchy(params: UseMetricsTreemapHierarchyParams) {
|
|
|
254
254
|
// @ts-expect-error
|
|
255
255
|
const tremapLayout = createTremapLayout(treemapHierarchy);
|
|
256
256
|
|
|
257
|
-
return tremapLayout.leaves().filter((
|
|
257
|
+
return tremapLayout.leaves().filter((tile) => Boolean(tile.parent));
|
|
258
258
|
}, [height, width, treemapHierarchy]);
|
|
259
259
|
|
|
260
|
-
return
|
|
260
|
+
return tiles;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
interface MetricsTreemapProps {
|
|
@@ -270,26 +270,26 @@ export const MetricsTreemap = (props: MetricsTreemapProps & React.ComponentProps
|
|
|
270
270
|
const { className = '', items, onItemClick, emptyMessage = 'No data', ...restProps } = props;
|
|
271
271
|
|
|
272
272
|
const [containerRef, { width, height }] = useMeasure<HTMLDivElement>();
|
|
273
|
-
const
|
|
273
|
+
const tiles = useMetricsTreemapHierarchy({ items, width, height });
|
|
274
274
|
|
|
275
275
|
return (
|
|
276
276
|
<div className={cx(css.root, className)} {...restProps} ref={containerRef}>
|
|
277
|
-
{
|
|
277
|
+
{tiles.length > 0 ? (
|
|
278
278
|
<div className={css.canvas}>
|
|
279
|
-
{
|
|
280
|
-
if (!
|
|
279
|
+
{tiles.map((tile) => {
|
|
280
|
+
if (!tile.parent) {
|
|
281
281
|
return null;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
return (
|
|
285
|
-
<
|
|
286
|
-
data={
|
|
287
|
-
left={
|
|
288
|
-
top={
|
|
289
|
-
width={
|
|
290
|
-
height={
|
|
285
|
+
<Tile
|
|
286
|
+
data={tile.data as TreeNode}
|
|
287
|
+
left={tile.x0}
|
|
288
|
+
top={tile.y0}
|
|
289
|
+
width={tile.x1 - tile.x0}
|
|
290
|
+
height={tile.y1 - tile.y0}
|
|
291
291
|
onClick={onItemClick}
|
|
292
|
-
key={
|
|
292
|
+
key={tile.id}
|
|
293
293
|
/>
|
|
294
294
|
);
|
|
295
295
|
})}
|
package/src/css/variables.css
CHANGED
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.outline > :first-child {
|
|
11
|
-
border-radius: var(--radius-medium)
|
|
11
|
+
border-top-left-radius: var(--radius-medium);
|
|
12
|
+
border-top-right-radius: var(--radius-medium);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
.outline > :last-child {
|
|
15
|
-
border-radius:
|
|
16
|
+
border-bottom-left-radius: var(--radius-medium);
|
|
17
|
+
border-bottom-right-radius: var(--radius-medium);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
.outlineHover {
|
|
@@ -89,6 +89,36 @@
|
|
|
89
89
|
border-width: 1px;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/** cascade border radius */
|
|
93
|
+
.root thead,
|
|
94
|
+
.root thead tr:first-child {
|
|
95
|
+
border-top-left-radius: inherit;
|
|
96
|
+
border-top-right-radius: inherit;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.root thead tr:first-child th:first-child {
|
|
100
|
+
border-top-left-radius: inherit;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.root thead tr:first-child th:last-child {
|
|
104
|
+
border-top-right-radius: inherit;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.root tbody:last-child,
|
|
108
|
+
.root tbody:last-child tr:last-child {
|
|
109
|
+
border-bottom-left-radius: inherit;
|
|
110
|
+
border-bottom-right-radius: inherit;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.root tbody:last-child tr:last-child th:first-child,
|
|
114
|
+
.root tbody:last-child tr:last-child td:first-child {
|
|
115
|
+
border-bottom-left-radius: inherit;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.root tbody:last-child tr:last-child td:last-child {
|
|
119
|
+
border-bottom-right-radius: inherit;
|
|
120
|
+
}
|
|
121
|
+
|
|
92
122
|
/* compact variation */
|
|
93
123
|
.compact td,
|
|
94
124
|
.compact th {
|
|
@@ -42,7 +42,7 @@ a.root:active {
|
|
|
42
42
|
/** Size variation */
|
|
43
43
|
/** default: medium */
|
|
44
44
|
.root {
|
|
45
|
-
border-radius: var(--radius-
|
|
45
|
+
border-radius: var(--radius-small);
|
|
46
46
|
padding: calc(var(--space-xxxsmall) / 2) var(--space-xxxsmall);
|
|
47
47
|
min-width: var(--space-small);
|
|
48
48
|
height: var(--space-small);
|
|
@@ -51,7 +51,7 @@ a.root:active {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
.small {
|
|
54
|
-
border-radius: var(--radius-
|
|
54
|
+
border-radius: var(--radius-xsmall);
|
|
55
55
|
padding: calc(var(--space-xxxsmall) / 2);
|
|
56
56
|
height: var(--space-xsmall);
|
|
57
57
|
min-width: var(--space-xsmall);
|
|
@@ -60,7 +60,7 @@ a.root:active {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.large {
|
|
63
|
-
border-radius: var(--radius-
|
|
63
|
+
border-radius: var(--radius-medium);
|
|
64
64
|
padding: var(--space-xxxsmall) var(--space-xxsmall);
|
|
65
65
|
min-width: var(--space-medium);
|
|
66
66
|
height: var(--space-medium);
|