@bundle-stats/ui 3.2.3 → 3.2.4-alpha.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/lib/components/bundle-assets/bundle-assets.js +9 -7
  3. package/lib/components/bundle-assets/bundle-assets.module.css +5 -0
  4. package/lib/components/bundle-modules/bundle-modules.js +34 -63
  5. package/lib/components/bundle-modules/bundle-modules.module.css +0 -4
  6. package/lib/components/bundle-packages/bundle-packages.js +29 -24
  7. package/lib/components/bundle-packages/bundle-packages.module.css +37 -20
  8. package/lib/components/metrics-table-title/metrics-table-title.js +7 -3
  9. package/lib/components/summary-item/summary-item.js +16 -18
  10. package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
  11. package/lib/ui/dropdown/dropdown.js +15 -19
  12. package/lib/ui/filters/filters.js +3 -5
  13. package/lib/ui/hover-card/hover-card.js +65 -0
  14. package/lib/ui/hover-card/hover-card.module.css +29 -0
  15. package/lib/ui/hover-card/hover-card.stories.js +26 -0
  16. package/lib/ui/{popover → hover-card}/index.js +4 -4
  17. package/lib/ui/icon/icon.module.css +1 -0
  18. package/lib/ui/index.js +8 -8
  19. package/lib/ui/sort-dropdown/sort-dropdown.js +2 -5
  20. package/lib/ui/tooltip/tooltip.js +22 -14
  21. package/lib/ui/tooltip/tooltip.module.css +5 -3
  22. package/lib-esm/components/bundle-assets/bundle-assets.js +9 -7
  23. package/lib-esm/components/bundle-assets/bundle-assets.module.css +5 -0
  24. package/lib-esm/components/bundle-modules/bundle-modules.js +17 -29
  25. package/lib-esm/components/bundle-modules/bundle-modules.module.css +0 -4
  26. package/lib-esm/components/bundle-packages/bundle-packages.js +28 -23
  27. package/lib-esm/components/bundle-packages/bundle-packages.module.css +37 -20
  28. package/lib-esm/components/metrics-table-title/metrics-table-title.js +6 -3
  29. package/lib-esm/components/summary-item/summary-item.js +15 -18
  30. package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
  31. package/lib-esm/ui/dropdown/dropdown.js +9 -19
  32. package/lib-esm/ui/filters/filters.js +3 -5
  33. package/lib-esm/ui/hover-card/hover-card.js +45 -0
  34. package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
  35. package/lib-esm/ui/hover-card/hover-card.stories.js +9 -0
  36. package/lib-esm/ui/hover-card/index.js +1 -0
  37. package/lib-esm/ui/icon/icon.module.css +1 -0
  38. package/lib-esm/ui/index.js +1 -1
  39. package/lib-esm/ui/sort-dropdown/sort-dropdown.js +2 -5
  40. package/lib-esm/ui/tooltip/tooltip.js +15 -14
  41. package/lib-esm/ui/tooltip/tooltip.module.css +5 -3
  42. package/package.json +25 -22
  43. package/src/components/bundle-assets/bundle-assets.jsx +51 -42
  44. package/src/components/bundle-assets/bundle-assets.module.css +5 -0
  45. package/src/components/bundle-modules/bundle-modules.jsx +28 -31
  46. package/src/components/bundle-modules/bundle-modules.module.css +0 -4
  47. package/src/components/bundle-packages/bundle-packages.jsx +31 -25
  48. package/src/components/bundle-packages/bundle-packages.module.css +37 -20
  49. package/src/components/metrics-table-options/metrics-table-options.jsx +1 -1
  50. package/src/components/metrics-table-title/metrics-table-title.jsx +4 -3
  51. package/src/components/summary-item/summary-item.jsx +21 -26
  52. package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
  53. package/src/ui/dropdown/dropdown.jsx +14 -18
  54. package/src/ui/filters/filters.jsx +30 -39
  55. package/src/ui/hover-card/hover-card.jsx +42 -0
  56. package/src/ui/hover-card/hover-card.module.css +29 -0
  57. package/src/ui/hover-card/index.js +1 -0
  58. package/src/ui/icon/icon.module.css +1 -0
  59. package/src/ui/index.js +1 -1
  60. package/src/ui/sort-dropdown/sort-dropdown.jsx +9 -11
  61. package/src/ui/tooltip/tooltip.jsx +20 -27
  62. package/src/ui/tooltip/tooltip.module.css +5 -3
  63. package/lib/ui/popover/popover.js +0 -92
  64. package/lib/ui/popover/popover.module.css +0 -66
  65. package/lib/ui/popover/popover.stories.js +0 -26
  66. package/lib-esm/ui/popover/index.js +0 -1
  67. package/lib-esm/ui/popover/popover.js +0 -71
  68. package/lib-esm/ui/popover/popover.module.css +0 -66
  69. package/lib-esm/ui/popover/popover.stories.js +0 -14
  70. package/src/ui/popover/index.js +0 -1
  71. package/src/ui/popover/popover.jsx +0 -79
  72. package/src/ui/popover/popover.module.css +0 -66
