@bundle-stats/ui 4.0.3 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/metric/metric.js +40 -25
- package/lib/components/metric/metric.module.css +4 -14
- package/lib/components/summary-item/summary-item.js +18 -5
- package/lib/components/summary-item/summary-item.module.css +0 -9
- package/lib/ui/dropdown/dropdown.module.css +3 -2
- package/lib/ui/filters/filters.js +11 -8
- package/lib/ui/filters/filters.module.css +11 -12
- package/lib/ui/hover-card/hover-card.js +3 -8
- package/lib/ui/skeleton/skeleton.js +11 -5
- package/lib/ui/skeleton/skeleton.module.css +6 -2
- package/lib/ui/skeleton/skeleton.stories.js +48 -9
- package/lib/ui/sort-dropdown/sort-dropdown.js +90 -30
- package/lib/ui/sort-dropdown/sort-dropdown.module.css +5 -3
- package/lib-esm/components/metric/metric.js +40 -15
- package/lib-esm/components/metric/metric.module.css +4 -14
- package/lib-esm/components/summary-item/summary-item.js +12 -3
- package/lib-esm/components/summary-item/summary-item.module.css +0 -9
- package/lib-esm/ui/dropdown/dropdown.module.css +3 -2
- package/lib-esm/ui/filters/filters.js +9 -7
- package/lib-esm/ui/filters/filters.module.css +11 -12
- package/lib-esm/ui/hover-card/hover-card.js +3 -8
- package/lib-esm/ui/skeleton/skeleton.js +10 -4
- package/lib-esm/ui/skeleton/skeleton.module.css +6 -2
- package/lib-esm/ui/skeleton/skeleton.stories.js +32 -5
- package/lib-esm/ui/sort-dropdown/sort-dropdown.js +72 -23
- package/lib-esm/ui/sort-dropdown/sort-dropdown.module.css +5 -3
- package/package.json +5 -5
- package/src/components/metric/metric.jsx +32 -24
- package/src/components/metric/metric.module.css +4 -14
- package/src/components/summary-item/summary-item.jsx +26 -16
- package/src/components/summary-item/summary-item.module.css +0 -9
- package/src/ui/dropdown/dropdown.module.css +3 -2
- package/src/ui/filters/filters.jsx +24 -18
- package/src/ui/filters/filters.module.css +11 -12
- package/src/ui/hover-card/hover-card.jsx +1 -6
- package/src/ui/skeleton/skeleton.jsx +7 -3
- package/src/ui/skeleton/skeleton.module.css +6 -2
- package/src/ui/sort-dropdown/sort-dropdown.jsx +70 -27
- package/src/ui/sort-dropdown/sort-dropdown.module.css +5 -3
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.SortDropdown = void 0;
|
|
7
9
|
|
|
8
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
10
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
13
|
|
|
@@ -17,11 +19,15 @@ var _icon = require("../icon");
|
|
|
17
19
|
|
|
18
20
|
var _sortDropdownModule = _interopRequireDefault(require("./sort-dropdown.module.css"));
|
|
19
21
|
|
|
22
|
+
var _excluded = ["className", "as", "id", "label", "active", "direction", "defaultDirection", "getButtonOnClick"];
|
|
23
|
+
|
|
20
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
25
|
|
|
22
|
-
function
|
|
26
|
+
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); }
|
|
23
27
|
|
|
24
|
-
function
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
31
|
|
|
26
32
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
33
|
|
|
@@ -35,6 +41,67 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
35
41
|
|
|
36
42
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
43
|
|
|
44
|
+
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); }
|
|
45
|
+
|
|
46
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
47
|
+
|
|
48
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
49
|
+
|
|
50
|
+
var Item = function Item(_ref) {
|
|
51
|
+
var className = _ref.className,
|
|
52
|
+
Component = _ref.as,
|
|
53
|
+
id = _ref.id,
|
|
54
|
+
label = _ref.label,
|
|
55
|
+
active = _ref.active,
|
|
56
|
+
direction = _ref.direction,
|
|
57
|
+
defaultDirection = _ref.defaultDirection,
|
|
58
|
+
getButtonOnClick = _ref.getButtonOnClick,
|
|
59
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
60
|
+
|
|
61
|
+
var buttonProps = (0, _react.useMemo)(function () {
|
|
62
|
+
var resolveNextDirection = defaultDirection;
|
|
63
|
+
|
|
64
|
+
if (active) {
|
|
65
|
+
resolveNextDirection = direction === 'asc' ? 'desc' : 'asc';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (resolveNextDirection === 'desc') {
|
|
69
|
+
return {
|
|
70
|
+
className: _sortDropdownModule["default"].itemAsc,
|
|
71
|
+
onClick: getButtonOnClick(id, 'desc'),
|
|
72
|
+
title: "Order data by ".concat(label, " descending")
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
onClick: getButtonOnClick(id, 'asc'),
|
|
78
|
+
title: "Order data by ".concat(label, " ascending")
|
|
79
|
+
};
|
|
80
|
+
}, [active, direction, defaultDirection, id, label]);
|
|
81
|
+
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, restProps, buttonProps, {
|
|
82
|
+
className: (0, _classnames["default"])(className, _sortDropdownModule["default"].item, active && _sortDropdownModule["default"].itemActive, buttonProps.className)
|
|
83
|
+
}), /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
84
|
+
className: _sortDropdownModule["default"].itemIcon,
|
|
85
|
+
glyph: "arrow"
|
|
86
|
+
}), /*#__PURE__*/_react["default"].createElement("span", {
|
|
87
|
+
className: _sortDropdownModule["default"].itemLabel
|
|
88
|
+
}, label));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Item.propTypes = {
|
|
92
|
+
className: _propTypes["default"].string,
|
|
93
|
+
as: _propTypes["default"].element.isRequired,
|
|
94
|
+
id: _propTypes["default"].string.isRequired,
|
|
95
|
+
label: _propTypes["default"].string.isRequired,
|
|
96
|
+
active: _propTypes["default"].bool.isRequired,
|
|
97
|
+
direction: _propTypes["default"].string.isRequired,
|
|
98
|
+
defaultDirection: _propTypes["default"].string.isRequired,
|
|
99
|
+
getButtonOnClick: _propTypes["default"].func.isRequired
|
|
100
|
+
};
|
|
101
|
+
Item.defaultProps = {
|
|
102
|
+
className: ''
|
|
103
|
+
};
|
|
104
|
+
|
|
38
105
|
var SortDropdown = function SortDropdown(props) {
|
|
39
106
|
var className = props.className,
|
|
40
107
|
label = props.label,
|
|
@@ -49,11 +116,11 @@ var SortDropdown = function SortDropdown(props) {
|
|
|
49
116
|
label: customLabel,
|
|
50
117
|
glyph: "sort",
|
|
51
118
|
align: "right"
|
|
52
|
-
}, function (
|
|
53
|
-
var MenuItem =
|
|
54
|
-
menu =
|
|
55
|
-
menuItemClassName =
|
|
56
|
-
menuItemActiveClassName =
|
|
119
|
+
}, function (_ref2) {
|
|
120
|
+
var MenuItem = _ref2.MenuItem,
|
|
121
|
+
menu = _ref2.menu,
|
|
122
|
+
menuItemClassName = _ref2.menuItemClassName,
|
|
123
|
+
menuItemActiveClassName = _ref2.menuItemActiveClassName;
|
|
57
124
|
|
|
58
125
|
var getButtonOnClick = function getButtonOnClick(newField, newDirection) {
|
|
59
126
|
return function () {
|
|
@@ -67,30 +134,23 @@ var SortDropdown = function SortDropdown(props) {
|
|
|
67
134
|
|
|
68
135
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
69
136
|
className: _sortDropdownModule["default"].items
|
|
70
|
-
}, Object.entries(fields).map(function (
|
|
71
|
-
var
|
|
72
|
-
key =
|
|
73
|
-
item =
|
|
137
|
+
}, Object.entries(fields).map(function (_ref3) {
|
|
138
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
139
|
+
key = _ref4[0],
|
|
140
|
+
item = _ref4[1];
|
|
74
141
|
|
|
75
|
-
var buttonProps = direction === 'asc' ? {
|
|
76
|
-
className: _sortDropdownModule["default"].itemAsc,
|
|
77
|
-
onClick: getButtonOnClick(key, 'desc'),
|
|
78
|
-
title: "Order data by ".concat(item.label, " descending")
|
|
79
|
-
} : {
|
|
80
|
-
onClick: getButtonOnClick(key, 'asc'),
|
|
81
|
-
title: "Order data by ".concat(item.label, " ascending")
|
|
82
|
-
};
|
|
83
142
|
var isActive = field === key;
|
|
84
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
85
|
-
key: key
|
|
86
|
-
|
|
87
|
-
className: (0, _classnames["default"])(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
143
|
+
return /*#__PURE__*/_react["default"].createElement(Item, {
|
|
144
|
+
key: key,
|
|
145
|
+
as: MenuItem,
|
|
146
|
+
className: (0, _classnames["default"])(menuItemClassName, isActive && menuItemActiveClassName),
|
|
147
|
+
id: key,
|
|
148
|
+
label: item.label,
|
|
149
|
+
direction: direction,
|
|
150
|
+
defaultDirection: item.defaultDirection,
|
|
151
|
+
active: isActive,
|
|
152
|
+
getButtonOnClick: getButtonOnClick
|
|
153
|
+
});
|
|
94
154
|
}));
|
|
95
155
|
});
|
|
96
156
|
};
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.itemIcon {
|
|
7
|
-
|
|
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
|
-
.
|
|
19
|
-
|
|
20
|
+
.itemActive .itemIcon {
|
|
21
|
+
visibility: visible;
|
|
20
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
import
|
|
4
|
+
import css from './metric.module.css'; // Separate value and unit
|
|
5
5
|
|
|
6
6
|
const EXTRACT_VALUE_UNIT_PATTERN = /([\d|.|,| ]*)(\w*|%)$/;
|
|
7
7
|
export const Metric = _ref => {
|
|
@@ -10,29 +10,55 @@ export const Metric = _ref => {
|
|
|
10
10
|
value,
|
|
11
11
|
formatter,
|
|
12
12
|
inline,
|
|
13
|
-
anchored,
|
|
14
13
|
children,
|
|
15
14
|
enhanced
|
|
16
15
|
} = _ref;
|
|
17
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
displayValue,
|
|
18
|
+
displayUnit
|
|
19
|
+
} = useMemo(() => {
|
|
20
|
+
const formattedValue = formatter == null ? void 0 : formatter(value);
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
if (!formattedValue) {
|
|
23
|
+
return {
|
|
24
|
+
displayValue: value
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!enhanced) {
|
|
29
|
+
return {
|
|
30
|
+
displayValue: formattedValue
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const matches = formattedValue.match(EXTRACT_VALUE_UNIT_PATTERN);
|
|
35
|
+
|
|
36
|
+
if (!matches) {
|
|
37
|
+
return {
|
|
38
|
+
displayValue: value
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
displayUnit: matches[2],
|
|
44
|
+
displayValue: matches[1]
|
|
45
|
+
};
|
|
46
|
+
}, [formatter, value]);
|
|
47
|
+
const rootClassName = cx(className, css.root, inline && css.inline);
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
49
|
className: rootClassName
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: css.display
|
|
23
52
|
}, /*#__PURE__*/React.createElement("span", {
|
|
24
|
-
className:
|
|
25
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
26
|
-
className: styles.displayValue
|
|
53
|
+
className: css.displayValue
|
|
27
54
|
}, displayValue), displayUnit && /*#__PURE__*/React.createElement("span", {
|
|
28
|
-
className:
|
|
29
|
-
}, displayUnit)), /*#__PURE__*/React.createElement("
|
|
30
|
-
className:
|
|
55
|
+
className: css.displayUnit
|
|
56
|
+
}, displayUnit)), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: css.delta
|
|
31
58
|
}, children));
|
|
32
59
|
};
|
|
33
60
|
Metric.defaultProps = {
|
|
34
61
|
className: '',
|
|
35
|
-
anchored: false,
|
|
36
62
|
enhanced: false,
|
|
37
63
|
inline: false,
|
|
38
64
|
value: 0,
|
|
@@ -43,7 +69,6 @@ Metric.propTypes = {
|
|
|
43
69
|
className: PropTypes.string,
|
|
44
70
|
enhanced: PropTypes.bool,
|
|
45
71
|
inline: PropTypes.bool,
|
|
46
|
-
anchored: PropTypes.bool,
|
|
47
72
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
48
73
|
formatter: PropTypes.func,
|
|
49
74
|
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
|
-
|
|
6
|
+
font-size: var(--size-small);
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
.delta {
|
|
11
|
-
|
|
12
|
-
font-size: var(--size-xsmall);
|
|
10
|
+
font-size: var(--size-small);
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
.
|
|
16
|
-
|
|
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 {
|
|
@@ -1,6 +1,6 @@
|
|
|
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, { useCallback } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
@@ -16,11 +16,18 @@ const MetricInfo = _ref => {
|
|
|
16
16
|
description,
|
|
17
17
|
url
|
|
18
18
|
} = _ref;
|
|
19
|
+
// The component parent can be rendered inside an anchor tag, using button
|
|
20
|
+
// to avoid using nesting links
|
|
21
|
+
const onClick = useCallback(() => {
|
|
22
|
+
if (url) {
|
|
23
|
+
window.open(url);
|
|
24
|
+
}
|
|
25
|
+
}, [url]);
|
|
19
26
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
20
27
|
space: "xxxsmall"
|
|
21
28
|
}, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("button", {
|
|
22
29
|
type: "button",
|
|
23
|
-
onClick:
|
|
30
|
+
onClick: onClick,
|
|
24
31
|
className: css.readMoreLink
|
|
25
32
|
}, "Read more")));
|
|
26
33
|
};
|
|
@@ -56,7 +63,7 @@ export const SummaryItem = _ref2 => {
|
|
|
56
63
|
const showMetricDescriptionTooltip = showMetricDescription && (metric == null ? void 0 : metric.description);
|
|
57
64
|
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
58
65
|
return /*#__PURE__*/React.createElement(Stack, _extends({
|
|
59
|
-
space: "
|
|
66
|
+
space: "xxxsmall",
|
|
60
67
|
as: Component,
|
|
61
68
|
className: rootClassName
|
|
62
69
|
}, props), /*#__PURE__*/React.createElement("h3", {
|
|
@@ -78,8 +85,10 @@ export const SummaryItem = _ref2 => {
|
|
|
78
85
|
value: baseline,
|
|
79
86
|
formatter: metric.formatter
|
|
80
87
|
})) : /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Skeleton, {
|
|
88
|
+
as: "p",
|
|
81
89
|
className: cx(css.currentMetric, css.loading)
|
|
82
90
|
}), /*#__PURE__*/React.createElement(Skeleton, {
|
|
91
|
+
as: "p",
|
|
83
92
|
className: cx(css.baselineMetric, css.loading)
|
|
84
93
|
})));
|
|
85
94
|
};
|
|
@@ -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
|
}
|
|
@@ -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-
|
|
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-
|
|
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 {
|
|
@@ -13,6 +13,7 @@ import css from './filters.module.css';
|
|
|
13
13
|
const Filter = props => {
|
|
14
14
|
const {
|
|
15
15
|
className,
|
|
16
|
+
as: Component = 'div',
|
|
16
17
|
buttonClassName,
|
|
17
18
|
label,
|
|
18
19
|
name,
|
|
@@ -21,7 +22,7 @@ const Filter = props => {
|
|
|
21
22
|
} = props;
|
|
22
23
|
const id = `filter-${name}`;
|
|
23
24
|
const rootClassName = cx(css.filter, className);
|
|
24
|
-
return /*#__PURE__*/React.createElement(
|
|
25
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
25
26
|
className: rootClassName
|
|
26
27
|
}, /*#__PURE__*/React.createElement(FlexStack, {
|
|
27
28
|
space: "xxxsmall",
|
|
@@ -44,6 +45,7 @@ const Filter = props => {
|
|
|
44
45
|
|
|
45
46
|
Filter.propTypes = {
|
|
46
47
|
className: PropTypes.string,
|
|
48
|
+
as: PropTypes.elementType,
|
|
47
49
|
buttonClassName: PropTypes.string,
|
|
48
50
|
name: PropTypes.string.isRequired,
|
|
49
51
|
label: PropTypes.string.isRequired,
|
|
@@ -51,6 +53,7 @@ Filter.propTypes = {
|
|
|
51
53
|
};
|
|
52
54
|
Filter.defaultProps = {
|
|
53
55
|
className: '',
|
|
56
|
+
as: 'div',
|
|
54
57
|
buttonClassName: '',
|
|
55
58
|
getOnOnlyClick: null
|
|
56
59
|
};
|
|
@@ -123,18 +126,17 @@ const FilterGroup = props => {
|
|
|
123
126
|
[id]: true
|
|
124
127
|
});
|
|
125
128
|
|
|
126
|
-
return /*#__PURE__*/React.createElement(
|
|
127
|
-
key: id
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}), /*#__PURE__*/React.createElement(Filter, {
|
|
129
|
+
return /*#__PURE__*/React.createElement(Filter, {
|
|
130
|
+
key: id,
|
|
131
|
+
className: menuItemClassName,
|
|
132
|
+
as: MenuItem,
|
|
131
133
|
name: id,
|
|
132
134
|
label: itemData.label,
|
|
133
135
|
onChange: onCheckboxChange,
|
|
134
136
|
checked: values[id],
|
|
135
137
|
disabled: itemData.disabled,
|
|
136
138
|
getOnOnlyClick: getOnOnlyClick
|
|
137
|
-
})
|
|
139
|
+
});
|
|
138
140
|
})), /*#__PURE__*/React.createElement("div", {
|
|
139
141
|
className: css.filterGroupActions
|
|
140
142
|
}, areAllGroupItemsChecked ? /*#__PURE__*/React.createElement(MenuItem, {
|
|
@@ -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-
|
|
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:
|
|
39
|
-
|
|
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-
|
|
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-
|
|
106
|
+
margin-bottom: calc(0px - var(--space-xxsmall));
|
|
108
107
|
border-top: 1px solid var(--color-outline);
|
|
109
108
|
}
|
|
110
109
|
|
|
@@ -29,7 +29,8 @@ export const HoverCard = props => {
|
|
|
29
29
|
children
|
|
30
30
|
} = props;
|
|
31
31
|
const state = useHovercardState({
|
|
32
|
-
gutter: 8
|
|
32
|
+
gutter: 8,
|
|
33
|
+
timeout: 700
|
|
33
34
|
});
|
|
34
35
|
const hoverCardProps = useHovercard({
|
|
35
36
|
state,
|
|
@@ -37,11 +38,6 @@ export const HoverCard = props => {
|
|
|
37
38
|
}); // Fallback to span if no href
|
|
38
39
|
|
|
39
40
|
const Component = resolveComponent(as, href);
|
|
40
|
-
|
|
41
|
-
const handleOnClick = event => {
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
};
|
|
44
|
-
|
|
45
41
|
return /*#__PURE__*/React.createElement("div", {
|
|
46
42
|
className: cx(css.root, className)
|
|
47
43
|
}, /*#__PURE__*/React.createElement(HovercardAnchor, {
|
|
@@ -54,8 +50,7 @@ export const HoverCard = props => {
|
|
|
54
50
|
className: cx(css.hoverCard, hoverCardClassName),
|
|
55
51
|
style: {
|
|
56
52
|
zIndex: 10000
|
|
57
|
-
}
|
|
58
|
-
onClick: handleOnClick
|
|
53
|
+
}
|
|
59
54
|
}), /*#__PURE__*/React.createElement(HovercardArrow, {
|
|
60
55
|
size: 24
|
|
61
56
|
}), typeof children === 'function' ? children({
|
|
@@ -7,16 +7,22 @@ import css from './skeleton.module.css';
|
|
|
7
7
|
export const Skeleton = props => {
|
|
8
8
|
const {
|
|
9
9
|
className,
|
|
10
|
+
as: Component,
|
|
11
|
+
block,
|
|
10
12
|
...restProps
|
|
11
13
|
} = props;
|
|
12
|
-
const rootClassName = cx(css.root, className);
|
|
13
|
-
return /*#__PURE__*/React.createElement(
|
|
14
|
+
const rootClassName = cx(css.root, className, block && css.block);
|
|
15
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
14
16
|
className: rootClassName
|
|
15
17
|
}, restProps));
|
|
16
18
|
};
|
|
17
19
|
Skeleton.propTypes = {
|
|
18
|
-
className: PropTypes.string
|
|
20
|
+
className: PropTypes.string,
|
|
21
|
+
as: PropTypes.elementType,
|
|
22
|
+
block: PropTypes.bool
|
|
19
23
|
};
|
|
20
24
|
Skeleton.defaultProps = {
|
|
21
|
-
className: ''
|
|
25
|
+
className: '',
|
|
26
|
+
as: 'p',
|
|
27
|
+
block: false
|
|
22
28
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
.root {
|
|
2
|
-
|
|
3
|
-
background: linear-gradient(transparent 10%, currentColor 10.1%, currentColor 90%, transparent 90.1%);
|
|
2
|
+
background: linear-gradient(transparent 12.5%, currentColor 12.6%, currentColor 86.4%, transparent 86.5%);
|
|
4
3
|
opacity: 0.06;
|
|
5
4
|
pointer-events: none;
|
|
5
|
+
min-width: 6em;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/** empty char to keep the text height */
|
|
@@ -11,3 +11,7 @@
|
|
|
11
11
|
content: '\A0';
|
|
12
12
|
color: transparent;
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
.block {
|
|
16
|
+
background: currentColor;
|
|
17
|
+
}
|
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { getWrapperDecorator } from '../../stories';
|
|
4
2
|
import { Skeleton } from '.';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export default {
|
|
4
|
+
title: 'UI/Skeleton',
|
|
5
|
+
component: Skeleton
|
|
6
|
+
};
|
|
7
|
+
export const MultipleTextLines = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Skeleton, {
|
|
8
|
+
as: "h1",
|
|
9
|
+
style: {
|
|
10
|
+
outline: '1px solid magenta'
|
|
11
|
+
}
|
|
12
|
+
}), /*#__PURE__*/React.createElement(Skeleton, {
|
|
13
|
+
as: "h2",
|
|
14
|
+
style: {
|
|
15
|
+
outline: '1px solid magenta'
|
|
16
|
+
}
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Skeleton, {
|
|
18
|
+
as: "p",
|
|
19
|
+
style: {
|
|
20
|
+
outline: '1px solid magenta'
|
|
21
|
+
}
|
|
22
|
+
}), /*#__PURE__*/React.createElement(Skeleton, {
|
|
23
|
+
style: {
|
|
24
|
+
outline: '1px solid pink'
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
export const Block = () => /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
style: {
|
|
29
|
+
outline: '1px solid magenta'
|
|
30
|
+
}
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Skeleton, {
|
|
32
|
+
as: "div",
|
|
33
|
+
block: true
|
|
34
|
+
}));
|