@bundle-stats/ui 3.4.0-beta.0 → 4.0.0-alpha.9

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.
Files changed (139) hide show
  1. package/lib/app/app.js +6 -21
  2. package/lib/app/app.stories.js +1 -22
  3. package/lib/assets/icons.svg +0 -8
  4. package/lib/components/asset-info/asset-info.js +1 -1
  5. package/lib/components/bundle-assets/bundle-assets.js +1 -1
  6. package/lib/components/bundle-assets/index.js +1 -1
  7. package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
  8. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +8 -43
  9. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  10. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
  11. package/lib/components/bundle-modules/bundle-modules.js +1 -1
  12. package/lib/components/bundle-modules/index.js +1 -1
  13. package/lib/components/bundle-packages/bundle-packages.js +1 -1
  14. package/lib/components/bundle-packages/index.js +1 -1
  15. package/lib/components/component-link.js +1 -1
  16. package/lib/components/index.js +0 -8
  17. package/lib/components/job-meta/job-meta.js +1 -1
  18. package/lib/components/job-name/job-name.js +1 -1
  19. package/lib/components/metrics-table/metrics-table.js +1 -1
  20. package/lib/components/metrics-table-options/metrics-table-options.js +1 -1
  21. package/lib/components/module-info/module-info.js +1 -1
  22. package/lib/components/summary/summary.js +8 -13
  23. package/lib/components/summary/summary.stories.js +1 -58
  24. package/lib/components/summary-item/summary-item.js +6 -21
  25. package/lib/components/summary-item/summary-item.module.css +0 -6
  26. package/lib/components/summary-item/summary-item.stories.js +53 -65
  27. package/lib/constants.js +4 -4
  28. package/lib/layout/box/box.js +1 -1
  29. package/lib/layout/flex-stack/flex-stack.js +1 -1
  30. package/lib/layout/footer/footer.js +1 -1
  31. package/lib/layout/separator.js +1 -1
  32. package/lib/layout/stack/stack.js +1 -1
  33. package/lib/query-state.js +1 -1
  34. package/lib/ui/alert/alert.js +3 -13
  35. package/lib/ui/container/container.js +1 -1
  36. package/lib/ui/filters/filters.container.js +3 -3
  37. package/lib/ui/filters/filters.js +1 -1
  38. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +2 -2
  39. package/lib/ui/hover-card/hover-card.js +1 -1
  40. package/lib/ui/hover-card/hover-card.stories.js +1 -1
  41. package/lib/ui/icon/icon.js +1 -3
  42. package/lib/ui/input/input.js +1 -1
  43. package/lib/ui/loader/loader.js +1 -1
  44. package/lib/ui/logo/logo.js +1 -1
  45. package/lib/ui/panels/panels.js +1 -1
  46. package/lib/ui/skeleton/skeleton.js +1 -1
  47. package/lib/ui/sort-dropdown/sort-dropdown.js +1 -1
  48. package/lib/ui/tag/tag.js +1 -1
  49. package/lib/ui/tooltip/tooltip.js +1 -1
  50. package/lib-esm/app/app.js +6 -20
  51. package/lib-esm/app/app.stories.js +1 -22
  52. package/lib-esm/assets/icons.svg +0 -8
  53. package/lib-esm/components/asset-info/asset-info.js +1 -1
  54. package/lib-esm/components/bundle-assets/bundle-assets.js +1 -1
  55. package/lib-esm/components/bundle-assets/bundle-assets.utils.js +1 -0
  56. package/lib-esm/components/bundle-assets/index.js +1 -1
  57. package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
  58. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +8 -24
  59. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  60. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
  61. package/lib-esm/components/bundle-modules/bundle-modules.js +1 -1
  62. package/lib-esm/components/bundle-modules/index.js +1 -1
  63. package/lib-esm/components/bundle-packages/bundle-packages.js +1 -1
  64. package/lib-esm/components/bundle-packages/bundle-packages.utils.js +1 -0
  65. package/lib-esm/components/bundle-packages/index.js +1 -1
  66. package/lib-esm/components/component-link.js +1 -1
  67. package/lib-esm/components/index.js +0 -1
  68. package/lib-esm/components/job-meta/job-meta.js +1 -1
  69. package/lib-esm/components/job-name/job-name.js +1 -1
  70. package/lib-esm/components/metrics-table/metrics-table.js +1 -1
  71. package/lib-esm/components/metrics-table-options/metrics-table-options.js +1 -1
  72. package/lib-esm/components/module-info/module-info.js +1 -1
  73. package/lib-esm/components/summary/summary.js +9 -12
  74. package/lib-esm/components/summary/summary.stories.js +1 -56
  75. package/lib-esm/components/summary-item/summary-item.js +5 -18
  76. package/lib-esm/components/summary-item/summary-item.module.css +0 -6
  77. package/lib-esm/components/summary-item/summary-item.stories.js +38 -64
  78. package/lib-esm/constants.js +4 -4
  79. package/lib-esm/layout/box/box.js +1 -1
  80. package/lib-esm/layout/flex-stack/flex-stack.js +1 -1
  81. package/lib-esm/layout/footer/footer.js +1 -1
  82. package/lib-esm/layout/separator.js +1 -1
  83. package/lib-esm/layout/stack/stack.js +1 -1
  84. package/lib-esm/query-state.js +1 -1
  85. package/lib-esm/ui/alert/alert.js +3 -6
  86. package/lib-esm/ui/container/container.js +1 -1
  87. package/lib-esm/ui/filters/filters.container.js +1 -1
  88. package/lib-esm/ui/filters/filters.js +2 -1
  89. package/lib-esm/ui/hover-card/hover-card.js +1 -1
  90. package/lib-esm/ui/hover-card/hover-card.stories.js +1 -1
  91. package/lib-esm/ui/icon/icon.js +1 -3
  92. package/lib-esm/ui/input/input.js +1 -1
  93. package/lib-esm/ui/loader/loader.js +1 -1
  94. package/lib-esm/ui/logo/logo.js +1 -1
  95. package/lib-esm/ui/panels/panels.js +1 -1
  96. package/lib-esm/ui/skeleton/skeleton.js +1 -1
  97. package/lib-esm/ui/sort-dropdown/sort-dropdown.js +1 -1
  98. package/lib-esm/ui/tag/tag.js +1 -1
  99. package/lib-esm/ui/tooltip/tooltip.js +1 -1
  100. package/package.json +22 -22
  101. package/src/app/app.jsx +5 -12
  102. package/src/assets/icons.svg +0 -8
  103. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -27
  104. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  105. package/src/components/index.js +0 -1
  106. package/src/components/summary/summary.jsx +7 -8
  107. package/src/components/summary-item/summary-item.jsx +3 -10
  108. package/src/components/summary-item/summary-item.module.css +0 -6
  109. package/src/constants.js +11 -7
  110. package/src/ui/alert/alert.jsx +2 -7
  111. package/src/ui/icon/icon.jsx +0 -2
  112. package/lib/assets/icons/alert-circle.svg +0 -1
  113. package/lib/assets/icons/check-circle.svg +0 -1
  114. package/lib/components/budget-info/budget-info.js +0 -74
  115. package/lib/components/budget-info/budget-info.module.css +0 -40
  116. package/lib/components/budget-info/budget-info.stories.js +0 -59
  117. package/lib/components/budget-info/index.js +0 -18
  118. package/lib/components/budget-insights/budget-insights.js +0 -162
  119. package/lib/components/budget-insights/budget-insights.module.css +0 -61
  120. package/lib/components/budget-insights/budget-insights.stories.js +0 -165
  121. package/lib/components/budget-insights/index.js +0 -18
  122. package/lib-esm/assets/icons/alert-circle.svg +0 -1
  123. package/lib-esm/assets/icons/check-circle.svg +0 -1
  124. package/lib-esm/components/budget-info/budget-info.js +0 -57
  125. package/lib-esm/components/budget-info/budget-info.module.css +0 -40
  126. package/lib-esm/components/budget-info/budget-info.stories.js +0 -45
  127. package/lib-esm/components/budget-info/index.js +0 -1
  128. package/lib-esm/components/budget-insights/budget-insights.js +0 -112
  129. package/lib-esm/components/budget-insights/budget-insights.module.css +0 -61
  130. package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -144
  131. package/lib-esm/components/budget-insights/index.js +0 -1
  132. package/src/assets/icons/alert-circle.svg +0 -1
  133. package/src/assets/icons/check-circle.svg +0 -1
  134. package/src/components/budget-info/budget-info.jsx +0 -55
  135. package/src/components/budget-info/budget-info.module.css +0 -40
  136. package/src/components/budget-info/index.js +0 -1
  137. package/src/components/budget-insights/budget-insights.jsx +0 -124
  138. package/src/components/budget-insights/budget-insights.module.css +0 -61
  139. package/src/components/budget-insights/index.js +0 -1
