@bundle-stats/ui 4.22.2 → 4.23.0-beta.1
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/.babelrc.js +65 -24
- package/globals.d.ts +13 -0
- package/lib/app/app.js +3 -0
- package/lib/app/app.js.map +1 -1
- package/lib/app/app.module.css +11 -1
- package/lib/components/bundle-modules/index.js.map +1 -1
- 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/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 +69 -0
- package/lib/components/metric-run-info/metric-run-info.js +30 -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 +8 -8
- 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 +1 -1
- 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/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/default.css +1 -1
- package/lib/css/variables.css +71 -58
- package/lib/hooks/rows-sort.js +13 -12
- package/lib/hooks/rows-sort.js.map +1 -1
- 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 +4 -3
- package/lib/ui/dropdown/dropdown.js.map +1 -1
- package/lib/ui/dropdown/dropdown.module.css +11 -0
- package/lib/ui/empty-set/empty-set.js +3 -3
- package/lib/ui/empty-set/empty-set.js.map +1 -1
- package/lib/ui/hover-card/hover-card.js +1 -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 +1 -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 +11 -1
- package/lib-esm/components/bundle-modules/index.js.map +1 -1
- 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/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 +69 -0
- package/lib-esm/components/metric-run-info/metric-run-info.js +31 -8
- 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 +8 -8
- 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 +1 -1
- 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/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/default.css +1 -1
- package/lib-esm/css/variables.css +71 -58
- package/lib-esm/hooks/rows-sort.js +10 -8
- package/lib-esm/hooks/rows-sort.js.map +1 -1
- 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 +4 -3
- package/lib-esm/ui/dropdown/dropdown.js.map +1 -1
- package/lib-esm/ui/dropdown/dropdown.module.css +11 -0
- package/lib-esm/ui/empty-set/empty-set.js +3 -3
- package/lib-esm/ui/empty-set/empty-set.js.map +1 -1
- package/lib-esm/ui/hover-card/hover-card.js +1 -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 +1 -1
- package/lib-esm/ui/tooltip/tooltip.js.map +1 -1
- package/lib-esm/ui/tooltip/tooltip.module.css +11 -0
- package/package.json +26 -15
- package/src/app/app.jsx +6 -1
- package/src/app/app.module.css +11 -1
- package/src/app/app.stories.tsx +2 -2
- package/src/components/asset-info/asset-info.stories.tsx +47 -39
- package/src/components/asset-name/asset-name.stories.tsx +1 -3
- package/src/components/asset-not-predictive/asset-not-predictive.stories.tsx +22 -15
- package/src/components/browsertime-table/browsertime-table.stories.tsx +45 -0
- package/src/components/bundle-assets-totals/bundle-assets-totals.stories.tsx +47 -0
- package/src/components/bundle-modules/bundle-modules.stories.tsx +191 -0
- package/src/components/bundle-modules/bundle-modules.tsx +1 -1
- package/src/components/bundle-modules/index.tsx +4 -0
- package/src/components/bundle-packages/bundle-packages.stories.tsx +87 -0
- package/src/components/delta/delta.module.css +13 -12
- package/src/components/delta/delta.stories.tsx +57 -0
- package/src/components/delta/delta.tsx +32 -0
- package/src/components/entry-info/entry-info.stories.tsx +49 -54
- package/src/components/{index.js → index.ts} +7 -2
- package/src/components/insight-icon/insight-icon.module.css +6 -6
- package/src/components/insights/insights.stories.tsx +36 -33
- package/src/components/job-name/job-name.jsx +2 -3
- package/src/components/job-name/job-name.stories.tsx +46 -0
- package/src/components/jobs-header/jobs-header.stories.tsx +19 -15
- package/src/components/lighthouse-table/lighthouse-table.stories.tsx +30 -0
- package/src/components/metric/metric.stories.tsx +24 -22
- package/src/components/metric-change-legend/index.ts +1 -0
- package/src/components/metric-change-legend/metric-change-legend.module.css +69 -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.stories.tsx +45 -41
- package/src/components/metric-run-info/metric-run-info.tsx +41 -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/metrics-table.stories.tsx +33 -13
- package/src/components/metrics-table/metrics-table.tsx +1 -1
- package/src/components/metrics-table-header/metrics-table-header.module.css +8 -12
- package/src/components/metrics-table-header/metrics-table-header.tsx +14 -10
- package/src/components/metrics-table-options/metrics-table-options.tsx +1 -1
- package/src/components/metrics-table-title/metrics-table-title.jsx +1 -1
- package/src/components/module-info/module-info.stories.tsx +41 -30
- package/src/components/package-info/package-info.stories.tsx +20 -15
- package/src/components/run-info/run-info.module.css +35 -26
- package/src/components/run-info/run-info.stories.tsx +47 -39
- package/src/components/run-info/run-info.tsx +132 -73
- package/src/components/summary/summary.module.css +60 -10
- package/src/components/summary/summary.stories.tsx +26 -32
- package/src/components/summary/summary.tsx +47 -50
- package/src/constants.ts +13 -0
- package/src/css/default.css +1 -1
- package/src/css/variables.css +71 -58
- package/src/hooks/rows-sort.ts +9 -6
- package/src/layout/box/box.stories.tsx +35 -28
- package/src/layout/flex-stack/flex-stack.stories.tsx +79 -48
- package/src/layout/footer/footer.stories.tsx +30 -0
- package/src/layout/stack/stack.stories.tsx +68 -44
- package/src/ui/alert/alert.stories.tsx +25 -21
- package/src/ui/button/button.stories.tsx +181 -176
- package/src/ui/button/button.tsx +8 -1
- package/src/ui/container/container.stories.tsx +28 -21
- package/src/ui/control-group/control-group.stories.tsx +23 -16
- package/src/ui/dialog/dialog.module.css +22 -0
- package/src/ui/dialog/dialog.tsx +9 -2
- package/src/ui/dropdown/dropdown.module.css +11 -0
- package/src/ui/dropdown/dropdown.stories.tsx +23 -15
- package/src/ui/dropdown/dropdown.tsx +5 -1
- package/src/ui/empty-set/empty-set.jsx +16 -4
- package/src/ui/empty-set/empty-set.stories.tsx +41 -0
- package/src/ui/file-name/file-name.stories.tsx +45 -0
- package/src/ui/filters/filters.stories.tsx +29 -26
- package/src/ui/hover-card/hover-card.module.css +14 -0
- package/src/ui/hover-card/hover-card.stories.tsx +35 -26
- package/src/ui/hover-card/hover-card.tsx +1 -1
- package/src/ui/icon/icon.stories.tsx +36 -28
- package/src/ui/input/input.stories.tsx +17 -5
- package/src/ui/input-search/input-search.stories.tsx +31 -0
- package/src/ui/loader/loader.stories.tsx +22 -0
- package/src/ui/skeleton/skeleton.stories.tsx +42 -0
- package/src/ui/table/table.module.css +0 -1
- package/src/ui/table/table.stories.tsx +244 -218
- package/src/ui/tag/tag.stories.tsx +11 -10
- package/src/ui/toolbar/toolbar.stories.tsx +41 -0
- package/src/ui/tooltip/tooltip.module.css +11 -0
- package/src/ui/tooltip/tooltip.tsx +1 -1
- package/types/components/bundle-modules/bundle-modules.d.ts +1 -1
- package/types/components/bundle-modules/index.d.ts +2 -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 +25 -20
- 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 +2 -6
- package/types/components/metrics-table/metrics-table.d.ts +1 -1
- package/types/components/metrics-table-header/metrics-table-header.d.ts +1 -1
- package/types/components/run-info/run-info.d.ts +16 -7
- package/types/constants.d.ts +12 -0
- package/types/hooks/rows-sort.d.ts +2 -2
- package/types/ui/button/button.d.ts +1 -1
- package/types/ui/dialog/dialog.d.ts +3 -2
- package/types/ui/dropdown/dropdown.d.ts +1 -0
- package/vitest.config.ts +47 -0
- package/vitest.setup.ts +26 -0
- package/lib/assets/icons.svg.js +0 -100
- package/lib/assets/icons.svg.js.map +0 -1
- package/lib-esm/assets/icons.svg.js +0 -63
- package/lib-esm/assets/icons.svg.js.map +0 -1
- package/src/assets/icons.svg.jsx +0 -279
- package/src/components/delta/delta.jsx +0 -22
- package/types/assets/icons.svg.d.ts +0 -2
- /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
|
}
|
|
@@ -1,65 +1,73 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Meta, Story } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
2
|
|
|
4
3
|
import { RunInfo } from './run-info';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
const meta = {
|
|
7
6
|
title: 'Components/RunInfo',
|
|
8
7
|
component: RunInfo,
|
|
9
8
|
args: {
|
|
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
|
-
}
|
|
19
|
-
|
|
20
|
-
const Template: Story = (args) => <RunInfo id="webpack.totalSizeByTypeALL" {...args} />;
|
|
21
|
-
|
|
22
|
-
export const Default = Template.bind({});
|
|
30
|
+
} satisfies Meta<typeof RunInfo>;
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
title: 'Bundle Size',
|
|
26
|
-
current: '120KiB',
|
|
27
|
-
baseline: '100KiB',
|
|
28
|
-
delta: '+20%',
|
|
29
|
-
deltaType: 'HIGH_NEGATIVE',
|
|
30
|
-
};
|
|
32
|
+
export default meta;
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
export const Default: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
title: 'Bundle Size',
|
|
39
|
+
current: '678.91MiB',
|
|
40
|
+
baseline: '123.45MiB',
|
|
41
|
+
delta: '+555.46MiB',
|
|
42
|
+
deltaPercentage: '+549.94%',
|
|
43
|
+
deltaType: 'HIGH_NEGATIVE',
|
|
44
|
+
},
|
|
37
45
|
};
|
|
38
46
|
|
|
39
|
-
export const SizeLarge =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
export const SizeLarge: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
...Default.args,
|
|
50
|
+
size: 'large',
|
|
51
|
+
},
|
|
44
52
|
};
|
|
45
53
|
|
|
46
|
-
export const TitleHoverCard =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
export const TitleHoverCard: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
...Default.args,
|
|
57
|
+
titleHoverCard: 'Info',
|
|
58
|
+
},
|
|
51
59
|
};
|
|
52
60
|
|
|
53
|
-
export const TitleTooltip =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
export const TitleTooltip: Story = {
|
|
62
|
+
args: {
|
|
63
|
+
...Default.args,
|
|
64
|
+
titleTooltip: 'Info',
|
|
65
|
+
},
|
|
58
66
|
};
|
|
59
67
|
|
|
60
|
-
export const Loading =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
export const Loading: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
title: 'Bundle Size',
|
|
71
|
+
loading: true,
|
|
72
|
+
},
|
|
65
73
|
};
|
|
@@ -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
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Meta,
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { createJobs } from '@bundle-stats/utils';
|
|
4
4
|
|
|
5
5
|
/* eslint-disable import/no-relative-packages */
|
|
6
6
|
import baselineData from '../../../../../fixtures/webpack-stats.baseline.json';
|
|
7
7
|
import currentData from '../../../../../fixtures/webpack-stats.current.json';
|
|
8
8
|
/* eslint-enable import/no-relative-packages */
|
|
9
|
-
import { METRICS_WEBPACK_ASSETS } from '../../constants';
|
|
10
9
|
import { getWrapperDecorator } from '../../stories';
|
|
11
10
|
import { Summary } from '.';
|
|
12
11
|
|
|
@@ -14,46 +13,41 @@ const MULTIPLE_JOBS = createJobs([{ webpack: currentData }, { webpack: baselineD
|
|
|
14
13
|
|
|
15
14
|
const SINGLE_JOB = createJobs([{ webpack: currentData }]);
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
const meta = {
|
|
18
17
|
title: 'Components/Summary',
|
|
19
18
|
component: Summary,
|
|
20
19
|
decorators: [getWrapperDecorator()],
|
|
21
|
-
}
|
|
20
|
+
} satisfies Meta<typeof Summary>;
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
export default meta;
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
26
25
|
|
|
27
|
-
Default
|
|
28
|
-
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
data: MULTIPLE_JOBS[0].summary!.webpack,
|
|
29
|
+
},
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
data: MULTIPLE_JOBS[0].summary,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const Loading = Template.bind({});
|
|
39
|
-
|
|
40
|
-
Loading.args = {
|
|
41
|
-
loading: true,
|
|
32
|
+
export const Loading: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
loading: true,
|
|
35
|
+
},
|
|
42
36
|
};
|
|
43
37
|
|
|
44
|
-
export const SingleRun =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
export const SingleRun: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
data: SINGLE_JOB[0].summary!.webpack,
|
|
41
|
+
showSummaryItemDelta: false,
|
|
42
|
+
showSummaryItemBaseline: false,
|
|
43
|
+
},
|
|
50
44
|
};
|
|
51
45
|
|
|
52
|
-
export const WithLink =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
export const WithLink: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
data: MULTIPLE_JOBS[0].summary!.webpack,
|
|
49
|
+
summaryItemLink: (linkProps) => (
|
|
50
|
+
<button {...linkProps} type="button" onClick={() => alert(JSON.stringify(linkProps))} />
|
|
51
|
+
),
|
|
52
|
+
},
|
|
59
53
|
};
|