@pingux/astro 2.19.0-alpha.1 → 2.19.0-alpha.2
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/cjs/components/Text/Text.styles.d.ts +31 -5
- package/lib/cjs/components/Text/Text.styles.js +6 -4
- package/lib/cjs/experimental/PanelHeader/PanelHeader.js +20 -20
- package/lib/cjs/experimental/PanelHeader/PanelHeader.mdx +11 -4
- package/lib/cjs/experimental/PanelHeader/PanelHeader.stories.js +33 -2
- package/lib/cjs/experimental/PanelHeader/PanelHeader.styles.js +15 -11
- package/lib/cjs/experimental/PanelHeader/PanelHeader.test.js +48 -4
- package/lib/cjs/experimental/PanelHeader/controls/PanelHeaderSwitchField.stories.js +1 -2
- package/lib/components/Text/Text.styles.js +6 -4
- package/lib/experimental/PanelHeader/PanelHeader.js +21 -21
- package/lib/experimental/PanelHeader/PanelHeader.mdx +11 -4
- package/lib/experimental/PanelHeader/PanelHeader.stories.js +29 -0
- package/lib/experimental/PanelHeader/PanelHeader.styles.js +15 -11
- package/lib/experimental/PanelHeader/PanelHeader.test.js +45 -1
- package/lib/experimental/PanelHeader/controls/PanelHeaderSwitchField.stories.js +1 -2
- package/package.json +1 -1
@@ -207,13 +207,13 @@ export declare const text: {
|
|
207
207
|
wordBreak: string;
|
208
208
|
};
|
209
209
|
listViewItemSubtext: {
|
210
|
+
textOverflow: string;
|
211
|
+
overflow: string;
|
212
|
+
whiteSpace: string;
|
210
213
|
alignSelf: string;
|
211
214
|
fontSize: string;
|
212
215
|
lineHeight: string;
|
213
216
|
my: string;
|
214
|
-
textOverflow: string;
|
215
|
-
overflow: string;
|
216
|
-
whiteSpace: string;
|
217
217
|
color: string;
|
218
218
|
fontFamily: string;
|
219
219
|
fontWeight: number;
|
@@ -224,11 +224,11 @@ export declare const text: {
|
|
224
224
|
wordBreak: string;
|
225
225
|
};
|
226
226
|
listViewItemText: {
|
227
|
-
alignSelf: string;
|
228
|
-
fontSize: string;
|
229
227
|
textOverflow: string;
|
230
228
|
overflow: string;
|
231
229
|
whiteSpace: string;
|
230
|
+
alignSelf: string;
|
231
|
+
fontSize: string;
|
232
232
|
color: string;
|
233
233
|
fontFamily: string;
|
234
234
|
fontWeight: number;
|
@@ -243,6 +243,32 @@ export declare const text: {
|
|
243
243
|
color: string;
|
244
244
|
fontFamily: string;
|
245
245
|
};
|
246
|
+
panelHeaderSubtext: {
|
247
|
+
alignSelf: string;
|
248
|
+
fontSize: string;
|
249
|
+
lineHeight: string;
|
250
|
+
my: string;
|
251
|
+
color: string;
|
252
|
+
fontFamily: string;
|
253
|
+
fontWeight: number;
|
254
|
+
display: string;
|
255
|
+
overflowWrap: string;
|
256
|
+
maxWidth: string;
|
257
|
+
wordWrap: string;
|
258
|
+
wordBreak: string;
|
259
|
+
};
|
260
|
+
panelHeaderText: {
|
261
|
+
alignSelf: string;
|
262
|
+
fontSize: string;
|
263
|
+
color: string;
|
264
|
+
fontFamily: string;
|
265
|
+
fontWeight: number;
|
266
|
+
display: string;
|
267
|
+
overflowWrap: string;
|
268
|
+
maxWidth: string;
|
269
|
+
wordWrap: string;
|
270
|
+
wordBreak: string;
|
271
|
+
};
|
246
272
|
sectionTitle: {
|
247
273
|
fontSize: string;
|
248
274
|
fontWeight: number;
|
@@ -89,11 +89,11 @@ var textEllipsis = {
|
|
89
89
|
overflow: 'hidden',
|
90
90
|
whiteSpace: 'nowrap'
|
91
91
|
};
|
92
|
-
var listViewItemText = _objectSpread(_objectSpread(
|
92
|
+
var listViewItemText = _objectSpread(_objectSpread({}, bodyStrong), {}, {
|
93
93
|
alignSelf: 'start',
|
94
94
|
fontSize: 'md'
|
95
95
|
});
|
96
|
-
var listViewItemSubtext = _objectSpread(_objectSpread(
|
96
|
+
var listViewItemSubtext = _objectSpread(_objectSpread({}, subtitle), {}, {
|
97
97
|
alignSelf: 'start',
|
98
98
|
fontSize: 'sm',
|
99
99
|
lineHeight: '16px',
|
@@ -180,13 +180,15 @@ var text = {
|
|
180
180
|
fontWeight: 0,
|
181
181
|
color: 'text.secondary'
|
182
182
|
}, textEllipsis),
|
183
|
-
listViewItemSubtext: listViewItemSubtext,
|
184
|
-
listViewItemText: listViewItemText,
|
183
|
+
listViewItemSubtext: _objectSpread(_objectSpread({}, listViewItemSubtext), textEllipsis),
|
184
|
+
listViewItemText: _objectSpread(_objectSpread({}, listViewItemText), textEllipsis),
|
185
185
|
placeholder: {
|
186
186
|
fontWeight: -1,
|
187
187
|
color: 'text.secondary',
|
188
188
|
fontFamily: 'standard'
|
189
189
|
},
|
190
|
+
panelHeaderSubtext: listViewItemSubtext,
|
191
|
+
panelHeaderText: listViewItemText,
|
190
192
|
sectionTitle: sectionTitle,
|
191
193
|
subtitle: subtitle,
|
192
194
|
tabLabel: tabLabel,
|
@@ -37,47 +37,47 @@ var PanelHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
37
37
|
data = _ref.data,
|
38
38
|
others = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
39
39
|
var icon = data.icon,
|
40
|
+
image = data.image,
|
40
41
|
subtext = data.subtext,
|
41
42
|
text = data.text;
|
43
|
+
var getWrapperVariant = function getWrapperVariant() {
|
44
|
+
if (image && !icon) return 'panelHeader.imageWrapper';
|
45
|
+
return 'panelHeader.wrapper';
|
46
|
+
};
|
42
47
|
var renderIcon = (0, _react2.jsx)(_index.Box, {
|
43
|
-
|
44
|
-
width: 25,
|
45
|
-
color: 'accent.40'
|
46
|
-
}
|
48
|
+
width: "25px"
|
47
49
|
}, icon && (0, _react2.jsx)(_index.Icon, {
|
50
|
+
color: "accent.40",
|
48
51
|
icon: icon,
|
49
52
|
size: "md",
|
50
53
|
title: {
|
51
54
|
name: (0, _concat["default"])(_context = "".concat(text)).call(_context, PANEL_HEADER_ICON)
|
52
55
|
}
|
53
56
|
}));
|
57
|
+
var renderImage = !icon && image && (0, _react2.jsx)(_index.Box, {
|
58
|
+
width: "35px"
|
59
|
+
}, (0, _react2.jsx)(_index.Image, {
|
60
|
+
src: image.src,
|
61
|
+
alt: image.alt,
|
62
|
+
"aria-label": image['aria-label']
|
63
|
+
}));
|
54
64
|
var renderData = (0, _react2.jsx)(_index.Box, {
|
55
65
|
isRow: true,
|
56
66
|
variant: "panelHeader.data"
|
57
|
-
}, renderIcon, (0, _react2.jsx)(_index.Box, {
|
58
|
-
|
59
|
-
ml: 'md'
|
60
|
-
}
|
67
|
+
}, icon ? renderIcon : renderImage, (0, _react2.jsx)(_index.Box, {
|
68
|
+
variant: getWrapperVariant()
|
61
69
|
}, text && (0, _react2.jsx)(_index.Text, {
|
62
|
-
variant: "
|
63
|
-
sx: {
|
64
|
-
alignSelf: 'start',
|
65
|
-
fontSize: 'md'
|
66
|
-
}
|
70
|
+
variant: "panelHeaderText"
|
67
71
|
}, text), subtext && (0, _react2.jsx)(_index.Text, {
|
68
|
-
variant: "
|
69
|
-
sx: {
|
70
|
-
fontSize: 'sm',
|
71
|
-
lineHeight: '16px',
|
72
|
-
my: '1px'
|
73
|
-
}
|
72
|
+
variant: "panelHeaderSubtext"
|
74
73
|
}, subtext)));
|
75
74
|
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
76
75
|
variant: "panelHeader.container",
|
77
76
|
className: className,
|
78
77
|
ref: ref
|
79
78
|
}, others), (0, _react2.jsx)(_index.Box, {
|
80
|
-
|
79
|
+
isRow: true,
|
80
|
+
variant: getWrapperVariant()
|
81
81
|
}, renderData, (0, _react2.jsx)(_index.Box, {
|
82
82
|
isRow: true,
|
83
83
|
variant: "panelHeader.controls"
|
@@ -4,16 +4,23 @@ import { Meta } from '@storybook/addon-docs';
|
|
4
4
|
|
5
5
|
# PanelHeader
|
6
6
|
|
7
|
-
The PanelHeader component allows for easy creation of header items within a panel. It comes with pre-defined styles that match Ping specs. You can utilize the `data` prop to pass in text, subtext, and an mdi or svg icon.
|
7
|
+
The PanelHeader component allows for easy creation of header items within a panel. It comes with pre-defined styles that match Ping specs. You can utilize the `data` prop to pass in text, subtext, image and an mdi or svg icon.
|
8
8
|
|
9
9
|
### Recommended Use
|
10
10
|
This component is intended to be used as a header within a panel.
|
11
11
|
|
12
|
+
#### Icons and Images
|
13
|
+
Add an icon by passing an mdi or svg icon to the `data.icon` prop. Default size is 25px.
|
14
|
+
|
15
|
+
Add an image by passing an object with a `src` key to the `data.image` prop. `alt` and `aria-label` keys are supported but not required. Default size is 35px.
|
16
|
+
|
17
|
+
If both an icon and an image are provided the icon will be rendered.
|
18
|
+
|
12
19
|
#### Children
|
13
20
|
To add action controls, include control elements as `{children}`. All elements passed in this way will be right-justified and center-aligned. You can use the following pre-styled control components to easily match Ping specs:
|
14
|
-
- [
|
15
|
-
- [PanelHeaderMenu](./?path=/
|
16
|
-
- [PanelHeaderSwitchField](./?path=/
|
21
|
+
- [PanelHeaderCloseButton](./?path=/docs/experimental-panelheader-controls-panelheaderclosebutton--docs)
|
22
|
+
- [PanelHeaderMenu](./?path=/docs/experimental-panelheader-controls-panelheadermenu--docs)
|
23
|
+
- [PanelHeaderSwitchField](./?path=/docs/experimental-panelheader-controls-panelheaderswitchfield--docs)
|
17
24
|
|
18
25
|
### Note:
|
19
26
|
Components styled to match design specs may be updated over time as design specs change. Be aware that styles within this component may undergo minor adjustments over time to stay in sync with the latest design specifications.
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
5
5
|
_Object$defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
|
-
exports["default"] = exports.WithSubtext = exports.WithControls = exports.Default = void 0;
|
8
|
+
exports["default"] = exports.WithSubtext = exports.WithImage = exports.WithExtraLongText = exports.WithControls = exports.Default = void 0;
|
9
9
|
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectDestructuringEmpty"));
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
@@ -13,6 +13,7 @@ var _AccountIcon = _interopRequireDefault(require("@pingux/mdi-react/AccountIcon
|
|
13
13
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
14
14
|
var _listViewItemAttributes = require("../../components/ListViewItem/listViewItemAttributes");
|
15
15
|
var _index = require("../../index");
|
16
|
+
var _images = require("../../utils/devUtils/constants/images");
|
16
17
|
var _PanelHeader = _interopRequireDefault(require("./PanelHeader.mdx"));
|
17
18
|
var _react2 = require("@emotion/react");
|
18
19
|
var _default = {
|
@@ -68,4 +69,34 @@ var WithControls = function WithControls(_ref3) {
|
|
68
69
|
key: "delete"
|
69
70
|
}, "Delete user")), (0, _react2.jsx)(_index.PanelHeaderCloseButton, null));
|
70
71
|
};
|
71
|
-
exports.WithControls = WithControls;
|
72
|
+
exports.WithControls = WithControls;
|
73
|
+
var WithImage = function WithImage() {
|
74
|
+
return (0, _react2.jsx)(_index.PanelHeader, {
|
75
|
+
data: {
|
76
|
+
image: {
|
77
|
+
src: _images.pingImg,
|
78
|
+
alt: 'Ping Identity Logo',
|
79
|
+
'aria-label': 'Ping Identity Logo'
|
80
|
+
},
|
81
|
+
text: 'Fons Vernall'
|
82
|
+
}
|
83
|
+
});
|
84
|
+
};
|
85
|
+
exports.WithImage = WithImage;
|
86
|
+
var WithExtraLongText = function WithExtraLongText(_ref4) {
|
87
|
+
var args = (0, _extends2["default"])({}, ((0, _objectDestructuringEmpty2["default"])(_ref4), _ref4));
|
88
|
+
return (0, _react2.jsx)(_index.PanelHeader, (0, _extends2["default"])({}, args, {
|
89
|
+
data: {
|
90
|
+
icon: _AccountIcon["default"],
|
91
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
92
|
+
subtext: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
|
93
|
+
}
|
94
|
+
}), (0, _react2.jsx)(_index.PanelHeaderSwitchField, null), (0, _react2.jsx)(_index.PanelHeaderMenu, null, (0, _react2.jsx)(_index.Item, {
|
95
|
+
key: "enable"
|
96
|
+
}, "Enable user"), (0, _react2.jsx)(_index.Item, {
|
97
|
+
key: "disable"
|
98
|
+
}, "Disable user"), (0, _react2.jsx)(_index.Item, {
|
99
|
+
key: "delete"
|
100
|
+
}, "Delete user")), (0, _react2.jsx)(_index.PanelHeaderCloseButton, null));
|
101
|
+
};
|
102
|
+
exports.WithExtraLongText = WithExtraLongText;
|
@@ -7,32 +7,36 @@ _Object$defineProperty(exports, "__esModule", {
|
|
7
7
|
exports["default"] = void 0;
|
8
8
|
var container = {
|
9
9
|
bg: 'accent.99',
|
10
|
-
justifyContent: 'center',
|
11
|
-
minHeight: 60,
|
12
10
|
borderBottom: '1px',
|
11
|
+
borderBottomColor: 'accent.90',
|
13
12
|
borderBottomStyle: 'solid',
|
14
|
-
|
13
|
+
justifyContent: 'center',
|
14
|
+
minHeight: 60
|
15
15
|
};
|
16
16
|
var controls = {
|
17
|
-
alignSelf: 'center',
|
18
17
|
alignItems: 'center',
|
18
|
+
alignSelf: 'center',
|
19
|
+
flexShrink: 0,
|
19
20
|
gap: 'sm',
|
20
|
-
ml: 'auto'
|
21
|
+
ml: 'auto',
|
22
|
+
mr: 'md'
|
21
23
|
};
|
22
24
|
var data = {
|
23
|
-
alignItems: 'center'
|
24
|
-
display: 'grid !important',
|
25
|
-
gridTemplateColumns: 'max-content auto'
|
25
|
+
alignItems: 'center'
|
26
26
|
};
|
27
27
|
var wrapper = {
|
28
|
-
display: '
|
29
|
-
|
30
|
-
|
28
|
+
display: 'flex',
|
29
|
+
flex: '1 1 0px',
|
30
|
+
ml: 'md'
|
31
|
+
};
|
32
|
+
var imageWrapper = {
|
33
|
+
ml: 'sm'
|
31
34
|
};
|
32
35
|
var _default = {
|
33
36
|
container: container,
|
34
37
|
controls: controls,
|
35
38
|
data: data,
|
39
|
+
imageWrapper: imageWrapper,
|
36
40
|
wrapper: wrapper
|
37
41
|
};
|
38
42
|
exports["default"] = _default;
|
@@ -1,26 +1,51 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
3
11
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
4
12
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
5
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
6
15
|
var _react = _interopRequireDefault(require("react"));
|
7
16
|
var _AccountIcon = _interopRequireDefault(require("@pingux/mdi-react/AccountIcon"));
|
17
|
+
var _react2 = require("@testing-library/react");
|
8
18
|
var _index = require("../../index");
|
19
|
+
var _images = require("../../utils/devUtils/constants/images");
|
9
20
|
var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
|
10
21
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
11
22
|
var _PanelHeader = require("./PanelHeader");
|
12
|
-
var
|
23
|
+
var _react3 = require("@emotion/react");
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
26
|
var defaultProps = {
|
14
27
|
data: {
|
15
28
|
text: 'testText',
|
16
29
|
subtext: 'testSubtext',
|
17
|
-
icon: _AccountIcon["default"]
|
30
|
+
icon: _AccountIcon["default"],
|
31
|
+
image: {
|
32
|
+
src: _images.pingImg,
|
33
|
+
alt: 'avatar',
|
34
|
+
'aria-label': 'avatar'
|
35
|
+
}
|
18
36
|
}
|
19
37
|
};
|
20
38
|
var getComponent = function getComponent() {
|
21
39
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
22
|
-
return (0, _testWrapper.render)((0,
|
40
|
+
return (0, _testWrapper.render)((0, _react3.jsx)(_index.PanelHeader, (0, _extends2["default"])({}, defaultProps, props)));
|
23
41
|
};
|
42
|
+
var fallbackImageObj = null;
|
43
|
+
jest.mock('../../hooks/useFallbackImage', function () {
|
44
|
+
return function (props) {
|
45
|
+
fallbackImageObj = _objectSpread({}, props);
|
46
|
+
return [];
|
47
|
+
};
|
48
|
+
});
|
24
49
|
|
25
50
|
// Need to be added to each test file to test accessibility using axe.
|
26
51
|
(0, _testAxe["default"])(getComponent);
|
@@ -39,8 +64,27 @@ describe('PanelHeader', function () {
|
|
39
64
|
});
|
40
65
|
test('renders children', function () {
|
41
66
|
getComponent({
|
42
|
-
children: (0,
|
67
|
+
children: (0, _react3.jsx)(_index.PanelHeaderSwitchField, null)
|
43
68
|
});
|
44
69
|
_testWrapper.screen.getByRole('switch');
|
45
70
|
});
|
71
|
+
});
|
72
|
+
test('renders icon if both icon and image are passed', function () {
|
73
|
+
getComponent();
|
74
|
+
var icon = _testWrapper.screen.getByRole('img');
|
75
|
+
expect(icon).not.toHaveAttribute('src', _images.pingImg);
|
76
|
+
expect(icon.tagName.toLowerCase()).toBe('svg');
|
77
|
+
expect(icon.tagName.toLowerCase()).not.toBe('img');
|
78
|
+
});
|
79
|
+
test('renders image', function () {
|
80
|
+
delete defaultProps.data.icon;
|
81
|
+
getComponent();
|
82
|
+
(0, _react2.act)(function () {
|
83
|
+
fallbackImageObj.onImageLoad();
|
84
|
+
});
|
85
|
+
var image = _testWrapper.screen.getByRole('img');
|
86
|
+
expect(image.tagName.toLowerCase()).toBe('img');
|
87
|
+
expect(image).toHaveAttribute('src', _images.pingImg);
|
88
|
+
expect(image).toHaveAttribute('alt', 'avatar');
|
89
|
+
expect(image).toHaveAttribute('aria-label', 'avatar');
|
46
90
|
});
|
@@ -17,7 +17,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
17
17
|
var _react = _interopRequireDefault(require("react"));
|
18
18
|
var _switchFieldAttributes = require("../../../components/SwitchField/switchFieldAttributes");
|
19
19
|
var _index = require("../../../index");
|
20
|
-
var _hoverProps = require("../../../utils/docUtils/hoverProps");
|
21
20
|
var _react2 = require("@emotion/react");
|
22
21
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
23
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
@@ -32,7 +31,7 @@ var _default = {
|
|
32
31
|
}
|
33
32
|
}
|
34
33
|
},
|
35
|
-
argTypes: _objectSpread(
|
34
|
+
argTypes: _objectSpread({}, _switchFieldAttributes.switchFieldArgTypes)
|
36
35
|
};
|
37
36
|
exports["default"] = _default;
|
38
37
|
var Default = function Default(args) {
|
@@ -80,11 +80,11 @@ var textEllipsis = {
|
|
80
80
|
overflow: 'hidden',
|
81
81
|
whiteSpace: 'nowrap'
|
82
82
|
};
|
83
|
-
var listViewItemText = _objectSpread(_objectSpread(
|
83
|
+
var listViewItemText = _objectSpread(_objectSpread({}, bodyStrong), {}, {
|
84
84
|
alignSelf: 'start',
|
85
85
|
fontSize: 'md'
|
86
86
|
});
|
87
|
-
var listViewItemSubtext = _objectSpread(_objectSpread(
|
87
|
+
var listViewItemSubtext = _objectSpread(_objectSpread({}, subtitle), {}, {
|
88
88
|
alignSelf: 'start',
|
89
89
|
fontSize: 'sm',
|
90
90
|
lineHeight: '16px',
|
@@ -171,13 +171,15 @@ export var text = {
|
|
171
171
|
fontWeight: 0,
|
172
172
|
color: 'text.secondary'
|
173
173
|
}, textEllipsis),
|
174
|
-
listViewItemSubtext: listViewItemSubtext,
|
175
|
-
listViewItemText: listViewItemText,
|
174
|
+
listViewItemSubtext: _objectSpread(_objectSpread({}, listViewItemSubtext), textEllipsis),
|
175
|
+
listViewItemText: _objectSpread(_objectSpread({}, listViewItemText), textEllipsis),
|
176
176
|
placeholder: {
|
177
177
|
fontWeight: -1,
|
178
178
|
color: 'text.secondary',
|
179
179
|
fontFamily: 'standard'
|
180
180
|
},
|
181
|
+
panelHeaderSubtext: listViewItemSubtext,
|
182
|
+
panelHeaderText: listViewItemText,
|
181
183
|
sectionTitle: sectionTitle,
|
182
184
|
subtitle: subtitle,
|
183
185
|
tabLabel: tabLabel,
|
@@ -15,7 +15,7 @@ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/obje
|
|
15
15
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
16
16
|
import React, { forwardRef } from 'react';
|
17
17
|
import { SharedItemPropTypes } from '../../components/ListViewItem/listViewItemAttributes';
|
18
|
-
import { Box, Icon, Text } from '../../index';
|
18
|
+
import { Box, Icon, Image, Text } from '../../index';
|
19
19
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
20
20
|
export var PANEL_HEADER_ICON = '-panel-header-icon';
|
21
21
|
var PanelHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
@@ -25,47 +25,47 @@ var PanelHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
25
25
|
data = _ref.data,
|
26
26
|
others = _objectWithoutProperties(_ref, _excluded);
|
27
27
|
var icon = data.icon,
|
28
|
+
image = data.image,
|
28
29
|
subtext = data.subtext,
|
29
30
|
text = data.text;
|
31
|
+
var getWrapperVariant = function getWrapperVariant() {
|
32
|
+
if (image && !icon) return 'panelHeader.imageWrapper';
|
33
|
+
return 'panelHeader.wrapper';
|
34
|
+
};
|
30
35
|
var renderIcon = ___EmotionJSX(Box, {
|
31
|
-
|
32
|
-
width: 25,
|
33
|
-
color: 'accent.40'
|
34
|
-
}
|
36
|
+
width: "25px"
|
35
37
|
}, icon && ___EmotionJSX(Icon, {
|
38
|
+
color: "accent.40",
|
36
39
|
icon: icon,
|
37
40
|
size: "md",
|
38
41
|
title: {
|
39
42
|
name: _concatInstanceProperty(_context = "".concat(text)).call(_context, PANEL_HEADER_ICON)
|
40
43
|
}
|
41
44
|
}));
|
45
|
+
var renderImage = !icon && image && ___EmotionJSX(Box, {
|
46
|
+
width: "35px"
|
47
|
+
}, ___EmotionJSX(Image, {
|
48
|
+
src: image.src,
|
49
|
+
alt: image.alt,
|
50
|
+
"aria-label": image['aria-label']
|
51
|
+
}));
|
42
52
|
var renderData = ___EmotionJSX(Box, {
|
43
53
|
isRow: true,
|
44
54
|
variant: "panelHeader.data"
|
45
|
-
}, renderIcon, ___EmotionJSX(Box, {
|
46
|
-
|
47
|
-
ml: 'md'
|
48
|
-
}
|
55
|
+
}, icon ? renderIcon : renderImage, ___EmotionJSX(Box, {
|
56
|
+
variant: getWrapperVariant()
|
49
57
|
}, text && ___EmotionJSX(Text, {
|
50
|
-
variant: "
|
51
|
-
sx: {
|
52
|
-
alignSelf: 'start',
|
53
|
-
fontSize: 'md'
|
54
|
-
}
|
58
|
+
variant: "panelHeaderText"
|
55
59
|
}, text), subtext && ___EmotionJSX(Text, {
|
56
|
-
variant: "
|
57
|
-
sx: {
|
58
|
-
fontSize: 'sm',
|
59
|
-
lineHeight: '16px',
|
60
|
-
my: '1px'
|
61
|
-
}
|
60
|
+
variant: "panelHeaderSubtext"
|
62
61
|
}, subtext)));
|
63
62
|
return ___EmotionJSX(Box, _extends({
|
64
63
|
variant: "panelHeader.container",
|
65
64
|
className: className,
|
66
65
|
ref: ref
|
67
66
|
}, others), ___EmotionJSX(Box, {
|
68
|
-
|
67
|
+
isRow: true,
|
68
|
+
variant: getWrapperVariant()
|
69
69
|
}, renderData, ___EmotionJSX(Box, {
|
70
70
|
isRow: true,
|
71
71
|
variant: "panelHeader.controls"
|
@@ -4,16 +4,23 @@ import { Meta } from '@storybook/addon-docs';
|
|
4
4
|
|
5
5
|
# PanelHeader
|
6
6
|
|
7
|
-
The PanelHeader component allows for easy creation of header items within a panel. It comes with pre-defined styles that match Ping specs. You can utilize the `data` prop to pass in text, subtext, and an mdi or svg icon.
|
7
|
+
The PanelHeader component allows for easy creation of header items within a panel. It comes with pre-defined styles that match Ping specs. You can utilize the `data` prop to pass in text, subtext, image and an mdi or svg icon.
|
8
8
|
|
9
9
|
### Recommended Use
|
10
10
|
This component is intended to be used as a header within a panel.
|
11
11
|
|
12
|
+
#### Icons and Images
|
13
|
+
Add an icon by passing an mdi or svg icon to the `data.icon` prop. Default size is 25px.
|
14
|
+
|
15
|
+
Add an image by passing an object with a `src` key to the `data.image` prop. `alt` and `aria-label` keys are supported but not required. Default size is 35px.
|
16
|
+
|
17
|
+
If both an icon and an image are provided the icon will be rendered.
|
18
|
+
|
12
19
|
#### Children
|
13
20
|
To add action controls, include control elements as `{children}`. All elements passed in this way will be right-justified and center-aligned. You can use the following pre-styled control components to easily match Ping specs:
|
14
|
-
- [
|
15
|
-
- [PanelHeaderMenu](./?path=/
|
16
|
-
- [PanelHeaderSwitchField](./?path=/
|
21
|
+
- [PanelHeaderCloseButton](./?path=/docs/experimental-panelheader-controls-panelheaderclosebutton--docs)
|
22
|
+
- [PanelHeaderMenu](./?path=/docs/experimental-panelheader-controls-panelheadermenu--docs)
|
23
|
+
- [PanelHeaderSwitchField](./?path=/docs/experimental-panelheader-controls-panelheaderswitchfield--docs)
|
17
24
|
|
18
25
|
### Note:
|
19
26
|
Components styled to match design specs may be updated over time as design specs change. Be aware that styles within this component may undergo minor adjustments over time to stay in sync with the latest design specifications.
|
@@ -5,6 +5,7 @@ import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
|
5
5
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
6
6
|
import { SharedItemArgTypes } from '../../components/ListViewItem/listViewItemAttributes';
|
7
7
|
import { Item, PanelHeader, PanelHeaderCloseButton, PanelHeaderMenu, PanelHeaderSwitchField } from '../../index';
|
8
|
+
import { pingImg } from '../../utils/devUtils/constants/images';
|
8
9
|
import PanelHeaderReadMe from './PanelHeader.mdx';
|
9
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
11
|
export default {
|
@@ -56,4 +57,32 @@ export var WithControls = function WithControls(_ref3) {
|
|
56
57
|
}, "Disable user"), ___EmotionJSX(Item, {
|
57
58
|
key: "delete"
|
58
59
|
}, "Delete user")), ___EmotionJSX(PanelHeaderCloseButton, null));
|
60
|
+
};
|
61
|
+
export var WithImage = function WithImage() {
|
62
|
+
return ___EmotionJSX(PanelHeader, {
|
63
|
+
data: {
|
64
|
+
image: {
|
65
|
+
src: pingImg,
|
66
|
+
alt: 'Ping Identity Logo',
|
67
|
+
'aria-label': 'Ping Identity Logo'
|
68
|
+
},
|
69
|
+
text: 'Fons Vernall'
|
70
|
+
}
|
71
|
+
});
|
72
|
+
};
|
73
|
+
export var WithExtraLongText = function WithExtraLongText(_ref4) {
|
74
|
+
var args = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
|
75
|
+
return ___EmotionJSX(PanelHeader, _extends({}, args, {
|
76
|
+
data: {
|
77
|
+
icon: AccountIcon,
|
78
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
79
|
+
subtext: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
|
80
|
+
}
|
81
|
+
}), ___EmotionJSX(PanelHeaderSwitchField, null), ___EmotionJSX(PanelHeaderMenu, null, ___EmotionJSX(Item, {
|
82
|
+
key: "enable"
|
83
|
+
}, "Enable user"), ___EmotionJSX(Item, {
|
84
|
+
key: "disable"
|
85
|
+
}, "Disable user"), ___EmotionJSX(Item, {
|
86
|
+
key: "delete"
|
87
|
+
}, "Delete user")), ___EmotionJSX(PanelHeaderCloseButton, null));
|
59
88
|
};
|
@@ -1,30 +1,34 @@
|
|
1
1
|
var container = {
|
2
2
|
bg: 'accent.99',
|
3
|
-
justifyContent: 'center',
|
4
|
-
minHeight: 60,
|
5
3
|
borderBottom: '1px',
|
4
|
+
borderBottomColor: 'accent.90',
|
6
5
|
borderBottomStyle: 'solid',
|
7
|
-
|
6
|
+
justifyContent: 'center',
|
7
|
+
minHeight: 60
|
8
8
|
};
|
9
9
|
var controls = {
|
10
|
-
alignSelf: 'center',
|
11
10
|
alignItems: 'center',
|
11
|
+
alignSelf: 'center',
|
12
|
+
flexShrink: 0,
|
12
13
|
gap: 'sm',
|
13
|
-
ml: 'auto'
|
14
|
+
ml: 'auto',
|
15
|
+
mr: 'md'
|
14
16
|
};
|
15
17
|
var data = {
|
16
|
-
alignItems: 'center'
|
17
|
-
display: 'grid !important',
|
18
|
-
gridTemplateColumns: 'max-content auto'
|
18
|
+
alignItems: 'center'
|
19
19
|
};
|
20
20
|
var wrapper = {
|
21
|
-
display: '
|
22
|
-
|
23
|
-
|
21
|
+
display: 'flex',
|
22
|
+
flex: '1 1 0px',
|
23
|
+
ml: 'md'
|
24
|
+
};
|
25
|
+
var imageWrapper = {
|
26
|
+
ml: 'sm'
|
24
27
|
};
|
25
28
|
export default {
|
26
29
|
container: container,
|
27
30
|
controls: controls,
|
28
31
|
data: data,
|
32
|
+
imageWrapper: imageWrapper,
|
29
33
|
wrapper: wrapper
|
30
34
|
};
|
@@ -1,8 +1,21 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
1
10
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
11
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
3
14
|
import React from 'react';
|
4
15
|
import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
16
|
+
import { act } from '@testing-library/react';
|
5
17
|
import { PanelHeader, PanelHeaderSwitchField } from '../../index';
|
18
|
+
import { pingImg } from '../../utils/devUtils/constants/images';
|
6
19
|
import axeTest from '../../utils/testUtils/testAxe';
|
7
20
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
8
21
|
import { PANEL_HEADER_ICON } from './PanelHeader';
|
@@ -11,13 +24,25 @@ var defaultProps = {
|
|
11
24
|
data: {
|
12
25
|
text: 'testText',
|
13
26
|
subtext: 'testSubtext',
|
14
|
-
icon: AccountIcon
|
27
|
+
icon: AccountIcon,
|
28
|
+
image: {
|
29
|
+
src: pingImg,
|
30
|
+
alt: 'avatar',
|
31
|
+
'aria-label': 'avatar'
|
32
|
+
}
|
15
33
|
}
|
16
34
|
};
|
17
35
|
var getComponent = function getComponent() {
|
18
36
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
19
37
|
return render(___EmotionJSX(PanelHeader, _extends({}, defaultProps, props)));
|
20
38
|
};
|
39
|
+
var fallbackImageObj = null;
|
40
|
+
jest.mock('../../hooks/useFallbackImage', function () {
|
41
|
+
return function (props) {
|
42
|
+
fallbackImageObj = _objectSpread({}, props);
|
43
|
+
return [];
|
44
|
+
};
|
45
|
+
});
|
21
46
|
|
22
47
|
// Need to be added to each test file to test accessibility using axe.
|
23
48
|
axeTest(getComponent);
|
@@ -40,4 +65,23 @@ describe('PanelHeader', function () {
|
|
40
65
|
});
|
41
66
|
screen.getByRole('switch');
|
42
67
|
});
|
68
|
+
});
|
69
|
+
test('renders icon if both icon and image are passed', function () {
|
70
|
+
getComponent();
|
71
|
+
var icon = screen.getByRole('img');
|
72
|
+
expect(icon).not.toHaveAttribute('src', pingImg);
|
73
|
+
expect(icon.tagName.toLowerCase()).toBe('svg');
|
74
|
+
expect(icon.tagName.toLowerCase()).not.toBe('img');
|
75
|
+
});
|
76
|
+
test('renders image', function () {
|
77
|
+
delete defaultProps.data.icon;
|
78
|
+
getComponent();
|
79
|
+
act(function () {
|
80
|
+
fallbackImageObj.onImageLoad();
|
81
|
+
});
|
82
|
+
var image = screen.getByRole('img');
|
83
|
+
expect(image.tagName.toLowerCase()).toBe('img');
|
84
|
+
expect(image).toHaveAttribute('src', pingImg);
|
85
|
+
expect(image).toHaveAttribute('alt', 'avatar');
|
86
|
+
expect(image).toHaveAttribute('aria-label', 'avatar');
|
43
87
|
});
|
@@ -12,7 +12,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
12
12
|
import React from 'react';
|
13
13
|
import { switchFieldArgTypes } from '../../../components/SwitchField/switchFieldAttributes';
|
14
14
|
import { PanelHeaderSwitchField } from '../../../index';
|
15
|
-
import { onHoverArgTypes } from '../../../utils/docUtils/hoverProps';
|
16
15
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
17
16
|
delete switchFieldArgTypes.label;
|
18
17
|
export default {
|
@@ -25,7 +24,7 @@ export default {
|
|
25
24
|
}
|
26
25
|
}
|
27
26
|
},
|
28
|
-
argTypes: _objectSpread(
|
27
|
+
argTypes: _objectSpread({}, switchFieldArgTypes)
|
29
28
|
};
|
30
29
|
export var Default = function Default(args) {
|
31
30
|
return ___EmotionJSX(PanelHeaderSwitchField, args);
|