@bundle-stats/ui 4.0.0 → 4.0.4

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 (55) hide show
  1. package/lib/components/bundle-assets/bundle-assets.js +3 -3
  2. package/lib/components/bundle-assets/bundle-assets.utils.js +1 -1
  3. package/lib/components/metric/metric.js +40 -25
  4. package/lib/components/metric/metric.module.css +4 -14
  5. package/lib/components/metrics-table-title/metrics-table-title.js +1 -1
  6. package/lib/components/metrics-table-title/metrics-table-title.module.css +3 -3
  7. package/lib/components/summary-item/summary-item.js +1 -1
  8. package/lib/components/summary-item/summary-item.module.css +0 -9
  9. package/lib/components/total-size-type-title/total-size-type-title.js +6 -3
  10. package/lib/components/total-size-type-title/total-size-type-title.module.css +9 -1
  11. package/lib/i18n.js +2 -2
  12. package/lib/ui/dropdown/dropdown.module.css +3 -2
  13. package/lib/ui/filters/filters.js +11 -8
  14. package/lib/ui/filters/filters.module.css +11 -12
  15. package/lib/ui/hover-card/hover-card.js +8 -2
  16. package/lib/ui/index.js +8 -0
  17. package/lib/ui/sort-dropdown/sort-dropdown.js +90 -30
  18. package/lib/ui/sort-dropdown/sort-dropdown.module.css +5 -3
  19. package/lib-esm/components/bundle-assets/bundle-assets.js +3 -3
  20. package/lib-esm/components/bundle-assets/bundle-assets.utils.js +1 -1
  21. package/lib-esm/components/metric/metric.js +40 -15
  22. package/lib-esm/components/metric/metric.module.css +4 -14
  23. package/lib-esm/components/metrics-table-title/metrics-table-title.js +1 -1
  24. package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +3 -3
  25. package/lib-esm/components/summary-item/summary-item.js +1 -1
  26. package/lib-esm/components/summary-item/summary-item.module.css +0 -9
  27. package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
  28. package/lib-esm/components/total-size-type-title/total-size-type-title.module.css +9 -1
  29. package/lib-esm/i18n.js +2 -2
  30. package/lib-esm/ui/dropdown/dropdown.module.css +3 -2
  31. package/lib-esm/ui/filters/filters.js +9 -7
  32. package/lib-esm/ui/filters/filters.module.css +11 -12
  33. package/lib-esm/ui/hover-card/hover-card.js +8 -2
  34. package/lib-esm/ui/index.js +1 -0
  35. package/lib-esm/ui/sort-dropdown/sort-dropdown.js +72 -23
  36. package/lib-esm/ui/sort-dropdown/sort-dropdown.module.css +5 -3
  37. package/package.json +8 -8
  38. package/src/components/bundle-assets/bundle-assets.jsx +3 -3
  39. package/src/components/bundle-assets/bundle-assets.utils.js +1 -1
  40. package/src/components/metric/metric.jsx +32 -24
  41. package/src/components/metric/metric.module.css +4 -14
  42. package/src/components/metrics-table-title/metrics-table-title.jsx +1 -1
  43. package/src/components/metrics-table-title/metrics-table-title.module.css +3 -3
  44. package/src/components/summary-item/summary-item.jsx +1 -1
  45. package/src/components/summary-item/summary-item.module.css +0 -9
  46. package/src/components/total-size-type-title/total-size-type-title.jsx +3 -3
  47. package/src/components/total-size-type-title/total-size-type-title.module.css +9 -1
  48. package/src/i18n.js +2 -2
  49. package/src/ui/dropdown/dropdown.module.css +3 -2
  50. package/src/ui/filters/filters.jsx +24 -18
  51. package/src/ui/filters/filters.module.css +11 -12
  52. package/src/ui/hover-card/hover-card.jsx +11 -3
  53. package/src/ui/index.js +1 -0
  54. package/src/ui/sort-dropdown/sort-dropdown.jsx +70 -27
  55. package/src/ui/sort-dropdown/sort-dropdown.module.css +5 -3
@@ -1,11 +1,67 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
2
 
3
- import React from 'react';
3
+ import React, { useMemo } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import cx from 'classnames';
6
6
  import { Dropdown } from '../dropdown';
