@bundle-stats/ui 4.22.3 → 4.23.0-beta.2
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/app/app.js +3 -0
- package/lib/app/app.js.map +1 -1
- package/lib/app/app.module.css +12 -2
- package/lib/chart-colors.json +58 -44
- package/lib/components/delta/delta.js +3 -13
- package/lib/components/delta/delta.js.map +1 -1
- package/lib/components/delta/delta.module.css +13 -12
- package/lib/components/delta/index.js.map +1 -1
- package/lib/components/entry-info/entry-info.js +1 -1
- package/lib/components/entry-info/entry-info.js.map +1 -1
- package/lib/components/entry-info/entry-info.module.css +1 -1
- package/lib/components/index.js +3 -1
- package/lib/components/index.js.map +1 -1
- package/lib/components/insight-icon/insight-icon.module.css +6 -6
- package/lib/components/job-name/job-name.js +1 -2
- package/lib/components/job-name/job-name.js.map +1 -1
- package/lib/components/metric-change-legend/index.js +18 -0
- package/lib/components/metric-change-legend/index.js.map +1 -0
- package/lib/components/metric-change-legend/metric-change-legend.js +91 -0
- package/lib/components/metric-change-legend/metric-change-legend.js.map +1 -0
- package/lib/components/metric-change-legend/metric-change-legend.module.css +80 -0
- package/lib/components/metric-run-info/metric-run-info.js +22 -7
- package/lib/components/metric-run-info/metric-run-info.js.map +1 -1
- package/lib/components/metrics-display-selector/metrics-display-selector.js +7 -9
- package/lib/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
- package/lib/components/metrics-display-selector/metrics-display-selector.module.css +0 -25
- package/lib/components/metrics-table-header/metrics-table-header.js +6 -6
- package/lib/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib/components/metrics-table-header/metrics-table-header.module.css +8 -12
- package/lib/components/metrics-table-options/metrics-table-options.js +2 -3
- package/lib/components/metrics-table-options/metrics-table-options.js.map +1 -1
- package/lib/components/metrics-table-title/metrics-table-title.js +1 -1
- package/lib/components/metrics-table-title/metrics-table-title.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.constants.js +3 -1
- package/lib/components/metrics-treemap/metrics-treemap.constants.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.js +68 -57
- package/lib/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.module.css +9 -16
- package/lib/components/metrics-treemap/metrics-treemap.utils.js +72 -16
- package/lib/components/metrics-treemap/metrics-treemap.utils.js.map +1 -1
- package/lib/components/run-info/run-info.js +26 -14
- package/lib/components/run-info/run-info.js.map +1 -1
- package/lib/components/run-info/run-info.module.css +35 -26
- package/lib/components/summary/summary.js +9 -10
- package/lib/components/summary/summary.js.map +1 -1
- package/lib/components/summary/summary.module.css +60 -10
- package/lib/constants.js +13 -1
- package/lib/constants.js.map +1 -1
- package/lib/css/variables.css +71 -58
- package/lib/ui/button/button.js +2 -2
- package/lib/ui/button/button.js.map +1 -1
- package/lib/ui/dialog/dialog.js +4 -2
- package/lib/ui/dialog/dialog.js.map +1 -1
- package/lib/ui/dialog/dialog.module.css +22 -0
- package/lib/ui/dropdown/dropdown.js +13 -4
- package/lib/ui/dropdown/dropdown.js.map +1 -1
- package/lib/ui/dropdown/dropdown.module.css +51 -6
- package/lib/ui/filters/filters.js +22 -11
- package/lib/ui/filters/filters.js.map +1 -1
- package/lib/ui/filters/filters.module.css +0 -14
- package/lib/ui/hover-card/hover-card.js +7 -1
- package/lib/ui/hover-card/hover-card.js.map +1 -1
- package/lib/ui/hover-card/hover-card.module.css +14 -0
- package/lib/ui/table/table.module.css +0 -1
- package/lib/ui/tooltip/tooltip.js +6 -1
- package/lib/ui/tooltip/tooltip.js.map +1 -1
- package/lib/ui/tooltip/tooltip.module.css +11 -0
- package/lib-esm/app/app.js +4 -1
- package/lib-esm/app/app.js.map +1 -1
- package/lib-esm/app/app.module.css +12 -2
- package/lib-esm/chart-colors.json +58 -44
- package/lib-esm/components/delta/delta.js +3 -13
- package/lib-esm/components/delta/delta.js.map +1 -1
- package/lib-esm/components/delta/delta.module.css +13 -12
- package/lib-esm/components/delta/index.js.map +1 -1
- package/lib-esm/components/entry-info/entry-info.js +1 -1
- package/lib-esm/components/entry-info/entry-info.js.map +1 -1
- package/lib-esm/components/entry-info/entry-info.module.css +1 -1
- package/lib-esm/components/index.js +1 -0
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/components/insight-icon/insight-icon.module.css +6 -6
- package/lib-esm/components/job-name/job-name.js +1 -2
- package/lib-esm/components/job-name/job-name.js.map +1 -1
- package/lib-esm/components/metric-change-legend/index.js +2 -0
- package/lib-esm/components/metric-change-legend/index.js.map +1 -0
- package/lib-esm/components/metric-change-legend/metric-change-legend.js +84 -0
- package/lib-esm/components/metric-change-legend/metric-change-legend.js.map +1 -0
- package/lib-esm/components/metric-change-legend/metric-change-legend.module.css +80 -0
- package/lib-esm/components/metric-run-info/metric-run-info.js +22 -7
- package/lib-esm/components/metric-run-info/metric-run-info.js.map +1 -1
- package/lib-esm/components/metrics-display-selector/metrics-display-selector.js +7 -9
- package/lib-esm/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
- package/lib-esm/components/metrics-display-selector/metrics-display-selector.module.css +0 -25
- package/lib-esm/components/metrics-table-header/metrics-table-header.js +6 -6
- package/lib-esm/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib-esm/components/metrics-table-header/metrics-table-header.module.css +8 -12
- package/lib-esm/components/metrics-table-options/metrics-table-options.js +3 -4
- package/lib-esm/components/metrics-table-options/metrics-table-options.js.map +1 -1
- package/lib-esm/components/metrics-table-title/metrics-table-title.js +1 -1
- package/lib-esm/components/metrics-table-title/metrics-table-title.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.constants.js +2 -0
- package/lib-esm/components/metrics-treemap/metrics-treemap.constants.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.js +74 -63
- package/lib-esm/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.module.css +9 -16
- package/lib-esm/components/metrics-treemap/metrics-treemap.utils.js +71 -17
- package/lib-esm/components/metrics-treemap/metrics-treemap.utils.js.map +1 -1
- package/lib-esm/components/run-info/run-info.js +26 -14
- package/lib-esm/components/run-info/run-info.js.map +1 -1
- package/lib-esm/components/run-info/run-info.module.css +35 -26
- package/lib-esm/components/summary/summary.js +10 -11
- package/lib-esm/components/summary/summary.js.map +1 -1
- package/lib-esm/components/summary/summary.module.css +60 -10
- package/lib-esm/constants.js +12 -0
- package/lib-esm/constants.js.map +1 -1
- package/lib-esm/css/variables.css +71 -58
- package/lib-esm/ui/button/button.js +2 -2
- package/lib-esm/ui/button/button.js.map +1 -1
- package/lib-esm/ui/dialog/dialog.js +4 -2
- package/lib-esm/ui/dialog/dialog.js.map +1 -1
- package/lib-esm/ui/dialog/dialog.module.css +22 -0
- package/lib-esm/ui/dropdown/dropdown.js +11 -3
- package/lib-esm/ui/dropdown/dropdown.js.map +1 -1
- package/lib-esm/ui/dropdown/dropdown.module.css +51 -6
- package/lib-esm/ui/filters/filters.js +23 -12
- package/lib-esm/ui/filters/filters.js.map +1 -1
- package/lib-esm/ui/filters/filters.module.css +0 -14
- package/lib-esm/ui/hover-card/hover-card.js +7 -1
- package/lib-esm/ui/hover-card/hover-card.js.map +1 -1
- package/lib-esm/ui/hover-card/hover-card.module.css +14 -0
- package/lib-esm/ui/table/table.module.css +0 -1
- package/lib-esm/ui/tooltip/tooltip.js +6 -1
- package/lib-esm/ui/tooltip/tooltip.js.map +1 -1
- package/lib-esm/ui/tooltip/tooltip.module.css +11 -0
- package/package.json +16 -16
- package/src/app/app.jsx +6 -1
- package/src/app/app.module.css +12 -2
- package/src/chart-colors.json +58 -44
- package/src/components/delta/delta.module.css +13 -12
- package/src/components/delta/delta.tsx +32 -0
- package/src/components/entry-info/entry-info.module.css +1 -1
- package/src/components/entry-info/entry-info.tsx +2 -2
- package/src/components/index.ts +3 -0
- package/src/components/insight-icon/insight-icon.module.css +6 -6
- package/src/components/job-name/job-name.jsx +2 -3
- package/src/components/metric-change-legend/index.ts +1 -0
- package/src/components/metric-change-legend/metric-change-legend.module.css +80 -0
- package/src/components/metric-change-legend/metric-change-legend.stories.tsx +13 -0
- package/src/components/metric-change-legend/metric-change-legend.tsx +148 -0
- package/src/components/metric-run-info/metric-run-info.tsx +32 -17
- package/src/components/metrics-display-selector/metrics-display-selector.module.css +0 -25
- package/src/components/metrics-display-selector/metrics-display-selector.tsx +25 -37
- package/src/components/metrics-table-header/metrics-table-header.module.css +8 -12
- package/src/components/metrics-table-header/metrics-table-header.tsx +5 -6
- package/src/components/metrics-table-options/metrics-table-options.tsx +5 -6
- package/src/components/metrics-table-title/metrics-table-title.jsx +1 -1
- package/src/components/metrics-treemap/metrics-treemap.constants.ts +8 -0
- package/src/components/metrics-treemap/metrics-treemap.module.css +9 -16
- package/src/components/metrics-treemap/metrics-treemap.tsx +160 -135
- package/src/components/metrics-treemap/metrics-treemap.utils.ts +141 -27
- package/src/components/run-info/run-info.module.css +35 -26
- package/src/components/run-info/run-info.stories.tsx +16 -10
- package/src/components/run-info/run-info.tsx +132 -73
- package/src/components/summary/summary.module.css +60 -10
- package/src/components/summary/summary.tsx +47 -50
- package/src/constants.ts +13 -0
- package/src/css/variables.css +71 -58
- package/src/ui/button/button.tsx +2 -1
- package/src/ui/dialog/dialog.module.css +22 -0
- package/src/ui/dialog/dialog.tsx +9 -2
- package/src/ui/dropdown/dropdown.module.css +51 -6
- package/src/ui/dropdown/dropdown.tsx +17 -2
- package/src/ui/filters/filters.module.css +0 -14
- package/src/ui/filters/filters.tsx +111 -47
- package/src/ui/hover-card/hover-card.module.css +14 -0
- package/src/ui/hover-card/hover-card.tsx +7 -1
- package/src/ui/table/table.module.css +0 -1
- package/src/ui/tooltip/tooltip.module.css +11 -0
- package/src/ui/tooltip/tooltip.tsx +6 -1
- package/types/components/delta/delta.d.ts +7 -21
- package/types/components/delta/index.d.ts +1 -1
- package/types/components/index.d.ts +3 -0
- package/types/components/metric-change-legend/index.d.ts +1 -0
- package/types/components/metric-change-legend/metric-change-legend.d.ts +4 -0
- package/types/components/metric-run-info/metric-run-info.d.ts +3 -6
- package/types/components/metrics-treemap/metrics-treemap.constants.d.ts +2 -0
- package/types/components/metrics-treemap/metrics-treemap.utils.d.ts +11 -5
- package/types/components/run-info/run-info.d.ts +16 -7
- package/types/constants.d.ts +12 -0
- package/types/ui/dialog/dialog.d.ts +3 -2
- package/types/ui/dropdown/dropdown.d.ts +4 -1
- package/types/ui/filters/filters.d.ts +2 -1
- package/vitest.config.ts +4 -0
- package/lib/components/metrics-table-options/metrics-table-options.module.css +0 -15
- package/lib-esm/components/metrics-table-options/metrics-table-options.module.css +0 -15
- package/src/components/delta/delta.jsx +0 -22
- package/src/components/metrics-table-options/metrics-table-options.module.css +0 -15
- /package/src/components/delta/{index.js → index.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.title {
|
|
2
|
-
color: var(--color-text-
|
|
2
|
+
color: var(--color-text-light);
|
|
3
3
|
font-weight: bold;
|
|
4
4
|
font-size: var(--size-xsmall);
|
|
5
5
|
text-transform: uppercase;
|
|
@@ -16,14 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
.titleIcon {
|
|
18
18
|
flex: 0 0 var(--space-small);
|
|
19
|
+
/* compensate for the button icon spacing */
|
|
19
20
|
margin-top: -3px !important;
|
|
20
21
|
margin-bottom: -3px !important;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
.title + .info {
|
|
24
|
-
margin-top: var(--space-xxsmall);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
24
|
.currentMetric {
|
|
28
25
|
color: var(--color-heading);
|
|
29
26
|
white-space: nowrap;
|
|
@@ -32,33 +29,32 @@
|
|
|
32
29
|
height: var(--line-height-number);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
.delta {
|
|
36
|
-
font-weight: bold;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.deltaValue + .deltaValue::before {
|
|
40
|
-
margin-left: calc(var(--space-xxxsmall) / 2);
|
|
41
|
-
margin-right: calc(var(--space-xxxsmall) / 2);
|
|
42
|
-
content: '/';
|
|
43
|
-
color: var(--color-text-ultra-light);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
32
|
.baselineMetric {
|
|
47
33
|
color: var(--color-text-ultra-light);
|
|
48
34
|
font-size: var(--size-small);
|
|
35
|
+
font-family: var(--font-family-fixed);
|
|
36
|
+
font-weight: normal;
|
|
49
37
|
line-height: var(--line-height-number);
|
|
50
38
|
height: var(--line-height-number);
|
|
51
39
|
}
|
|
52
40
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
max-width: 8em;
|
|
41
|
+
.baselineMetricValue {
|
|
42
|
+
color: var(--color-text-light);
|
|
43
|
+
line-height: inherit;
|
|
57
44
|
}
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
|
|
47
|
+
.delta {
|
|
48
|
+
font-weight: bold;
|
|
49
|
+
font-size: var(--size-small);
|
|
50
|
+
line-height: var(--line-height-number);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.deltaValue + .deltaValue::before {
|
|
54
|
+
margin-left: var(--space-xxxsmall);
|
|
55
|
+
margin-right: var(--space-xxxsmall);
|
|
56
|
+
content: '/';
|
|
57
|
+
color: var(--color-outline-dark);
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
/* Hover state */
|
|
@@ -82,15 +78,28 @@
|
|
|
82
78
|
visibility 0s;
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
/*
|
|
86
|
-
.currentMetric {
|
|
87
|
-
|
|
81
|
+
/* Loading state */
|
|
82
|
+
.loading .currentMetric {
|
|
83
|
+
max-width: 6em;
|
|
88
84
|
}
|
|
89
85
|
|
|
86
|
+
.loading .baselineMetric {
|
|
87
|
+
max-width: 6em;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.loading .delta {
|
|
91
|
+
max-width: 12em;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Size variation */
|
|
90
95
|
.small .currentMetric {
|
|
91
96
|
font-size: var(--size-medium);
|
|
92
97
|
}
|
|
93
98
|
|
|
99
|
+
.currentMetric {
|
|
100
|
+
font-size: var(--size-xxlarge);
|
|
101
|
+
}
|
|
102
|
+
|
|
94
103
|
.large .currentMetric {
|
|
95
104
|
font-size: var(--size-xxxlarge);
|
|
96
105
|
}
|
|
@@ -8,12 +8,24 @@ const meta = {
|
|
|
8
8
|
args: {
|
|
9
9
|
id: 'webpack.totalSizeByTypeALL',
|
|
10
10
|
size: 'medium',
|
|
11
|
+
loading: false,
|
|
12
|
+
showBaseline: true,
|
|
13
|
+
showDelta: true,
|
|
11
14
|
},
|
|
12
15
|
argTypes: {
|
|
13
16
|
size: {
|
|
14
17
|
options: ['small', 'medium', 'large', 'xlarge'],
|
|
15
18
|
control: { type: 'select' },
|
|
16
19
|
},
|
|
20
|
+
loading: {
|
|
21
|
+
control: { type: 'boolean' },
|
|
22
|
+
},
|
|
23
|
+
showBaseline: {
|
|
24
|
+
control: { type: 'boolean' },
|
|
25
|
+
},
|
|
26
|
+
showDelta: {
|
|
27
|
+
control: { type: 'boolean' },
|
|
28
|
+
},
|
|
17
29
|
},
|
|
18
30
|
} satisfies Meta<typeof RunInfo>;
|
|
19
31
|
|
|
@@ -24,20 +36,14 @@ type Story = StoryObj<typeof meta>;
|
|
|
24
36
|
export const Default: Story = {
|
|
25
37
|
args: {
|
|
26
38
|
title: 'Bundle Size',
|
|
27
|
-
current: '
|
|
28
|
-
baseline: '
|
|
29
|
-
delta: '+
|
|
39
|
+
current: '678.91MiB',
|
|
40
|
+
baseline: '123.45MiB',
|
|
41
|
+
delta: '+555.46MiB',
|
|
42
|
+
deltaPercentage: '+549.94%',
|
|
30
43
|
deltaType: 'HIGH_NEGATIVE',
|
|
31
44
|
},
|
|
32
45
|
};
|
|
33
46
|
|
|
34
|
-
export const DeltaPercentage: Story = {
|
|
35
|
-
args: {
|
|
36
|
-
...Default.args,
|
|
37
|
-
deltaPercentage: '+20KiB',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
47
|
export const SizeLarge: Story = {
|
|
42
48
|
args: {
|
|
43
49
|
...Default.args,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { type ReactNode, useMemo } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
+
import type { MetricRunInfoDeltaType } from '@bundle-stats/utils';
|
|
3
4
|
|
|
4
5
|
import { Icon } from '../../ui/icon';
|
|
5
6
|
import { HoverCard } from '../../ui/hover-card';
|
|
@@ -24,23 +25,125 @@ const getMetricParams = (value: string): [string, string?] => {
|
|
|
24
25
|
return [matches[1], matches[2]];
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
type RunInfoTitleProps = {
|
|
29
|
+
className?: string;
|
|
28
30
|
title?: ReactNode;
|
|
29
31
|
titleHoverCard?: ReactNode;
|
|
30
32
|
titleTooltip?: ReactNode;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const RunInfoTitle = ({ className, title, titleHoverCard, titleTooltip }: RunInfoTitleProps) => (
|
|
36
|
+
<FlexStack space="xxxsmall" alignItems="center" as="h3" className={cx(css.title, className)}>
|
|
37
|
+
<span className={css.titleText}>{title}</span>
|
|
38
|
+
{titleHoverCard && (
|
|
39
|
+
<HoverCard
|
|
40
|
+
label={<Icon glyph={Icon.ICONS.HELP} />}
|
|
41
|
+
className={cx(css.titleIcon, css.titleHoverCardIcon)}
|
|
42
|
+
>
|
|
43
|
+
{titleHoverCard}
|
|
44
|
+
</HoverCard>
|
|
45
|
+
)}
|
|
46
|
+
{titleTooltip && (
|
|
47
|
+
<Tooltip title={titleTooltip} className={cx(css.titleIcon, css.titleTooltipIcon)}>
|
|
48
|
+
<Icon glyph={Icon.ICONS.HELP} />
|
|
49
|
+
</Tooltip>
|
|
50
|
+
)}
|
|
51
|
+
</FlexStack>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
type RunInfoContentProps = {
|
|
55
|
+
className?: string;
|
|
56
|
+
loading?: boolean;
|
|
31
57
|
current?: ReactNode;
|
|
58
|
+
enhance?: boolean;
|
|
32
59
|
baseline?: string;
|
|
33
60
|
delta?: string;
|
|
34
61
|
deltaPercentage?: string;
|
|
35
|
-
deltaType?:
|
|
62
|
+
deltaType?: MetricRunInfoDeltaType;
|
|
63
|
+
showBaseline?: boolean;
|
|
64
|
+
showDelta?: boolean;
|
|
65
|
+
};
|
|
36
66
|
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
const RunInfoContent = ({
|
|
68
|
+
className,
|
|
69
|
+
loading = false,
|
|
70
|
+
current = '',
|
|
71
|
+
enhance = false,
|
|
72
|
+
baseline = '',
|
|
73
|
+
delta = '',
|
|
74
|
+
deltaPercentage = '',
|
|
75
|
+
deltaType = 'NO_CHANGE',
|
|
76
|
+
showBaseline = true,
|
|
77
|
+
showDelta = true,
|
|
78
|
+
}: RunInfoContentProps) => {
|
|
79
|
+
const currentValueParams: [ReactNode, string?] = useMemo(() => {
|
|
80
|
+
if (!enhance || typeof current !== 'string') {
|
|
81
|
+
return [current];
|
|
82
|
+
}
|
|
39
83
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
84
|
+
return getMetricParams(current);
|
|
85
|
+
}, [current, enhance]);
|
|
86
|
+
|
|
87
|
+
const contentClassName = cx(css.content, className);
|
|
88
|
+
|
|
89
|
+
if (loading) {
|
|
90
|
+
return (
|
|
91
|
+
<Stack space="xxxsmall" className={contentClassName}>
|
|
92
|
+
<Skeleton className={css.currentMetric} />
|
|
93
|
+
{showBaseline && <Skeleton className={css.baselineMetric} />}
|
|
94
|
+
</Stack>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Stack space="xxxsmall" className={contentClassName}>
|
|
100
|
+
<Metric
|
|
101
|
+
value={currentValueParams[0]}
|
|
102
|
+
unit={currentValueParams[1]}
|
|
103
|
+
inline
|
|
104
|
+
className={css.currentMetric}
|
|
105
|
+
>
|
|
106
|
+
{showDelta && (
|
|
107
|
+
<div className={css.delta}>
|
|
108
|
+
{deltaPercentage && (
|
|
109
|
+
<Delta
|
|
110
|
+
displayValue={deltaPercentage}
|
|
111
|
+
deltaType={deltaType}
|
|
112
|
+
className={css.deltaValue}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
{delta && (
|
|
116
|
+
<Delta displayValue={delta} deltaType={deltaType} className={css.deltaValue} />
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</Metric>
|
|
121
|
+
{showBaseline && (
|
|
122
|
+
<FlexStack alignItems="center" space="xxxsmall" className={css.baselineMetric}>
|
|
123
|
+
<span className={css.baselineMetricLabel}>vs</span>
|
|
124
|
+
<Metric value={baseline} inline className={css.baselineMetricValue} />
|
|
125
|
+
</FlexStack>
|
|
126
|
+
)}
|
|
127
|
+
</Stack>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type RunInfoProps = Pick<RunInfoTitleProps, 'title' | 'titleHoverCard' | 'titleTooltip'> &
|
|
132
|
+
Pick<
|
|
133
|
+
RunInfoContentProps,
|
|
134
|
+
| 'current'
|
|
135
|
+
| 'baseline'
|
|
136
|
+
| 'delta'
|
|
137
|
+
| 'deltaPercentage'
|
|
138
|
+
| 'deltaType'
|
|
139
|
+
| 'showBaseline'
|
|
140
|
+
| 'showDelta'
|
|
141
|
+
| 'loading'
|
|
142
|
+
| 'enhance'
|
|
143
|
+
> & {
|
|
144
|
+
as?: React.ElementType;
|
|
145
|
+
size?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
146
|
+
};
|
|
44
147
|
|
|
45
148
|
export const RunInfo = ({
|
|
46
149
|
className = '',
|
|
@@ -51,81 +154,37 @@ export const RunInfo = ({
|
|
|
51
154
|
baseline = '',
|
|
52
155
|
delta = '',
|
|
53
156
|
deltaPercentage = '',
|
|
54
|
-
deltaType = '',
|
|
157
|
+
deltaType = 'NO_CHANGE',
|
|
55
158
|
as: Component = 'div',
|
|
56
159
|
size = 'medium',
|
|
57
160
|
showBaseline = true,
|
|
161
|
+
showDelta = true,
|
|
58
162
|
loading = false,
|
|
59
163
|
enhance = false,
|
|
164
|
+
children,
|
|
60
165
|
...restProps
|
|
61
166
|
}: RunInfoProps & Omit<React.ComponentProps<'div'>, 'title'>) => {
|
|
62
|
-
const rootClassName = cx(
|
|
63
|
-
css.root,
|
|
64
|
-
className,
|
|
65
|
-
css[size],
|
|
66
|
-
(delta || deltaPercentage) && css.showDelta,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const currentValueParams: [ReactNode, string?] = useMemo(() => {
|
|
70
|
-
if (!enhance || typeof current !== 'string') {
|
|
71
|
-
return [current];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return getMetricParams(current);
|
|
75
|
-
}, [current, enhance]);
|
|
167
|
+
const rootClassName = cx(css.root, loading && css.loading, css[size], className);
|
|
76
168
|
|
|
77
169
|
return (
|
|
78
170
|
<Component className={rootClassName} {...restProps}>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)}
|
|
97
|
-
|
|
98
|
-
{!loading ? (
|
|
99
|
-
<Stack space="xxxsmall" className={css.info}>
|
|
100
|
-
<Metric
|
|
101
|
-
value={currentValueParams[0]}
|
|
102
|
-
unit={currentValueParams[1]}
|
|
103
|
-
inline
|
|
104
|
-
className={css.currentMetric}
|
|
105
|
-
>
|
|
106
|
-
{(delta || deltaPercentage) && (
|
|
107
|
-
<span className={css.delta}>
|
|
108
|
-
{deltaPercentage && (
|
|
109
|
-
<Delta
|
|
110
|
-
displayValue={deltaPercentage}
|
|
111
|
-
deltaType={deltaType}
|
|
112
|
-
className={css.deltaValue}
|
|
113
|
-
/>
|
|
114
|
-
)}
|
|
115
|
-
{delta && (
|
|
116
|
-
<Delta displayValue={delta} deltaType={deltaType} className={css.deltaValue} />
|
|
117
|
-
)}
|
|
118
|
-
</span>
|
|
119
|
-
)}
|
|
120
|
-
</Metric>
|
|
121
|
-
{showBaseline && <Metric className={css.baselineMetric} value={baseline} />}
|
|
122
|
-
</Stack>
|
|
123
|
-
) : (
|
|
124
|
-
<Stack space="xxxsmall" className={css.info}>
|
|
125
|
-
<Skeleton className={cx(css.currentMetric, css.loading)} />
|
|
126
|
-
{showBaseline && <Skeleton as="p" className={cx(css.baselineMetric, css.loading)} />}
|
|
127
|
-
</Stack>
|
|
128
|
-
)}
|
|
171
|
+
<Stack space="xsmall">
|
|
172
|
+
{title && (
|
|
173
|
+
<RunInfoTitle title={title} titleHoverCard={titleHoverCard} titleTooltip={titleTooltip} />
|
|
174
|
+
)}
|
|
175
|
+
<RunInfoContent
|
|
176
|
+
loading={loading}
|
|
177
|
+
current={current}
|
|
178
|
+
enhance={enhance}
|
|
179
|
+
baseline={baseline}
|
|
180
|
+
delta={delta}
|
|
181
|
+
deltaPercentage={deltaPercentage}
|
|
182
|
+
deltaType={deltaType}
|
|
183
|
+
showBaseline={showBaseline}
|
|
184
|
+
showDelta={showDelta}
|
|
185
|
+
/>
|
|
186
|
+
{children}
|
|
187
|
+
</Stack>
|
|
129
188
|
</Component>
|
|
130
189
|
);
|
|
131
190
|
};
|
|
@@ -3,29 +3,79 @@
|
|
|
3
3
|
width: 100%;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
.
|
|
6
|
+
.row {
|
|
7
7
|
width: 100%;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: stretch;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
gap: var(--space-small);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.rowGroup {
|
|
15
|
+
flex: 1 1 auto;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
.
|
|
18
|
+
.rowGroupTitle {
|
|
19
|
+
position: absolute;
|
|
20
|
+
font-size: 0;
|
|
21
|
+
width: 0;
|
|
22
|
+
left: -99999px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.row + .row {
|
|
11
26
|
margin-top: var(--summary-gap);
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
.items {
|
|
15
30
|
display: flex;
|
|
31
|
+
align-items: stretch;
|
|
16
32
|
flex-wrap: wrap;
|
|
17
|
-
|
|
18
|
-
margin-top: calc(0px - var(--summary-gap));
|
|
19
|
-
margin-left: calc(0px - var(--summary-gap));
|
|
33
|
+
gap: var(--space-medium);
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
.item {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
min-width: 12em;
|
|
37
|
+
flex: 1 1 10%; /* force equal sizes */
|
|
38
|
+
min-width: 8em;
|
|
26
39
|
text-decoration: none;
|
|
40
|
+
position: relative;
|
|
41
|
+
z-index: 0;
|
|
27
42
|
}
|
|
28
43
|
|
|
29
|
-
.
|
|
30
|
-
|
|
44
|
+
.item::before {
|
|
45
|
+
content: "";
|
|
46
|
+
border-radius: var(--radius-medium);
|
|
47
|
+
background: var(--color-highlight);
|
|
48
|
+
display: block;
|
|
49
|
+
position: absolute;
|
|
50
|
+
z-index: -1;
|
|
51
|
+
top: calc(0px - var(--space-xsmall));
|
|
52
|
+
right: calc(0px - var(--space-xsmall));
|
|
53
|
+
bottom: calc(0px - var(--space-xsmall));
|
|
54
|
+
left: calc(0px - var(--space-xsmall));
|
|
55
|
+
opacity: 0;
|
|
56
|
+
transition: var(--transition-out);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.item:hover::before {
|
|
60
|
+
opacity: 1;
|
|
61
|
+
transition: var(--transition-in);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.item + .item::after {
|
|
65
|
+
content: "";
|
|
66
|
+
border-radius: var(--radius-medium);
|
|
67
|
+
background: var(--color-outline);
|
|
68
|
+
display: block;
|
|
69
|
+
width: 1px;
|
|
70
|
+
position: absolute;
|
|
71
|
+
left: calc(0px - var(--space-xsmall));
|
|
72
|
+
top: var(--space-xxsmall);
|
|
73
|
+
bottom: var(--space-xxsmall);
|
|
74
|
+
opacity: 1;
|
|
75
|
+
transition: var(--transition-out);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.item:hover::after, .item:hover + .item::after {
|
|
79
|
+
opacity: 0;
|
|
80
|
+
transition: var(--transition-in);
|
|
31
81
|
}
|
|
@@ -4,21 +4,16 @@ import get from 'lodash/get';
|
|
|
4
4
|
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
METRICS_GROUP_ASSETS,
|
|
8
|
+
METRICS_GROUP_MODULES,
|
|
9
|
+
METRICS_GROUP_PACKAGES,
|
|
8
10
|
METRICS_WEBPACK_GENERAL,
|
|
9
|
-
METRICS_WEBPACK_MODULES,
|
|
10
|
-
METRICS_WEBPACK_PACKAGES,
|
|
11
11
|
} from '../../constants';
|
|
12
12
|
import { Box } from '../../layout/box';
|
|
13
13
|
import { ComponentLink } from '../component-link';
|
|
14
14
|
import { MetricRunInfo, MetricRunInfoProps } from '../metric-run-info';
|
|
15
15
|
import css from './summary.module.css';
|
|
16
|
-
|
|
17
|
-
const METRICS_WEBPACK_OTHERS = [
|
|
18
|
-
...METRICS_WEBPACK_ASSETS,
|
|
19
|
-
...METRICS_WEBPACK_MODULES,
|
|
20
|
-
...METRICS_WEBPACK_PACKAGES,
|
|
21
|
-
];
|
|
16
|
+
import { Stack } from '../../layout';
|
|
22
17
|
|
|
23
18
|
interface SummaryItemProps {
|
|
24
19
|
metricId: string;
|
|
@@ -46,15 +41,7 @@ const SummaryItem = (props: SummaryItemProps & React.ComponentProps<'div'>) => {
|
|
|
46
41
|
const metricData = get(data, metricId, { current: 0, baseline: 0 });
|
|
47
42
|
|
|
48
43
|
return (
|
|
49
|
-
<
|
|
50
|
-
key={metricId}
|
|
51
|
-
outline
|
|
52
|
-
outlineHover
|
|
53
|
-
padding="small"
|
|
54
|
-
as={SummaryItemCustomLink}
|
|
55
|
-
{...componentLink?.link}
|
|
56
|
-
className={className}
|
|
57
|
-
>
|
|
44
|
+
<SummaryItemCustomLink key={metricId} {...componentLink?.link} className={className}>
|
|
58
45
|
<MetricRunInfo
|
|
59
46
|
metricId={metricId}
|
|
60
47
|
current={metricData.current}
|
|
@@ -64,7 +51,7 @@ const SummaryItem = (props: SummaryItemProps & React.ComponentProps<'div'>) => {
|
|
|
64
51
|
size={size}
|
|
65
52
|
loading={loading}
|
|
66
53
|
/>
|
|
67
|
-
</
|
|
54
|
+
</SummaryItemCustomLink>
|
|
68
55
|
);
|
|
69
56
|
};
|
|
70
57
|
|
|
@@ -90,38 +77,48 @@ export const Summary = ({
|
|
|
90
77
|
summaryItemLink = ComponentLink,
|
|
91
78
|
}: SummaryProps & React.ComponentProps<'div'>) => (
|
|
92
79
|
<Box className={cx(css.root, className)}>
|
|
93
|
-
<div className={css.
|
|
94
|
-
<
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
80
|
+
<div className={css.row}>
|
|
81
|
+
<Box outline padding="small" className={css.rowGroup}>
|
|
82
|
+
<div className={css.items}>
|
|
83
|
+
{METRICS_WEBPACK_GENERAL.map((metricId) => (
|
|
84
|
+
<SummaryItem
|
|
85
|
+
key={metricId}
|
|
86
|
+
className={css.item}
|
|
87
|
+
metricId={metricId}
|
|
88
|
+
data={data}
|
|
89
|
+
size="xlarge"
|
|
90
|
+
loading={loading}
|
|
91
|
+
customLink={summaryItemLink}
|
|
92
|
+
showDelta={showSummaryItemDelta}
|
|
93
|
+
showBaseline={showSummaryItemBaseline}
|
|
94
|
+
/>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
</Box>
|
|
109
98
|
</div>
|
|
110
|
-
<div className={css.
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
className={
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
99
|
+
<div className={css.row}>
|
|
100
|
+
{[METRICS_GROUP_ASSETS, METRICS_GROUP_MODULES, METRICS_GROUP_PACKAGES].map((metricGroup) => (
|
|
101
|
+
<Stack className={css.rowGroup} key={metricGroup.title}>
|
|
102
|
+
<h3 className={css.rowGroupTitle}>{metricGroup.title}</h3>
|
|
103
|
+
<Box outline padding="small">
|
|
104
|
+
<div className={css.items}>
|
|
105
|
+
{metricGroup.metrics.map((metricId) => (
|
|
106
|
+
<SummaryItem
|
|
107
|
+
key={metricId}
|
|
108
|
+
className={css.item}
|
|
109
|
+
metricId={metricId}
|
|
110
|
+
data={data}
|
|
111
|
+
size="large"
|
|
112
|
+
loading={loading}
|
|
113
|
+
customLink={summaryItemLink}
|
|
114
|
+
showDelta={showSummaryItemDelta}
|
|
115
|
+
showBaseline={showSummaryItemBaseline}
|
|
116
|
+
/>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
</Box>
|
|
120
|
+
</Stack>
|
|
121
|
+
))}
|
|
125
122
|
</div>
|
|
126
123
|
</Box>
|
|
127
124
|
);
|
package/src/constants.ts
CHANGED
|
@@ -36,6 +36,19 @@ export const METRICS_WEBPACK_MODULES = [
|
|
|
36
36
|
];
|
|
37
37
|
export const METRICS_WEBPACK_PACKAGES = ['webpack.packageCount', 'webpack.duplicatePackagesCount'];
|
|
38
38
|
|
|
39
|
+
export const METRICS_GROUP_ASSETS = {
|
|
40
|
+
title: 'Assets',
|
|
41
|
+
metrics: METRICS_WEBPACK_ASSETS,
|
|
42
|
+
};
|
|
43
|
+
export const METRICS_GROUP_MODULES = {
|
|
44
|
+
title: 'Modules',
|
|
45
|
+
metrics: METRICS_WEBPACK_MODULES,
|
|
46
|
+
};
|
|
47
|
+
export const METRICS_GROUP_PACKAGES = {
|
|
48
|
+
title: 'Packages',
|
|
49
|
+
metrics: METRICS_WEBPACK_PACKAGES,
|
|
50
|
+
};
|
|
51
|
+
|
|
39
52
|
export const SORT = {
|
|
40
53
|
ASC: 'asc',
|
|
41
54
|
DESC: 'desc',
|