@bundle-stats/ui 3.3.0-alpha.1 → 3.3.0-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.
Files changed (240) hide show
  1. package/CHANGELOG.md +65 -13
  2. package/lib/app/app.js +124 -104
  3. package/lib/app/app.module.css +11 -4
  4. package/lib/app/app.stories.js +1 -22
  5. package/lib/app/header/header.js +1 -10
  6. package/lib/assets/icons.svg +0 -8
  7. package/lib/components/asset-info/asset-info.module.css +1 -0
  8. package/lib/components/bundle-assets/bundle-assets.js +104 -52
  9. package/lib/components/bundle-assets/bundle-assets.module.css +24 -26
  10. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +16 -42
  11. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  12. package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
  13. package/lib/components/bundle-modules/bundle-modules.js +68 -68
  14. package/lib/components/bundle-modules/bundle-modules.module.css +11 -2
  15. package/lib/components/bundle-modules/bundle-modules.utils.js +14 -10
  16. package/lib/components/bundle-modules/index.js +4 -4
  17. package/lib/components/bundle-packages/bundle-packages.js +100 -44
  18. package/lib/components/bundle-packages/bundle-packages.module.css +17 -21
  19. package/lib/components/delta/delta.module.css +1 -0
  20. package/lib/components/index.js +0 -8
  21. package/lib/components/job-header/job-header.js +3 -1
  22. package/lib/components/job-header/job-header.module.css +6 -8
  23. package/lib/components/jobs-header/jobs-header.module.css +5 -0
  24. package/lib/components/metrics-table/metrics-table.js +72 -59
  25. package/lib/components/metrics-table/metrics-table.module.css +18 -7
  26. package/lib/components/metrics-table-search/metrics-table-search.module.css +5 -4
  27. package/lib/components/metrics-table-title/metrics-table-title.js +9 -7
  28. package/lib/components/metrics-table-title/metrics-table-title.module.css +2 -0
  29. package/lib/components/module-info/module-info.js +2 -2
  30. package/lib/components/module-info/module-info.module.css +1 -0
  31. package/lib/components/summary/summary.js +7 -12
  32. package/lib/components/summary/summary.module.css +1 -1
  33. package/lib/components/summary/summary.stories.js +0 -29
  34. package/lib/components/summary-item/summary-item.js +18 -38
  35. package/lib/components/summary-item/summary-item.module.css +1 -34
  36. package/lib/components/summary-item/summary-item.stories.js +53 -51
  37. package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
  38. package/lib/constants.js +4 -4
  39. package/lib/css/default.css +14 -3
  40. package/lib/css/variables.css +17 -17
  41. package/lib/hooks/search-params.js +31 -31
  42. package/lib/layout/box/box.module.css +9 -0
  43. package/lib/layout/footer/footer.module.css +1 -1
  44. package/lib/layout/index.js +8 -0
  45. package/lib/layout/separator.js +48 -0
  46. package/lib/layout/separator.module.css +5 -0
  47. package/lib/ui/alert/alert.js +3 -13
  48. package/lib/ui/dropdown/dropdown.js +21 -26
  49. package/lib/ui/dropdown/dropdown.module.css +11 -12
  50. package/lib/ui/dropdown/dropdown.stories.js +2 -9
  51. package/lib/ui/empty-set/empty-set.js +5 -4
  52. package/lib/ui/empty-set/empty-set.module.css +2 -2
  53. package/lib/ui/filters/filters.container.js +1 -1
  54. package/lib/ui/filters/filters.js +22 -7
  55. package/lib/ui/filters/filters.module.css +3 -3
  56. package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +1 -1
  57. package/lib/ui/hover-card/hover-card.js +102 -0
  58. package/lib/ui/hover-card/hover-card.module.css +29 -0
  59. package/lib/ui/hover-card/hover-card.stories.js +56 -0
  60. package/lib/{components/budget-info → ui/hover-card}/index.js +4 -4
  61. package/lib/ui/icon/icon.js +6 -8
  62. package/lib/ui/icon/icon.module.css +1 -0
  63. package/lib/ui/index.js +8 -8
  64. package/lib/ui/table/table.js +5 -74
  65. package/lib/ui/table/table.module.css +41 -25
  66. package/lib/ui/table/table.stories.js +1 -1
  67. package/lib/ui/{popover → tag}/index.js +4 -4
  68. package/lib/ui/tag/tag.js +72 -0
  69. package/lib/ui/tag/tag.module.css +55 -0
  70. package/lib/ui/tag/tag.stories.js +38 -0
  71. package/lib/ui/tooltip/tooltip.js +10 -9
  72. package/lib/ui/tooltip/tooltip.module.css +2 -1
  73. package/lib-esm/app/app.js +119 -103
  74. package/lib-esm/app/app.module.css +11 -4
  75. package/lib-esm/app/app.stories.js +1 -22
  76. package/lib-esm/app/header/header.js +1 -9
  77. package/lib-esm/assets/icons.svg +0 -8
  78. package/lib-esm/components/asset-info/asset-info.module.css +1 -0
  79. package/lib-esm/components/bundle-assets/bundle-assets.js +97 -56
  80. package/lib-esm/components/bundle-assets/bundle-assets.module.css +24 -26
  81. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +13 -26
  82. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  83. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
  84. package/lib-esm/components/bundle-modules/bundle-modules.js +50 -51
  85. package/lib-esm/components/bundle-modules/bundle-modules.module.css +11 -2
  86. package/lib-esm/components/bundle-modules/bundle-modules.utils.js +14 -6
  87. package/lib-esm/components/bundle-modules/index.js +5 -3
  88. package/lib-esm/components/bundle-packages/bundle-packages.js +88 -41
  89. package/lib-esm/components/bundle-packages/bundle-packages.module.css +17 -21
  90. package/lib-esm/components/delta/delta.module.css +1 -0
  91. package/lib-esm/components/index.js +0 -1
  92. package/lib-esm/components/job-header/job-header.js +2 -1
  93. package/lib-esm/components/job-header/job-header.module.css +6 -8
  94. package/lib-esm/components/jobs-header/jobs-header.module.css +5 -0
  95. package/lib-esm/components/metrics-table/metrics-table.js +61 -53
  96. package/lib-esm/components/metrics-table/metrics-table.module.css +18 -7
  97. package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +5 -4
  98. package/lib-esm/components/metrics-table-title/metrics-table-title.js +8 -7
  99. package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +2 -0
  100. package/lib-esm/components/module-info/module-info.js +2 -2
  101. package/lib-esm/components/module-info/module-info.module.css +1 -0
  102. package/lib-esm/components/summary/summary.js +7 -11
  103. package/lib-esm/components/summary/summary.module.css +1 -1
  104. package/lib-esm/components/summary/summary.stories.js +0 -27
  105. package/lib-esm/components/summary-item/summary-item.js +16 -36
  106. package/lib-esm/components/summary-item/summary-item.module.css +1 -34
  107. package/lib-esm/components/summary-item/summary-item.stories.js +38 -50
  108. package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
  109. package/lib-esm/constants.js +4 -4
  110. package/lib-esm/css/default.css +14 -3
  111. package/lib-esm/css/variables.css +17 -17
  112. package/lib-esm/hooks/search-params.js +27 -28
  113. package/lib-esm/layout/box/box.module.css +9 -0
  114. package/lib-esm/layout/footer/footer.module.css +1 -1
  115. package/lib-esm/layout/index.js +1 -0
  116. package/lib-esm/layout/separator.js +28 -0
  117. package/lib-esm/layout/separator.module.css +5 -0
  118. package/lib-esm/ui/alert/alert.js +3 -6
  119. package/lib-esm/ui/dropdown/dropdown.js +20 -25
  120. package/lib-esm/ui/dropdown/dropdown.module.css +11 -12
  121. package/lib-esm/ui/dropdown/dropdown.stories.js +2 -7
  122. package/lib-esm/ui/empty-set/empty-set.js +4 -4
  123. package/lib-esm/ui/empty-set/empty-set.module.css +2 -2
  124. package/lib-esm/ui/filters/filters.js +20 -5
  125. package/lib-esm/ui/filters/filters.module.css +3 -3
  126. package/lib-esm/ui/hover-card/hover-card.js +83 -0
  127. package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
  128. package/lib-esm/ui/hover-card/hover-card.stories.js +35 -0
  129. package/lib-esm/ui/hover-card/index.js +1 -0
  130. package/lib-esm/ui/icon/icon.js +3 -5
  131. package/lib-esm/ui/icon/icon.module.css +1 -0
  132. package/lib-esm/ui/index.js +1 -1
  133. package/lib-esm/ui/table/table.js +5 -65
  134. package/lib-esm/ui/table/table.module.css +41 -25
  135. package/lib-esm/ui/table/table.stories.js +1 -1
  136. package/lib-esm/ui/tag/index.js +1 -0
  137. package/lib-esm/ui/tag/tag.js +45 -0
  138. package/lib-esm/ui/tag/tag.module.css +55 -0
  139. package/lib-esm/ui/tag/tag.stories.js +23 -0
  140. package/lib-esm/ui/tooltip/tooltip.js +10 -9
  141. package/lib-esm/ui/tooltip/tooltip.module.css +2 -1
  142. package/package.json +33 -31
  143. package/src/app/app.jsx +135 -145
  144. package/src/app/app.module.css +11 -4
  145. package/src/app/header/header.jsx +0 -10
  146. package/src/assets/icons.svg +0 -8
  147. package/src/components/asset-info/asset-info.module.css +1 -0
  148. package/src/components/bundle-assets/bundle-assets.jsx +85 -31
  149. package/src/components/bundle-assets/bundle-assets.module.css +24 -26
  150. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -25
  151. package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
  152. package/src/components/bundle-modules/bundle-modules.jsx +53 -36
  153. package/src/components/bundle-modules/bundle-modules.module.css +11 -2
  154. package/src/components/bundle-modules/bundle-modules.utils.js +16 -4
  155. package/src/components/bundle-modules/index.jsx +3 -0
  156. package/src/components/bundle-packages/bundle-packages.jsx +89 -39
  157. package/src/components/bundle-packages/bundle-packages.module.css +17 -21
  158. package/src/components/delta/delta.module.css +1 -0
  159. package/src/components/index.js +0 -1
  160. package/src/components/job-header/job-header.jsx +2 -1
  161. package/src/components/job-header/job-header.module.css +6 -8
  162. package/src/components/jobs-header/jobs-header.module.css +5 -0
  163. package/src/components/metrics-table/metrics-table.jsx +53 -44
  164. package/src/components/metrics-table/metrics-table.module.css +18 -7
  165. package/src/components/metrics-table-search/metrics-table-search.module.css +5 -4
  166. package/src/components/metrics-table-title/metrics-table-title.jsx +20 -21
  167. package/src/components/metrics-table-title/metrics-table-title.module.css +2 -0
  168. package/src/components/module-info/module-info.jsx +3 -7
  169. package/src/components/module-info/module-info.module.css +1 -0
  170. package/src/components/summary/summary.jsx +7 -8
  171. package/src/components/summary/summary.module.css +1 -1
  172. package/src/components/summary-item/summary-item.jsx +23 -40
  173. package/src/components/summary-item/summary-item.module.css +1 -34
  174. package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
  175. package/src/constants.js +11 -7
  176. package/src/css/default.css +14 -3
  177. package/src/css/variables.css +17 -17
  178. package/src/hooks/search-params.js +42 -33
  179. package/src/layout/box/box.module.css +9 -0
  180. package/src/layout/footer/footer.module.css +1 -1
  181. package/src/layout/index.js +1 -0
  182. package/src/layout/separator.jsx +25 -0
  183. package/src/layout/separator.module.css +5 -0
  184. package/src/ui/alert/alert.jsx +2 -7
  185. package/src/ui/dropdown/dropdown.jsx +16 -22
  186. package/src/ui/dropdown/dropdown.module.css +11 -12
  187. package/src/ui/empty-set/empty-set.jsx +25 -21
  188. package/src/ui/empty-set/empty-set.module.css +2 -2
  189. package/src/ui/filters/filters.jsx +64 -53
  190. package/src/ui/filters/filters.module.css +3 -3
  191. package/src/ui/hover-card/hover-card.jsx +73 -0
  192. package/src/ui/hover-card/hover-card.module.css +29 -0
  193. package/src/ui/hover-card/index.js +1 -0
  194. package/src/ui/icon/icon.jsx +11 -9
  195. package/src/ui/icon/icon.module.css +1 -0
  196. package/src/ui/index.js +1 -1
  197. package/src/ui/table/table.jsx +5 -52
  198. package/src/ui/table/table.module.css +41 -25
  199. package/src/ui/tag/index.js +1 -0
  200. package/src/ui/tag/tag.jsx +49 -0
  201. package/src/ui/tag/tag.module.css +55 -0
  202. package/src/ui/tooltip/tooltip.jsx +10 -14
  203. package/src/ui/tooltip/tooltip.module.css +2 -1
  204. package/lib/assets/icons/alert-circle.svg +0 -1
  205. package/lib/assets/icons/check-circle.svg +0 -1
  206. package/lib/components/budget-info/budget-info.js +0 -80
  207. package/lib/components/budget-info/budget-info.module.css +0 -40
  208. package/lib/components/budget-info/budget-info.stories.js +0 -44
  209. package/lib/components/budget-insights/budget-insights.js +0 -200
  210. package/lib/components/budget-insights/budget-insights.module.css +0 -53
  211. package/lib/components/budget-insights/budget-insights.stories.js +0 -104
  212. package/lib/components/budget-insights/index.js +0 -18
  213. package/lib/ui/popover/popover.js +0 -92
  214. package/lib/ui/popover/popover.module.css +0 -66
  215. package/lib/ui/popover/popover.stories.js +0 -26
  216. package/lib-esm/assets/icons/alert-circle.svg +0 -1
  217. package/lib-esm/assets/icons/check-circle.svg +0 -1
  218. package/lib-esm/components/budget-info/budget-info.js +0 -58
  219. package/lib-esm/components/budget-info/budget-info.module.css +0 -40
  220. package/lib-esm/components/budget-info/budget-info.stories.js +0 -30
  221. package/lib-esm/components/budget-info/index.js +0 -1
  222. package/lib-esm/components/budget-insights/budget-insights.js +0 -148
  223. package/lib-esm/components/budget-insights/budget-insights.module.css +0 -53
  224. package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -84
  225. package/lib-esm/components/budget-insights/index.js +0 -1
  226. package/lib-esm/ui/popover/index.js +0 -1
  227. package/lib-esm/ui/popover/popover.js +0 -71
  228. package/lib-esm/ui/popover/popover.module.css +0 -66
  229. package/lib-esm/ui/popover/popover.stories.js +0 -14
  230. package/src/assets/icons/alert-circle.svg +0 -1
  231. package/src/assets/icons/check-circle.svg +0 -1
  232. package/src/components/budget-info/budget-info.jsx +0 -65
  233. package/src/components/budget-info/budget-info.module.css +0 -40
  234. package/src/components/budget-info/index.js +0 -1
  235. package/src/components/budget-insights/budget-insights.jsx +0 -157
  236. package/src/components/budget-insights/budget-insights.module.css +0 -53
  237. package/src/components/budget-insights/index.js +0 -1
  238. package/src/ui/popover/index.js +0 -1
  239. package/src/ui/popover/popover.jsx +0 -79
  240. package/src/ui/popover/popover.module.css +0 -66
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.Popover = void 0;
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
- var _Popover = require("reakit/Popover");
17
-
18
- var _icon = require("../icon");
19
-
20
- var _popoverModule = _interopRequireDefault(require("./popover.module.css"));
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
-
26
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
28
- 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); }
29
-
30
- var Popover = function Popover(_ref) {
31
- var className = _ref.className,
32
- icon = _ref.icon,
33
- label = _ref.label,
34
- ariaLabel = _ref.ariaLabel,
35
- children = _ref.children;
36
- var popover = (0, _Popover.usePopoverState)({
37
- baseId: process.env.NODE_ENV === 'test' && 'id-test',
38
- gutter: 12,
39
- modal: true,
40
- placement: 'top'
41
- });
42
- var onCloseButtonClick = (0, _react.useCallback)(function (event) {
43
- event.preventDefault();
44
- popover.toggle();
45
- }, [popover]);
46
- var onButtonClick = (0, _react.useCallback)(function (event) {
47
- event.preventDefault();
48
- popover.toggle();
49
- }, [popover]);
50
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Popover.PopoverDisclosure, _extends({
51
- className: (0, _classnames["default"])(_popoverModule["default"].button, className)
52
- }, popover, {
53
- onClick: onButtonClick,
54
- "aria-label": ariaLabel
55
- }), icon && (typeof icon === 'string' ? /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
56
- className: _popoverModule["default"].icon,
57
- glyph: icon
58
- }) : icon), label && /*#__PURE__*/_react["default"].createElement("span", {
59
- className: _popoverModule["default"].label
60
- }, label)), /*#__PURE__*/_react["default"].createElement(_Popover.Popover, _extends({
61
- className: _popoverModule["default"].popover
62
- }, popover, {
63
- tabIndex: 0
64
- }), /*#__PURE__*/_react["default"].createElement(_Popover.PopoverArrow, _extends({
65
- className: _popoverModule["default"].arrow
66
- }, popover, {
67
- size: 16
68
- })), typeof children === 'function' ? children({
69
- popoverToggle: popover.toggle
70
- }) : children, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
71
- glyph: "close",
72
- as: "button",
73
- type: "button",
74
- className: _popoverModule["default"].closeBtn,
75
- onClick: onCloseButtonClick
76
- })));
77
- };
78
-
79
- exports.Popover = Popover;
80
- Popover.propTypes = {
81
- className: _propTypes["default"].string,
82
- label: _propTypes["default"].element,
83
- icon: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
84
- children: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element, _propTypes["default"].func]).isRequired,
85
- ariaLabel: _propTypes["default"].string
86
- };
87
- Popover.defaultProps = {
88
- className: '',
89
- icon: '',
90
- label: '',
91
- ariaLabel: 'View more info'
92
- };
@@ -1,66 +0,0 @@
1
- .button {
2
- display: inline-flex;
3
- align-items: center;
4
- justify-content: flex-start;
5
- border: none;
6
- outline: none;
7
- padding: 0;
8
- background: none;
9
- color: inherit;
10
- cursor: pointer;
11
- line-height: inherit;
12
- text-align: inherit;
13
- }
14
-
15
- .button:hover,
16
- .button:active,
17
- .button:focus {
18
- color: var(--color-primary);
19
- }
20
-
21
- .button:hover .label {
22
- text-decoration: underline;
23
- }
24
-
25
- .popover {
26
- padding: var(--space-small) var(--space-large) var(--space-small) var(--space-small);
27
- border-radius: var(--radius-small);
28
- max-width: 360px;
29
- outline: none;
30
- filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
31
- background: var(--color-light);
32
- font-size: var(--size-small);
33
- }
34
-
35
- .arrow svg {
36
- display: block;
37
- }
38
-
39
- .arrow :global .fill {
40
- fill: var(--color-light);
41
- }
42
-
43
- .arrow :global .stroke {
44
- fill: var(--color-light);
45
- }
46
-
47
- .closeBtn {
48
- position: absolute;
49
- right: 0;
50
- top: 0;
51
- width: var(--space-large);
52
- height: var(--space-large);
53
- padding: var(--space-xxsmall);
54
- background: none;
55
- border: none;
56
- cursor: pointer;
57
- color: var(--color-text-ultra-light);
58
- transition: var(--transition-out);
59
- }
60
-
61
- .closeBtn:hover,
62
- .closeBtn:active,
63
- .closeBtn:focus {
64
- color: var(--color-text-light);
65
- transition: var(--transition-in);
66
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _react2 = require("@storybook/react");
6
-
7
- var _stories = require("../../stories");
8
-
9
- var _ = require(".");
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
-
13
- var stories = (0, _react2.storiesOf)('UI/Popover', module);
14
- stories.addDecorator((0, _stories.getWrapperDecorator)({
15
- padding: '64px'
16
- }));
17
- stories.add('default', function () {
18
- return /*#__PURE__*/_react["default"].createElement(_.Popover, {
19
- label: "Job #100"
20
- }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
21
- });
22
- stories.add('with icon', function () {
23
- return /*#__PURE__*/_react["default"].createElement(_.Popover, {
24
- icon: "help"
25
- }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
26
- });
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
@@ -1,58 +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
- import * as budgetsInsightsTransformer from '@bundle-stats/utils/lib-esm/transformers/budgets-insights';
6
- import { Icon } from '../../ui/icon';
7
- import { Tooltip } from '../../ui/tooltip';
8
- import css from './budget-info.module.css';
9
- const INSIGHT_TYPE_MAP = {
10
- [InsightType.SUCCESS]: {
11
- className: css.success,
12
- glyph: Icon.ICONS.CHECK_CIRCLE
13
- },
14
- [InsightType.ERROR]: {
15
- className: css.error,
16
- glyph: Icon.ICONS.ALERT_CIRCLE
17
- },
18
- [InsightType.WARNING]: {
19
- className: css.warning,
20
- glyph: Icon.ICONS.WARNING
21
- }
22
- };
23
- export const BudgetInfo = _ref => {
24
- let {
25
- className = '',
26
- metricId,
27
- budgetInsight
28
- } = _ref;
29
- const budgetInsightInfo = budgetsInsightsTransformer.getInfo(metricId, budgetInsight);
30
- const {
31
- className: insightTypeClassName,
32
- glyph
33
- } = INSIGHT_TYPE_MAP[budgetInsightInfo.type];
34
- const rootClassName = cx(css.root, insightTypeClassName, className);
35
- const {
36
- data: messageData
37
- } = budgetInsightInfo.message;
38
- return /*#__PURE__*/React.createElement(Tooltip, {
39
- className: rootClassName,
40
- title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__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 `)
41
- }, /*#__PURE__*/React.createElement(Icon, {
42
- className: css.icon,
43
- glyph: glyph,
44
- size: "medium"
45
- }));
46
- };
47
- BudgetInfo.propTypes = {
48
- metricId: PropTypes.string.isRequired,
49
- budgetInsight: PropTypes.shape({
50
- currentValue: PropTypes.number,
51
- budgetValue: PropTypes.number,
52
- failed: PropTypes.bool
53
- }).isRequired,
54
- className: PropTypes.string
55
- };
56
- BudgetInfo.defaultProps = {
57
- className: ''
58
- };
@@ -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,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';
@@ -1 +0,0 @@
1
- export * from './popover';
@@ -1,71 +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, { useCallback } from 'react';
4
- import PropTypes from 'prop-types';
5
- import cx from 'classnames';
6
- import { usePopoverState, Popover as UIPopover, PopoverDisclosure as UIPopoverDisclosure, PopoverArrow as UIPopoverArrow } from 'reakit/Popover';
7
- import { Icon } from '../icon';
8
- import css from './popover.module.css';
9
- export const Popover = _ref => {
10
- let {
11
- className,
12
- icon,
13
- label,
14
- ariaLabel,
15
- children
16
- } = _ref;
17
- const popover = usePopoverState({
18
- baseId: process.env.NODE_ENV === 'test' && 'id-test',
19
- gutter: 12,
20
- modal: true,
21
- placement: 'top'
22
- });
23
- const onCloseButtonClick = useCallback(event => {
24
- event.preventDefault();
25
- popover.toggle();
26
- }, [popover]);
27
- const onButtonClick = useCallback(event => {
28
- event.preventDefault();
29
- popover.toggle();
30
- }, [popover]);
31
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UIPopoverDisclosure, _extends({
32
- className: cx(css.button, className)
33
- }, popover, {
34
- onClick: onButtonClick,
35
- "aria-label": ariaLabel
36
- }), icon && (typeof icon === 'string' ? /*#__PURE__*/React.createElement(Icon, {
37
- className: css.icon,
38
- glyph: icon
39
- }) : icon), label && /*#__PURE__*/React.createElement("span", {
40
- className: css.label
41
- }, label)), /*#__PURE__*/React.createElement(UIPopover, _extends({
42
- className: css.popover
43
- }, popover, {
44
- tabIndex: 0
45
- }), /*#__PURE__*/React.createElement(UIPopoverArrow, _extends({
46
- className: css.arrow
47
- }, popover, {
48
- size: 16
49
- })), typeof children === 'function' ? children({
50
- popoverToggle: popover.toggle
51
- }) : children, /*#__PURE__*/React.createElement(Icon, {
52
- glyph: "close",
53
- as: "button",
54
- type: "button",
55
- className: css.closeBtn,
56
- onClick: onCloseButtonClick
57
- })));
58
- };
59
- Popover.propTypes = {
60
- className: PropTypes.string,
61
- label: PropTypes.element,
62
- icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
63
- children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,
64
- ariaLabel: PropTypes.string
65
- };
66
- Popover.defaultProps = {
67
- className: '',
68
- icon: '',
69
- label: '',
70
- ariaLabel: 'View more info'
71
- };