@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insights.js","sourceRoot":"","sources":["../../../src/components/insights/insights.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"insights.js","sourceRoot":"","sources":["../../../src/components/insights/insights.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,GAAG,MAAM,uBAAuB,CAAC;AAOxC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,EAAE;IAC/C,MAAM,EACJ,QAAQ,EACR,mBAAmB,EAAE,mBAAmB,GAAG,aAAa,EACxD,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CACL,oBAAC,KAAK,IAAC,KAAK,EAAC,SAAS,KAAK,SAAS,IACjC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAwB,CAAC;QAClD,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,IAAI,EACT,KAAK,EAAC,SAAS,EACf,UAAU,EAAC,QAAQ,EACnB,EAAE,EAAE,mBAAmB,KACnB,IAAI,EACR,SAAS,EAAE,GAAG,CAAC,KAAK;YAEpB,oBAAC,WAAW,IAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,IAAI,GAAI;YACxD,kCAAO,IAAI,CAAQ,CACT,CACb,CAAC;IACJ,CAAC,CAAC,CACI,CACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/metric/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/metric/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import cx from 'classnames';
|
|
4
3
|
import css from './metric.module.css';
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const { displayValue, displayUnit } = useMemo(() => {
|
|
8
|
-
const formattedValue = formatter === null || formatter === void 0 ? void 0 : formatter(value);
|
|
9
|
-
if (!formattedValue) {
|
|
10
|
-
return { displayValue: value };
|
|
11
|
-
}
|
|
12
|
-
if (!enhanced) {
|
|
13
|
-
return { displayValue: formattedValue };
|
|
14
|
-
}
|
|
15
|
-
const matches = formattedValue.match(EXTRACT_VALUE_UNIT_PATTERN);
|
|
16
|
-
if (!matches) {
|
|
17
|
-
return { displayValue: value };
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
displayUnit: matches[2],
|
|
21
|
-
displayValue: matches[1],
|
|
22
|
-
};
|
|
23
|
-
}, [formatter, value]);
|
|
4
|
+
export const Metric = (props) => {
|
|
5
|
+
const { className = '', value = '0', unit = '', inline = false, children = null, ...restProps } = props;
|
|
24
6
|
const rootClassName = cx(className, css.root, inline && css.inline);
|
|
25
|
-
return (React.createElement("div", { className: rootClassName },
|
|
7
|
+
return (React.createElement("div", { className: rootClassName, ...restProps },
|
|
26
8
|
React.createElement("div", { className: css.display },
|
|
27
|
-
React.createElement("span", { className: css.displayValue },
|
|
28
|
-
|
|
29
|
-
React.createElement("div", { className: css.
|
|
30
|
-
};
|
|
31
|
-
Metric.defaultProps = {
|
|
32
|
-
className: '',
|
|
33
|
-
enhanced: false,
|
|
34
|
-
inline: false,
|
|
35
|
-
value: 0,
|
|
36
|
-
children: [],
|
|
37
|
-
formatter: (val) => val,
|
|
38
|
-
};
|
|
39
|
-
Metric.propTypes = {
|
|
40
|
-
className: PropTypes.string,
|
|
41
|
-
enhanced: PropTypes.bool,
|
|
42
|
-
inline: PropTypes.bool,
|
|
43
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
44
|
-
formatter: PropTypes.func,
|
|
45
|
-
children: PropTypes.node,
|
|
9
|
+
React.createElement("span", { className: css.displayValue }, value),
|
|
10
|
+
unit && React.createElement("span", { className: css.displayUnit }, unit)),
|
|
11
|
+
children && React.createElement("div", { className: css.content }, children)));
|
|
46
12
|
};
|
|
47
13
|
//# sourceMappingURL=metric.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/components/metric/metric.
|
|
1
|
+
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/components/metric/metric.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,GAAG,MAAM,qBAAqB,CAAC;AAiBtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAgD,EAAE,EAAE;IACzE,MAAM,EACJ,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,GAAG,EACX,IAAI,GAAG,EAAE,EACT,MAAM,GAAG,KAAK,EACd,QAAQ,GAAG,IAAI,EACf,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,aAAa,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAEpE,OAAO,CACL,6BAAK,SAAS,EAAE,aAAa,KAAM,SAAS;QAC1C,6BAAK,SAAS,EAAE,GAAG,CAAC,OAAO;YACzB,8BAAM,SAAS,EAAE,GAAG,CAAC,YAAY,IAAG,KAAK,CAAQ;YAChD,IAAI,IAAI,8BAAM,SAAS,EAAE,GAAG,CAAC,WAAW,IAAG,IAAI,CAAQ,CACpD;QACL,QAAQ,IAAI,6BAAK,SAAS,EAAE,GAAG,CAAC,OAAO,IAAG,QAAQ,CAAO,CACtD,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
font-size: var(--size-small);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.
|
|
9
|
+
.content {
|
|
10
10
|
font-size: var(--size-small);
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
display: inline-block;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.inline .
|
|
17
|
+
.inline .content {
|
|
18
18
|
display: inline-block;
|
|
19
19
|
margin: 0 0 0 var(--space-xxxsmall);
|
|
20
20
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/metric-run-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,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 './metric-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 MetricRunInfo = ({ 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=metric-run-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metric-run-info.js","sourceRoot":"","sources":["../../../src/components/metric-run-info/metric-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,EAAE,SAAS,EAAE,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,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,GAAI,CAC7D,CACT,CACK,CACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -25,24 +25,6 @@
|
|
|
25
25
|
line-height: var(--line-height-heading);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.readMoreLink {
|
|
29
|
-
appearance: none;
|
|
30
|
-
background: none;
|
|
31
|
-
margin: 0;
|
|
32
|
-
border: 0;
|
|
33
|
-
padding: 0;
|
|
34
|
-
color: var(--color-primary);
|
|
35
|
-
text-decoration: underline;
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.readMoreLink:hover,
|
|
40
|
-
.readMoreLink:active,
|
|
41
|
-
.readMoreLink:focus {
|
|
42
|
-
color: var(--color-primary-dark);
|
|
43
|
-
text-decoration: none;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
28
|
/* Loading state */
|
|
47
29
|
.loading.currentMetric {
|
|
48
30
|
width: 8em;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/summary/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/summary/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
3
2
|
import cx from 'classnames';
|
|
4
3
|
import get from 'lodash/get';
|
|
5
|
-
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
4
|
+
import { METRIC_COMPONENT_LINKS, getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
6
5
|
import { METRICS_WEBPACK_GENERAL } from '../../constants';
|
|
7
6
|
import { Box } from '../../layout/box';
|
|
8
7
|
import { FlexStack } from '../../layout/flex-stack';
|
|
8
|
+
import { Stack } from '../../layout/stack';
|
|
9
9
|
import { ComponentLink } from '../component-link';
|
|
10
|
-
import {
|
|
10
|
+
import { MetricRunInfo } from '../metric-run-info';
|
|
11
11
|
import css from './summary.module.css';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
keys: METRICS_WEBPACK_GENERAL,
|
|
23
|
-
showSummaryItemDelta: true,
|
|
24
|
-
summaryItemLink: ComponentLink,
|
|
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")))));
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
className:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
showSummaryItemDelta: PropTypes.bool,
|
|
38
|
-
summaryItemLink: PropTypes.elementType,
|
|
23
|
+
const SummaryItem = (props) => {
|
|
24
|
+
const { className = '', metricId, data, summaryItemLink: SummaryItemCustomLink, size, loading, showSummaryItemDelta } = props;
|
|
25
|
+
const componentLink = METRIC_COMPONENT_LINKS.get(metricId);
|
|
26
|
+
const metricData = get(data, metricId, { current: 0, baseline: 0 });
|
|
27
|
+
const metric = getGlobalMetricType(metricId);
|
|
28
|
+
const metricRunInfo = getMetricRunInfo(metric, metricData.current, metricData.baseline);
|
|
29
|
+
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, { title: metric.label, titleHoverCard: React.createElement(MetricInfo, { description: metric.description, url: metric.url }), current: metricRunInfo.displayValue, baseline: metric.formatter(metricData.baseline), size: size, loading: loading, ...(showSummaryItemDelta && (componentLink === null || componentLink === void 0 ? void 0 : componentLink.showDelta) !== false && {
|
|
31
|
+
delta: metricRunInfo.displayDeltaPercentage,
|
|
32
|
+
deltaType: metricRunInfo.deltaType,
|
|
33
|
+
}) })));
|
|
39
34
|
};
|
|
35
|
+
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
|
+
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 }))))));
|
|
40
37
|
//# sourceMappingURL=summary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../src/components/summary/summary.
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../src/components/summary/summary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,O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C,WAAW,IACV,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,GAAG,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"}
|
|
@@ -7,3 +7,22 @@
|
|
|
7
7
|
min-width: 16em;
|
|
8
8
|
text-decoration: none;
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
.readMoreLink {
|
|
12
|
+
appearance: none;
|
|
13
|
+
background: none;
|
|
14
|
+
margin: 0;
|
|
15
|
+
border: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
color: var(--color-primary);
|
|
18
|
+
text-decoration: underline;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.readMoreLink:hover,
|
|
23
|
+
.readMoreLink:active,
|
|
24
|
+
.readMoreLink:focus {
|
|
25
|
+
color: var(--color-primary-dark);
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.js","sourceRoot":"","sources":["../../../src/layout/box/box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"box.js","sourceRoot":"","sources":["../../../src/layout/box/box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAU,MAAM,cAAc,CAAC;AAChD,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAanC,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,KAAqE,EACrE,EAAE;IACF,MAAM,EACJ,SAAS,GAAG,EAAE,EACd,EAAE,EAAE,SAAS,GAAG,KAAK,EACrB,OAAO,GAAG,QAAQ,EAClB,iBAAiB,GAAG,EAAE,EACtB,eAAe,GAAG,EAAE,EACpB,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,KAAK,EACpB,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,eAAe,EAAE,uBAAuB,EAAE,yBAAyB,CAAC,GAAG,KAAK,CAAC,OAAO,CACzF,OAAO,CACR;QACC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC;QACpB,CAAC,CAAC,CAAC,OAAO,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAElD,MAAM,aAAa,GAAG,EAAE,CACtB,GAAG,CAAC,IAAI,EACR,SAAS,EACT,eAAe,IAAI,GAAG,CAAC,WAAW,eAAe,EAAE,CAAC,EACpD,uBAAuB,IAAI,GAAG,CAAC,oBAAoB,uBAAuB,EAAE,CAAC,EAC7E,yBAAyB,IAAI,GAAG,CAAC,sBAAsB,yBAAyB,EAAE,CAAC,EACnF,OAAO,IAAI,GAAG,CAAC,OAAO,EACtB,YAAY,IAAI,GAAG,CAAC,YAAY,CACjC,CAAC;IAEF,OAAO,oBAAC,SAAS,OAAK,SAAS,EAAE,SAAS,EAAE,aAAa,GAAI,CAAC;AAChE,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex-stack.js","sourceRoot":"","sources":["../../../src/layout/flex-stack/flex-stack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAU,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"flex-stack.js","sourceRoot":"","sources":["../../../src/layout/flex-stack/flex-stack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAU,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,GAAG,MAAM,yBAAyB,CAAC;AAW1C,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAiF,EACjF,EAAE;IACF,MAAM,EACJ,EAAE,EAAE,SAAS,GAAG,KAAK,EACrB,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,QAAQ,EAChB,MAAM,GAAG,KAAK,EACd,QAAQ,GAAG,IAAI,EACf,UAAU,GAAG,EAAE,EACf,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,aAAa,GAAG,EAAE,CACtB,SAAS,EACT,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,UAAU,KAAK,EAAE,CAAC,EACtB,GAAG,CAAC,gBAAgB,UAAU,EAAE,CAAC,EACjC,MAAM,IAAI,GAAG,CAAC,MAAM,CACrB,CAAC;IAEF,OAAO,CACL,oBAAC,SAAS,OAAK,SAAS,EAAE,SAAS,EAAE,aAAa,IAC/C,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,2BAA2B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAC1D,CACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/ui/container/container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/ui/container/container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,GAAG,MAAM,wBAAwB,CAAC;AAMzC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,EAAE,EAAE,SAAS,GAAG,KAAK,EACrB,SAAS,GAAG,EAAE,EACd,GAAG,SAAS,EACG,EAAE,EAAE,CAAC,CACpB,oBAAC,SAAS,IAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;IAC3C,6BAAK,SAAS,EAAE,GAAG,CAAC,KAAK,KAAM,SAAS,GAAI,CAClC,CACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../src/ui/tooltip/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,aAAa,IAAI,eAAe,EAChC,YAAY,IAAI,cAAc,EAC9B,eAAe,GAChB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../src/ui/tooltip/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,aAAa,IAAI,eAAe,EAChC,YAAY,IAAI,cAAc,EAC9B,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,GAAG,MAAM,sBAAsB,CAAC;AAWvC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,KAA6E,EAC7E,EAAE;IACF,MAAM,EACJ,SAAS,GAAG,EAAE,EACd,gBAAgB,GAAG,EAAE,EACrB,KAAK,GAAG,EAAE,EACV,EAAE,EAAE,SAAS,GAAG,MAAM,EACtB,YAAY,EAAE,GAAG,EACjB,QAAQ,GAAG,IAAI,EACf,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAEtD,OAAO,CACL;QACE,oBAAC,eAAe,IACd,EAAE,EAAE,SAA8B,EAClC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,EAClC,KAAK,EAAE,OAAO,KACV,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACpB,SAAS,GACb;QACD,KAAK,IAAI,CACR,oBAAC,SAAS,IACR,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,IAAI,GAAG,CAAC,eAAe,CAAC;YAE7E,oBAAC,cAAc,IAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAI;YACjE,KAAK,CACI,CACb,CACA,CACJ,CAAC;AACJ,CAAC,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.1",
|
|
4
4
|
"description": "UI components for BundleStats projects.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -69,22 +69,23 @@
|
|
|
69
69
|
"react-router-dom": "5.3.4",
|
|
70
70
|
"react-test-renderer": "18.2.0",
|
|
71
71
|
"rimraf": "4.2.0",
|
|
72
|
-
"typescript": "4.9.5"
|
|
72
|
+
"typescript": "4.9.5",
|
|
73
|
+
"typescript-plugin-css-modules": "4.2.3"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
76
|
"classnames": "^2.0.0",
|
|
76
77
|
"lodash": "^4.0.0",
|
|
77
78
|
"prop-types": "^15.0.0",
|
|
78
|
-
"react": "^17.0.0
|
|
79
|
-
"react-dom": "^17.0.0
|
|
79
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
80
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
80
81
|
"react-router-dom": "^5.0.0"
|
|
81
82
|
},
|
|
82
83
|
"dependencies": {
|
|
83
|
-
"@bundle-stats/utils": "^4.2.5-beta.
|
|
84
|
+
"@bundle-stats/utils": "^4.2.5-beta.1",
|
|
84
85
|
"ariakit": "2.0.0-next.43",
|
|
85
86
|
"modern-css-reset": "1.4.0",
|
|
86
87
|
"query-string": "7.1.3",
|
|
87
88
|
"use-query-params": "2.2.0"
|
|
88
89
|
},
|
|
89
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "9fe36de1be394c9da1685e32ae09782b2a2982cb"
|
|
90
91
|
}
|
|
@@ -5,29 +5,37 @@ import map from 'lodash/map';
|
|
|
5
5
|
import max from 'lodash/max';
|
|
6
6
|
import sum from 'lodash/sum';
|
|
7
7
|
import * as webpack from '@bundle-stats/utils/lib-esm/webpack';
|
|
8
|
-
import { getBundleAssetsFileTypeComponentLink } from '@bundle-stats/utils';
|
|
8
|
+
import { getBundleAssetsFileTypeComponentLink, getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
9
9
|
|
|
10
10
|
import { ASSETS_SIZES_FILE_TYPE_MAP } from '../../constants';
|
|
11
11
|
import { HorizontalBarChart } from '../../ui/horizontal-bar-chart';
|
|
12
12
|
import { ComponentLink } from '../component-link'
|
|
13
13
|
import { getColors } from '../../utils';
|
|
14
14
|
import { Stack } from '../../layout/stack';
|
|
15
|
-
import {
|
|
15
|
+
import { MetricRunInfo } from '../metric-run-info';
|
|
16
16
|
import css from './bundle-assets-totals-chart-bars.module.css';
|
|
17
17
|
|
|
18
|
-
const getTooltip = (items, jobs, itemIndex, runIndex) => () =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
const getTooltip = (items, jobs, itemIndex, runIndex) => () => {
|
|
19
|
+
const metricId = items?.[itemIndex]?.key;
|
|
20
|
+
const metric = getGlobalMetricType(metricId);
|
|
21
|
+
const current = items?.[itemIndex]?.runs?.[runIndex]?.value || 0;
|
|
22
|
+
const baseline = items?.[itemIndex]?.runs?.[runIndex + 1]?.value || 0;
|
|
23
|
+
const metricRunInfo = getMetricRunInfo(metric, current, baseline);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<MetricRunInfo
|
|
27
|
+
className={css.itemTooltip}
|
|
28
|
+
title={metric.label}
|
|
29
|
+
current={metricRunInfo.displayValue}
|
|
30
|
+
{...(runIndex < jobs.length - 1 && {
|
|
31
|
+
baseline: metric.formatter(baseline),
|
|
32
|
+
delta: metricRunInfo.displayDeltaPercentage,
|
|
33
|
+
deltaType: metricRunInfo.deltaType,
|
|
34
|
+
})}
|
|
35
|
+
size="large"
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
31
39
|
|
|
32
40
|
export const BundleAssetsTotalsChartBars = ({
|
|
33
41
|
className,
|
package/src/components/index.js
CHANGED
|
@@ -13,11 +13,11 @@ export { JobHeader } from './job-header';
|
|
|
13
13
|
export { JobsHeader } from './jobs-header';
|
|
14
14
|
export { LighthouseTable } from './lighthouse-table';
|
|
15
15
|
export { Metric } from './metric';
|
|
16
|
+
export { MetricRunInfo, MetricRunInfoProps } from './metric-run-info';
|
|
16
17
|
export { MetricsTable } from './metrics-table';
|
|
17
18
|
export { MetricsTableOptions } from './metrics-table-options';
|
|
18
19
|
export { MetricsTableSearch } from './metrics-table-search';
|
|
19
20
|
export { MetricsTableTitle } from './metrics-table-title';
|
|
20
21
|
export { ModuleInfo } from './module-info';
|
|
21
|
-
export { SummaryItem } from './summary-item';
|
|
22
22
|
export { Summary } from './summary';
|
|
23
23
|
export { TotalSizeTypeTitle } from './total-size-type-title';
|
|
@@ -3,7 +3,6 @@ import cx from 'classnames';
|
|
|
3
3
|
import { InsightType } from '@bundle-stats/utils';
|
|
4
4
|
|
|
5
5
|
import { Icon } from '../../ui/icon';
|
|
6
|
-
// @ts-ignore
|
|
7
6
|
import css from './insight-icon.module.css';
|
|
8
7
|
|
|
9
8
|
const InsightTypeIconMap = new Map([
|
|
@@ -24,4 +23,3 @@ export const InsightIcon = (props: InsightIconProps) => {
|
|
|
24
23
|
|
|
25
24
|
return <Icon glyph={glyph} className={rootClassName} />;
|
|
26
25
|
};
|
|
27
|
-
|
|
@@ -5,7 +5,6 @@ import { FlexStack } from '../../layout/flex-stack';
|
|
|
5
5
|
import { Stack } from '../../layout/stack';
|
|
6
6
|
import { ComponentLink } from '../component-link';
|
|
7
7
|
import { InsightIcon } from '../insight-icon';
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
import css from './insights.module.css';
|
|
10
9
|
|
|
11
10
|
interface InsightsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
font-size: var(--size-small);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.
|
|
9
|
+
.content {
|
|
10
10
|
font-size: var(--size-small);
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
display: inline-block;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.inline .
|
|
17
|
+
.inline .content {
|
|
18
18
|
display: inline-block;
|
|
19
19
|
margin: 0 0 0 var(--space-xxxsmall);
|
|
20
20
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { getWrapperDecorator } from '../../stories';
|
|
5
|
+
import { Delta } from '../delta';
|
|
6
|
+
import { Metric } from '.';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/Metric',
|
|
10
|
+
component: Metric,
|
|
11
|
+
decorators: [getWrapperDecorator({ maxWidth: '200px' })],
|
|
12
|
+
} as Meta;
|
|
13
|
+
|
|
14
|
+
const Template: Story = (args) => <Metric {...args} />;
|
|
15
|
+
|
|
16
|
+
export const Default = Template.bind({});
|
|
17
|
+
|
|
18
|
+
Default.args = {
|
|
19
|
+
value: '100',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const WithUnit = Template.bind({});
|
|
23
|
+
|
|
24
|
+
WithUnit.args = {
|
|
25
|
+
value: '100',
|
|
26
|
+
unit: 'KiB',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const WithDelta = Template.bind({});
|
|
30
|
+
|
|
31
|
+
WithDelta.args = {
|
|
32
|
+
...WithUnit.args,
|
|
33
|
+
children: <Delta displayValue="+10%" deltaType="POSITIVE" />,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Inline = Template.bind({});
|
|
37
|
+
|
|
38
|
+
Inline.args = {
|
|
39
|
+
...WithDelta.args,
|
|
40
|
+
inline: true,
|
|
41
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
|
|
4
|
+
import css from './metric.module.css';
|
|
5
|
+
|
|
6
|
+
export interface MetricProps {
|
|
7
|
+
/**
|
|
8
|
+
* Metric value
|
|
9
|
+
*/
|
|
10
|
+
value?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Metric value unit
|
|
13
|
+
*/
|
|
14
|
+
unit?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Inline variant - render children inline
|
|
17
|
+
*/
|
|
18
|
+
inline?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Metric = (props: MetricProps & React.ComponentProps<'div'>) => {
|
|
22
|
+
const {
|
|
23
|
+
className = '',
|
|
24
|
+
value = '0',
|
|
25
|
+
unit = '',
|
|
26
|
+
inline = false,
|
|
27
|
+
children = null,
|
|
28
|
+
...restProps
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const rootClassName = cx(className, css.root, inline && css.inline);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className={rootClassName} {...restProps}>
|
|
35
|
+
<div className={css.display}>
|
|
36
|
+
<span className={css.displayValue}>{value}</span>
|
|
37
|
+
{unit && <span className={css.displayUnit}>{unit}</span>}
|
|
38
|
+
</div>
|
|
39
|
+
{children && <div className={css.content}>{children}</div>}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './metric-run-info';
|
|
@@ -25,24 +25,6 @@
|
|
|
25
25
|
line-height: var(--line-height-heading);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.readMoreLink {
|
|
29
|
-
appearance: none;
|
|
30
|
-
background: none;
|
|
31
|
-
margin: 0;
|
|
32
|
-
border: 0;
|
|
33
|
-
padding: 0;
|
|
34
|
-
color: var(--color-primary);
|
|
35
|
-
text-decoration: underline;
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.readMoreLink:hover,
|
|
40
|
-
.readMoreLink:active,
|
|
41
|
-
.readMoreLink:focus {
|
|
42
|
-
color: var(--color-primary-dark);
|
|
43
|
-
text-decoration: none;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
28
|
/* Loading state */
|
|
47
29
|
.loading.currentMetric {
|
|
48
30
|
width: 8em;
|