@@ -2,14 +2,19 @@ import React, { useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import { get, map } from 'lodash';
5
- import { ASSET_ENTRY_TYPE, ASSET_FILE_TYPE, ASSET_FILTERS, FILE_TYPE_LABELS } from '@bundle-stats/utils';
5
+ import {
6
+ ASSET_ENTRY_TYPE,
7
+ ASSET_FILE_TYPE,
8
+ ASSET_FILTERS,
9
+ FILE_TYPE_LABELS,
10
+ } from '@bundle-stats/utils';
6
11
 
7
12
  import config from '../../config.json';
8
13
  import I18N from '../../i18n';
9
14
  import { FlexStack } from '../../layout/flex-stack';
10
15
  import { Icon } from '../../ui/icon';
11
16
  import { FileName } from '../../ui/file-name';
12
- import { Popover } from '../../ui/popover';
17
+ import { HoverCard } from '../../ui/hover-card';
13
18
  import { Tooltip } from '../../ui/tooltip';
14
19
  import { Filters } from '../../ui/filters';
15
20
  import { SortDropdown } from '../../ui/sort-dropdown';
@@ -71,47 +76,51 @@ TooltipNotPredictive.propTypes = {
71
76
  runs: PropTypes.array, // eslint-disable-line react/forbid-prop-types
72
77
  };
73
78
 
74
- const getRenderRowHeader = ({ labels, CustomComponentLink, chunks }) => (item) => {
75
- const { label, isNotPredictive, runs, isChunk, isEntry, isInitial } = item;
79
+ const getRenderRowHeader =
80
+ ({ labels, CustomComponentLink, chunks }) =>
81
+ (item) => {
82
+ const { label, isNotPredictive, runs, isChunk, isEntry, isInitial } = item;
76
83
 
77
- return (
78
- <Popover
79
- label={<FileName name={label} />}
80
- icon={
81
- <div className={css.assetInfoFlags}>
82
- {isNotPredictive && (
83
- <Tooltip className={css.notPredictive} title={<TooltipNotPredictive runs={runs} />}>
84
- <Icon className={css.notPredictiveIcon} glyph="warning" />
85
- </Tooltip>
86
- )}
87
- {isChunk && (
88
- <span title="Chunk" className={css.flagChunk}>
89
- c
90
- </span>
91
- )}
92
- {isEntry && (
93
- <span title="Entrypoint" className={css.flagEntry}>
94
- e
95
- </span>
96
- )}
97
- {isInitial && (
98
- <span title="Initial" className={css.flagInitial}>
99
- i
100
- </span>
101
- )}
102
- </div>
103
- }
104
- >
105
- <AssetInfo
106
- className={css.assetInfo}
107
- item={item}
108
- labels={labels}
109
- chunks={chunks}
110
- CustomComponentLink={CustomComponentLink}
111
- />
112
- </Popover>
113
- );
114
- };
84
+ return (
85
+ <HoverCard
86
+ label={
87
+ <FlexStack space="xxxsmall" className={css.assetName}>
88
+ <div className={css.assetInfoFlags}>
89
+ {isNotPredictive && (
90
+ <Tooltip className={css.notPredictive} title={<TooltipNotPredictive runs={runs} />}>
91
+ <Icon className={css.notPredictiveIcon} glyph="warning" />
92
+ </Tooltip>
93
+ )}
94
+ {isChunk && (
95
+ <span title="Chunk" className={css.flagChunk}>
96
+ c
97
+ </span>
98
+ )}
99
+ {isEntry && (
100
+ <span title="Entrypoint" className={css.flagEntry}>
101
+ e
102
+ </span>
103
+ )}
104
+ {isInitial && (
105
+ <span title="Initial" className={css.flagInitial}>
106
+ i
107
+ </span>
108
+ )}
109
+ </div>
110
+ <FileName name={label} />
111
+ </FlexStack>
112
+ }
113
+ >
114
+ <AssetInfo
115
+ className={css.assetInfo}
116
+ item={item}
117
+ labels={labels}
118
+ chunks={chunks}
119
+ CustomComponentLink={CustomComponentLink}
120
+ />
121
+ </HoverCard>
122
+ );
123
+ };
115
124
 
116
125
  export const BundleAssets = (props) => {
117
126
  const {
@@ -8,6 +8,11 @@
8
8
  margin-right: -1px; /** collapse border */
9
9
  }
10
10
 
11
+ .assetName {
12
+ display: inline-flex;
13
+ align-items: center;
14
+ }
15
+
11
16
  .notPredictive {
12
17
  margin-right: var(--space-xxsmall);
13
18
  display: inline-block;
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import { get, isEmpty, map } from 'lodash';
@@ -18,7 +18,7 @@ import { FlexStack } from '../../layout/flex-stack';
18
18
  import { EmptySet } from '../../ui/empty-set';
19
19
  import { FileName } from '../../ui/file-name';
20
20
  import { Filters } from '../../ui/filters';
21
- import { Popover } from '../../ui/popover';
21
+ import { HoverCard } from '../../ui/hover-card';
22
22
  import { SortDropdown } from '../../ui/sort-dropdown';
23
23
  import { Toolbar } from '../../ui/toolbar';
24
24
  import { MetricsTable } from '../metrics-table';
@@ -30,31 +30,18 @@ import css from './bundle-modules.module.css';
30
30
 
31
31
  const RowHeader = ({ row, chunks, labels, CustomComponentLink }) => {
32
32
  const chunkIds = map(chunks, 'id');
33
-
34
- const [showPopopver, setPopover] = useState(false);
35
- const handleOnMouseEnter = useCallback(() => setPopover(true), [showPopopver]);
36
33
  const content = <FileName name={row.label} />;
37
34
 
38
35
  return (
39
- <div onMouseEnter={handleOnMouseEnter}>
40
- {!showPopopver ?
41
- content
42
- : (
43
- <Popover ariaLabel="View module info" label={content}>
44
- {({ popoverToggle }) => (
45
- <ModuleInfo
46
- className={css.namePopover}
47
- item={row}
48
- chunks={chunks}
49
- chunkIds={chunkIds}
50
- labels={labels}
51
- customComponentLink={CustomComponentLink}
52
- onClick={popoverToggle}
53
- />
54
- )}
55
- </Popover>
56
- )}
57
- </div>
36
+ <HoverCard label={content}>
37
+ <ModuleInfo
38
+ item={row}
39
+ chunks={chunks}
40
+ chunkIds={chunkIds}
41
+ labels={labels}
42
+ customComponentLink={CustomComponentLink}
43
+ />
44
+ </HoverCard>
58
45
  );
59
46
  };
60
47
 
@@ -76,9 +63,17 @@ RowHeader.defaultProps = {
76
63
  chunks: [],
77
64
  };
78
65
 
79
- const getRenderRowHeader = ({ labels, chunks, CustomComponentLink }) => (row) => (
80
- <RowHeader row={row} chunks={chunks} labels={labels} CustomComponentLink={CustomComponentLink} />
81
- );
66
+ const getRenderRowHeader =
67
+ ({ labels, chunks, CustomComponentLink }) =>
68
+ (row) =>
69
+ (
70
+ <RowHeader
71
+ row={row}
72
+ chunks={chunks}
73
+ labels={labels}
74
+ CustomComponentLink={CustomComponentLink}
75
+ />
76
+ );
82
77
 
83
78
  export const BundleModules = ({
84
79
  className,
@@ -240,10 +235,12 @@ BundleModules.propTypes = {
240
235
  jobs: PropTypes.array, // eslint-disable-line react/forbid-prop-types
241
236
 
242
237
  /** Chunks data */
243
- chunks: PropTypes.arrayOf(PropTypes.shape({
244
- id: PropTypes.string,
245
- name: PropTypes.string,
246
- })).isRequired,
238
+ chunks: PropTypes.arrayOf(
239
+ PropTypes.shape({
240
+ id: PropTypes.string,
241
+ name: PropTypes.string,
242
+ }),
243
+ ).isRequired,
247
244
 
248
245
  /** total row count */
249
246
  totalRowCount: PropTypes.number,
@@ -11,7 +11,3 @@
11
11
  max-width: 240px;
12
12
  margin-right: -1px; /** collapse border */
13
13
  }
14
-
15
- .namePopover {
16
- min-width: 280px;
17
- }
@@ -1,4 +1,4 @@
1
- import React, {useCallback} from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import {
@@ -15,7 +15,7 @@ import { Stack } from '../../layout/stack';
15
15
  import { FlexStack } from '../../layout/flex-stack';
16
16
  import { EmptySet } from '../../ui/empty-set';
17
17
  import { Filters } from '../../ui/filters';
18
- import { Popover } from '../../ui/popover';
18
+ import { HoverCard } from '../../ui/hover-card';
19
19
  import { SortDropdown } from '../../ui/sort-dropdown';
20
20
  import { Toolbar } from '../../ui/toolbar';
21
21
  import { FileName } from '../../ui/file-name';
@@ -26,28 +26,29 @@ import { MetricsTableOptions } from '../metrics-table-options';
26
26
  import { MetricsTableTitle } from '../metrics-table-title';
27
27
  import css from './bundle-packages.module.css';
28
28
 
29
- const PackagePopoverContent = ({ name, fullName, path, duplicate, CustomComponentLink }) => {
30
- const normalizedPackagePath = path || `node_modules/${fullName.split(PACKAGES_SEPARATOR).join('/node_modules/')}/`;
29
+ const PackageCard = ({ name, fullName, path, duplicate, CustomComponentLink }) => {
30
+ const normalizedPackagePath =
31
+ path || `node_modules/${fullName.split(PACKAGES_SEPARATOR).join('/node_modules/')}/`;
31
32
  const [normalizedName, packageId] = name.split(PACKAGE_ID_SEPARATOR);
32
33
 
33
34
  return (
34
- <Stack space="xxsmall" className={css.packagePopover}>
35
+ <Stack space="xxsmall" className={css.packageCard}>
35
36
  <Stack space="xxxsmall">
36
- <h3 className={css.packagePopoverTitle}>
37
+ <h3 className={css.packageCardTitle}>
37
38
  {normalizedName}
38
39
  {packageId && (
39
- <span className={css.packagePopoverTitleIndex}>
40
+ <span className={css.packageCardTitleIndex}>
40
41
  {`${PACKAGE_ID_SEPARATOR}${packageId}`}
41
42
  </span>
42
43
  )}
43
44
  </h3>
44
- <p className={css.packagePopoverPath}>
45
- <FileName className={css.packagePopoverPathValue} name={normalizedPackagePath} />
45
+ <p className={css.packageCardPath}>
46
+ <FileName className={css.packageCardPathValue} name={normalizedPackagePath} />
46
47
  </p>
47
48
  </Stack>
48
49
 
49
- <ul className={css.packagePopoverList}>
50
- <li className={css.packagePopoverItem}>
50
+ <ul className={css.packageCardList}>
51
+ <li className={css.packageCardItem}>
51
52
  <a
52
53
  href={`https://www.npmjs.com/package/${normalizedName}`}
53
54
  target="_blank"
@@ -56,7 +57,7 @@ const PackagePopoverContent = ({ name, fullName, path, duplicate, CustomComponen
56
57
  npmjs.com
57
58
  </a>
58
59
  </li>
59
- <li className={css.packagePopoverItem}>
60
+ <li className={css.packageCardItem}>
60
61
  <a
61
62
  href={`https://bundlephobia.com/result?p=${normalizedName}`}
62
63
  target="_blank"
@@ -67,7 +68,7 @@ const PackagePopoverContent = ({ name, fullName, path, duplicate, CustomComponen
67
68
  </li>
68
69
  </ul>
69
70
 
70
- <Stack space="xxxsmall" className={css.packagePopover.actions}>
71
+ <Stack space="xxxsmall" className={css.packageCardActions}>
71
72
  {duplicate && (
72
73
  <div>
73
74
  <CustomComponentLink {...getBundlePackagesByNameComponentLink(normalizedName)}>
@@ -84,7 +85,7 @@ const PackagePopoverContent = ({ name, fullName, path, duplicate, CustomComponen
84
85
  );
85
86
  };
86
87
 
87
- PackagePopoverContent.propTypes = {
88
+ PackageCard.propTypes = {
88
89
  name: PropTypes.string.isRequired,
89
90
  path: PropTypes.string,
90
91
  fullName: PropTypes.string.isRequired,
@@ -92,7 +93,7 @@ PackagePopoverContent.propTypes = {
92
93
  CustomComponentLink: PropTypes.elementType.isRequired,
93
94
  };
94
95
 
95
- PackagePopoverContent.defaultProps = {
96
+ PackageCard.defaultProps = {
96
97
  path: '',
97
98
  };
98
99
 
@@ -101,28 +102,33 @@ const PackageRowHeader = ({ item, CustomComponentLink }) => {
101
102
  const { path } = item.runs[0] || {};
102
103
 
103
104
  return (
104
- <span className={css.packageNames}>
105
+ <FlexStack space="xxxsmall" className={css.packageNames}>
105
106
  {packageNames.map((packageName, index) => {
106
- // Render duplicate flag only for the last entry
107
- const duplicateFlag = index === packageNames.length - 1 && item.duplicate && (
108
- <span className={css.duplicate} title="Duplicate package">
109
- D
110
- </span>
107
+ const label = (
108
+ <FlexStack space="xxxsmall" className={css.packageNameLabel}>
109
+ {/* Render duplicate flag only for the last entry */}
110
+ {index === packageNames.length - 1 && item.duplicate && (
111
+ <span className={css.packageNameDuplicate} title="Duplicate package">
112
+ D
113
+ </span>
114
+ )}
115
+ <span className={css.packageNameText}>{packageName}</span>
116
+ </FlexStack>
111
117
  );
112
118
 
113
119
  return (
114
- <Popover className={css.packageName} icon={duplicateFlag} label={packageName}>
115
- <PackagePopoverContent
120
+ <HoverCard label={label} key={packageName} className={css.packageName}>
121
+ <PackageCard
116
122
  name={packageName}
117
123
  path={path}
118
124
  fullName={item.label}
119
125
  duplicate={item.duplicate}
120
126
  CustomComponentLink={CustomComponentLink}
121
127
  />
122
- </Popover>
128
+ </HoverCard>
123
129
  );
124
130
  })}
125
- </span>
131
+ </FlexStack>
126
132
  );
127
133
  };
128
134
 
@@ -12,20 +12,8 @@
12
12
  margin-right: -1px; /** collapse border */
13
13
  }
14
14
 
15
- .duplicate {
16
- margin-right: var(--space-xxxsmall);
17
- display: inline-block;
18
- width: var(--space-small);
19
- height: var(--space-small);
20
- font-size: 10px;
21
- font-weight: bold;
22
- line-height: var(--space-small);
23
- text-align: center;
24
- text-transform: uppercase;
25
- vertical-align: middle;
26
-
27
- background: var(--color-danger);
28
- color: var(--color-light);
15
+ .packageNames {
16
+ align-items: center;
29
17
  }
30
18
 
31
19
  .packageName {
@@ -38,27 +26,56 @@
38
26
 
39
27
  .packageName + .packageName::before {
40
28
  display: inline-block;
41
- margin: 0 var(--space-xxxsmall);
29
+ margin: 0 var(--space-xxxsmall) 0 0;
42
30
  content: '/';
43
31
  color: var(--color-text-ultra-light);
44
32
  }
45
33
 
46
- .packagePopover {
47
- min-width: 320px;
34
+ .packageNameLabel {
35
+ display: inline-flex;
36
+ align-items: center;
37
+ }
38
+
39
+ .packageNameDuplicate {
40
+ margin-right: var(--space-xxxsmall);
41
+ display: inline-block;
42
+ width: var(--space-xsmall);
43
+ height: var(--space-xsmall);
44
+ font-size: 8px;
45
+ font-weight: bold;
46
+ line-height: var(--space-xsmall);
47
+ text-align: center;
48
+ text-transform: uppercase;
49
+ vertical-align: middle;
50
+
51
+ background: var(--color-danger);
52
+ color: var(--color-light);
53
+ }
54
+
55
+ .packageName:hover,
56
+ .packageName:active,
57
+ .packageName:focus {
58
+ text-decoration: none !important;
59
+ }
60
+
61
+ .packageName:hover .packageNameText,
62
+ .packageName:active .packageNameText,
63
+ .packageName:focus .packageNameText {
64
+ text-decoration: underline !important;
48
65
  }
49
66
 
50
- .packagePopoverTitleIndex {
67
+ .packageCardTitleIndex {
51
68
  color: var(--color-text-light);
52
69
  font-weight: normal;
53
70
  }
54
71
 
55
- .packagePopoverPathValue {
72
+ .packageCardPathValue {
56
73
  padding: var(--space-xxxsmall);
57
74
  background: var(--color-highlight-warning);
58
75
  font-family: var(--font-family-monospace);
59
76
  }
60
77
 
61
- .packagePopoverList {
78
+ .packageCardList {
62
79
  padding: 0;
63
80
  list-style: inside;
64
81
  }
@@ -5,7 +5,7 @@ import I18N from '../../i18n';
5
5
  import { Dropdown } from '../../ui/dropdown';
6
6
 
7
7
  export const MetricsTableOptions = (props) => {
8
- const { className, handleViewAll, handleResetFilters, ...restProps } = props;
8
+ const { className, handleViewAll, handleResetFilters, ...restProps } = props;
9
9
 
10
10
  return (
11
11
  <Dropdown className={className} glyph="menu" {...restProps}>
@@ -5,7 +5,8 @@ import cx from 'classnames';
5
5
  import I18N from '../../i18n';
6
6
  import { FlexStack } from '../../layout/flex-stack';
7
7
  import { Stack } from '../../layout/stack';
8
- import { Popover } from '../../ui/popover';
8
+ import { Icon } from '../../ui/icon';
9
+ import { HoverCard } from '../../ui/hover-card';
9
10
  import css from './metrics-table-title.module.css';
10
11
 
11
12
  export const MetricsTableTitle = (props) => {
@@ -18,7 +19,7 @@ export const MetricsTableTitle = (props) => {
18
19
  <span>{title}</span>
19
20
  {info && <span className={css.info}>{info}</span>}
20
21
  {(popoverInfo || popoverHref) && (
21
- <Popover icon="help">
22
+ <HoverCard label={<Icon glyph="help" />}>
22
23
  <Stack space="xxxsmall">
23
24
  {popoverInfo && <p>{popoverInfo}</p>}
24
25
  {popoverHref && (
@@ -29,7 +30,7 @@ export const MetricsTableTitle = (props) => {
29
30
  </p>
30
31
  )}
31
32
  </Stack>
32
- </Popover>
33
+ </HoverCard>
33
34
  )}
34
35
  </FlexStack>
35
36
  </Stack>
@@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
5
5
 
6
- import { Popover } from '../../ui/popover';
6
+ import { Icon } from '../../ui/icon';
7
+ import { HoverCard } from '../../ui/hover-card';
7
8
  import { Skeleton } from '../../ui/skeleton';
8
9
  import { Stack } from '../../layout/stack';
9
10
  import { FlexStack } from '../../layout/flex-stack';
@@ -11,32 +12,26 @@ import { Metric } from '../metric';
11
12
  import { Delta } from '../delta';
12
13
  import css from './summary-item.module.css';
13
14
 
14
- const MetricInfoPopover = ({ description, url }) => {
15
- // Workaround cases where the parent is a link
16
- const readMoreOnClick = () => {
17
- window.open(url);
18
- };
19
-
20
- return (
21
- <Stack space="xxxsmall">
22
- <p>{description}</p>
23
- {url && (
24
- <p>
25
- <button type="button" className={css.readMoreBtn} onClick={readMoreOnClick}>
26
- Read more
27
- </button>
28
- </p>
29
- )}
30
- </Stack>
31
- );
32
- };
33
-
34
- MetricInfoPopover.propTypes = {
15
+ const MetricDescriptionCard = ({ description, url }) => (
16
+ <Stack space="xxsmall">
17
+ <p>{description}</p>
18
+
19
+ {url && (
20
+ <p>
21
+ <a href={url} target="_blank" rel="noopener noreferrer">
22
+ Read more
23
+ </a>
24
+ </p>
25
+ )}
26
+ </Stack>
27
+ );
28
+
29
+ MetricDescriptionCard.propTypes = {
35
30
  description: PropTypes.string.isRequired,
36
31
  url: PropTypes.string,
37
32
  };
38
33
 
39
- MetricInfoPopover.defaultProps = {
34
+ MetricDescriptionCard.defaultProps = {
40
35
  url: '',
41
36
  };
42
37
 
@@ -65,9 +60,9 @@ export const SummaryItem = ({
65
60
  <span>{metric.label}</span>
66
61
 
67
62
  {showMetricDescriptionTooltip && (
68
- <Popover className={css.icon} icon="help">
69
- <MetricInfoPopover {...metric} />
70
- </Popover>
63
+ <HoverCard className={css.icon} label={<Icon glyph="help" />}>
64
+ <MetricDescriptionCard {...metric} />
65
+ </HoverCard>
71
66
  )}
72
67
  </FlexStack>
73
68
 
@@ -1,31 +1,28 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import cx from 'classnames'
3
+ import cx from 'classnames';
4
4
 
5
5
  import config from '../../config.json';
6
6
  import I18N from '../../i18n';
7
7
  import { FlexStack } from '../../layout/flex-stack';
8
8
  import { Stack } from '../../layout/stack';
9
- import { Popover } from '../../ui/popover';
9
+ import { Icon } from '../../ui/icon';
10
+ import { HoverCard } from '../../ui/hover-card';
10
11
  import css from './total-size-type-title.module.css';
11
12
 
12
13
  export const TotalSizeTypeTitle = ({ className }) => (
13
14
  <FlexStack space="xxxsmall" className={cx(css.title, className)}>
14
15
  <span>{I18N.ASSET_TOTALS}</span>
15
- <Popover icon="help">
16
+ <HoverCard label={<Icon glyph="help" />}>
16
17
  <Stack space="xxxsmall">
17
18
  <p>{I18N.ASSET_TOTALS_INFO}</p>
18
19
  <p>
19
- <a
20
- href={config.documentation.assets}
21
- target="_blank"
22
- rel="noreferrer"
23
- >
20
+ <a href={config.documentation.assets} target="_blank" rel="noreferrer">
24
21
  {I18N.READ_MORE}
25
22
  </a>
26
23
  </p>
27
24
  </Stack>
28
- </Popover>
25
+ </HoverCard>
29
26
  </FlexStack>
30
27
  );
31
28
 
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
- import { Menu, MenuItem, MenuButton, useMenuState } from 'reakit/Menu';
4
+ import * as BaseDropdownMenu from '@radix-ui/react-dropdown-menu';
5
5
 
6
6
  import { FlexStack } from '../../layout/flex-stack';
7
7
  import { Icon } from '../icon';
@@ -11,29 +11,28 @@ export const Dropdown = (props) => {
11
11
  const { className, label, ariaLabel, glyph, activeLabel, children } = props;
12
12
  const rootClassName = cx(css.root, activeLabel && css.activeLabel, className);
13
13
 
14
- const menu = useMenuState({baseId: process.env.NODE_ENV === 'test' && 'id-test', modal: true });
15
-
16
14
  return (
17
- <>
18
- <MenuButton {...menu} className={rootClassName} tabIndex={null}>
15
+ <BaseDropdownMenu.Root>
16
+ <BaseDropdownMenu.Trigger className={rootClassName}>
19
17
  <FlexStack space="xxxsmall" className={css.label}>
20
18
  {glyph && <Icon className={css.labelIcon} glyph={glyph} />}
21
19
  {label}
22
20
  </FlexStack>
23
- </MenuButton>
24
- <Menu {...menu} aria-label={ariaLabel || label} className={css.dropdown}>
21
+ </BaseDropdownMenu.Trigger>
22
+ <BaseDropdownMenu.Content
23
+ className={css.dropdown}
24
+ aria-label={ariaLabel || label}
25
+ align="start"
26
+ >
25
27
  {typeof children === 'function'
26
- ?
27
- children({
28
- MenuItem,
29
- menu,
28
+ ? children({
29
+ MenuItem: BaseDropdownMenu.Item,
30
30
  menuItemClassName: css.menuItem,
31
31
  menuItemActiveClassName: css.menuItemActive,
32
32
  })
33
- : children
34
- }
35
- </Menu>
36
- </>
33
+ : children}
34
+ </BaseDropdownMenu.Content>
35
+ </BaseDropdownMenu.Root>
37
36
  );
38
37
  };
39
38
 
@@ -58,9 +57,6 @@ Dropdown.propTypes = {
58
57
  /** Icon glyph */
59
58
  glyph: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
60
59
 
61
- /** Dropdown open state */
62
- open: PropTypes.bool.isRequired,
63
-
64
60
  /** Active label flag */
65
61
  activeLabel: PropTypes.bool,
66
62