@bundle-stats/ui 3.3.1-beta.8 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/app.js +8 -21
- package/lib/app/app.stories.js +1 -22
- package/lib/app/header/header.js +2 -1
- package/lib/assets/icons.svg +0 -8
- package/lib/components/bundle-assets/bundle-assets.js +2 -1
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +7 -43
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
- package/lib/components/bundle-modules/bundle-modules.js +1 -1
- package/lib/components/index.js +0 -8
- package/lib/components/summary/summary.js +7 -12
- package/lib/components/summary/summary.module.css +1 -1
- package/lib/components/summary/summary.stories.js +0 -29
- package/lib/components/summary-item/summary-item.js +5 -22
- package/lib/components/summary-item/summary-item.module.css +0 -11
- package/lib/components/summary-item/summary-item.stories.js +53 -51
- package/lib/constants.js +4 -4
- package/lib/ui/alert/alert.js +3 -13
- package/lib/ui/icon/icon.js +0 -2
- package/lib-esm/app/app.js +8 -20
- package/lib-esm/app/app.stories.js +1 -22
- package/lib-esm/app/header/header.js +2 -1
- package/lib-esm/assets/icons.svg +0 -8
- package/lib-esm/components/bundle-assets/bundle-assets.js +2 -1
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +7 -24
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
- package/lib-esm/components/bundle-modules/bundle-modules.js +1 -1
- package/lib-esm/components/index.js +0 -1
- package/lib-esm/components/summary/summary.js +7 -11
- package/lib-esm/components/summary/summary.module.css +1 -1
- package/lib-esm/components/summary/summary.stories.js +0 -27
- package/lib-esm/components/summary-item/summary-item.js +4 -20
- package/lib-esm/components/summary-item/summary-item.module.css +0 -11
- package/lib-esm/components/summary-item/summary-item.stories.js +38 -50
- package/lib-esm/constants.js +4 -4
- package/lib-esm/ui/alert/alert.js +3 -6
- package/lib-esm/ui/icon/icon.js +0 -2
- package/package.json +3 -3
- package/src/components/bundle-modules/bundle-modules.jsx +1 -1
- package/build-storybook.log +0 -4691
- package/lib/assets/icons/alert-circle.svg +0 -1
- package/lib/assets/icons/check-circle.svg +0 -1
- package/lib/components/budget-info/budget-info.js +0 -80
- package/lib/components/budget-info/budget-info.module.css +0 -40
- package/lib/components/budget-info/budget-info.stories.js +0 -44
- package/lib/components/budget-info/index.js +0 -18
- package/lib/components/budget-insights/budget-insights.js +0 -200
- package/lib/components/budget-insights/budget-insights.module.css +0 -53
- package/lib/components/budget-insights/budget-insights.stories.js +0 -104
- package/lib/components/budget-insights/index.js +0 -18
- package/lib-esm/assets/icons/alert-circle.svg +0 -1
- package/lib-esm/assets/icons/check-circle.svg +0 -1
- package/lib-esm/components/budget-info/budget-info.js +0 -58
- package/lib-esm/components/budget-info/budget-info.module.css +0 -40
- package/lib-esm/components/budget-info/budget-info.stories.js +0 -30
- package/lib-esm/components/budget-info/index.js +0 -1
- package/lib-esm/components/budget-insights/budget-insights.js +0 -148
- package/lib-esm/components/budget-insights/budget-insights.module.css +0 -53
- package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -84
- package/lib-esm/components/budget-insights/index.js +0 -1
- package/storybook-static/favicon.ico +0 -0
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { getWrapperDecorator } from '../../stories';
|
|
4
|
-
import { BudgetInfo } from '.';
|
|
5
|
-
const stories = storiesOf('Components/BudgetInfo', module);
|
|
6
|
-
stories.addDecorator(getWrapperDecorator());
|
|
7
|
-
stories.add('default', () => /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
8
|
-
metricId: "webpack.assetCount",
|
|
9
|
-
budgetInsight: {
|
|
10
|
-
budgetValue: 300,
|
|
11
|
-
currentValue: 250,
|
|
12
|
-
failed: false
|
|
13
|
-
}
|
|
14
|
-
}));
|
|
15
|
-
stories.add('error', () => /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
16
|
-
metricId: "webpack.assetCount",
|
|
17
|
-
budgetInsight: {
|
|
18
|
-
budgetValue: 300,
|
|
19
|
-
currentValue: 350,
|
|
20
|
-
failed: true
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
stories.add('warning', () => /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
24
|
-
metricId: "webpack.assetCount",
|
|
25
|
-
budgetInsight: {
|
|
26
|
-
budgetValue: 300,
|
|
27
|
-
currentValue: 300,
|
|
28
|
-
failed: false
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './budget-info';
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
|
-
import React, { useMemo, useState } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import cx from 'classnames';
|
|
6
|
-
import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
|
|
7
|
-
import * as budgetsInsightsTransformer from '@bundle-stats/utils/lib-esm/transformers/budgets-insights';
|
|
8
|
-
import { Box } from '../../layout/box';
|
|
9
|
-
import { Stack } from '../../layout/stack';
|
|
10
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
11
|
-
import { Alert } from '../../ui/alert';
|
|
12
|
-
import { Icon } from '../../ui/icon';
|
|
13
|
-
import { ComponentLink } from '../component-link';
|
|
14
|
-
import css from './budget-insights.module.css';
|
|
15
|
-
|
|
16
|
-
const Budget = props => {
|
|
17
|
-
const {
|
|
18
|
-
className,
|
|
19
|
-
metricId,
|
|
20
|
-
budgetInsight,
|
|
21
|
-
CustomLink
|
|
22
|
-
} = props;
|
|
23
|
-
const componentLinkOptions = METRIC_COMPONENT_LINKS.get(metricId);
|
|
24
|
-
const budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
|
|
25
|
-
const {
|
|
26
|
-
data: messageData
|
|
27
|
-
} = budgetInsightInfo.message;
|
|
28
|
-
return /*#__PURE__*/React.createElement(CustomLink, _extends({
|
|
29
|
-
className: cx(css.budget, className)
|
|
30
|
-
}, componentLinkOptions == null ? void 0 : componentLinkOptions.link), /*#__PURE__*/React.createElement("strong", null, messageData.metricLabel), ` value (`, /*#__PURE__*/React.createElement("strong", null, messageData.currentValue), `) is ${messageData.diffLabel} `, /*#__PURE__*/React.createElement("strong", null, messageData.budgetValue), ` budget `);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
Budget.propTypes = {
|
|
34
|
-
className: PropTypes.string,
|
|
35
|
-
metricId: PropTypes.string.isRequired,
|
|
36
|
-
budgetInsight: PropTypes.shape({
|
|
37
|
-
currentValue: PropTypes.number.isRequired,
|
|
38
|
-
budgetValue: PropTypes.number.isRequired,
|
|
39
|
-
failed: PropTypes.bool.isRequired
|
|
40
|
-
}).isRequired,
|
|
41
|
-
CustomLink: PropTypes.elementType.isRequired
|
|
42
|
-
};
|
|
43
|
-
Budget.defaultProps = {
|
|
44
|
-
className: ''
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const BudgetsGroup = props => {
|
|
48
|
-
const {
|
|
49
|
-
className,
|
|
50
|
-
kind,
|
|
51
|
-
source,
|
|
52
|
-
budgets,
|
|
53
|
-
CustomLink
|
|
54
|
-
} = props;
|
|
55
|
-
const [showBudgets, setShowBudgets] = useState(false);
|
|
56
|
-
const isFailed = kind === 'danger';
|
|
57
|
-
return /*#__PURE__*/React.createElement(Alert, {
|
|
58
|
-
kind: kind,
|
|
59
|
-
padding: "none",
|
|
60
|
-
className: cx(css.group, css[kind], className)
|
|
61
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
62
|
-
padding: ['xsmall', 'small'],
|
|
63
|
-
className: css.groupHeader,
|
|
64
|
-
as: "button",
|
|
65
|
-
type: "button",
|
|
66
|
-
onClick: () => setShowBudgets(!showBudgets)
|
|
67
|
-
}, /*#__PURE__*/React.createElement(FlexStack, {
|
|
68
|
-
space: "xxsmall",
|
|
69
|
-
className: css.groupTitle
|
|
70
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
71
|
-
className: css.groupIcon,
|
|
72
|
-
glyph: isFailed ? Icon.ICONS.ALERT_CIRCLE : Icon.ICONS.CHECK_CIRCLE
|
|
73
|
-
}), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, budgets.length), ` budget ${budgets.length > 1 ? 'checks' : 'check'} ${isFailed ? 'failed' : 'passed'}`), /*#__PURE__*/React.createElement("span", {
|
|
74
|
-
className: css.groupTitleToggle
|
|
75
|
-
}, showBudgets ? 'hide' : 'show', " all"))), showBudgets && /*#__PURE__*/React.createElement(Box, {
|
|
76
|
-
padding: ['xsmall', 'small'],
|
|
77
|
-
className: css.groupContent
|
|
78
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
79
|
-
space: "none"
|
|
80
|
-
}, budgets.map(_ref => {
|
|
81
|
-
let [key, budget] = _ref;
|
|
82
|
-
return /*#__PURE__*/React.createElement(Budget, {
|
|
83
|
-
key: key,
|
|
84
|
-
metricId: `${source}.${key}`,
|
|
85
|
-
budgetInsight: budget,
|
|
86
|
-
CustomLink: CustomLink
|
|
87
|
-
});
|
|
88
|
-
}))));
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
BudgetsGroup.propTypes = {
|
|
92
|
-
className: PropTypes.string,
|
|
93
|
-
kind: PropTypes.oneOf(['success', 'danger']).isRequired,
|
|
94
|
-
source: PropTypes.string.isRequired,
|
|
95
|
-
budgets: PropTypes.object.isRequired,
|
|
96
|
-
// eslint-disable-line react/forbid-prop-types
|
|
97
|
-
CustomLink: PropTypes.elementType.isRequired
|
|
98
|
-
};
|
|
99
|
-
BudgetsGroup.defaultProps = {
|
|
100
|
-
className: ''
|
|
101
|
-
};
|
|
102
|
-
export const BudgetInsights = props => {
|
|
103
|
-
const {
|
|
104
|
-
className,
|
|
105
|
-
source,
|
|
106
|
-
budgets,
|
|
107
|
-
CustomLink
|
|
108
|
-
} = props;
|
|
109
|
-
const [failedBudgets, passedBudgets] = useMemo(() => {
|
|
110
|
-
const passed = [];
|
|
111
|
-
const failed = [];
|
|
112
|
-
Object.entries(budgets).forEach(_ref2 => {
|
|
113
|
-
let [key, budget] = _ref2;
|
|
114
|
-
|
|
115
|
-
if (budget.failed) {
|
|
116
|
-
failed.push([key, budget]);
|
|
117
|
-
} else {
|
|
118
|
-
passed.push([key, budget]);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
return [failed, passed];
|
|
122
|
-
}, [budgets]);
|
|
123
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
124
|
-
className: className,
|
|
125
|
-
space: "xsmall"
|
|
126
|
-
}, failedBudgets.length > 0 && /*#__PURE__*/React.createElement(BudgetsGroup, {
|
|
127
|
-
kind: "danger",
|
|
128
|
-
source: source,
|
|
129
|
-
budgets: failedBudgets,
|
|
130
|
-
CustomLink: CustomLink
|
|
131
|
-
}), passedBudgets.length > 0 && /*#__PURE__*/React.createElement(BudgetsGroup, {
|
|
132
|
-
kind: "success",
|
|
133
|
-
source: source,
|
|
134
|
-
budgets: passedBudgets,
|
|
135
|
-
CustomLink: CustomLink
|
|
136
|
-
}));
|
|
137
|
-
};
|
|
138
|
-
BudgetInsights.propTypes = {
|
|
139
|
-
className: PropTypes.string,
|
|
140
|
-
source: PropTypes.string.isRequired,
|
|
141
|
-
budgets: PropTypes.object.isRequired,
|
|
142
|
-
// eslint-disable-line react/forbid-prop-types
|
|
143
|
-
CustomLink: PropTypes.elementType
|
|
144
|
-
};
|
|
145
|
-
BudgetInsights.defaultProps = {
|
|
146
|
-
className: '',
|
|
147
|
-
CustomLink: ComponentLink
|
|
148
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
.groupHeader {
|
|
2
|
-
width: 100%;
|
|
3
|
-
border: none;
|
|
4
|
-
background: none;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
color: inherit;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.groupTitle {
|
|
10
|
-
width: 100%;
|
|
11
|
-
align-items: center;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.groupTitle:hover {
|
|
15
|
-
color: var(--color-text-dark);
|
|
16
|
-
text-decoration: underline;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.groupTitleToggle {
|
|
20
|
-
margin: 0 0 0 auto !important;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.danger .groupIcon {
|
|
24
|
-
color: var(--color-danger);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.success .groupIcon {
|
|
28
|
-
color: var(--color-success);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.groupContent {
|
|
32
|
-
padding-top: 0px;
|
|
33
|
-
background: transparent;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.budget {
|
|
37
|
-
display: block;
|
|
38
|
-
color: var(--color-text);
|
|
39
|
-
text-decoration: none;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.budgetLabel,
|
|
43
|
-
.budgetValue {
|
|
44
|
-
color: var(--color-text-dark);
|
|
45
|
-
font-weight: 500;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.budget:hover,
|
|
49
|
-
.budget:focus,
|
|
50
|
-
.budget:active {
|
|
51
|
-
color: var(--color-text);
|
|
52
|
-
text-decoration: underline;
|
|
53
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
-
import { BudgetInsights } from '.';
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Components/BudgetInsights',
|
|
6
|
-
component: BudgetInsights,
|
|
7
|
-
decorators: [Story => /*#__PURE__*/React.createElement(MemoryRouter, null, /*#__PURE__*/React.createElement(Story, null))]
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const Template = args => /*#__PURE__*/React.createElement(BudgetInsights, args);
|
|
11
|
-
|
|
12
|
-
export const Default = Template.bind();
|
|
13
|
-
Default.args = {
|
|
14
|
-
source: 'webpack',
|
|
15
|
-
budgets: {
|
|
16
|
-
totalSizeByTypeALL: {
|
|
17
|
-
currentValue: 2097917,
|
|
18
|
-
budgetValue: 2097152,
|
|
19
|
-
failed: true
|
|
20
|
-
},
|
|
21
|
-
totalInitialSizeJS: {
|
|
22
|
-
currentValue: 1265645,
|
|
23
|
-
budgetValue: 524288,
|
|
24
|
-
failed: true
|
|
25
|
-
},
|
|
26
|
-
totalInitialSizeCSS: {
|
|
27
|
-
currentValue: 48866,
|
|
28
|
-
budgetValue: 51200,
|
|
29
|
-
failed: false
|
|
30
|
-
},
|
|
31
|
-
chunkCount: {
|
|
32
|
-
currentValue: 12,
|
|
33
|
-
budgetValue: 50,
|
|
34
|
-
failed: false
|
|
35
|
-
},
|
|
36
|
-
moduleCount: {
|
|
37
|
-
currentValue: 1059,
|
|
38
|
-
budgetValue: 2000,
|
|
39
|
-
failed: false
|
|
40
|
-
},
|
|
41
|
-
duplicatePackagesCount: {
|
|
42
|
-
currentValue: 13,
|
|
43
|
-
budgetValue: 5,
|
|
44
|
-
failed: true
|
|
45
|
-
},
|
|
46
|
-
'sizes.totalSizeByTypeJS': {
|
|
47
|
-
currentValue: 1981470,
|
|
48
|
-
budgetValue: 2097152,
|
|
49
|
-
failed: false
|
|
50
|
-
},
|
|
51
|
-
'sizes.totalSizeByTypeCSS': {
|
|
52
|
-
currentValue: 56091,
|
|
53
|
-
budgetValue: 20480,
|
|
54
|
-
failed: true
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
export const FailedBudgets = Template.bind();
|
|
59
|
-
FailedBudgets.args = {
|
|
60
|
-
source: 'webpack',
|
|
61
|
-
budgets: {
|
|
62
|
-
totalSizeByTypeALL: {
|
|
63
|
-
currentValue: 2097917,
|
|
64
|
-
budgetValue: 2097152,
|
|
65
|
-
failed: true
|
|
66
|
-
},
|
|
67
|
-
totalInitialSizeJS: {
|
|
68
|
-
currentValue: 1265645,
|
|
69
|
-
budgetValue: 524288,
|
|
70
|
-
failed: true
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
export const SingleBudget = Template.bind();
|
|
75
|
-
SingleBudget.args = {
|
|
76
|
-
source: 'webpack',
|
|
77
|
-
budgets: {
|
|
78
|
-
totalInitialSizeJS: {
|
|
79
|
-
currentValue: 524288,
|
|
80
|
-
budgetValue: 1265645,
|
|
81
|
-
failed: false
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './budget-insights';
|
|
Binary file
|