@bundle-stats/ui 4.2.5-beta.1 → 4.2.5-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/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +2 -8
- package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js.map +1 -1
- package/lib/components/index.js +3 -1
- package/lib/components/index.js.map +1 -1
- package/lib/components/metric-run-info/metric-run-info.js +47 -33
- package/lib/components/metric-run-info/metric-run-info.js.map +1 -1
- package/lib/components/metric-run-info/metric-run-info.module.css +14 -36
- package/lib/components/metrics-table-title/metrics-table-title.module.css +1 -0
- package/lib/components/run-info/index.js +18 -0
- package/lib/components/run-info/index.js.map +1 -0
- package/lib/components/run-info/run-info.js +45 -0
- package/lib/components/run-info/run-info.js.map +1 -0
- package/lib/components/run-info/run-info.module.css +41 -0
- package/lib/components/summary/summary.js +3 -43
- package/lib/components/summary/summary.js.map +1 -1
- package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +2 -8
- package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.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/metric-run-info/metric-run-info.js +24 -33
- package/lib-esm/components/metric-run-info/metric-run-info.js.map +1 -1
- package/lib-esm/components/metric-run-info/metric-run-info.module.css +14 -36
- package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +1 -0
- package/lib-esm/components/run-info/index.js +2 -0
- package/lib-esm/components/run-info/index.js.map +1 -0
- package/lib-esm/components/run-info/run-info.js +38 -0
- package/lib-esm/components/run-info/run-info.js.map +1 -0
- package/lib-esm/components/run-info/run-info.module.css +41 -0
- package/lib-esm/components/summary/summary.js +4 -21
- package/lib-esm/components/summary/summary.js.map +1 -1
- package/package.json +6 -6
- package/src/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.jsx +5 -10
- package/src/components/index.js +1 -0
- package/src/components/metric-run-info/metric-run-info.module.css +14 -36
- package/src/components/metric-run-info/metric-run-info.stories.tsx +13 -29
- package/src/components/metric-run-info/metric-run-info.tsx +52 -86
- package/src/components/metrics-table-title/metrics-table-title.module.css +1 -0
- package/src/components/run-info/index.ts +1 -0
- package/src/components/run-info/run-info.module.css +41 -0
- package/src/components/run-info/run-info.stories.tsx +49 -0
- package/src/components/run-info/run-info.tsx +100 -0
- package/src/components/summary/summary.tsx +14 -41
- package/types/components/index.d.ts +1 -0
- package/types/components/metric-run-info/metric-run-info.d.ts +9 -11
- package/types/components/run-info/index.d.ts +1 -0
- package/types/components/run-info/run-info.d.ts +14 -0
|
@@ -1,40 +1,18 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
.readMoreLink {
|
|
2
|
+
appearance: none;
|
|
3
|
+
background: none;
|
|
4
|
+
margin: 0;
|
|
5
|
+
border: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
color: var(--color-primary);
|
|
8
|
+
text-decoration: underline;
|
|
9
|
+
cursor: pointer;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
.readMoreLink:hover,
|
|
13
|
+
.readMoreLink:active,
|
|
14
|
+
.readMoreLink:focus {
|
|
15
|
+
color: var(--color-primary-dark);
|
|
16
|
+
text-decoration: none;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
.currentMetric {
|
|
15
|
-
color: var(--color-heading);
|
|
16
|
-
font-size: var(--size-large);
|
|
17
|
-
line-height: var(--line-height-heading);
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
font-weight: bold;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.baselineMetric {
|
|
23
|
-
color: var(--color-text-light);
|
|
24
|
-
font-size: var(--size-small);
|
|
25
|
-
line-height: var(--line-height-heading);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Loading state */
|
|
29
|
-
.loading.currentMetric {
|
|
30
|
-
width: 8em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.loading.baselineMetric {
|
|
34
|
-
width: 5em;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Size large */
|
|
38
|
-
.large .currentMetric {
|
|
39
|
-
font-size: var(--size-xxxlarge);
|
|
40
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/run-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { Icon } from '../../ui/icon';
|
|
4
|
+
import { HoverCard } from '../../ui/hover-card';
|
|
5
|
+
import { Tooltip } from '../../ui/tooltip';
|
|
6
|
+
import { Skeleton } from '../../ui/skeleton';
|
|
7
|
+
import { FlexStack } from '../../layout/flex-stack';
|
|
8
|
+
import { Stack } from '../../layout/stack';
|
|
9
|
+
import { Metric } from '../metric';
|
|
10
|
+
import { Delta } from '../delta';
|
|
11
|
+
import css from './run-info.module.css';
|
|
12
|
+
const EXTRACT_VALUE_UNIT_PATTERN = /([\d|.|,| ]*)(\w*|%)$/;
|
|
13
|
+
const getMetricParams = (value) => {
|
|
14
|
+
const matches = value.match(EXTRACT_VALUE_UNIT_PATTERN);
|
|
15
|
+
if (!matches) {
|
|
16
|
+
return { value, unit: '' };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
value: matches[1],
|
|
20
|
+
unit: matches[2],
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const RunInfo = ({ className = '', title = '', titleHoverCard = null, titleTooltip = null, current = '', baseline = '', delta = '', deltaType = '', as: Component = 'div', size = 'medium', loading = false, ...restProps }) => {
|
|
24
|
+
const metricParams = getMetricParams(current);
|
|
25
|
+
const rootClassName = cx(css.root, className, css[size], delta && css.showDelta);
|
|
26
|
+
return (React.createElement(Stack, { space: "xxsmall", as: Component, className: rootClassName, ...restProps },
|
|
27
|
+
title && (React.createElement(FlexStack, { space: "xxxsmall", alignItems: "center", as: "h3", className: css.title },
|
|
28
|
+
React.createElement("span", null, title),
|
|
29
|
+
titleHoverCard && (React.createElement(HoverCard, { label: React.createElement(Icon, { glyph: Icon.ICONS.HELP }), className: css.titleIcon }, titleHoverCard)),
|
|
30
|
+
titleTooltip && (React.createElement(Tooltip, { title: titleTooltip, className: css.titleIcon },
|
|
31
|
+
React.createElement(Icon, { glyph: Icon.ICONS.HELP }))))),
|
|
32
|
+
!loading ? (React.createElement(Stack, null,
|
|
33
|
+
React.createElement(Metric, { className: css.currentMetric, value: metricParams.value, unit: metricParams.unit, inline: true }, delta && React.createElement(Delta, { className: css.delta, displayValue: delta, deltaType: deltaType })),
|
|
34
|
+
React.createElement(Metric, { className: css.baselineMetric, value: baseline }))) : (React.createElement(Stack, null,
|
|
35
|
+
React.createElement(Skeleton, { as: "p", className: cx(css.currentMetric, css.loading) }),
|
|
36
|
+
React.createElement(Skeleton, { as: "p", className: cx(css.baselineMetric, css.loading) })))));
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=run-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-info.js","sourceRoot":"","sources":["../../../src/components/run-info/run-info.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,E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EAAE,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,GAAI,CAC7D,CACT,CACK,CACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.title {
|
|
2
|
+
color: var(--color-text-ultra-light);
|
|
3
|
+
font-weight: bold;
|
|
4
|
+
font-size: var(--size-xsmall);
|
|
5
|
+
text-transform: uppercase;
|
|
6
|
+
white-space: nowrap;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.titleIcon {
|
|
10
|
+
flex: 0 0 var(--space-small);
|
|
11
|
+
margin-top: -4px !important;
|
|
12
|
+
margin-bottom: -4px !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.currentMetric {
|
|
16
|
+
color: var(--color-heading);
|
|
17
|
+
font-size: var(--size-xlarge);
|
|
18
|
+
line-height: var(--line-height-heading);
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
font-weight: bold;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.baselineMetric {
|
|
24
|
+
color: var(--color-text-light);
|
|
25
|
+
font-size: var(--size-medium);
|
|
26
|
+
line-height: var(--line-height-heading);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Loading state */
|
|
30
|
+
.loading.currentMetric {
|
|
31
|
+
width: 8em;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.loading.baselineMetric {
|
|
35
|
+
width: 5em;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Size large */
|
|
39
|
+
.large .currentMetric {
|
|
40
|
+
font-size: var(--size-xxxlarge);
|
|
41
|
+
}
|
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
|
-
import { METRIC_COMPONENT_LINKS
|
|
4
|
+
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
5
5
|
import { METRICS_WEBPACK_GENERAL } from '../../constants';
|
|
6
6
|
import { Box } from '../../layout/box';
|
|
7
7
|
import { FlexStack } from '../../layout/flex-stack';
|
|
8
|
-
import { Stack } from '../../layout/stack';
|
|
9
8
|
import { ComponentLink } from '../component-link';
|
|
10
9
|
import { MetricRunInfo } from '../metric-run-info';
|
|
11
10
|
import css from './summary.module.css';
|
|
12
|
-
const MetricInfo = ({ description, url }) => {
|
|
13
|
-
const onClick = useCallback(() => {
|
|
14
|
-
if (url) {
|
|
15
|
-
window.open(url);
|
|
16
|
-
}
|
|
17
|
-
}, [url]);
|
|
18
|
-
return (React.createElement(Stack, { space: "xxxsmall" },
|
|
19
|
-
React.createElement("p", null, description),
|
|
20
|
-
url && (React.createElement("p", null,
|
|
21
|
-
React.createElement("button", { type: "button", onClick: onClick, className: css.readMoreLink }, "Read more")))));
|
|
22
|
-
};
|
|
23
11
|
const SummaryItem = (props) => {
|
|
24
|
-
const { className = '', metricId, data, summaryItemLink: SummaryItemCustomLink, size, loading, showSummaryItemDelta } = props;
|
|
12
|
+
const { className = '', metricId, data, summaryItemLink: SummaryItemCustomLink, size, loading, showSummaryItemDelta, } = props;
|
|
25
13
|
const componentLink = METRIC_COMPONENT_LINKS.get(metricId);
|
|
26
14
|
const metricData = get(data, metricId, { current: 0, baseline: 0 });
|
|
27
|
-
const metric = getGlobalMetricType(metricId);
|
|
28
|
-
const metricRunInfo = getMetricRunInfo(metric, metricData.current, metricData.baseline);
|
|
29
15
|
return (React.createElement(Box, { key: metricId, outline: true, outlineHover: true, padding: "small", as: SummaryItemCustomLink, ...componentLink === null || componentLink === void 0 ? void 0 : componentLink.link, className: className },
|
|
30
|
-
React.createElement(MetricRunInfo, {
|
|
31
|
-
delta: metricRunInfo.displayDeltaPercentage,
|
|
32
|
-
deltaType: metricRunInfo.deltaType,
|
|
33
|
-
}) })));
|
|
16
|
+
React.createElement(MetricRunInfo, { metricId: metricId, current: metricData.current, baseline: metricData.baseline, showDelta: showSummaryItemDelta && (componentLink === null || componentLink === void 0 ? void 0 : componentLink.showDelta), size: size, loading: loading })));
|
|
34
17
|
};
|
|
35
18
|
export const Summary = ({ className = '', size = 'medium', keys = METRICS_WEBPACK_GENERAL, data = null, loading = false, showSummaryItemDelta = true, summaryItemLink = ComponentLink, }) => (React.createElement(Box, { className: cx(css.root, className) },
|
|
36
19
|
React.createElement(FlexStack, { space: "small", className: css.items }, keys.map((metricId) => (React.createElement(SummaryItem, { key: metricId, className: css.item, metricId: metricId, data: data, summaryItemLink: summaryItemLink, size: size, loading: loading, showSummaryItemDelta: showSummaryItemDelta }))))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../src/components/summary/summary.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../src/components/summary/summary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AACvE,OAAO,GAAG,MAAM,sBAAsB,CAAC;AAyBvC,MAAM,WAAW,GAAG,CAAC,KAAqD,EAAE,EAAE;IAC5E,MAAM,EACJ,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,IAAI,EACJ,eAAe,EAAE,qBAAqB,EACtC,IAAI,EACJ,OAAO,EACP,oBAAoB,GACrB,GAAG,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AG,CAAC,IAAI,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,oBAAoB,GAC1C,CACH,CAAC,CACQ,CACR,CACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundle-stats/ui",
|
|
3
|
-
"version": "4.2.5-beta.
|
|
3
|
+
"version": "4.2.5-beta.2",
|
|
4
4
|
"description": "UI components for BundleStats projects.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"enzyme-to-json": "3.6.2",
|
|
59
59
|
"hex-rgb": "5.0.0",
|
|
60
60
|
"identity-obj-proxy": "3.0.0",
|
|
61
|
-
"jest": "29.
|
|
61
|
+
"jest": "29.5.0",
|
|
62
62
|
"jest-date-mock": "1.0.8",
|
|
63
|
-
"jest-environment-jsdom": "29.
|
|
63
|
+
"jest-environment-jsdom": "29.5.0",
|
|
64
64
|
"lodash": "4.17.21",
|
|
65
65
|
"postcss": "8.4.21",
|
|
66
66
|
"prop-types": "15.8.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"react-dom": "17.0.2",
|
|
69
69
|
"react-router-dom": "5.3.4",
|
|
70
70
|
"react-test-renderer": "18.2.0",
|
|
71
|
-
"rimraf": "4.
|
|
71
|
+
"rimraf": "4.4.0",
|
|
72
72
|
"typescript": "4.9.5",
|
|
73
73
|
"typescript-plugin-css-modules": "4.2.3"
|
|
74
74
|
},
|
|
@@ -81,11 +81,11 @@
|
|
|
81
81
|
"react-router-dom": "^5.0.0"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@bundle-stats/utils": "^4.2.5-beta.
|
|
84
|
+
"@bundle-stats/utils": "^4.2.5-beta.2",
|
|
85
85
|
"ariakit": "2.0.0-next.43",
|
|
86
86
|
"modern-css-reset": "1.4.0",
|
|
87
87
|
"query-string": "7.1.3",
|
|
88
88
|
"use-query-params": "2.2.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "83ffccdec6180b14d9b820c7af909e02c906d0dd"
|
|
91
91
|
}
|
|
@@ -17,21 +17,16 @@ import css from './bundle-assets-totals-chart-bars.module.css';
|
|
|
17
17
|
|
|
18
18
|
const getTooltip = (items, jobs, itemIndex, runIndex) => () => {
|
|
19
19
|
const metricId = items?.[itemIndex]?.key;
|
|
20
|
-
const metric = getGlobalMetricType(metricId);
|
|
21
20
|
const current = items?.[itemIndex]?.runs?.[runIndex]?.value || 0;
|
|
22
|
-
const baseline = items?.[itemIndex]?.runs?.[runIndex + 1]?.value
|
|
23
|
-
const metricRunInfo = getMetricRunInfo(metric, current, baseline);
|
|
21
|
+
const baseline = items?.[itemIndex]?.runs?.[runIndex + 1]?.value;
|
|
24
22
|
|
|
25
23
|
return (
|
|
26
24
|
<MetricRunInfo
|
|
27
25
|
className={css.itemTooltip}
|
|
28
|
-
|
|
29
|
-
current={
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
delta: metricRunInfo.displayDeltaPercentage,
|
|
33
|
-
deltaType: metricRunInfo.deltaType,
|
|
34
|
-
})}
|
|
26
|
+
metricId={metricId}
|
|
27
|
+
current={current}
|
|
28
|
+
baseline={baseline}
|
|
29
|
+
showMetridDescription={false}
|
|
35
30
|
size="large"
|
|
36
31
|
/>
|
|
37
32
|
);
|
package/src/components/index.js
CHANGED
|
@@ -19,5 +19,6 @@ export { MetricsTableOptions } from './metrics-table-options';
|
|
|
19
19
|
export { MetricsTableSearch } from './metrics-table-search';
|
|
20
20
|
export { MetricsTableTitle } from './metrics-table-title';
|
|
21
21
|
export { ModuleInfo } from './module-info';
|
|
22
|
+
export { RunInfo, RunInfoProps } from './run-info';
|
|
22
23
|
export { Summary } from './summary';
|
|
23
24
|
export { TotalSizeTypeTitle } from './total-size-type-title';
|
|
@@ -1,40 +1,18 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
.readMoreLink {
|
|
2
|
+
appearance: none;
|
|
3
|
+
background: none;
|
|
4
|
+
margin: 0;
|
|
5
|
+
border: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
color: var(--color-primary);
|
|
8
|
+
text-decoration: underline;
|
|
9
|
+
cursor: pointer;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
.readMoreLink:hover,
|
|
13
|
+
.readMoreLink:active,
|
|
14
|
+
.readMoreLink:focus {
|
|
15
|
+
color: var(--color-primary-dark);
|
|
16
|
+
text-decoration: none;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
.currentMetric {
|
|
15
|
-
color: var(--color-heading);
|
|
16
|
-
font-size: var(--size-large);
|
|
17
|
-
line-height: var(--line-height-heading);
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
font-weight: bold;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.baselineMetric {
|
|
23
|
-
color: var(--color-text-light);
|
|
24
|
-
font-size: var(--size-small);
|
|
25
|
-
line-height: var(--line-height-heading);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Loading state */
|
|
29
|
-
.loading.currentMetric {
|
|
30
|
-
width: 8em;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.loading.baselineMetric {
|
|
34
|
-
width: 5em;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Size large */
|
|
38
|
-
.large .currentMetric {
|
|
39
|
-
font-size: var(--size-xxxlarge);
|
|
40
|
-
}
|
|
@@ -1,49 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Meta, Story } from '@storybook/react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { Meta, Story } from '@storybook/react';
|
|
4
|
+
import { MetricRunInfo } from '.';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Components/MetricRunInfo',
|
|
8
8
|
component: MetricRunInfo,
|
|
9
9
|
} as Meta;
|
|
10
10
|
|
|
11
|
-
const Template: Story = (args) => <MetricRunInfo
|
|
11
|
+
const Template: Story = (args: any) => <MetricRunInfo {...args} />;
|
|
12
12
|
|
|
13
13
|
export const Default = Template.bind({});
|
|
14
14
|
|
|
15
15
|
Default.args = {
|
|
16
|
-
|
|
17
|
-
current:
|
|
18
|
-
baseline:
|
|
19
|
-
delta: '+20%',
|
|
20
|
-
deltaType: 'HIGH_NEGATIVE',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const SizeLarge = Template.bind({});
|
|
24
|
-
|
|
25
|
-
SizeLarge.args = {
|
|
26
|
-
...Default.args,
|
|
27
|
-
size: 'large',
|
|
16
|
+
metricId: 'webpack.totalSizeByTypeALL',
|
|
17
|
+
current: 120 * 1024,
|
|
18
|
+
baseline: 100 * 1024,
|
|
28
19
|
};
|
|
29
20
|
|
|
30
|
-
export const
|
|
21
|
+
export const NoBaseline = Template.bind({});
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
NoBaseline.args = {
|
|
24
|
+
metricId: 'webpack.totalSizeByTypeALL',
|
|
25
|
+
current: 120 * 1024,
|
|
35
26
|
};
|
|
36
27
|
|
|
37
|
-
export const
|
|
28
|
+
export const NoDelta = Template.bind({});
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
NoDelta.args = {
|
|
40
31
|
...Default.args,
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const Loading = Template.bind({});
|
|
45
|
-
|
|
46
|
-
Loading.args = {
|
|
47
|
-
title: 'Bundle Size',
|
|
48
|
-
loading: true,
|
|
32
|
+
showDelta: false,
|
|
49
33
|
};
|
|
@@ -1,101 +1,67 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
3
3
|
|
|
4
|
-
import { Icon } from '../../ui/icon';
|
|
5
|
-
import { HoverCard } from '../../ui/hover-card';
|
|
6
|
-
import { Tooltip } from '../../ui/tooltip';
|
|
7
|
-
import { Skeleton } from '../../ui/skeleton';
|
|
8
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
9
4
|
import { Stack } from '../../layout/stack';
|
|
10
|
-
import {
|
|
11
|
-
import { Delta } from '../delta';
|
|
5
|
+
import { RunInfo, RunInfoProps } from '../run-info';
|
|
12
6
|
import css from './metric-run-info.module.css';
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const matches = value.match(EXTRACT_VALUE_UNIT_PATTERN);
|
|
8
|
+
interface MetricInfoProps {
|
|
9
|
+
description: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
const MetricHoverCard = ({ description, url }: MetricInfoProps) => {
|
|
14
|
+
// The component parent can be rendered inside a link, use button to avoid using nested links
|
|
15
|
+
const onClick = useCallback(() => {
|
|
16
|
+
if (url) {
|
|
17
|
+
window.open(url);
|
|
18
|
+
}
|
|
19
|
+
}, [url]);
|
|
23
20
|
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
return (
|
|
22
|
+
<Stack space="xxxsmall">
|
|
23
|
+
<p>{description}</p>
|
|
24
|
+
{url && (
|
|
25
|
+
<p>
|
|
26
|
+
<button type="button" onClick={onClick} className={css.readMoreLink}>
|
|
27
|
+
Read more
|
|
28
|
+
</button>
|
|
29
|
+
</p>
|
|
30
|
+
)}
|
|
31
|
+
</Stack>
|
|
32
|
+
);
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
export interface MetricRunInfoProps {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
as?: React.ElementType;
|
|
40
|
-
size?: 'medium' | 'large';
|
|
41
|
-
|
|
42
|
-
loading?: boolean;
|
|
36
|
+
metricId: string;
|
|
37
|
+
current: number;
|
|
38
|
+
baseline?: number;
|
|
39
|
+
showDelta?: boolean;
|
|
40
|
+
showMetridDescription?: boolean;
|
|
41
|
+
size?: RunInfoProps['size'];
|
|
42
|
+
loading?: RunInfoProps['loading'];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export const MetricRunInfo = ({
|
|
46
|
-
|
|
47
|
-
title = '',
|
|
48
|
-
titleHoverCard = null,
|
|
49
|
-
titleTooltip = null,
|
|
50
|
-
current = '',
|
|
51
|
-
baseline = '',
|
|
52
|
-
delta = '',
|
|
53
|
-
deltaType = '',
|
|
54
|
-
as: Component = 'div',
|
|
55
|
-
size = 'medium',
|
|
56
|
-
loading = false,
|
|
57
|
-
...restProps
|
|
58
|
-
}: MetricRunInfoProps & React.ComponentProps<'div'>) => {
|
|
59
|
-
const metricParams = getMetricParams(current);
|
|
60
|
-
const rootClassName = cx(css.root, className, css[size], delta && css.showDelta);
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<Stack space="xxsmall" as={Component} className={rootClassName} {...restProps}>
|
|
64
|
-
{title && (
|
|
65
|
-
<FlexStack space="xxxsmall" alignItems="center" as="h3" className={css.title}>
|
|
66
|
-
<span>{title}</span>
|
|
45
|
+
export const MetricRunInfo = (props: MetricRunInfoProps & React.ComponentProps<'div'>) => {
|
|
46
|
+
const { metricId, current, baseline = undefined, showDelta = true, showMetridDescription = true, ...restProps } = props;
|
|
67
47
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
</HoverCard>
|
|
72
|
-
)}
|
|
73
|
-
{titleTooltip && (
|
|
74
|
-
<Tooltip title={titleTooltip} className={css.titleIcon}>
|
|
75
|
-
<Icon glyph={Icon.ICONS.HELP} />
|
|
76
|
-
</Tooltip>
|
|
77
|
-
)}
|
|
78
|
-
</FlexStack>
|
|
79
|
-
)}
|
|
48
|
+
const metric = getGlobalMetricType(metricId);
|
|
49
|
+
const metricRunInfo = getMetricRunInfo(metric, current, baseline || 0);
|
|
50
|
+
const showBaseline = typeof baseline !== 'undefined';
|
|
80
51
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<Skeleton as="p" className={cx(css.currentMetric, css.loading)} />
|
|
96
|
-
<Skeleton as="p" className={cx(css.baselineMetric, css.loading)} />
|
|
97
|
-
</Stack>
|
|
98
|
-
)}
|
|
99
|
-
</Stack>
|
|
52
|
+
return (
|
|
53
|
+
<RunInfo
|
|
54
|
+
title={metric.label}
|
|
55
|
+
titleHoverCard={showMetridDescription && <MetricHoverCard description={metric.description} url={metric.url} />}
|
|
56
|
+
current={metricRunInfo.displayValue}
|
|
57
|
+
{...(showBaseline && {
|
|
58
|
+
baseline: metric.formatter(baseline),
|
|
59
|
+
})}
|
|
60
|
+
{...(showDelta && showBaseline && {
|
|
61
|
+
delta: metricRunInfo.displayDeltaPercentage,
|
|
62
|
+
deltaType: metricRunInfo.deltaType,
|
|
63
|
+
})}
|
|
64
|
+
{...restProps}
|
|
65
|
+
/>
|
|
100
66
|
);
|
|
101
67
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './run-info';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.title {
|
|
2
|
+
color: var(--color-text-ultra-light);
|
|
3
|
+
font-weight: bold;
|
|
4
|
+
font-size: var(--size-xsmall);
|
|
5
|
+
text-transform: uppercase;
|
|
6
|
+
white-space: nowrap;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.titleIcon {
|
|
10
|
+
flex: 0 0 var(--space-small);
|
|
11
|
+
margin-top: -4px !important;
|
|
12
|
+
margin-bottom: -4px !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.currentMetric {
|
|
16
|
+
color: var(--color-heading);
|
|
17
|
+
font-size: var(--size-xlarge);
|
|
18
|
+
line-height: var(--line-height-heading);
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
font-weight: bold;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.baselineMetric {
|
|
24
|
+
color: var(--color-text-light);
|
|
25
|
+
font-size: var(--size-medium);
|
|
26
|
+
line-height: var(--line-height-heading);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Loading state */
|
|
30
|
+
.loading.currentMetric {
|
|
31
|
+
width: 8em;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.loading.baselineMetric {
|
|
35
|
+
width: 5em;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Size large */
|
|
39
|
+
.large .currentMetric {
|
|
40
|
+
font-size: var(--size-xxxlarge);
|
|
41
|
+
}
|