@bundle-stats/ui 4.2.4 → 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/constants.js +1 -23
- package/lib/constants.js.map +1 -1
- package/lib/layout/box/box.js +2 -2
- package/lib/layout/box/box.js.map +1 -1
- package/lib/layout/flex-stack/flex-stack.js +3 -19
- package/lib/layout/flex-stack/flex-stack.js.map +1 -1
- package/lib/layout/flex-stack/index.js.map +1 -1
- package/lib/layout/stack/stack.js +3 -3
- package/lib/layout/stack/stack.js.map +1 -1
- package/lib/tokens.js +26 -0
- package/lib/tokens.js.map +1 -0
- package/lib/ui/container/container.js.map +1 -1
- package/lib/ui/tooltip/index.js.map +1 -1
- package/lib/ui/tooltip/tooltip.js +2 -22
- 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/constants.js +0 -22
- package/lib-esm/constants.js.map +1 -1
- package/lib-esm/layout/box/box.js +1 -1
- package/lib-esm/layout/box/box.js.map +1 -1
- package/lib-esm/layout/flex-stack/flex-stack.js +3 -19
- package/lib-esm/layout/flex-stack/flex-stack.js.map +1 -1
- package/lib-esm/layout/flex-stack/index.js.map +1 -1
- package/lib-esm/layout/stack/stack.js +1 -1
- package/lib-esm/layout/stack/stack.js.map +1 -1
- package/lib-esm/tokens.js +23 -0
- package/lib-esm/tokens.js.map +1 -0
- package/lib-esm/ui/container/container.js.map +1 -1
- package/lib-esm/ui/tooltip/index.js.map +1 -1
- package/lib-esm/ui/tooltip/tooltip.js +2 -22
- 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/constants.js +0 -24
- package/src/layout/box/box.tsx +11 -8
- package/src/layout/flex-stack/flex-stack.stories.tsx +59 -0
- package/src/layout/flex-stack/flex-stack.tsx +43 -0
- package/src/layout/stack/stack.jsx +1 -1
- package/src/tokens.ts +23 -0
- package/src/ui/container/container.tsx +0 -1
- package/src/ui/tooltip/tooltip.stories.tsx +30 -0
- package/src/ui/tooltip/tooltip.tsx +56 -0
- 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/constants.d.ts +0 -11
- package/types/layout/box/box.d.ts +8 -7
- package/types/layout/flex-stack/flex-stack.d.ts +10 -33
- package/types/layout/flex-stack/index.d.ts +1 -1
- package/types/layout/stack/stack.d.ts +2 -2
- package/types/tokens.d.ts +11 -0
- package/types/ui/tooltip/index.d.ts +1 -1
- package/types/ui/tooltip/tooltip.d.ts +10 -28
- 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/src/layout/flex-stack/flex-stack.jsx +0 -49
- package/src/ui/tooltip/tooltip.jsx +0 -67
- 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
- /package/src/layout/flex-stack/{index.js → index.ts} +0 -0
- /package/src/ui/tooltip/{index.js → index.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/layout/stack/stack.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/layout/stack/stack.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE;IAC7B,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAC1E,MAAM,aAAa,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC;IAEtE,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;AAEF,KAAK,CAAC,YAAY,GAAG;IACnB,EAAE,EAAE,KAAK;IACT,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,KAAK,CAAC,SAAS,GAAG;IAChB,EAAE,EAAE,SAAS,CAAC,WAAW;IACzB,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const NO_SPACE = 'no-space';
|
|
2
|
+
export const SPACE_XXXSMALL = 'xxxsmall';
|
|
3
|
+
export const SPACE_XXSMALL = 'xxsmall';
|
|
4
|
+
export const SPACE_XSMALL = 'xsmall';
|
|
5
|
+
export const SPACE_SMALL = 'small';
|
|
6
|
+
export const SPACE_MEDIUM = 'medium';
|
|
7
|
+
export const SPACE_LARGE = 'large';
|
|
8
|
+
export const SPACE_XLARGE = 'xlarge';
|
|
9
|
+
export const SPACE_XXLARGE = 'xxlarge';
|
|
10
|
+
export const SPACE_XXXLARGE = 'xxxlarge';
|
|
11
|
+
export const SPACES = [
|
|
12
|
+
NO_SPACE,
|
|
13
|
+
SPACE_XXXSMALL,
|
|
14
|
+
SPACE_XXSMALL,
|
|
15
|
+
SPACE_XSMALL,
|
|
16
|
+
SPACE_SMALL,
|
|
17
|
+
SPACE_MEDIUM,
|
|
18
|
+
SPACE_LARGE,
|
|
19
|
+
SPACE_XLARGE,
|
|
20
|
+
SPACE_XXLARGE,
|
|
21
|
+
SPACE_XXXLARGE,
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,QAAQ;IACR,cAAc;IACd,aAAa;IACb,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,aAAa;IACb,cAAc;CACN,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":"index.js","sourceRoot":"","sources":["../../../src/ui/tooltip/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/tooltip/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import cx from 'classnames';
|
|
4
3
|
import { Tooltip as UITooltip, TooltipAnchor as UITooltipAnchor, TooltipArrow as UITooltipArrow, useTooltipState, } from 'ariakit/tooltip';
|
|
5
4
|
import css from './tooltip.module.css';
|
|
6
5
|
export const Tooltip = (props) => {
|
|
7
|
-
const { className, tooltipClassName, title
|
|
6
|
+
const { className = '', tooltipClassName = '', title = '', as: Component = 'span', containerRef: ref, darkMode = true, ...restProps } = props;
|
|
8
7
|
const tooltip = useTooltipState({ placement: 'top' });
|
|
9
8
|
return (React.createElement(React.Fragment, null,
|
|
10
|
-
React.createElement(UITooltipAnchor, { as: Component, className: cx(css.root, className), state: tooltip, ...(ref ? { ref } : {}), ...restProps }
|
|
9
|
+
React.createElement(UITooltipAnchor, { as: Component, className: cx(css.root, className), state: tooltip, ...(ref ? { ref } : {}), ...restProps }),
|
|
11
10
|
title && (React.createElement(UITooltip, { state: tooltip, className: cx(css.tooltip, tooltipClassName, darkMode && css.tooltipDarkMode) },
|
|
12
11
|
React.createElement(UITooltipArrow, { state: tooltip, className: css.arrow, size: 12 }),
|
|
13
12
|
title))));
|
|
14
13
|
};
|
|
15
|
-
Tooltip.defaultProps = {
|
|
16
|
-
className: '',
|
|
17
|
-
tooltipClassName: '',
|
|
18
|
-
title: '',
|
|
19
|
-
as: 'span',
|
|
20
|
-
containerRef: null,
|
|
21
|
-
darkMode: true,
|
|
22
|
-
};
|
|
23
|
-
Tooltip.propTypes = {
|
|
24
|
-
className: PropTypes.string,
|
|
25
|
-
tooltipClassName: PropTypes.string,
|
|
26
|
-
title: PropTypes.node,
|
|
27
|
-
children: PropTypes.node.isRequired,
|
|
28
|
-
as: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]),
|
|
29
|
-
containerRef: PropTypes.shape({
|
|
30
|
-
current: PropTypes.object,
|
|
31
|
-
}),
|
|
32
|
-
darkMode: PropTypes.bool,
|
|
33
|
-
};
|
|
34
14
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../src/ui/tooltip/tooltip.
|
|
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.
|
|
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.
|
|
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;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { MetricRunInfo } from './metric-run-info';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/MetricRunInfo',
|
|
8
|
+
component: MetricRunInfo,
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story = (args) => <MetricRunInfo id="webpack.totalSizeByTypeALL" {...args} />;
|
|
12
|
+
|
|
13
|
+
export const Default = Template.bind({});
|
|
14
|
+
|
|
15
|
+
Default.args = {
|
|
16
|
+
title: 'Bundle Size',
|
|
17
|
+
current: '120KiB',
|
|
18
|
+
baseline: '100KiB',
|
|
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',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const TitleHoverCard = Template.bind({});
|
|
31
|
+
|
|
32
|
+
TitleHoverCard.args = {
|
|
33
|
+
...Default.args,
|
|
34
|
+
titleHoverCard: 'Info',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const TitleTooltip = Template.bind({});
|
|
38
|
+
|
|
39
|
+
TitleTooltip.args = {
|
|
40
|
+
...Default.args,
|
|
41
|
+
titleTooltip: 'Info',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Loading = Template.bind({});
|
|
45
|
+
|
|
46
|
+
Loading.args = {
|
|
47
|
+
title: 'Bundle Size',
|
|
48
|
+
loading: true,
|
|
49
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
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
|
+
import { Stack } from '../../layout/stack';
|
|
10
|
+
import { Metric } from '../metric';
|
|
11
|
+
import { Delta } from '../delta';
|
|
12
|
+
import css from './metric-run-info.module.css';
|
|
13
|
+
|
|
14
|
+
// Separate value and unit
|
|
15
|
+
const EXTRACT_VALUE_UNIT_PATTERN = /([\d|.|,| ]*)(\w*|%)$/;
|
|
16
|
+
|
|
17
|
+
const getMetricParams = (value: string) => {
|
|
18
|
+
const matches = value.match(EXTRACT_VALUE_UNIT_PATTERN);
|
|
19
|
+
|
|
20
|
+
if (!matches) {
|
|
21
|
+
return { value, unit: '' };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
value: matches[1],
|
|
26
|
+
unit: matches[2],
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export interface MetricRunInfoProps {
|
|
31
|
+
title?: string;
|
|
32
|
+
titleHoverCard?: React.ReactNode;
|
|
33
|
+
titleTooltip?: React.ReactNode;
|
|
34
|
+
current?: string;
|
|
35
|
+
baseline?: string;
|
|
36
|
+
delta?: string;
|
|
37
|
+
deltaType?: string;
|
|
38
|
+
|
|
39
|
+
as?: React.ElementType;
|
|
40
|
+
size?: 'medium' | 'large';
|
|
41
|
+
|
|
42
|
+
loading?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const MetricRunInfo = ({
|
|
46
|
+
className = '',
|
|
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>
|
|
67
|
+
|
|
68
|
+
{titleHoverCard && (
|
|
69
|
+
<HoverCard label={<Icon glyph={Icon.ICONS.HELP} />} className={css.titleIcon}>
|
|
70
|
+
{titleHoverCard}
|
|
71
|
+
</HoverCard>
|
|
72
|
+
)}
|
|
73
|
+
{titleTooltip && (
|
|
74
|
+
<Tooltip title={titleTooltip} className={css.titleIcon}>
|
|
75
|
+
<Icon glyph={Icon.ICONS.HELP} />
|
|
76
|
+
</Tooltip>
|
|
77
|
+
)}
|
|
78
|
+
</FlexStack>
|
|
79
|
+
)}
|
|
80
|
+
|
|
81
|
+
{!loading ? (
|
|
82
|
+
<Stack>
|
|
83
|
+
<Metric
|
|
84
|
+
className={css.currentMetric}
|
|
85
|
+
value={metricParams.value}
|
|
86
|
+
unit={metricParams.unit}
|
|
87
|
+
inline
|
|
88
|
+
>
|
|
89
|
+
{delta && <Delta className={css.delta} displayValue={delta} deltaType={deltaType} />}
|
|
90
|
+
</Metric>
|
|
91
|
+
<Metric className={css.baselineMetric} value={baseline} />
|
|
92
|
+
</Stack>
|
|
93
|
+
) : (
|
|
94
|
+
<Stack>
|
|
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>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
import { createJobs } from '@bundle-stats/utils';
|
|
4
|
+
|
|
5
|
+
import baselineData from '../../../__mocks__/webpack-stats.baseline.json';
|
|
6
|
+
import currentData from '../../../__mocks__/webpack-stats.current.json';
|
|
7
|
+
import { METRICS_WEBPACK_ASSETS } from '../../constants';
|
|
8
|
+
import { getWrapperDecorator } from '../../stories';
|
|
9
|
+
import { Summary } from '.';
|
|
10
|
+
|
|
11
|
+
const MULTIPLE_JOBS = createJobs([{ webpack: currentData }, { webpack: baselineData }]);
|
|
12
|
+
|
|
13
|
+
const SINGLE_JOB = createJobs([{ webpack: currentData }]);
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'Components/Summary',
|
|
17
|
+
component: Summary,
|
|
18
|
+
decorators: [getWrapperDecorator()],
|
|
19
|
+
} as Meta;
|
|
20
|
+
|
|
21
|
+
const Template: Story = (args) => <Summary {...args} />;
|
|
22
|
+
|
|
23
|
+
export const Default = Template.bind({});
|
|
24
|
+
|
|
25
|
+
Default.args = {
|
|
26
|
+
data: MULTIPLE_JOBS[0].summary,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const CustomKeys = Template.bind({});
|
|
30
|
+
|
|
31
|
+
CustomKeys.args = {
|
|
32
|
+
keys: METRICS_WEBPACK_ASSETS,
|
|
33
|
+
data: MULTIPLE_JOBS[0].summary,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Loading = Template.bind({});
|
|
37
|
+
|
|
38
|
+
Loading.args = {
|
|
39
|
+
loading: true,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const SingleRun = Template.bind({});
|
|
43
|
+
|
|
44
|
+
SingleRun.args = {
|
|
45
|
+
data: SINGLE_JOB[0].summary,
|
|
46
|
+
showSummaryItemDelta: false,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const WithLink = Template.bind({});
|
|
50
|
+
|
|
51
|
+
WithLink.args = {
|
|
52
|
+
data: MULTIPLE_JOBS[0].summary,
|
|
53
|
+
summaryItemLink: (linkProps: React.ComponentProps<'button'>) => (
|
|
54
|
+
<button {...linkProps} type="button" onClick={() => alert(JSON.stringify(linkProps))} />
|
|
55
|
+
),
|
|
56
|
+
};
|