@bundle-stats/ui 4.2.5-beta.0 → 4.2.5-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/globals.d.ts +4 -0
- package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +13 -5
- package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js.map +1 -1
- package/lib/components/index.js +3 -3
- package/lib/components/index.js.map +1 -1
- package/lib/components/insight-icon/insight-icon.js.map +1 -1
- package/lib/components/insights/insights.js.map +1 -1
- package/lib/components/metric/index.js.map +1 -1
- package/lib/components/metric/metric.js +7 -64
- package/lib/components/metric/metric.js.map +1 -1
- package/lib/components/metric/metric.module.css +2 -2
- package/lib/components/{summary-item → metric-run-info}/index.js +1 -1
- package/lib/components/metric-run-info/index.js.map +1 -0
- package/lib/components/metric-run-info/metric-run-info.js +45 -0
- package/lib/components/metric-run-info/metric-run-info.js.map +1 -0
- package/lib/components/{summary-item/summary-item.module.css → metric-run-info/metric-run-info.module.css} +0 -18
- package/lib/components/summary/index.js.map +1 -1
- package/lib/components/summary/summary.js +50 -30
- package/lib/components/summary/summary.js.map +1 -1
- package/lib/components/summary/summary.module.css +19 -0
- package/lib/layout/box/box.js.map +1 -1
- package/lib/layout/flex-stack/flex-stack.js.map +1 -1
- package/lib/ui/container/container.js.map +1 -1
- package/lib/ui/tooltip/tooltip.js.map +1 -1
- package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +12 -6
- 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 -1
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/components/insight-icon/insight-icon.js.map +1 -1
- package/lib-esm/components/insights/insights.js.map +1 -1
- package/lib-esm/components/metric/index.js.map +1 -1
- package/lib-esm/components/metric/metric.js +7 -41
- package/lib-esm/components/metric/metric.js.map +1 -1
- package/lib-esm/components/metric/metric.module.css +2 -2
- package/lib-esm/components/metric-run-info/index.js +2 -0
- package/lib-esm/components/metric-run-info/index.js.map +1 -0
- package/lib-esm/components/metric-run-info/metric-run-info.js +38 -0
- package/lib-esm/components/metric-run-info/metric-run-info.js.map +1 -0
- package/lib-esm/components/{summary-item/summary-item.module.css → metric-run-info/metric-run-info.module.css} +0 -18
- package/lib-esm/components/summary/index.js.map +1 -1
- package/lib-esm/components/summary/summary.js +27 -30
- package/lib-esm/components/summary/summary.js.map +1 -1
- package/lib-esm/components/summary/summary.module.css +19 -0
- package/lib-esm/layout/box/box.js.map +1 -1
- package/lib-esm/layout/flex-stack/flex-stack.js.map +1 -1
- package/lib-esm/ui/container/container.js.map +1 -1
- package/lib-esm/ui/tooltip/tooltip.js.map +1 -1
- package/package.json +7 -6
- package/src/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.jsx +23 -15
- package/src/components/index.js +1 -1
- package/src/components/insight-icon/insight-icon.tsx +0 -2
- package/src/components/insights/insights.tsx +0 -1
- package/src/components/metric/metric.module.css +2 -2
- package/src/components/metric/metric.stories.tsx +41 -0
- package/src/components/metric/metric.tsx +42 -0
- package/src/components/metric-run-info/index.ts +1 -0
- package/src/components/{summary-item/summary-item.module.css → metric-run-info/metric-run-info.module.css} +0 -18
- package/src/components/metric-run-info/metric-run-info.stories.tsx +49 -0
- package/src/components/metric-run-info/metric-run-info.tsx +101 -0
- package/src/components/summary/summary.module.css +19 -0
- package/src/components/summary/summary.stories.tsx +56 -0
- package/src/components/summary/summary.tsx +124 -0
- package/src/layout/box/box.tsx +0 -1
- package/src/layout/flex-stack/flex-stack.tsx +1 -2
- package/src/ui/container/container.tsx +0 -1
- package/src/ui/tooltip/tooltip.tsx +0 -1
- package/types/components/index.d.ts +1 -1
- package/types/components/metric/index.d.ts +1 -1
- package/types/components/metric/metric.d.ts +6 -32
- package/types/components/metric-run-info/index.d.ts +1 -0
- package/types/components/metric-run-info/metric-run-info.d.ts +14 -0
- package/types/components/summary/index.d.ts +1 -1
- package/types/components/summary/summary.d.ts +15 -36
- package/types/layout/flex-stack/flex-stack.d.ts +2 -1
- package/lib/components/summary-item/index.js.map +0 -1
- package/lib/components/summary-item/summary-item.js +0 -97
- package/lib/components/summary-item/summary-item.js.map +0 -1
- package/lib-esm/components/summary-item/index.js +0 -2
- package/lib-esm/components/summary-item/index.js.map +0 -1
- package/lib-esm/components/summary-item/summary-item.js +0 -67
- package/lib-esm/components/summary-item/summary-item.js.map +0 -1
- package/src/components/metric/metric.jsx +0 -63
- package/src/components/summary/summary.jsx +0 -74
- package/src/components/summary-item/index.js +0 -1
- package/src/components/summary-item/summary-item.jsx +0 -142
- package/types/components/summary-item/index.d.ts +0 -1
- package/types/components/summary-item/summary-item.d.ts +0 -40
- /package/src/components/metric/{index.js → index.ts} +0 -0
- /package/src/components/summary/{index.js → index.ts} +0 -0
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
5
|
-
import { Icon } from '../../ui/icon';
|
|
6
|
-
import { HoverCard } from '../../ui/hover-card';
|
|
7
|
-
import { Skeleton } from '../../ui/skeleton';
|
|
8
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
9
|
-
import { Stack } from '../../layout/stack';
|
|
10
|
-
import { Metric } from '../metric';
|
|
11
|
-
import { Delta } from '../delta';
|
|
12
|
-
import css from './summary-item.module.css';
|
|
13
|
-
const MetricInfo = ({ description, url }) => {
|
|
14
|
-
const onClick = useCallback(() => {
|
|
15
|
-
if (url) {
|
|
16
|
-
window.open(url);
|
|
17
|
-
}
|
|
18
|
-
}, [url]);
|
|
19
|
-
return (React.createElement(Stack, { space: "xxxsmall" },
|
|
20
|
-
React.createElement("p", null, description),
|
|
21
|
-
url && (React.createElement("p", null,
|
|
22
|
-
React.createElement("button", { type: "button", onClick: onClick, className: css.readMoreLink }, "Read more")))));
|
|
23
|
-
};
|
|
24
|
-
MetricInfo.propTypes = {
|
|
25
|
-
description: PropTypes.string.isRequired,
|
|
26
|
-
url: PropTypes.string,
|
|
27
|
-
};
|
|
28
|
-
MetricInfo.defaultProps = {
|
|
29
|
-
url: '',
|
|
30
|
-
};
|
|
31
|
-
export const SummaryItem = ({ className, as: Component, size, id, data, loading, showDelta, showMetricDescription, ...props }) => {
|
|
32
|
-
const { baseline, current } = data || { baseline: 0, current: 0 };
|
|
33
|
-
const metric = getGlobalMetricType(id);
|
|
34
|
-
const runInfo = getMetricRunInfo(metric, current, baseline);
|
|
35
|
-
const showMetricDescriptionTooltip = showMetricDescription && (metric === null || metric === void 0 ? void 0 : metric.description);
|
|
36
|
-
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
37
|
-
return (React.createElement(Stack, { space: "xxsmall", as: Component, className: rootClassName, ...props },
|
|
38
|
-
React.createElement(FlexStack, { space: "xxxsmall", alignItems: "center", as: "h3", className: css.title },
|
|
39
|
-
React.createElement("span", null, metric.label),
|
|
40
|
-
showMetricDescriptionTooltip && (React.createElement(HoverCard, { label: React.createElement(Icon, { glyph: Icon.ICONS.HELP }), className: css.titleIcon },
|
|
41
|
-
React.createElement(MetricInfo, { ...metric })))),
|
|
42
|
-
!loading ? (React.createElement(Stack, null,
|
|
43
|
-
React.createElement(Metric, { className: css.currentMetric, value: current, formatter: metric.formatter, enhanced: true, inline: true }, showDelta && (React.createElement(Delta, { className: css.delta, displayValue: runInfo.displayDeltaPercentage, deltaType: runInfo.deltaType }))),
|
|
44
|
-
React.createElement(Metric, { className: css.baselineMetric, value: baseline, formatter: metric.formatter }))) : (React.createElement(Stack, null,
|
|
45
|
-
React.createElement(Skeleton, { as: "p", className: cx(css.currentMetric, css.loading) }),
|
|
46
|
-
React.createElement(Skeleton, { as: "p", className: cx(css.baselineMetric, css.loading) })))));
|
|
47
|
-
};
|
|
48
|
-
SummaryItem.defaultProps = {
|
|
49
|
-
className: '',
|
|
50
|
-
as: 'div',
|
|
51
|
-
data: null,
|
|
52
|
-
size: 'medium',
|
|
53
|
-
loading: false,
|
|
54
|
-
showMetricDescription: false,
|
|
55
|
-
showDelta: true,
|
|
56
|
-
};
|
|
57
|
-
SummaryItem.propTypes = {
|
|
58
|
-
className: PropTypes.string,
|
|
59
|
-
as: PropTypes.elementType,
|
|
60
|
-
size: PropTypes.oneOf(['medium', 'large']),
|
|
61
|
-
id: PropTypes.string.isRequired,
|
|
62
|
-
loading: PropTypes.bool,
|
|
63
|
-
data: PropTypes.object,
|
|
64
|
-
showMetricDescription: PropTypes.bool,
|
|
65
|
-
showDelta: PropTypes.bool,
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=summary-item.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summary-item.js","sourceRoot":"","sources":["../../../src/components/summary-item/summary-item.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,GAAG,MAAM,2BAA2B,CAAC;AAE5C,MAAM,UAAU,GAA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,EAAE,GAAG,CAAC,OAAO,CAAC,GAAI;YAClE,oBAAC,QAAQ,IAAC,EAAE,EAAC,GAAG,EAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,GAAI,CAC7D,CACT,CACK,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,WAAW,CAAC,YAAY,GAAG;IACzB,SAAS,EAAE,EAAE;IACb,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,KAAK;IACd,qBAAqB,EAAE,KAAK;IAC5B,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF,WAAW,CAAC,SAAS,GAAG;IAEtB,SAAS,EAAE,SAAS,CAAC,MAAM;IAG3B,EAAE,EAAE,SAAS,CAAC,WAAW;IAGzB,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAG1C,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAG/B,OAAO,EAAE,SAAS,CAAC,IAAI;IAGvB,IAAI,EAAE,SAAS,CAAC,MAAM;IAGtB,qBAAqB,EAAE,SAAS,CAAC,IAAI;IAGrC,SAAS,EAAE,SAAS,CAAC,IAAI;CAC1B,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
|
|
5
|
-
import css from './metric.module.css';
|
|
6
|
-
|
|
7
|
-
// Separate value and unit
|
|
8
|
-
const EXTRACT_VALUE_UNIT_PATTERN = /([\d|.|,| ]*)(\w*|%)$/;
|
|
9
|
-
|
|
10
|
-
export const Metric = ({ className, value, formatter, inline, children, enhanced }) => {
|
|
11
|
-
const { displayValue, displayUnit } = useMemo(() => {
|
|
12
|
-
const formattedValue = formatter?.(value);
|
|
13
|
-
|
|
14
|
-
if (!formattedValue) {
|
|
15
|
-
return { displayValue: value };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!enhanced) {
|
|
19
|
-
return { displayValue: formattedValue };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const matches = formattedValue.match(EXTRACT_VALUE_UNIT_PATTERN);
|
|
23
|
-
|
|
24
|
-
if (!matches) {
|
|
25
|
-
return { displayValue: value };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
displayUnit: matches[2],
|
|
30
|
-
displayValue: matches[1],
|
|
31
|
-
};
|
|
32
|
-
}, [formatter, value]);
|
|
33
|
-
|
|
34
|
-
const rootClassName = cx(className, css.root, inline && css.inline);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div className={rootClassName}>
|
|
38
|
-
<div className={css.display}>
|
|
39
|
-
<span className={css.displayValue}>{displayValue}</span>
|
|
40
|
-
{displayUnit && <span className={css.displayUnit}>{displayUnit}</span>}
|
|
41
|
-
</div>
|
|
42
|
-
<div className={css.delta}>{children}</div>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
Metric.defaultProps = {
|
|
48
|
-
className: '',
|
|
49
|
-
enhanced: false,
|
|
50
|
-
inline: false,
|
|
51
|
-
value: 0,
|
|
52
|
-
children: [],
|
|
53
|
-
formatter: (val) => val,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
Metric.propTypes = {
|
|
57
|
-
className: PropTypes.string,
|
|
58
|
-
enhanced: PropTypes.bool,
|
|
59
|
-
inline: PropTypes.bool,
|
|
60
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
61
|
-
formatter: PropTypes.func,
|
|
62
|
-
children: PropTypes.node,
|
|
63
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import get from 'lodash/get';
|
|
5
|
-
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
6
|
-
|
|
7
|
-
import { METRICS_WEBPACK_GENERAL } from '../../constants';
|
|
8
|
-
import { Box } from '../../layout/box';
|
|
9
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
10
|
-
import { ComponentLink } from '../component-link';
|
|
11
|
-
import { SummaryItem } from '../summary-item';
|
|
12
|
-
import css from './summary.module.css';
|
|
13
|
-
|
|
14
|
-
export const Summary = ({
|
|
15
|
-
className,
|
|
16
|
-
size,
|
|
17
|
-
keys,
|
|
18
|
-
data,
|
|
19
|
-
loading,
|
|
20
|
-
showSummaryItemDelta,
|
|
21
|
-
summaryItemLink: SummaryItemCustomLink,
|
|
22
|
-
}) => (
|
|
23
|
-
<Box className={cx(css.root, className)}>
|
|
24
|
-
<FlexStack space="small" className={css.items}>
|
|
25
|
-
{Array.from(METRIC_COMPONENT_LINKS)
|
|
26
|
-
.filter(([metricId]) => keys.includes(metricId))
|
|
27
|
-
.map(([metricId, metricOptions]) => (
|
|
28
|
-
<Box
|
|
29
|
-
key={metricId}
|
|
30
|
-
outline
|
|
31
|
-
outlineHover
|
|
32
|
-
padding="small"
|
|
33
|
-
as={SummaryItemCustomLink}
|
|
34
|
-
{...metricOptions.link}
|
|
35
|
-
className={css.item}
|
|
36
|
-
>
|
|
37
|
-
<SummaryItem
|
|
38
|
-
size={size}
|
|
39
|
-
id={metricId}
|
|
40
|
-
data={get(data, metricId)}
|
|
41
|
-
loading={loading}
|
|
42
|
-
showMetricDescription
|
|
43
|
-
showDelta={showSummaryItemDelta && metricOptions.showDelta !== false}
|
|
44
|
-
/>
|
|
45
|
-
</Box>
|
|
46
|
-
))}
|
|
47
|
-
</FlexStack>
|
|
48
|
-
</Box>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
Summary.defaultProps = {
|
|
52
|
-
className: '',
|
|
53
|
-
data: null,
|
|
54
|
-
loading: false,
|
|
55
|
-
size: '',
|
|
56
|
-
keys: METRICS_WEBPACK_GENERAL,
|
|
57
|
-
showSummaryItemDelta: true,
|
|
58
|
-
summaryItemLink: ComponentLink,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
Summary.propTypes = {
|
|
62
|
-
className: PropTypes.string,
|
|
63
|
-
size: PropTypes.string,
|
|
64
|
-
keys: PropTypes.arrayOf(PropTypes.string),
|
|
65
|
-
data: PropTypes.shape({
|
|
66
|
-
[PropTypes.string]: PropTypes.shape({
|
|
67
|
-
baseline: PropTypes.number,
|
|
68
|
-
current: PropTypes.number,
|
|
69
|
-
}),
|
|
70
|
-
}),
|
|
71
|
-
loading: PropTypes.bool,
|
|
72
|
-
showSummaryItemDelta: PropTypes.bool,
|
|
73
|
-
summaryItemLink: PropTypes.elementType,
|
|
74
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './summary-item';
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
5
|
-
|
|
6
|
-
import { Icon } from '../../ui/icon';
|
|
7
|
-
import { HoverCard } from '../../ui/hover-card';
|
|
8
|
-
import { Skeleton } from '../../ui/skeleton';
|
|
9
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
10
|
-
import { Stack } from '../../layout/stack';
|
|
11
|
-
import { Metric } from '../metric';
|
|
12
|
-
import { Delta } from '../delta';
|
|
13
|
-
import css from './summary-item.module.css';
|
|
14
|
-
|
|
15
|
-
const MetricInfo = ({ description, url }) => {
|
|
16
|
-
// The component parent can be rendered inside a link, use button to avoid using nested links
|
|
17
|
-
const onClick = useCallback(() => {
|
|
18
|
-
if (url) {
|
|
19
|
-
window.open(url);
|
|
20
|
-
}
|
|
21
|
-
}, [url]);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Stack space="xxxsmall">
|
|
25
|
-
<p>{description}</p>
|
|
26
|
-
{url && (
|
|
27
|
-
<p>
|
|
28
|
-
<button type="button" onClick={onClick} className={css.readMoreLink}>
|
|
29
|
-
Read more
|
|
30
|
-
</button>
|
|
31
|
-
</p>
|
|
32
|
-
)}
|
|
33
|
-
</Stack>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
MetricInfo.propTypes = {
|
|
38
|
-
description: PropTypes.string.isRequired,
|
|
39
|
-
url: PropTypes.string,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
MetricInfo.defaultProps = {
|
|
43
|
-
url: '',
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const SummaryItem = ({
|
|
47
|
-
className,
|
|
48
|
-
as: Component,
|
|
49
|
-
size,
|
|
50
|
-
id,
|
|
51
|
-
data,
|
|
52
|
-
loading,
|
|
53
|
-
showDelta,
|
|
54
|
-
showMetricDescription,
|
|
55
|
-
...props
|
|
56
|
-
}) => {
|
|
57
|
-
const { baseline, current } = data || { baseline: 0, current: 0 };
|
|
58
|
-
|
|
59
|
-
const metric = getGlobalMetricType(id);
|
|
60
|
-
const runInfo = getMetricRunInfo(metric, current, baseline);
|
|
61
|
-
const showMetricDescriptionTooltip = showMetricDescription && metric?.description;
|
|
62
|
-
|
|
63
|
-
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Stack space="xxsmall" as={Component} className={rootClassName} {...props}>
|
|
67
|
-
<FlexStack space="xxxsmall" alignItems="center" as="h3" className={css.title}>
|
|
68
|
-
<span>
|
|
69
|
-
{metric.label}
|
|
70
|
-
</span>
|
|
71
|
-
|
|
72
|
-
{showMetricDescriptionTooltip && (
|
|
73
|
-
<HoverCard label={<Icon glyph={Icon.ICONS.HELP} />} className={css.titleIcon}>
|
|
74
|
-
<MetricInfo {...metric} />
|
|
75
|
-
</HoverCard>
|
|
76
|
-
)}
|
|
77
|
-
</FlexStack>
|
|
78
|
-
|
|
79
|
-
{!loading ? (
|
|
80
|
-
<Stack>
|
|
81
|
-
<Metric
|
|
82
|
-
className={css.currentMetric}
|
|
83
|
-
value={current}
|
|
84
|
-
formatter={metric.formatter}
|
|
85
|
-
enhanced
|
|
86
|
-
inline
|
|
87
|
-
>
|
|
88
|
-
{showDelta && (
|
|
89
|
-
<Delta
|
|
90
|
-
className={css.delta}
|
|
91
|
-
displayValue={runInfo.displayDeltaPercentage}
|
|
92
|
-
deltaType={runInfo.deltaType}
|
|
93
|
-
/>
|
|
94
|
-
)}
|
|
95
|
-
</Metric>
|
|
96
|
-
<Metric className={css.baselineMetric} value={baseline} formatter={metric.formatter} />
|
|
97
|
-
</Stack>
|
|
98
|
-
) : (
|
|
99
|
-
<Stack>
|
|
100
|
-
<Skeleton as="p" className={cx(css.currentMetric, css.loading)} />
|
|
101
|
-
<Skeleton as="p" className={cx(css.baselineMetric, css.loading)} />
|
|
102
|
-
</Stack>
|
|
103
|
-
)}
|
|
104
|
-
</Stack>
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
SummaryItem.defaultProps = {
|
|
109
|
-
className: '',
|
|
110
|
-
as: 'div',
|
|
111
|
-
data: null,
|
|
112
|
-
size: 'medium',
|
|
113
|
-
loading: false,
|
|
114
|
-
showMetricDescription: false,
|
|
115
|
-
showDelta: true,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
SummaryItem.propTypes = {
|
|
119
|
-
/** Adopted child class name */
|
|
120
|
-
className: PropTypes.string,
|
|
121
|
-
|
|
122
|
-
/** Custom component */
|
|
123
|
-
as: PropTypes.elementType,
|
|
124
|
-
|
|
125
|
-
/** Size modifier */
|
|
126
|
-
size: PropTypes.oneOf(['medium', 'large']),
|
|
127
|
-
|
|
128
|
-
/** Metric id */
|
|
129
|
-
id: PropTypes.string.isRequired,
|
|
130
|
-
|
|
131
|
-
/** Loading flag */
|
|
132
|
-
loading: PropTypes.bool,
|
|
133
|
-
|
|
134
|
-
/** Summary data */
|
|
135
|
-
data: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
|
136
|
-
|
|
137
|
-
/** Show description */
|
|
138
|
-
showMetricDescription: PropTypes.bool,
|
|
139
|
-
|
|
140
|
-
/** Show delta */
|
|
141
|
-
showDelta: PropTypes.bool,
|
|
142
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./summary-item";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export function SummaryItem({ className, as: Component, size, id, data, loading, showDelta, showMetricDescription, ...props }: {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
className: any;
|
|
4
|
-
as: any;
|
|
5
|
-
size: any;
|
|
6
|
-
id: any;
|
|
7
|
-
data: any;
|
|
8
|
-
loading: any;
|
|
9
|
-
showDelta: any;
|
|
10
|
-
showMetricDescription: any;
|
|
11
|
-
}): JSX.Element;
|
|
12
|
-
export namespace SummaryItem {
|
|
13
|
-
namespace defaultProps {
|
|
14
|
-
const className: string;
|
|
15
|
-
const as: string;
|
|
16
|
-
const data: null;
|
|
17
|
-
const size: string;
|
|
18
|
-
const loading: boolean;
|
|
19
|
-
const showMetricDescription: boolean;
|
|
20
|
-
const showDelta: boolean;
|
|
21
|
-
}
|
|
22
|
-
namespace propTypes {
|
|
23
|
-
const className_1: PropTypes.Requireable<string>;
|
|
24
|
-
export { className_1 as className };
|
|
25
|
-
const as_1: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
26
|
-
export { as_1 as as };
|
|
27
|
-
const size_1: PropTypes.Requireable<string>;
|
|
28
|
-
export { size_1 as size };
|
|
29
|
-
export const id: PropTypes.Validator<string>;
|
|
30
|
-
const loading_1: PropTypes.Requireable<boolean>;
|
|
31
|
-
export { loading_1 as loading };
|
|
32
|
-
const data_1: PropTypes.Requireable<object>;
|
|
33
|
-
export { data_1 as data };
|
|
34
|
-
const showMetricDescription_1: PropTypes.Requireable<boolean>;
|
|
35
|
-
export { showMetricDescription_1 as showMetricDescription };
|
|
36
|
-
const showDelta_1: PropTypes.Requireable<boolean>;
|
|
37
|
-
export { showDelta_1 as showDelta };
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
import PropTypes from "prop-types";
|
|
File without changes
|
|
File without changes
|