@bundle-stats/ui 3.4.0-alpha.3 → 3.4.0-beta.0
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/app/app.js +3 -1
- package/lib/app/header/header.js +2 -1
- package/lib/components/budget-info/budget-info.js +11 -17
- package/lib/components/budget-info/budget-info.stories.js +27 -12
- package/lib/components/budget-insights/budget-insights.js +37 -75
- package/lib/components/budget-insights/budget-insights.module.css +10 -2
- package/lib/components/budget-insights/budget-insights.stories.js +124 -63
- package/lib/components/bundle-assets/bundle-assets.js +2 -1
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +3 -4
- package/lib/components/bundle-modules/bundle-modules.js +1 -1
- package/lib/components/summary/summary.js +6 -12
- package/lib/components/summary/summary.module.css +1 -45
- package/lib/components/summary/summary.stories.js +41 -13
- package/lib/components/summary-item/summary-item.js +14 -22
- package/lib/components/summary-item/summary-item.module.css +25 -7
- package/lib/components/summary-item/summary-item.stories.js +20 -6
- package/lib/ui/hover-card/hover-card.js +7 -1
- package/lib-esm/app/app.js +3 -1
- package/lib-esm/app/header/header.js +2 -1
- package/lib-esm/components/budget-info/budget-info.js +11 -12
- package/lib-esm/components/budget-info/budget-info.stories.js +27 -12
- package/lib-esm/components/budget-insights/budget-insights.js +35 -71
- package/lib-esm/components/budget-insights/budget-insights.module.css +10 -2
- package/lib-esm/components/budget-insights/budget-insights.stories.js +115 -55
- package/lib-esm/components/bundle-assets/bundle-assets.js +2 -1
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +3 -4
- package/lib-esm/components/bundle-modules/bundle-modules.js +1 -1
- package/lib-esm/components/summary/summary.js +6 -11
- package/lib-esm/components/summary/summary.module.css +1 -45
- package/lib-esm/components/summary/summary.stories.js +41 -13
- package/lib-esm/components/summary-item/summary-item.js +11 -20
- package/lib-esm/components/summary-item/summary-item.module.css +25 -7
- package/lib-esm/components/summary-item/summary-item.stories.js +20 -6
- package/lib-esm/ui/hover-card/hover-card.js +7 -1
- package/package.json +25 -25
- package/src/app/app.jsx +2 -2
- package/src/app/header/header.jsx +1 -1
- package/src/components/budget-info/budget-info.jsx +12 -22
- package/src/components/budget-insights/budget-insights.jsx +49 -82
- package/src/components/budget-insights/budget-insights.module.css +10 -2
- package/src/components/bundle-assets/bundle-assets.jsx +1 -1
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +3 -3
- package/src/components/bundle-modules/bundle-modules.jsx +1 -1
- package/src/components/summary/summary.jsx +13 -17
- package/src/components/summary/summary.module.css +1 -45
- package/src/components/summary-item/summary-item.jsx +11 -17
- package/src/components/summary-item/summary-item.module.css +25 -7
- package/src/ui/hover-card/hover-card.jsx +5 -0
|
@@ -1,84 +1,144 @@
|
|
|
1
|
+
import _merge from "lodash/merge";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { MemoryRouter } from 'react-router-dom';
|
|
3
4
|
import { BudgetInsights } from '.';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const Default = Template.bind();
|
|
13
|
-
Default.args = {
|
|
14
|
-
source: 'webpack',
|
|
15
|
-
budgets: {
|
|
5
|
+
const BUDGETS = {
|
|
6
|
+
type: 'SUCCESS',
|
|
7
|
+
message: {
|
|
8
|
+
text: '8 budget checks passed',
|
|
9
|
+
md: '**8** budget checks passed'
|
|
10
|
+
},
|
|
11
|
+
data: {
|
|
16
12
|
totalSizeByTypeALL: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
type: 'ERROR',
|
|
14
|
+
message: {
|
|
15
|
+
text: 'Bundle Size is above the budget',
|
|
16
|
+
md: 'Bundle Size is above the budget'
|
|
17
|
+
},
|
|
18
|
+
data: {
|
|
19
|
+
currentValue: 2097917,
|
|
20
|
+
budgetValue: 2097152,
|
|
21
|
+
failed: true
|
|
22
|
+
}
|
|
20
23
|
},
|
|
21
24
|
totalInitialSizeJS: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
type: 'ERROR',
|
|
26
|
+
message: {
|
|
27
|
+
text: 'Initial JS is above the budget',
|
|
28
|
+
md: 'Initial JS is above the budget'
|
|
29
|
+
},
|
|
30
|
+
data: {
|
|
31
|
+
currentValue: 1265645,
|
|
32
|
+
budgetValue: 524288,
|
|
33
|
+
failed: true
|
|
34
|
+
}
|
|
25
35
|
},
|
|
26
36
|
totalInitialSizeCSS: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
type: 'SUCCESS',
|
|
38
|
+
message: {
|
|
39
|
+
text: 'Initial CSS is below the budget',
|
|
40
|
+
md: 'Initial CSS is below the budget'
|
|
41
|
+
},
|
|
42
|
+
data: {
|
|
43
|
+
currentValue: 48866,
|
|
44
|
+
budgetValue: 51200,
|
|
45
|
+
failed: false
|
|
46
|
+
}
|
|
30
47
|
},
|
|
31
48
|
chunkCount: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
type: 'SUCCESS',
|
|
50
|
+
message: {
|
|
51
|
+
text: 'Chunks is below the budget',
|
|
52
|
+
md: 'Chunks is below the budget'
|
|
53
|
+
},
|
|
54
|
+
data: {
|
|
55
|
+
currentValue: 12,
|
|
56
|
+
budgetValue: 50,
|
|
57
|
+
failed: false
|
|
58
|
+
}
|
|
35
59
|
},
|
|
36
60
|
moduleCount: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
type: 'SUCCESS',
|
|
62
|
+
message: {
|
|
63
|
+
text: 'Modules is below the budget',
|
|
64
|
+
md: 'Modules is below the budget'
|
|
65
|
+
},
|
|
66
|
+
data: {
|
|
67
|
+
currentValue: 1059,
|
|
68
|
+
budgetValue: 2000,
|
|
69
|
+
failed: false
|
|
70
|
+
}
|
|
40
71
|
},
|
|
41
72
|
duplicatePackagesCount: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
73
|
+
type: 'ERROR',
|
|
74
|
+
message: {
|
|
75
|
+
text: 'Duplicate packages is above the budget',
|
|
76
|
+
md: 'Duplicate packages is above the budget'
|
|
77
|
+
},
|
|
78
|
+
data: {
|
|
79
|
+
currentValue: 13,
|
|
80
|
+
budgetValue: 5,
|
|
81
|
+
failed: true
|
|
82
|
+
}
|
|
45
83
|
},
|
|
46
84
|
'sizes.totalSizeByTypeJS': {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
85
|
+
type: 'SUCCESS',
|
|
86
|
+
message: {
|
|
87
|
+
text: 'JS is below the budget',
|
|
88
|
+
md: 'JS is below the budget'
|
|
89
|
+
},
|
|
90
|
+
data: {
|
|
91
|
+
currentValue: 1981470,
|
|
92
|
+
budgetValue: 2097152,
|
|
93
|
+
failed: false
|
|
94
|
+
}
|
|
50
95
|
},
|
|
51
96
|
'sizes.totalSizeByTypeCSS': {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
97
|
+
type: 'SUCCESS',
|
|
98
|
+
message: {
|
|
99
|
+
text: 'CSS is below the budget',
|
|
100
|
+
md: 'CSS is below the budget'
|
|
101
|
+
},
|
|
102
|
+
data: {
|
|
103
|
+
currentValue: 56091,
|
|
104
|
+
budgetValue: 20480,
|
|
105
|
+
failed: true
|
|
106
|
+
}
|
|
55
107
|
}
|
|
56
108
|
}
|
|
57
109
|
};
|
|
110
|
+
export default {
|
|
111
|
+
title: 'Components/BudgetInsights',
|
|
112
|
+
component: BudgetInsights,
|
|
113
|
+
decorators: [Story => /*#__PURE__*/React.createElement(MemoryRouter, null, /*#__PURE__*/React.createElement(Story, null))]
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const Template = args => /*#__PURE__*/React.createElement(BudgetInsights, args);
|
|
117
|
+
|
|
118
|
+
export const Default = Template.bind();
|
|
119
|
+
Default.args = {
|
|
120
|
+
source: 'webpack',
|
|
121
|
+
budgets: BUDGETS
|
|
122
|
+
};
|
|
58
123
|
export const FailedBudgets = Template.bind();
|
|
59
124
|
FailedBudgets.args = {
|
|
60
125
|
source: 'webpack',
|
|
61
|
-
budgets: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
totalInitialSizeJS: {
|
|
68
|
-
currentValue: 1265645,
|
|
69
|
-
budgetValue: 524288,
|
|
70
|
-
failed: true
|
|
126
|
+
budgets: _merge({}, BUDGETS, {
|
|
127
|
+
type: 'ERROR',
|
|
128
|
+
message: {
|
|
129
|
+
text: '2/8 budget checks failed',
|
|
130
|
+
md: '**2/8** budget checks failed'
|
|
71
131
|
}
|
|
72
|
-
}
|
|
132
|
+
})
|
|
73
133
|
};
|
|
74
|
-
export const
|
|
75
|
-
|
|
134
|
+
export const WarnedBudgets = Template.bind();
|
|
135
|
+
WarnedBudgets.args = {
|
|
76
136
|
source: 'webpack',
|
|
77
|
-
budgets: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
137
|
+
budgets: _merge({}, BUDGETS, {
|
|
138
|
+
type: 'WARNING',
|
|
139
|
+
message: {
|
|
140
|
+
text: '2/8 budget checks warned',
|
|
141
|
+
md: '**2/8** budget checks warned'
|
|
82
142
|
}
|
|
83
|
-
}
|
|
143
|
+
})
|
|
84
144
|
};
|
|
@@ -145,7 +145,8 @@ RowHeader.propTypes = {
|
|
|
145
145
|
isChunk: PropTypes.bool,
|
|
146
146
|
isInitial: PropTypes.bool,
|
|
147
147
|
isEntry: PropTypes.bool,
|
|
148
|
-
runs: PropTypes.arrayOf(PropTypes.object)
|
|
148
|
+
runs: PropTypes.arrayOf(PropTypes.object) // eslint-disable-line react/forbid-prop-types
|
|
149
|
+
|
|
149
150
|
}).isRequired,
|
|
150
151
|
chunks: PropTypes.arrayOf(PropTypes.shape({
|
|
151
152
|
id: PropTypes.string,
|
|
@@ -13,7 +13,7 @@ import { ComponentLink } from '../component-link';
|
|
|
13
13
|
import { BudgetInfo } from '../budget-info';
|
|
14
14
|
import css from './bundle-assets-totals-table.module.css';
|
|
15
15
|
export const BundleAssetsTotalsTable = _ref => {
|
|
16
|
-
var _jobs$0$insights, _jobs$0$insights$webp;
|
|
16
|
+
var _jobs$0$insights, _jobs$0$insights$webp, _jobs$0$insights$webp2;
|
|
17
17
|
|
|
18
18
|
let {
|
|
19
19
|
className,
|
|
@@ -22,7 +22,7 @@ export const BundleAssetsTotalsTable = _ref => {
|
|
|
22
22
|
...restProps
|
|
23
23
|
} = _ref;
|
|
24
24
|
const items = useMemo(() => webpack.compareBySection.sizes(jobs), [jobs]);
|
|
25
|
-
const budgets = (_jobs$0$insights = jobs[0].insights) == null ? void 0 : (_jobs$0$insights$webp = _jobs$0$insights.webpack) == null ? void 0 : _jobs$0$insights$webp.budgets;
|
|
25
|
+
const budgets = (_jobs$0$insights = jobs[0].insights) == null ? void 0 : (_jobs$0$insights$webp = _jobs$0$insights.webpack) == null ? void 0 : (_jobs$0$insights$webp2 = _jobs$0$insights$webp.budgets) == null ? void 0 : _jobs$0$insights$webp2.data;
|
|
26
26
|
const renderRowHeader = useCallback(item => {
|
|
27
27
|
const fileType = ASSETS_SIZES_FILE_TYPE_MAP[item.key];
|
|
28
28
|
const {
|
|
@@ -40,10 +40,9 @@ export const BundleAssetsTotalsTable = _ref => {
|
|
|
40
40
|
title: title,
|
|
41
41
|
params: params
|
|
42
42
|
}, /*#__PURE__*/React.createElement(FlexStack, {
|
|
43
|
-
space: "
|
|
43
|
+
space: "xxxsmall",
|
|
44
44
|
className: css.itemTitleText
|
|
45
45
|
}, /*#__PURE__*/React.createElement("span", null, item.label), budget && /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
46
|
-
metricId: item.key,
|
|
47
46
|
budgetInsight: budget
|
|
48
47
|
})));
|
|
49
48
|
}, [CustomComponentLink]);
|
|
@@ -121,7 +121,7 @@ export const BundleModules = _ref2 => {
|
|
|
121
121
|
disabled: jobs.length <= 1
|
|
122
122
|
},
|
|
123
123
|
[MODULE_FILTERS.DUPLICATED]: {
|
|
124
|
-
label: '
|
|
124
|
+
label: 'Duplicate',
|
|
125
125
|
defaultValue: filters[MODULE_FILTERS.DUPLICATED],
|
|
126
126
|
disabled: jobs.length <= 1
|
|
127
127
|
},
|
|
@@ -7,7 +7,6 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import cx from 'classnames';
|
|
8
8
|
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
9
9
|
import { METRICS_WEBPACK_GENERAL } from '../../constants';
|
|
10
|
-
import { Icon } from '../../ui/icon';
|
|
11
10
|
import { Box } from '../../layout/box';
|
|
12
11
|
import { FlexStack } from '../../layout/flex-stack';
|
|
13
12
|
import { ComponentLink } from '../component-link';
|
|
@@ -37,23 +36,19 @@ export const Summary = _ref => {
|
|
|
37
36
|
return keys.includes(getSourceMetricId(metricId));
|
|
38
37
|
}).map(_ref3 => {
|
|
39
38
|
let [metricId, metricOptions] = _ref3;
|
|
40
|
-
return /*#__PURE__*/React.createElement(
|
|
39
|
+
return /*#__PURE__*/React.createElement(SummaryItem, _extends({
|
|
41
40
|
key: metricId,
|
|
42
|
-
className: css.item
|
|
43
|
-
|
|
41
|
+
className: css.item,
|
|
42
|
+
as: SummaryItemCustomLink
|
|
43
|
+
}, metricOptions.link, {
|
|
44
44
|
size: size,
|
|
45
45
|
id: metricId,
|
|
46
46
|
data: _get(data, metricId),
|
|
47
|
-
budget: _get(budgets, getSourceMetricId(metricId)),
|
|
47
|
+
budget: _get(budgets, ['data', getSourceMetricId(metricId)]),
|
|
48
48
|
loading: loading,
|
|
49
49
|
showMetricDescription: true,
|
|
50
50
|
showDelta: showSummaryItemDelta && metricOptions.showDelta !== false
|
|
51
|
-
})
|
|
52
|
-
className: css.readMore
|
|
53
|
-
}), /*#__PURE__*/React.createElement(Icon, {
|
|
54
|
-
className: css.readMoreIcon,
|
|
55
|
-
glyph: Icon.ICONS.ARROW_RIGHT_CIRLCE
|
|
56
|
-
})));
|
|
51
|
+
}));
|
|
57
52
|
})));
|
|
58
53
|
};
|
|
59
54
|
Summary.defaultProps = {
|
|
@@ -6,49 +6,5 @@
|
|
|
6
6
|
.item {
|
|
7
7
|
padding: var(--space-small);
|
|
8
8
|
flex: 1 0 25%; /* force equal sizes */
|
|
9
|
-
|
|
10
|
-
z-index: 1;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.item::before {
|
|
14
|
-
content: '';
|
|
15
|
-
display: block;
|
|
16
|
-
width: 1px;
|
|
17
|
-
position: absolute;
|
|
18
|
-
left: -1px;
|
|
19
|
-
top: var(--space-small);
|
|
20
|
-
bottom: var(--space-small);
|
|
21
|
-
background: var(--color-outline);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.readMore {
|
|
25
|
-
display: block;
|
|
26
|
-
position: absolute;
|
|
27
|
-
right: 0;
|
|
28
|
-
bottom: 0;
|
|
29
|
-
padding: var(--space-small);
|
|
30
|
-
color: var(--color-text-ultra-light);
|
|
31
|
-
transition: var(--transition-out);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.readMore:hover,
|
|
35
|
-
.readMore:focus {
|
|
36
|
-
color: var(--color-primary);
|
|
37
|
-
transition: var(--transition-in);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.readMoreIcon {
|
|
41
|
-
display: block;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** hover state */
|
|
45
|
-
.readMore {
|
|
46
|
-
opacity: 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.item:hover .readMore,
|
|
50
|
-
.item:active .readMore,
|
|
51
|
-
.item:focus .readMore {
|
|
52
|
-
opacity: 1;
|
|
53
|
-
transition: var(--transition-in);
|
|
9
|
+
text-decoration: none;
|
|
54
10
|
}
|
|
@@ -24,26 +24,54 @@ stories.add('default', () => /*#__PURE__*/React.createElement(Summary, {
|
|
|
24
24
|
stories.add('budgets', () => /*#__PURE__*/React.createElement(Summary, {
|
|
25
25
|
data: MULTIPLE_JOBS[0].summary,
|
|
26
26
|
budgets: {
|
|
27
|
-
|
|
27
|
+
data: {
|
|
28
28
|
totalSizeByTypeALL: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
type: 'ERROR',
|
|
30
|
+
message: {
|
|
31
|
+
text: 'Metric is over the budget',
|
|
32
|
+
md: 'Metric is over the budget'
|
|
33
|
+
},
|
|
34
|
+
data: {
|
|
35
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.totalSizeByTypeALL.current,
|
|
36
|
+
budgetValue: 1024 * 1024,
|
|
37
|
+
failed: false
|
|
38
|
+
}
|
|
32
39
|
},
|
|
33
40
|
totalInitialSizeJS: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
type: 'WARNING',
|
|
42
|
+
message: {
|
|
43
|
+
text: 'Metric is over the budget',
|
|
44
|
+
md: 'Metric is over the budget'
|
|
45
|
+
},
|
|
46
|
+
data: {
|
|
47
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.totalInitialSizeJS.current,
|
|
48
|
+
budgetValue: 512 * 1024,
|
|
49
|
+
failed: true
|
|
50
|
+
}
|
|
37
51
|
},
|
|
38
52
|
totalInitialSizeCSS: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
type: 'SUCCESS',
|
|
54
|
+
message: {
|
|
55
|
+
text: 'Metric is under the budget',
|
|
56
|
+
md: 'Metric is under the budget'
|
|
57
|
+
},
|
|
58
|
+
data: {
|
|
59
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.totalInitialSizeCSS.current,
|
|
60
|
+
budgetValue: 50 * 1024,
|
|
61
|
+
failed: false
|
|
62
|
+
}
|
|
42
63
|
},
|
|
43
64
|
chunkCount: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
type: 'SUCCESS',
|
|
66
|
+
message: {
|
|
67
|
+
text: 'Metric is under the budget',
|
|
68
|
+
md: 'Metric is under the budget'
|
|
69
|
+
},
|
|
70
|
+
data: {
|
|
71
|
+
currentValue: MULTIPLE_JOBS[0].summary.webpack.chunkCount.current,
|
|
72
|
+
budgetValue: 50,
|
|
73
|
+
failed: false
|
|
74
|
+
}
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
}
|
|
@@ -5,10 +5,9 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
7
7
|
import { HoverCard } from '../../ui/hover-card';
|
|
8
|
-
import { Icon } from '../../ui/icon';
|
|
9
8
|
import { Skeleton } from '../../ui/skeleton';
|
|
10
|
-
import { Stack } from '../../layout/stack';
|
|
11
9
|
import { FlexStack } from '../../layout/flex-stack';
|
|
10
|
+
import { Stack } from '../../layout/stack';
|
|
12
11
|
import { Metric } from '../metric';
|
|
13
12
|
import { Delta } from '../delta';
|
|
14
13
|
import { BudgetInfo } from '../budget-info';
|
|
@@ -21,8 +20,9 @@ const MetricInfo = _ref => {
|
|
|
21
20
|
} = _ref;
|
|
22
21
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
23
22
|
space: "xxxsmall"
|
|
24
|
-
}, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("
|
|
25
|
-
|
|
23
|
+
}, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", {
|
|
24
|
+
type: "button",
|
|
25
|
+
onClick: () => window.open(url),
|
|
26
26
|
className: css.readMoreLink
|
|
27
27
|
}, "Read more")));
|
|
28
28
|
};
|
|
@@ -59,23 +59,17 @@ export const SummaryItem = _ref2 => {
|
|
|
59
59
|
const showMetricDescriptionTooltip = showMetricDescription && (metric == null ? void 0 : metric.description);
|
|
60
60
|
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
61
61
|
return /*#__PURE__*/React.createElement(Stack, _extends({
|
|
62
|
-
space: "
|
|
62
|
+
space: "xxsmall",
|
|
63
63
|
as: Component,
|
|
64
64
|
className: rootClassName
|
|
65
65
|
}, props), /*#__PURE__*/React.createElement(FlexStack, {
|
|
66
|
-
as: "h3",
|
|
67
66
|
space: "xxxsmall",
|
|
67
|
+
as: "h3",
|
|
68
68
|
className: css.title
|
|
69
|
-
}, /*#__PURE__*/React.createElement(
|
|
70
|
-
|
|
71
|
-
}, metric.label
|
|
72
|
-
className: css.icon,
|
|
73
|
-
label: /*#__PURE__*/React.createElement(Icon, {
|
|
74
|
-
glyph: "help"
|
|
75
|
-
})
|
|
76
|
-
}, /*#__PURE__*/React.createElement(MetricInfo, metric)), budget && /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
69
|
+
}, showMetricDescriptionTooltip ? /*#__PURE__*/React.createElement(HoverCard, {
|
|
70
|
+
label: metric.label
|
|
71
|
+
}, /*#__PURE__*/React.createElement(MetricInfo, metric)) : metric.label, budget && /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
77
72
|
className: css.budgetInfo,
|
|
78
|
-
metricId: id,
|
|
79
73
|
budgetInsight: budget
|
|
80
74
|
})), !loading ? /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Metric, {
|
|
81
75
|
className: css.currentMetric,
|
|
@@ -134,9 +128,6 @@ SummaryItem.propTypes = {
|
|
|
134
128
|
showDelta: PropTypes.bool,
|
|
135
129
|
|
|
136
130
|
/** Budget insight data */
|
|
137
|
-
budget: PropTypes.
|
|
138
|
-
|
|
139
|
-
budgetValue: PropTypes.number,
|
|
140
|
-
failed: PropTypes.bool
|
|
141
|
-
})
|
|
131
|
+
budget: PropTypes.object // eslint-disable-line react/forbid-prop-types
|
|
132
|
+
|
|
142
133
|
};
|
|
@@ -8,17 +8,11 @@
|
|
|
8
8
|
color: var(--color-text-ultra-light);
|
|
9
9
|
font-weight: bold;
|
|
10
10
|
font-size: var(--size-xsmall);
|
|
11
|
-
line-height:
|
|
11
|
+
line-height: 1;
|
|
12
12
|
text-transform: uppercase;
|
|
13
13
|
white-space: nowrap;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.budgetInfo {
|
|
17
|
-
position: absolute;
|
|
18
|
-
right: 0;
|
|
19
|
-
top: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
.currentMetric {
|
|
23
17
|
display: block;
|
|
24
18
|
color: var(--color-heading);
|
|
@@ -39,6 +33,30 @@
|
|
|
39
33
|
line-height: var(--space-small);
|
|
40
34
|
}
|
|
41
35
|
|
|
36
|
+
.readMoreLink {
|
|
37
|
+
appearance: none;
|
|
38
|
+
background: none;
|
|
39
|
+
margin: 0;
|
|
40
|
+
border: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
color: var(--color-primary);
|
|
43
|
+
text-decoration: underline;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.readMoreLink:hover,
|
|
48
|
+
.readMoreLink:active,
|
|
49
|
+
.readMoreLink:focus {
|
|
50
|
+
color: var(--color-primary-dark);
|
|
51
|
+
text-decoration: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Hover state */
|
|
55
|
+
.root:hover .title {
|
|
56
|
+
color: var(--color-text-light);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
42
60
|
/* Loading state */
|
|
43
61
|
.loading.currentMetric {
|
|
44
62
|
width: 8em;
|
|
@@ -37,18 +37,32 @@ export const BudgetError = Template.bind();
|
|
|
37
37
|
BudgetError.args = {
|
|
38
38
|
showMetricDescription: true,
|
|
39
39
|
budget: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
type: 'ERROR',
|
|
41
|
+
message: {
|
|
42
|
+
text: 'Metric is over the budget',
|
|
43
|
+
md: 'Metric is over the budget'
|
|
44
|
+
},
|
|
45
|
+
data: {
|
|
46
|
+
currentValue: 120 * 1000,
|
|
47
|
+
budgetValue: 100 * 1000,
|
|
48
|
+
failed: true
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
};
|
|
45
52
|
export const BudgetSuccess = Template.bind();
|
|
46
53
|
BudgetSuccess.args = {
|
|
47
54
|
showMetricDescription: true,
|
|
48
55
|
budget: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
type: 'SUCCESS',
|
|
57
|
+
message: {
|
|
58
|
+
text: 'Metric is under the budget',
|
|
59
|
+
md: 'Metric is under the budget'
|
|
60
|
+
},
|
|
61
|
+
data: {
|
|
62
|
+
currentValue: 120 * 1000,
|
|
63
|
+
budgetValue: 120 * 1024,
|
|
64
|
+
failed: false
|
|
65
|
+
}
|
|
52
66
|
}
|
|
53
67
|
};
|
|
54
68
|
export const Loading = Template.bind();
|
|
@@ -36,6 +36,11 @@ export const HoverCard = props => {
|
|
|
36
36
|
}); // Fallback to span if no href
|
|
37
37
|
|
|
38
38
|
const Component = resolveComponent(as, href);
|
|
39
|
+
|
|
40
|
+
const handleOnClick = event => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
};
|
|
43
|
+
|
|
39
44
|
return /*#__PURE__*/React.createElement("div", {
|
|
40
45
|
className: cx(css.root, className)
|
|
41
46
|
}, /*#__PURE__*/React.createElement(HovercardAnchor, {
|
|
@@ -48,7 +53,8 @@ export const HoverCard = props => {
|
|
|
48
53
|
className: cx(css.hoverCard, hoverCardClassName),
|
|
49
54
|
style: {
|
|
50
55
|
zIndex: 10000
|
|
51
|
-
}
|
|
56
|
+
},
|
|
57
|
+
onClick: handleOnClick
|
|
52
58
|
}), /*#__PURE__*/React.createElement(HovercardArrow, {
|
|
53
59
|
size: 24
|
|
54
60
|
}), typeof children === 'function' ? children({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundle-stats/ui",
|
|
3
|
-
"version": "3.4.0-
|
|
3
|
+
"version": "3.4.0-beta.0",
|
|
4
4
|
"description": "UI components for BundleStats projects.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -37,27 +37,27 @@
|
|
|
37
37
|
"homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/ui#readme",
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@babel/cli": "7.17.6",
|
|
40
|
-
"@babel/core": "7.17.
|
|
40
|
+
"@babel/core": "7.17.9",
|
|
41
41
|
"@babel/plugin-proposal-class-properties": "7.16.7",
|
|
42
42
|
"@babel/preset-env": "7.16.11",
|
|
43
43
|
"@babel/preset-react": "7.16.7",
|
|
44
44
|
"@simplyianm/babel-plugin-inline-react-svg": "1.2.0",
|
|
45
|
-
"@storybook/addon-essentials": "6.4.
|
|
45
|
+
"@storybook/addon-essentials": "6.4.20",
|
|
46
46
|
"@storybook/addon-knobs": "6.4.0",
|
|
47
47
|
"@storybook/addon-postcss": "2.0.0",
|
|
48
|
-
"@storybook/addon-storyshots": "6.4.
|
|
49
|
-
"@storybook/addons": "6.4.
|
|
50
|
-
"@storybook/builder-webpack5": "6.4.
|
|
51
|
-
"@storybook/manager-webpack5": "6.4.
|
|
52
|
-
"@storybook/react": "6.4.
|
|
48
|
+
"@storybook/addon-storyshots": "6.4.20",
|
|
49
|
+
"@storybook/addons": "6.4.20",
|
|
50
|
+
"@storybook/builder-webpack5": "6.4.20",
|
|
51
|
+
"@storybook/manager-webpack5": "6.4.20",
|
|
52
|
+
"@storybook/react": "6.4.20",
|
|
53
53
|
"babel-core": "7.0.0-bridge.0",
|
|
54
54
|
"babel-jest": "27.5.1",
|
|
55
55
|
"babel-plugin-lodash": "3.3.4",
|
|
56
56
|
"babel-plugin-require-context-hook": "1.0.0",
|
|
57
|
-
"chromatic": "6.5.
|
|
57
|
+
"chromatic": "6.5.3",
|
|
58
58
|
"classnames": "2.3.1",
|
|
59
59
|
"colormap": "2.3.2",
|
|
60
|
-
"core-js": "3.
|
|
60
|
+
"core-js": "3.21.1",
|
|
61
61
|
"cross-env": "7.0.3",
|
|
62
62
|
"enzyme": "3.11.0",
|
|
63
63
|
"enzyme-adapter-react-16": "1.15.6",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"jest": "27.5.1",
|
|
68
68
|
"jest-date-mock": "1.0.8",
|
|
69
69
|
"lodash": "4.17.21",
|
|
70
|
-
"postcss": "8.4.
|
|
70
|
+
"postcss": "8.4.12",
|
|
71
71
|
"prop-types": "15.8.1",
|
|
72
72
|
"react": "16.14.0",
|
|
73
73
|
"react-dom": "16.14.0",
|
|
@@ -76,21 +76,21 @@
|
|
|
76
76
|
"rimraf": "3.0.2"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"classnames": "2.
|
|
80
|
-
"core-js": "3.
|
|
81
|
-
"lodash": "4.
|
|
82
|
-
"prop-types": "15.
|
|
83
|
-
"react": "16.
|
|
84
|
-
"react-dom": "16.
|
|
85
|
-
"react-router-dom": "5.
|
|
79
|
+
"classnames": "^2.0.0",
|
|
80
|
+
"core-js": "^3.0.0",
|
|
81
|
+
"lodash": "^4.0.0",
|
|
82
|
+
"prop-types": "^15.0.0",
|
|
83
|
+
"react": "^16.0.0",
|
|
84
|
+
"react-dom": "^16.0.0",
|
|
85
|
+
"react-router-dom": "^5.0.0"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@bundle-stats/utils": "^3.4.0-
|
|
89
|
-
"ariakit": "2.0.0-alpha.
|
|
90
|
-
"date-fns": "2.28.0",
|
|
91
|
-
"modern-css-reset": "1.4.0",
|
|
92
|
-
"query-string": "7.1.
|
|
93
|
-
"use-query-params": "1.2.3"
|
|
88
|
+
"@bundle-stats/utils": "^3.4.0-beta.0",
|
|
89
|
+
"ariakit": "2.0.0-alpha.21",
|
|
90
|
+
"date-fns": "^2.28.0",
|
|
91
|
+
"modern-css-reset": "^1.4.0",
|
|
92
|
+
"query-string": "^7.1.0",
|
|
93
|
+
"use-query-params": "^1.2.3"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "45774cba629c670df5528d72a67d3cfaddd8fed7"
|
|
96
96
|
}
|