7
7
  import { Icon } from '../icon';
8
8
  import css from './sort-dropdown.module.css';
9
+
10
+ const Item = _ref => {
11
+ let {
12
+ className,
13
+ as: Component,
14
+ id,
15
+ label,
16
+ active,
17
+ direction,
18
+ defaultDirection,
19
+ getButtonOnClick,
20
+ ...restProps
21
+ } = _ref;
22
+ const buttonProps = useMemo(() => {
23
+ let resolveNextDirection = defaultDirection;
24
+
25
+ if (active) {
26
+ resolveNextDirection = direction === 'asc' ? 'desc' : 'asc';
27
+ }
28
+
29
+ if (resolveNextDirection === 'desc') {
30
+ return {
31
+ className: css.itemAsc,
32
+ onClick: getButtonOnClick(id, 'desc'),
33
+ title: `Order data by ${label} descending`
34
+ };
35
+ }
36
+
37
+ return {
38
+ onClick: getButtonOnClick(id, 'asc'),
39
+ title: `Order data by ${label} ascending`
40
+ };
41
+ }, [active, direction, defaultDirection, id, label]);
42
+ return /*#__PURE__*/React.createElement(Component, _extends({}, restProps, buttonProps, {
43
+ className: cx(className, css.item, active && css.itemActive, buttonProps.className)
44
+ }), /*#__PURE__*/React.createElement(Icon, {
45
+ className: css.itemIcon,
46
+ glyph: "arrow"
47
+ }), /*#__PURE__*/React.createElement("span", {
48
+ className: css.itemLabel
49
+ }, label));
50
+ };
51
+
52
+ Item.propTypes = {
53
+ className: PropTypes.string,
54
+ as: PropTypes.element.isRequired,
55
+ id: PropTypes.string.isRequired,
56
+ label: PropTypes.string.isRequired,
57
+ active: PropTypes.bool.isRequired,
58
+ direction: PropTypes.string.isRequired,
59
+ defaultDirection: PropTypes.string.isRequired,
60
+ getButtonOnClick: PropTypes.func.isRequired
61
+ };
62
+ Item.defaultProps = {
63
+ className: ''
64
+ };
9
65
  export const SortDropdown = props => {
10
66
  const {
11
67
  className,
@@ -22,13 +78,13 @@ export const SortDropdown = props => {
22
78
  label: customLabel,
23
79
  glyph: "sort",
24
80
  align: "right"
25
- }, _ref => {
81
+ }, _ref2 => {
26
82
  let {
27
83
  MenuItem,
28
84
  menu,
29
85
  menuItemClassName,
30
86
  menuItemActiveClassName
31
- } = _ref;
87
+ } = _ref2;
32
88
 
33
89
  const getButtonOnClick = (newField, newDirection) => () => {
34
90
  onChange({
@@ -40,27 +96,20 @@ export const SortDropdown = props => {
40
96
 
41
97
  return /*#__PURE__*/React.createElement("div", {
42
98
  className: css.items
43
- }, Object.entries(fields).map(_ref2 => {
44
- let [key, item] = _ref2;
45
- const buttonProps = direction === 'asc' ? {
46
- className: css.itemAsc,
47
- onClick: getButtonOnClick(key, 'desc'),
48
- title: `Order data by ${item.label} descending`
49
- } : {
50
- onClick: getButtonOnClick(key, 'asc'),
51
- title: `Order data by ${item.label} ascending`
52
- };
99
+ }, Object.entries(fields).map(_ref3 => {
100
+ let [key, item] = _ref3;
53
101
  const isActive = field === key;
54
- return /*#__PURE__*/React.createElement(MenuItem, _extends({
55
- key: key
56
- }, menu, buttonProps, {
57
- className: cx(buttonProps.className, menuItemClassName, css.item, isActive && menuItemActiveClassName, isActive && css.active)
58
- }), /*#__PURE__*/React.createElement("span", {
59
- className: css.itemLabel
60
- }, item.label), /*#__PURE__*/React.createElement(Icon, {
61
- className: css.itemIcon,
62
- glyph: "arrow"
63
- }));
102
+ return /*#__PURE__*/React.createElement(Item, {
103
+ key: key,
104
+ as: MenuItem,
105
+ className: cx(menuItemClassName, isActive && menuItemActiveClassName),
106
+ id: key,
107
+ label: item.label,
108
+ direction: direction,
109
+ defaultDirection: item.defaultDirection,
110
+ active: isActive,
111
+ getButtonOnClick: getButtonOnClick
112
+ });
64
113
  }));
65
114
  });
66
115
  };
@@ -4,7 +4,9 @@
4
4
  }
5
5
 
6
6
  .itemIcon {
7
- display: none;
7
+ flex: 0 0 auto;
8
+ visibility: hidden;
9
+ margin-right: var(--space-xxxsmall);
8
10
  }
9
11
 
10
12
  .itemLabel {
@@ -15,6 +17,6 @@
15
17
  transform: rotate(180deg);
16
18
  }
17
19
 
18
- .item.active .itemIcon {
19
- display: block;
20
+ .itemActive .itemIcon {
21
+ visibility: visible;
20
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bundle-stats/ui",
3
- "version": "4.0.0",
3
+ "version": "4.0.4",
4
4
  "description": "UI components for BundleStats projects.",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -36,10 +36,10 @@
36
36
  },
37
37
  "homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/ui#readme",
38
38
  "devDependencies": {
39
- "@babel/cli": "7.18.6",
40
- "@babel/core": "7.18.6",
39
+ "@babel/cli": "7.18.9",
40
+ "@babel/core": "7.18.9",
41
41
  "@babel/plugin-proposal-class-properties": "7.18.6",
42
- "@babel/preset-env": "7.18.6",
42
+ "@babel/preset-env": "7.18.9",
43
43
  "@babel/preset-react": "7.18.6",
44
44
  "@simplyianm/babel-plugin-inline-react-svg": "1.2.0",
45
45
  "@storybook/addon-essentials": "6.5.9",
@@ -54,10 +54,10 @@
54
54
  "babel-jest": "28.1.3",
55
55
  "babel-plugin-lodash": "3.3.4",
56
56
  "babel-plugin-require-context-hook": "1.0.0",
57
- "chromatic": "6.7.0",
57
+ "chromatic": "6.7.2",
58
58
  "classnames": "2.3.1",
59
59
  "colormap": "2.3.2",
60
- "core-js": "3.23.4",
60
+ "core-js": "3.24.1",
61
61
  "cross-env": "7.0.3",
62
62
  "enzyme": "3.11.0",
63
63
  "enzyme-adapter-react-16": "1.15.6",
@@ -85,12 +85,12 @@
85
85
  "react-router-dom": "^5.0.0"
86
86
  },
87
87
  "dependencies": {
88
- "@bundle-stats/utils": "^4.0.0",
88
+ "@bundle-stats/utils": "^4.0.4",
89
89
  "ariakit": "^2.0.0-next.33",
90
90
  "date-fns": "^2.28.0",
91
91
  "modern-css-reset": "^1.4.0",
92
92
  "query-string": "^7.1.0",
93
93
  "use-query-params": "^1.2.3"
94
94
  },
95
- "gitHead": "c22a455a35a0bef0b8ca4f1e259ada8e744990c4"
95
+ "gitHead": "a2d0cbcea629c27ca4acd979168868b83d1ad5f4"
96
96
  }
@@ -69,9 +69,9 @@ const getFilters = ({ compareMode, filters }) => ({
69
69
  label: 'Chunk',
70
70
  defaultValue: get(filters, `${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.CHUNK}`, true),
71
71
  },
72
- [ASSET_FILTERS.ASSET]: {
73
- label: 'Asset',
74
- defaultValue: get(filters, `${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.ASSET}`, true),
72
+ [ASSET_FILTERS.OTHER]: {
73
+ label: 'Other',
74
+ defaultValue: get(filters, `${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.OTHER}`, true),
75
75
  },
76
76
  },
77
77
  [ASSET_FILE_TYPE]: {
@@ -59,7 +59,7 @@ export const getRowFilter = (filters) => (item) => {
59
59
  (filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.ENTRY}`] && item.isEntry) ||
60
60
  (filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.INITIAL}`] && item.isInitial) ||
61
61
  (filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.CHUNK}`] && item.isChunk) ||
62
- (filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.ASSET}`] && item.isAsset)
62
+ (filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.OTHER}`] && item.isAsset)
63
63
  )
64
64
  ) {
65
65
  return false;
@@ -1,42 +1,51 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
 
5
- import styles from './metric.module.css';
5
+ import css from './metric.module.css';
6
6
 
7
7
  // Separate value and unit
8
8
  const EXTRACT_VALUE_UNIT_PATTERN = /([\d|.|,| ]*)(\w*|%)$/;
9
9
 
10
- export const Metric = ({ className, value, formatter, inline, anchored, children, enhanced }) => {
11
- const formattedValue = formatter(value);
10
+ export const Metric = ({ className, value, formatter, inline, children, enhanced }) => {
11
+ const { displayValue, displayUnit } = useMemo(() => {
12
+ const formattedValue = formatter?.(value);
12
13
 
13
- // eslint-disable-next-line no-unused-vars
14
- const [matched, displayValue, displayUnit] =
15
- enhanced && formattedValue
16
- ? formattedValue.match(EXTRACT_VALUE_UNIT_PATTERN)
17
- : [null, formattedValue, null];
14
+ if (!formattedValue) {
15
+ return { displayValue: value };
16
+ }
18
17
 
19
- const rootClassName = cx(
20
- className,
21
- styles.root,
22
- inline && styles.inline,
23
- anchored && styles.anchored,
24
- );
18
+ if (!enhanced) {
19
+ return { displayValue: formattedValue };
20
+ }
21
+
22
+ const matches = formattedValue.match(EXTRACT_VALUE_UNIT_PATTERN);
23
+
24
+ if (!matches) {
25
+ return { displayValue: value };
26
+ }
27
+
28
+ return {
29
+ displayUnit: matches[2],
30
+ displayValue: matches[1],
31
+ };
32
+ }, [formatter, value]);
33
+
34
+ const rootClassName = cx(className, css.root, inline && css.inline);
25
35
 
26
36
  return (
27
- <span className={rootClassName}>
28
- <span className={styles.display}>
29
- <span className={styles.displayValue}>{displayValue}</span>
30
- {displayUnit && <span className={styles.displayUnit}>{displayUnit}</span>}
31
- </span>
32
- <span className={styles.delta}>{children}</span>
33
- </span>
37
+ <div className={rootClassName}>
38
+ <div className={css.display}>
39
+ <span className={css.displayValue}>{displayValue}</span>
40
+ {displayUnit && <span className={css.displayUnit}>{displayUnit}</span>}
41
+ </div>
42
+ <div className={css.delta}>{children}</div>
43
+ </div>
34
44
  );
35
45
  };
36
46
 
37
47
  Metric.defaultProps = {
38
48
  className: '',
39
- anchored: false,
40
49
  enhanced: false,
41
50
  inline: false,
42
51
  value: 0,
@@ -48,7 +57,6 @@ Metric.propTypes = {
48
57
  className: PropTypes.string,
49
58
  enhanced: PropTypes.bool,
50
59
  inline: PropTypes.bool,
51
- anchored: PropTypes.bool,
52
60
  value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
53
61
  formatter: PropTypes.func,
54
62
  children: PropTypes.node,
@@ -1,27 +1,17 @@
1
1
  .root {
2
- display: block;
3
2
  letter-spacing: 0.05em;
4
3
  }
5
4
 
6
5
  .displayUnit {
7
- color: var(--color-text-ultra-light);
6
+ font-size: var(--size-small);
8
7
  }
9
8
 
10
9
  .delta {
11
- display: block;
12
- font-size: var(--size-xsmall);
10
+ font-size: var(--size-small);
13
11
  }
14
12
 
15
- .anchored {
16
- position: relative;
17
- }
18
-
19
- .anchored .delta {
20
- position: absolute;
21
- right: 0;
22
- top: 100%;
23
- line-height: 1;
24
- margin-top: -2px;
13
+ .inline .display {
14
+ display: inline-block;
25
15
  }
26
16
 
27
17
  .inline .delta {
@@ -18,7 +18,7 @@ export const MetricsTableTitle = (props) => {
18
18
  <FlexStack space="xxxsmall" className={css.title}>
19
19
  <span>{title}</span>
20
20
  {(popoverInfo || popoverHref) && (
21
- <HoverCard label={<Icon glyph="help" />} className={css.hoverCard}>
21
+ <HoverCard label={<Icon glyph="help" />} anchorClassName={css.anchor}>
22
22
  <Stack space="xxxsmall">
23
23
  {popoverInfo && <p>{popoverInfo}</p>}
24
24
  {popoverHref && (
@@ -2,14 +2,14 @@
2
2
  }
3
3
 
4
4
  .title {
5
- color: var(--color-text-light);
6
5
  align-items: center;
6
+ color: var(--color-text-light);
7
7
  font-weight: bold;
8
8
  text-transform: uppercase;
9
9
  }
10
10
 
11
- .hoverCard {
12
- line-height: 1;
11
+ .anchor {
12
+ display: block;
13
13
  }
14
14
 
15
15
  .info {
@@ -52,7 +52,7 @@ export const SummaryItem = ({
52
52
  const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
53
53
 
54
54
  return (
55
- <Stack space="xxsmall" as={Component} className={rootClassName} {...props}>
55
+ <Stack space="xxxsmall" as={Component} className={rootClassName} {...props}>
56
56
  <h3 className={css.title}>
57
57
  {showMetricDescriptionTooltip ? (
58
58
  <HoverCard label={metric.label}>
@@ -8,23 +8,15 @@
8
8
  }
9
9
 
10
10
  .currentMetric {
11
- display: block;
12
11
  color: var(--color-heading);
13
12
  font-size: var(--size-xlarge);
14
- line-height: var(--space-medium);
15
13
  white-space: nowrap;
16
14
  font-weight: bold;
17
15
  }
18
16
 
19
- .delta {
20
- font-size: var(--size-small);
21
- line-height: var(--space-medium);
22
- }
23
-
24
17
  .baselineMetric {
25
18
  color: var(--color-text-light);
26
19
  font-size: var(--size-small);
27
- line-height: var(--space-small);
28
20
  }
29
21
 
30
22
  .readMoreLink {
@@ -63,5 +55,4 @@
63
55
  /* Size large */
64
56
  .large .currentMetric {
65
57
  font-size: var(--size-xxxlarge);
66
- line-height: var(--space-medium);
67
58
  }
@@ -11,9 +11,9 @@ import { HoverCard } from '../../ui/hover-card';
11
11
  import css from './total-size-type-title.module.css';
12
12
 
13
13
  export const TotalSizeTypeTitle = ({ className }) => (
14
- <FlexStack space="xxxsmall" className={cx(css.title, className)}>
15
- <span>{I18N.ASSET_TOTALS}</span>
16
- <HoverCard label={<Icon glyph="help" />}>
14
+ <FlexStack space="xxxsmall" className={cx(css.root, className)}>
15
+ <span className={css.text}>{I18N.ASSET_TOTALS}</span>
16
+ <HoverCard label={<Icon glyph="help" />} anchorClassName={css.anchor}>
17
17
  <Stack space="xxxsmall">
18
18
  <p>{I18N.ASSET_TOTALS_INFO}</p>
19
19
  <p>
@@ -1,11 +1,19 @@
1
- .title {
1
+ .root {
2
2
  color: var(--color-text-light);
3
+ align-items: center;
4
+ }
5
+
6
+ .text {
3
7
  font-weight: bold;
4
8
  font-size: var(--size-medium);
5
9
  line-height: var(--space-medium);
6
10
  text-transform: uppercase;
7
11
  }
8
12
 
13
+ .anchor {
14
+ display: block;
15
+ }
16
+
9
17
  .readMoreLink {
10
18
  appearance: none;
11
19
  background: none;
package/src/i18n.js CHANGED
@@ -15,9 +15,9 @@ export default {
15
15
  ASSETS_INFO: 'Asset size - the size of the file produced by webpack',
16
16
  ASSET_TOTALS_INFO: 'The total size of the assets produced by webpack by type',
17
17
  MODULES_INFO:
18
- 'Module size - module file size before any transformation(ex: babel, typescript) or before any production optimization(ex: terser minification)',
18
+ 'Module size - module source size before any production optimization(ex: terser minification)',
19
19
  PACKAGES_INFO:
20
- "Package size - the total package's module size before any transformation(ex: babel, typescript) or before any production optimization(ex: terser minification)",
20
+ "Package size - the total package's module size before any production optimization(ex: terser minification)",
21
21
 
22
22
  RESET_FILTERS: 'Reset filters',
23
23
  VIEW_ALL: 'View all entries',
@@ -40,7 +40,7 @@
40
40
  background: var(--color-background);
41
41
  min-width: 180px;
42
42
  z-index: var(--layer-high);
43
- padding: var(--space-xsmall) 0;
43
+ padding: var(--space-xxsmall) 0;
44
44
  }
45
45
 
46
46
  .dropdown:focus {
@@ -55,12 +55,13 @@
55
55
  width: 100%;
56
56
  outline: none;
57
57
  border: 0;
58
- padding: var(--space-xxxsmall) var(--space-small);
58
+ padding: var(--space-xxxsmall) var(--space-xsmall);
59
59
  background: none;
60
60
  text-align: left;
61
61
  color: var(--color-text-light);
62
62
  font-size: var(--size-small);
63
63
  line-height: inherit;
64
+ text-decoration: none;
64
65
  }
65
66
 
66
67
  .menuItem:hover {
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
- import { get } from 'lodash';
5
4
 
6
5
  import { FlexStack } from '../../layout/flex-stack';
7
6
  import { Dropdown } from '../dropdown';
@@ -9,13 +8,21 @@ import { getGroupFiltersLabelSuffix, LABELS } from './filters.utils';
9
8
  import css from './filters.module.css';
10
9
 
11
10
  const Filter = (props) => {
12
- const { className, buttonClassName, label, name, getOnOnlyClick, ...inputProps } = props;
13
- const id = `filter-${name}`;
11
+ const {
12
+ className,
13
+ as: Component = 'div',
14
+ buttonClassName,
15
+ label,
16
+ name,
17
+ getOnOnlyClick,
18
+ ...inputProps
19
+ } = props;
14
20
 
21
+ const id = `filter-${name}`;
15
22
  const rootClassName = cx(css.filter, className);
16
23
 
17
24
  return (
18
- <div className={rootClassName}>
25
+ <Component className={rootClassName}>
19
26
  {/* eslint-disable */}
20
27
  <FlexStack space="xxxsmall" as="label" className={cx(css.filterCheckbox, buttonClassName)}>
21
28
  {/* eslint-enabled */}
@@ -30,12 +37,13 @@ const Filter = (props) => {
30
37
  only
31
38
  </button>
32
39
  )}
33
- </div>
40
+ </Component>
34
41
  );
35
42
  };
36
43
 
37
44
  Filter.propTypes = {
38
45
  className: PropTypes.string,
46
+ as: PropTypes.elementType,
39
47
  buttonClassName: PropTypes.string,
40
48
  name: PropTypes.string.isRequired,
41
49
  label: PropTypes.string.isRequired,
@@ -44,6 +52,7 @@ Filter.propTypes = {
44
52
 
45
53
  Filter.defaultProps = {
46
54
  className: '',
55
+ as: 'div',
47
56
  buttonClassName: '',
48
57
  getOnOnlyClick: null,
49
58
  };
@@ -105,20 +114,17 @@ const FilterGroup = (props) => {
105
114
  const getOnOnlyClick = () => getOnGroupCheck(false, { [id]: true });
106
115
 
107
116
  return (
108
- <MenuItem
117
+ <Filter
109
118
  key={id}
110
- {...menu}
111
- className={cx(menuItemClassName, css.filterGroupItem)}
112
- >
113
- <Filter
114
- name={id}
115
- label={itemData.label}
116
- onChange={onCheckboxChange}
117
- checked={values[id]}
118
- disabled={itemData.disabled}
119
- getOnOnlyClick={getOnOnlyClick}
120
- />
121
- </MenuItem>
119
+ className={menuItemClassName}
120
+ as={MenuItem}
121
+ name={id}
122
+ label={itemData.label}
123
+ onChange={onCheckboxChange}
124
+ checked={values[id]}
125
+ disabled={itemData.disabled}
126
+ getOnOnlyClick={getOnOnlyClick}
127
+ />
122
128
  );
123
129
  })}
124
130
  </div>
@@ -1,5 +1,9 @@
1
1
  /* Checkbox + label + button */
2
2
  .filter {
3
+ /* Update MenuItem padding */
4
+ padding-top: calc(var(--space-xxxsmall) / 2);
5
+ padding-bottom: calc(var(--space-xxxsmall) / 2);
6
+
3
7
  position: relative;
4
8
  width: 100%;
5
9
  max-width: 240px;
@@ -11,7 +15,6 @@
11
15
  }
12
16
 
13
17
  .filterInput {
14
- border-radius: var(--radius-small) 0 0 var(--radius-small);
15
18
  flex: 0 0 auto;
16
19
  height: 1em;
17
20
  cursor: pointer;
@@ -26,17 +29,17 @@
26
29
  }
27
30
 
28
31
  .filterOnlyButton {
29
- padding: var(--space-xxsmall);
32
+ padding: var(--space-xxxsmall) var(--space-xsmall);
30
33
  display: none;
31
34
  appearance: none;
32
35
  border: none;
33
36
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255) 30%);
34
37
  cursor: pointer;
35
- line-height: 1;
36
38
  position: absolute;
37
39
  right: 0;
38
- top: 50%;
39
- transform: translateY(-50%);
40
+ top: 0;
41
+ bottom: 0;
42
+ line-height: var(--space-xsmall);
40
43
  }
41
44
 
42
45
  /** filter disabled state */
@@ -63,6 +66,7 @@
63
66
 
64
67
  /** Filter standard variation */
65
68
  .filterStandalone {
69
+ padding: 0;
66
70
  width: auto;
67
71
  color: var(--color-text-light);
68
72
  z-index: var(--layout-xlow); /* show collapsed border */
@@ -95,16 +99,11 @@
95
99
  overflow: auto;
96
100
  }
97
101
 
98
- .filterGroupItem {
99
- padding-top: 2px;
100
- padding-bottom: 2px;
101
- }
102
-
103
102
  .filterGroupActions {
104
- margin-top: var(--space-xxsmall);
103
+ margin-top: var(--space-xxxsmall);
105
104
  padding-top: var(--space-xxxsmall);
106
105
  padding-bottom: var(--space-xxxsmall);
107
- margin-bottom: calc(0px - var(--space-xsmall));
106
+ margin-bottom: calc(0px - var(--space-xxsmall));
108
107
  border-top: 1px solid var(--color-outline);
109
108
  }
110
109
 
@@ -24,8 +24,8 @@ const resolveComponent = (as, href) => {
24
24
  };
25
25
 
26
26
  export const HoverCard = (props) => {
27
- const { className, hoverCardClassName, href, as, label, children } = props;
28
- const state = useHovercardState({ gutter: 8 });
27
+ const { className, anchorClassName, hoverCardClassName, href, as, label, children } = props;
28
+ const state = useHovercardState({ gutter: 8, timeout: 700 });
29
29
  const hoverCardProps = useHovercard({ state, portal: true });
30
30
 
31
31
  // Fallback to span if no href
@@ -37,7 +37,12 @@ export const HoverCard = (props) => {
37
37
 
38
38
  return (
39
39
  <div className={cx(css.root, className)}>
40
- <HovercardAnchor state={state} href={href} className={css.anchor} as={Component}>
40
+ <HovercardAnchor
41
+ state={state}
42
+ href={href}
43
+ className={cx(css.anchor, anchorClassName)}
44
+ as={Component}
45
+ >
41
46
  {label}
42
47
  </HovercardAnchor>
43
48
  <Hovercard
@@ -59,6 +64,8 @@ HoverCard.propTypes = {
59
64
  className: PropTypes.string,
60
65
  /** Adopted child class name for hover card */
61
66
  hoverCardClassName: PropTypes.string,
67
+ /** Adopted child class name for anchor */
68
+ anchorClassName: PropTypes.string,
62
69
  /** Anchor label */
63
70
  label: PropTypes.node,
64
71
  /** Anchor href */
@@ -72,6 +79,7 @@ HoverCard.propTypes = {
72
79
  HoverCard.defaultProps = {
73
80
  className: '',
74
81
  hoverCardClassName: '',
82
+ anchorClassName: '',
75
83
  label: '',
76
84
  as: '',
77
85
  href: '',