@@ -1,55 +0,0 @@
1
- import React from 'react';
2
- import cx from 'classnames';
3
- import PropTypes from 'prop-types';
4
- import { InsightType } from '@bundle-stats/utils';
5
-
6
- import { Icon } from '../../ui/icon';
7
- import { Tooltip } from '../../ui/tooltip';
8
-
9
- import css from './budget-info.module.css';
10
-
11
- const INSIGHT_TYPE_MAP = {
12
- [InsightType.SUCCESS]: {
13
- className: css.success,
14
- glyph: Icon.ICONS.CHECK_CIRCLE,
15
- },
16
- [InsightType.ERROR]: {
17
- className: css.error,
18
- glyph: Icon.ICONS.ALERT_CIRCLE,
19
- },
20
- [InsightType.WARNING]: {
21
- className: css.warning,
22
- glyph: Icon.ICONS.WARNING,
23
- },
24
- };
25
-
26
- export const BudgetInfo = ({ className = '', budgetInsight }) => {
27
- const { className: insightTypeClassName, glyph } = INSIGHT_TYPE_MAP[budgetInsight.type];
28
-
29
- const rootClassName = cx(css.root, insightTypeClassName, className);
30
-
31
- return (
32
- <Tooltip className={rootClassName} title={budgetInsight.message.text}>
33
- <Icon className={css.icon} glyph={glyph} size="medium" />
34
- </Tooltip>
35
- );
36
- };
37
-
38
- BudgetInfo.propTypes = {
39
- budgetInsight: PropTypes.shape({
40
- type: PropTypes.string,
41
- message: PropTypes.shape({
42
- text: PropTypes.string,
43
- }),
44
- data: PropTypes.shape({
45
- currentValue: PropTypes.number,
46
- budgetValue: PropTypes.number,
47
- failed: PropTypes.bool,
48
- }),
49
- }).isRequired,
50
- className: PropTypes.string,
51
- };
52
-
53
- BudgetInfo.defaultProps = {
54
- className: '',
55
- };
@@ -1,40 +0,0 @@
1
- .root {
2
- display: inline-block;
3
- line-height: 1em;
4
- }
5
-
6
- /* Budget error */
7
- .error .icon {
8
- color: var(--color-danger);
9
- }
10
-
11
- .error .icon:hover,
12
- .error .icon:focus,
13
- .error .icon:active
14
- {
15
- color: var(--color-danger-light);
16
- }
17
-
18
- /* Budget success */
19
- .success .icon {
20
- color: var(--color-success);
21
- }
22
-
23
- .success .icon:hover,
24
- .success .icon:focus,
25
- .success .icon:active
26
- {
27
- color: var(--color-success-light);
28
- }
29
-
30
- /* Budget warning */
31
- .warning .icon {
32
- color: var(--color-warning-dark);
33
- }
34
-
35
- .warning .icon:hover,
36
- .warning .icon:focus,
37
- .warning .icon:active
38
- {
39
- color: var(--color-warning);
40
- }
@@ -1 +0,0 @@
1
- export * from './budget-info';
@@ -1,124 +0,0 @@
1
- import React, { useMemo, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import cx from 'classnames';
4
- import { METRIC_COMPONENT_LINKS } from '@bundle-stats/utils';
5
-
6
- import { Box } from '../../layout/box';
7
- import { Stack } from '../../layout/stack';
8
- import { FlexStack } from '../../layout/flex-stack';
9
- import { Alert } from '../../ui/alert';
10
- import { Icon } from '../../ui/icon';
11
- import { ComponentLink } from '../component-link';
12
- import css from './budget-insights.module.css';
13
-
14
- const Budget = (props) => {
15
- const { className, metricId, budget, CustomLink } = props;
16
- const componentLinkOptions = METRIC_COMPONENT_LINKS.get(metricId);
17
-
18
- return (
19
- <CustomLink
20
- className={cx(css.budget, className, budget.type === 'SUCCESS' && css.budgetSuccess)}
21
- {...componentLinkOptions?.link}
22
- >
23
- {budget.message.text}
24
- </CustomLink>
25
- );
26
- };
27
-
28
- Budget.propTypes = {
29
- className: PropTypes.string,
30
- metricId: PropTypes.string.isRequired,
31
- budget: PropTypes.shape({
32
- type: PropTypes.string,
33
- message: PropTypes.shape({
34
- text: PropTypes.string,
35
- }),
36
- data: PropTypes.shape({
37
- currentValue: PropTypes.number.isRequired,
38
- budgetValue: PropTypes.number.isRequired,
39
- failed: PropTypes.bool.isRequired,
40
- }),
41
- }).isRequired,
42
- CustomLink: PropTypes.elementType.isRequired,
43
- };
44
-
45
- Budget.defaultProps = {
46
- className: '',
47
- };
48
-
49
- const BUDGET_ALERT_KIND = new Map([
50
- ['ERROR', 'danger'],
51
- ['WARNING', 'warning'],
52
- ['SUCCESS', 'success'],
53
- ]);
54
-
55
- const BUDGET_ICON = new Map([
56
- ['ERROR', Icon.ICONS.ALERT_CIRCLE],
57
- ['WARNING', Icon.ICONS.WARNING],
58
- ['SUCCESS', Icon.ICONS.CHECK_CIRCLE],
59
- ]);
60
-
61
- export const BudgetInsights = (props) => {
62
- const { className, source, budgets, CustomLink } = props;
63
- const [showBudgets, setShowBudgets] = useState(false);
64
-
65
- const iconGlyph = BUDGET_ICON.get(budgets.type);
66
- const alertKind = BUDGET_ALERT_KIND.get(budgets.type);
67
- const rootClassName = cx(css.group, className, css[`group-${alertKind}`]);
68
-
69
- const budgetItems = useMemo(() => {
70
- const items = Object.entries(budgets.data);
71
-
72
- // When there are errors/warnings, sort budget items first
73
- if (['ERROR', 'WARNING'].includes(budgets.type)) {
74
- items.sort((a) => (a[1].type === budgets.type ? -1 : 1));
75
- }
76
-
77
- return items;
78
- }, [budgets]);
79
-
80
- return (
81
- <Alert kind={alertKind} padding="none" className={rootClassName}>
82
- <Box
83
- padding={['xsmall', 'small']}
84
- className={css.groupHeader}
85
- as="button"
86
- type="button"
87
- onClick={() => setShowBudgets(!showBudgets)}
88
- >
89
- <FlexStack space="xxsmall" className={css.groupTitle}>
90
- {iconGlyph && <Icon className={css.groupIcon} glyph={iconGlyph} />}
91
- <span>{budgets.message.text}</span>
92
- <span className={css.groupTitleToggle}>{showBudgets ? 'hide' : 'show'} all</span>
93
- </FlexStack>
94
- </Box>
95
-
96
- {showBudgets && (
97
- <Box padding={['xsmall', 'small']} className={css.groupContent}>
98
- <Stack space="none">
99
- {budgetItems.map(([key, budget]) => (
100
- <Budget
101
- key={key}
102
- metricId={`${source}.${key}`}
103
- budget={budget}
104
- CustomLink={CustomLink}
105
- />
106
- ))}
107
- </Stack>
108
- </Box>
109
- )}
110
- </Alert>
111
- );
112
- };
113
-
114
- BudgetInsights.propTypes = {
115
- className: PropTypes.string,
116
- source: PropTypes.string.isRequired,
117
- budgets: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
118
- CustomLink: PropTypes.elementType,
119
- };
120
-
121
- BudgetInsights.defaultProps = {
122
- className: '',
123
- CustomLink: ComponentLink,
124
- };
@@ -1,61 +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
- .group-danger .groupIcon {
24
- color: var(--color-danger);
25
- }
26
-
27
- .group-warning .groupIcon {
28
- color: var(--color-warning);
29
- }
30
-
31
- .group-success .groupIcon {
32
- color: var(--color-success);
33
- }
34
-
35
- .groupContent {
36
- padding-top: 0px;
37
- background: transparent;
38
- }
39
-
40
- .budget {
41
- display: block;
42
- color: var(--color-text);
43
- text-decoration: none;
44
- }
45
-
46
- .budgetSuccess {
47
- color: var(--color-text-light);
48
- }
49
-
50
- .budgetLabel,
51
- .budgetValue {
52
- color: var(--color-text-dark);
53
- font-weight: 500;
54
- }
55
-
56
- .budget:hover,
57
- .budget:focus,
58
- .budget:active {
59
- color: var(--color-text);
60
- text-decoration: underline;
61
- }
@@ -1 +0,0 @@
1
- export * from './budget-insights';