@pingux/astro 2.18.1-alpha.1 → 2.18.1-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/experimental/ButtonBar/ButtonBar.js +7 -56
- package/lib/cjs/experimental/ButtonBar/ButtonBar.mdx +1 -5
- package/lib/cjs/experimental/ButtonBar/ButtonBar.stories.js +36 -67
- package/lib/cjs/experimental/ButtonBar/ButtonBar.test.js +40 -43
- package/lib/experimental/ButtonBar/ButtonBar.js +8 -57
- package/lib/experimental/ButtonBar/ButtonBar.mdx +1 -5
- package/lib/experimental/ButtonBar/ButtonBar.stories.js +33 -62
- package/lib/experimental/ButtonBar/ButtonBar.test.js +41 -44
- package/package.json +1 -1
@@ -6,55 +6,18 @@ _Object$defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
7
7
|
});
|
8
8
|
exports["default"] = void 0;
|
9
|
-
var _reverse = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reverse"));
|
10
|
-
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
11
|
-
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
12
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
13
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
15
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
17
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
18
|
-
var _buttonAttributes = require("../../components/Button/buttonAttributes");
|
19
13
|
var _index = require("../../index");
|
20
14
|
var _react2 = require("@emotion/react");
|
21
|
-
var _excluded = ["
|
22
|
-
var SaveButton = function SaveButton(props) {
|
23
|
-
return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
|
24
|
-
variant: "primary",
|
25
|
-
"data-id": "save-button"
|
26
|
-
}, props), props.text);
|
27
|
-
};
|
28
|
-
var CancelButton = function CancelButton(props) {
|
29
|
-
return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
|
30
|
-
variant: "link",
|
31
|
-
"data-id": "cancel-button"
|
32
|
-
}, props), props.text);
|
33
|
-
};
|
34
|
-
var RefreshButton = function RefreshButton(props) {
|
35
|
-
return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
|
36
|
-
"data-id": "refresh-button"
|
37
|
-
}, props), props.text);
|
38
|
-
};
|
15
|
+
var _excluded = ["align", "children"];
|
39
16
|
var ButtonBar = function ButtonBar(props) {
|
40
|
-
var
|
41
|
-
|
42
|
-
cancelButtonProps = props.cancelButtonProps,
|
43
|
-
refreshButtonProps = props.refreshButtonProps,
|
44
|
-
isJustifiedRight = props.isJustifiedRight,
|
17
|
+
var _props$align = props.align,
|
18
|
+
align = _props$align === void 0 ? 'left' : _props$align,
|
45
19
|
children = props.children,
|
46
20
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
47
|
-
var ButtonArray = [(0, _react2.jsx)(SaveButton, saveButtonProps), (0, _react2.jsx)(CancelButton, cancelButtonProps)];
|
48
|
-
var Content = function Content() {
|
49
|
-
var _context;
|
50
|
-
var content = isJustifiedRight ? (0, _reverse["default"])(_context = (0, _slice["default"])(ButtonArray).call(ButtonArray)).call(_context) : ButtonArray;
|
51
|
-
if (refreshButtonProps) {
|
52
|
-
(0, _splice["default"])(content).call(content, 1, 0, (0, _react2.jsx)(RefreshButton, refreshButtonProps));
|
53
|
-
}
|
54
|
-
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _map["default"])(content).call(content, function (child) {
|
55
|
-
return child;
|
56
|
-
}));
|
57
|
-
};
|
58
21
|
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
59
22
|
isRow: true,
|
60
23
|
gap: "md",
|
@@ -62,24 +25,12 @@ var ButtonBar = function ButtonBar(props) {
|
|
62
25
|
bg: 'white',
|
63
26
|
px: 'lg',
|
64
27
|
py: 'md',
|
65
|
-
justifyContent:
|
28
|
+
justifyContent: align === 'right' ? 'right' : 'left'
|
66
29
|
}
|
67
|
-
}, others), children
|
30
|
+
}, others), children);
|
68
31
|
};
|
69
32
|
ButtonBar.propTypes = {
|
70
|
-
|
71
|
-
cancelButtonProps: _propTypes["default"].shape(_buttonAttributes.buttonPropTypes),
|
72
|
-
refreshButtonProps: _propTypes["default"].shape(_buttonAttributes.buttonPropTypes),
|
73
|
-
isJustifiedRight: _propTypes["default"].bool
|
74
|
-
};
|
75
|
-
SaveButton.propTypes = {
|
76
|
-
text: _propTypes["default"].string
|
77
|
-
};
|
78
|
-
CancelButton.propTypes = {
|
79
|
-
text: _propTypes["default"].string
|
80
|
-
};
|
81
|
-
RefreshButton.propTypes = {
|
82
|
-
text: _propTypes["default"].string
|
33
|
+
align: _propTypes["default"].oneOf(['left', 'right'])
|
83
34
|
};
|
84
35
|
var _default = ButtonBar;
|
85
36
|
exports["default"] = _default;
|
@@ -6,8 +6,4 @@ import { Meta } from '@storybook/addon-docs';
|
|
6
6
|
|
7
7
|
This is a composed component that renders children in a simplified, organized and consistent manner.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
The **isJustifiedRight** prop will reverse the order of the children, and justify them to the right.
|
12
|
-
|
13
|
-
Supplying the ButtonBar with children using default React syntax will override the default render and render the custom children.
|
9
|
+
If the **align** prop is set to right it will justify the children to the right. Default is left justification.
|
@@ -5,8 +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.
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
8
|
+
exports["default"] = exports.RightAligned = exports.Default = void 0;
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
11
10
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
12
11
|
var _ = require("../..");
|
@@ -24,77 +23,47 @@ var _default = {
|
|
24
23
|
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_ButtonBar["default"], null), (0, _react2.jsx)(_storybookDocsLayout["default"], null));
|
25
24
|
}
|
26
25
|
}
|
26
|
+
},
|
27
|
+
argTypes: {
|
28
|
+
align: {
|
29
|
+
control: {
|
30
|
+
type: 'text'
|
31
|
+
}
|
32
|
+
}
|
27
33
|
}
|
28
34
|
};
|
29
35
|
exports["default"] = _default;
|
30
36
|
var Default = function Default(args) {
|
31
|
-
return (0, _react2.jsx)(_.ButtonBar, (0,
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
return alert('Save button pressed');
|
37
|
-
}
|
38
|
-
},
|
39
|
-
cancelButtonProps: {
|
40
|
-
key: 'cancel button',
|
41
|
-
text: 'Cancel',
|
42
|
-
onPress: function onPress() {
|
43
|
-
return alert('Cancel button pressed');
|
44
|
-
}
|
37
|
+
return (0, _react2.jsx)(_.ButtonBar, args, (0, _react2.jsx)(_.Button, {
|
38
|
+
variant: "primary",
|
39
|
+
"data-id": "save-button",
|
40
|
+
onPress: function onPress() {
|
41
|
+
return alert('Save button pressed');
|
45
42
|
}
|
46
|
-
},
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
saveButtonProps: {
|
52
|
-
key: 'save button',
|
53
|
-
text: 'Save',
|
54
|
-
onPress: function onPress() {
|
55
|
-
return alert('Save button pressed');
|
56
|
-
}
|
57
|
-
},
|
58
|
-
cancelButtonProps: {
|
59
|
-
key: 'cancel button',
|
60
|
-
text: 'Cancel',
|
61
|
-
onPress: function onPress() {
|
62
|
-
return alert('Cancel button pressed');
|
63
|
-
}
|
64
|
-
},
|
65
|
-
refreshButtonProps: {
|
66
|
-
key: 'refresh button',
|
67
|
-
text: 'Refresh',
|
68
|
-
onPress: function onPress() {
|
69
|
-
return alert('Refresh button pressed');
|
70
|
-
}
|
43
|
+
}, "Save"), (0, _react2.jsx)(_.Button, {
|
44
|
+
variant: "link",
|
45
|
+
"data-id": "cancel-button",
|
46
|
+
onPress: function onPress() {
|
47
|
+
return alert('Cancel button pressed');
|
71
48
|
}
|
72
|
-
},
|
49
|
+
}, "Cancel"));
|
73
50
|
};
|
74
|
-
exports.
|
75
|
-
var
|
51
|
+
exports.Default = Default;
|
52
|
+
var RightAligned = function RightAligned() {
|
76
53
|
return (0, _react2.jsx)(_.ButtonBar, {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
isJustifiedRight: true
|
92
|
-
});
|
93
|
-
};
|
94
|
-
exports.JustifiedRight = JustifiedRight;
|
95
|
-
var WithChildren = function WithChildren(args) {
|
96
|
-
return (0, _react2.jsx)(_.ButtonBar, args, (0, _react2.jsx)(_.Button, null, "Custom Button!"), (0, _react2.jsx)(_.Button, {
|
97
|
-
variant: "link"
|
98
|
-
}, "Custom Link!"));
|
54
|
+
align: "right"
|
55
|
+
}, (0, _react2.jsx)(_.Button, {
|
56
|
+
variant: "primary",
|
57
|
+
"data-id": "next-button",
|
58
|
+
onPress: function onPress() {
|
59
|
+
return alert('Next button pressed');
|
60
|
+
}
|
61
|
+
}, "Next"), (0, _react2.jsx)(_.Button, {
|
62
|
+
variant: "link",
|
63
|
+
"data-id": "cancel-button",
|
64
|
+
onPress: function onPress() {
|
65
|
+
return alert('Cancel button pressed');
|
66
|
+
}
|
67
|
+
}, "Cancel"));
|
99
68
|
};
|
100
|
-
exports.
|
69
|
+
exports.RightAligned = RightAligned;
|
@@ -8,35 +8,24 @@ var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
|
|
8
8
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
9
9
|
var _react2 = require("@emotion/react");
|
10
10
|
var testId = 'test-ButtonBar';
|
11
|
-
var saveButtonProps = {
|
12
|
-
key: 'save button',
|
13
|
-
text: 'Save',
|
14
|
-
onPress: function onPress() {
|
15
|
-
return alert('Save button pressed');
|
16
|
-
}
|
17
|
-
};
|
18
|
-
var cancelButtonProps = {
|
19
|
-
key: 'cancel button',
|
20
|
-
text: 'Cancel',
|
21
|
-
onPress: function onPress() {
|
22
|
-
return alert('Cancel button pressed');
|
23
|
-
}
|
24
|
-
};
|
25
|
-
var refreshButtonProps = {
|
26
|
-
key: 'refresh button',
|
27
|
-
text: 'Refresh',
|
28
|
-
onPress: function onPress() {
|
29
|
-
return alert('Refresh button pressed');
|
30
|
-
}
|
31
|
-
};
|
32
11
|
var defaultProps = {
|
33
|
-
'data-testid': testId
|
34
|
-
saveButtonProps: saveButtonProps,
|
35
|
-
cancelButtonProps: cancelButtonProps
|
12
|
+
'data-testid': testId
|
36
13
|
};
|
37
14
|
var getComponent = function getComponent() {
|
38
15
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
39
|
-
return (0, _testWrapper.render)((0, _react2.jsx)(_.ButtonBar, (0, _extends2["default"])({}, defaultProps, props))
|
16
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(_.ButtonBar, (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_.Button, {
|
17
|
+
variant: "primary",
|
18
|
+
"data-id": "save-button",
|
19
|
+
onPress: function onPress() {
|
20
|
+
return alert('Save button pressed');
|
21
|
+
}
|
22
|
+
}, "Save"), (0, _react2.jsx)(_.Button, {
|
23
|
+
variant: "link",
|
24
|
+
"data-id": "cancel-button",
|
25
|
+
onPress: function onPress() {
|
26
|
+
return alert('Cancel button pressed');
|
27
|
+
}
|
28
|
+
}, "Cancel")));
|
40
29
|
};
|
41
30
|
var getComponentCustomChildren = function getComponentCustomChildren() {
|
42
31
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -55,22 +44,11 @@ test('ButtonBar does render', function () {
|
|
55
44
|
var element = _testWrapper.screen.getByTestId(testId);
|
56
45
|
expect(element).toBeInTheDocument();
|
57
46
|
});
|
58
|
-
test('renders save and cancel buttons', function () {
|
47
|
+
test('renders child save and cancel buttons', function () {
|
59
48
|
getComponent();
|
60
|
-
var saveButton = _testWrapper.screen.getByText(
|
49
|
+
var saveButton = _testWrapper.screen.getByText('Save');
|
61
50
|
expect(saveButton).toBeInTheDocument();
|
62
|
-
var cancelButton = _testWrapper.screen.getByText(
|
63
|
-
expect(cancelButton).toBeInTheDocument();
|
64
|
-
});
|
65
|
-
test('renders all three buttons', function () {
|
66
|
-
getComponent({
|
67
|
-
refreshButtonProps: refreshButtonProps
|
68
|
-
});
|
69
|
-
var saveButton = _testWrapper.screen.getByText(saveButtonProps.text);
|
70
|
-
expect(saveButton).toBeInTheDocument();
|
71
|
-
var refreshButton = _testWrapper.screen.getByText(refreshButtonProps.text);
|
72
|
-
expect(refreshButton).toBeInTheDocument();
|
73
|
-
var cancelButton = _testWrapper.screen.getByText(cancelButtonProps.text);
|
51
|
+
var cancelButton = _testWrapper.screen.getByText('Cancel');
|
74
52
|
expect(cancelButton).toBeInTheDocument();
|
75
53
|
});
|
76
54
|
test('renders custom children', function () {
|
@@ -85,10 +63,29 @@ test('renders custom text', function () {
|
|
85
63
|
var firstText = _testWrapper.screen.getByText('custom text');
|
86
64
|
expect(firstText).toBeInTheDocument();
|
87
65
|
});
|
88
|
-
test('
|
66
|
+
test('justify-content right when align prop set to right', function () {
|
89
67
|
getComponent({
|
90
|
-
|
68
|
+
align: 'right'
|
91
69
|
});
|
92
|
-
var
|
93
|
-
expect(
|
70
|
+
var element = _testWrapper.screen.getByTestId(testId);
|
71
|
+
expect(element).toHaveStyleRule('justify-content', 'right');
|
72
|
+
});
|
73
|
+
test('justify-content left when align prop is set to left', function () {
|
74
|
+
getComponent({
|
75
|
+
align: 'left'
|
76
|
+
});
|
77
|
+
var element = _testWrapper.screen.getByTestId(testId);
|
78
|
+
expect(element).toHaveStyleRule('justify-content', 'left');
|
79
|
+
});
|
80
|
+
test('justify-content left when align prop is excluded', function () {
|
81
|
+
getComponent();
|
82
|
+
var element = _testWrapper.screen.getByTestId(testId);
|
83
|
+
expect(element).toHaveStyleRule('justify-content', 'left');
|
84
|
+
});
|
85
|
+
test('an error is thrown when align has invalid prop value', function () {
|
86
|
+
expect(function () {
|
87
|
+
return getComponent({
|
88
|
+
align: 'rihgt'
|
89
|
+
});
|
90
|
+
}).toThrow('Failed prop type');
|
94
91
|
});
|
@@ -1,52 +1,15 @@
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
2
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
|
-
|
4
|
-
|
5
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
6
|
-
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
7
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
8
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["align", "children"];
|
9
4
|
import React from 'react';
|
10
5
|
import PropTypes from 'prop-types';
|
11
|
-
import {
|
12
|
-
import { Box, Button } from '../../index';
|
6
|
+
import { Box } from '../../index';
|
13
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
|
-
var SaveButton = function SaveButton(props) {
|
15
|
-
return ___EmotionJSX(Button, _extends({
|
16
|
-
variant: "primary",
|
17
|
-
"data-id": "save-button"
|
18
|
-
}, props), props.text);
|
19
|
-
};
|
20
|
-
var CancelButton = function CancelButton(props) {
|
21
|
-
return ___EmotionJSX(Button, _extends({
|
22
|
-
variant: "link",
|
23
|
-
"data-id": "cancel-button"
|
24
|
-
}, props), props.text);
|
25
|
-
};
|
26
|
-
var RefreshButton = function RefreshButton(props) {
|
27
|
-
return ___EmotionJSX(Button, _extends({
|
28
|
-
"data-id": "refresh-button"
|
29
|
-
}, props), props.text);
|
30
|
-
};
|
31
8
|
var ButtonBar = function ButtonBar(props) {
|
32
|
-
var
|
33
|
-
|
34
|
-
cancelButtonProps = props.cancelButtonProps,
|
35
|
-
refreshButtonProps = props.refreshButtonProps,
|
36
|
-
isJustifiedRight = props.isJustifiedRight,
|
9
|
+
var _props$align = props.align,
|
10
|
+
align = _props$align === void 0 ? 'left' : _props$align,
|
37
11
|
children = props.children,
|
38
12
|
others = _objectWithoutProperties(props, _excluded);
|
39
|
-
var ButtonArray = [___EmotionJSX(SaveButton, saveButtonProps), ___EmotionJSX(CancelButton, cancelButtonProps)];
|
40
|
-
var Content = function Content() {
|
41
|
-
var _context;
|
42
|
-
var content = isJustifiedRight ? _reverseInstanceProperty(_context = _sliceInstanceProperty(ButtonArray).call(ButtonArray)).call(_context) : ButtonArray;
|
43
|
-
if (refreshButtonProps) {
|
44
|
-
_spliceInstanceProperty(content).call(content, 1, 0, ___EmotionJSX(RefreshButton, refreshButtonProps));
|
45
|
-
}
|
46
|
-
return ___EmotionJSX(React.Fragment, null, _mapInstanceProperty(content).call(content, function (child) {
|
47
|
-
return child;
|
48
|
-
}));
|
49
|
-
};
|
50
13
|
return ___EmotionJSX(Box, _extends({
|
51
14
|
isRow: true,
|
52
15
|
gap: "md",
|
@@ -54,23 +17,11 @@ var ButtonBar = function ButtonBar(props) {
|
|
54
17
|
bg: 'white',
|
55
18
|
px: 'lg',
|
56
19
|
py: 'md',
|
57
|
-
justifyContent:
|
20
|
+
justifyContent: align === 'right' ? 'right' : 'left'
|
58
21
|
}
|
59
|
-
}, others), children
|
22
|
+
}, others), children);
|
60
23
|
};
|
61
24
|
ButtonBar.propTypes = {
|
62
|
-
|
63
|
-
cancelButtonProps: PropTypes.shape(buttonPropTypes),
|
64
|
-
refreshButtonProps: PropTypes.shape(buttonPropTypes),
|
65
|
-
isJustifiedRight: PropTypes.bool
|
66
|
-
};
|
67
|
-
SaveButton.propTypes = {
|
68
|
-
text: PropTypes.string
|
69
|
-
};
|
70
|
-
CancelButton.propTypes = {
|
71
|
-
text: PropTypes.string
|
72
|
-
};
|
73
|
-
RefreshButton.propTypes = {
|
74
|
-
text: PropTypes.string
|
25
|
+
align: PropTypes.oneOf(['left', 'right'])
|
75
26
|
};
|
76
27
|
export default ButtonBar;
|
@@ -6,8 +6,4 @@ import { Meta } from '@storybook/addon-docs';
|
|
6
6
|
|
7
7
|
This is a composed component that renders children in a simplified, organized and consistent manner.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
The **isJustifiedRight** prop will reverse the order of the children, and justify them to the right.
|
12
|
-
|
13
|
-
Supplying the ButtonBar with children using default React syntax will override the default render and render the custom children.
|
9
|
+
If the **align** prop is set to right it will justify the children to the right. Default is left justification.
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
1
|
import React from 'react';
|
3
2
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
4
3
|
import { Button, ButtonBar } from '../..';
|
@@ -16,72 +15,44 @@ export default {
|
|
16
15
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(ButtonBarReadme, null), ___EmotionJSX(DocsLayout, null));
|
17
16
|
}
|
18
17
|
}
|
18
|
+
},
|
19
|
+
argTypes: {
|
20
|
+
align: {
|
21
|
+
control: {
|
22
|
+
type: 'text'
|
23
|
+
}
|
24
|
+
}
|
19
25
|
}
|
20
26
|
};
|
21
27
|
export var Default = function Default(args) {
|
22
|
-
return ___EmotionJSX(ButtonBar,
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
return alert('Save button pressed');
|
28
|
-
}
|
29
|
-
},
|
30
|
-
cancelButtonProps: {
|
31
|
-
key: 'cancel button',
|
32
|
-
text: 'Cancel',
|
33
|
-
onPress: function onPress() {
|
34
|
-
return alert('Cancel button pressed');
|
35
|
-
}
|
28
|
+
return ___EmotionJSX(ButtonBar, args, ___EmotionJSX(Button, {
|
29
|
+
variant: "primary",
|
30
|
+
"data-id": "save-button",
|
31
|
+
onPress: function onPress() {
|
32
|
+
return alert('Save button pressed');
|
36
33
|
}
|
37
|
-
},
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
key: 'save button',
|
43
|
-
text: 'Save',
|
44
|
-
onPress: function onPress() {
|
45
|
-
return alert('Save button pressed');
|
46
|
-
}
|
47
|
-
},
|
48
|
-
cancelButtonProps: {
|
49
|
-
key: 'cancel button',
|
50
|
-
text: 'Cancel',
|
51
|
-
onPress: function onPress() {
|
52
|
-
return alert('Cancel button pressed');
|
53
|
-
}
|
54
|
-
},
|
55
|
-
refreshButtonProps: {
|
56
|
-
key: 'refresh button',
|
57
|
-
text: 'Refresh',
|
58
|
-
onPress: function onPress() {
|
59
|
-
return alert('Refresh button pressed');
|
60
|
-
}
|
34
|
+
}, "Save"), ___EmotionJSX(Button, {
|
35
|
+
variant: "link",
|
36
|
+
"data-id": "cancel-button",
|
37
|
+
onPress: function onPress() {
|
38
|
+
return alert('Cancel button pressed');
|
61
39
|
}
|
62
|
-
},
|
40
|
+
}, "Cancel"));
|
63
41
|
};
|
64
|
-
export var
|
42
|
+
export var RightAligned = function RightAligned() {
|
65
43
|
return ___EmotionJSX(ButtonBar, {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
isJustifiedRight: true
|
81
|
-
});
|
82
|
-
};
|
83
|
-
export var WithChildren = function WithChildren(args) {
|
84
|
-
return ___EmotionJSX(ButtonBar, args, ___EmotionJSX(Button, null, "Custom Button!"), ___EmotionJSX(Button, {
|
85
|
-
variant: "link"
|
86
|
-
}, "Custom Link!"));
|
44
|
+
align: "right"
|
45
|
+
}, ___EmotionJSX(Button, {
|
46
|
+
variant: "primary",
|
47
|
+
"data-id": "next-button",
|
48
|
+
onPress: function onPress() {
|
49
|
+
return alert('Next button pressed');
|
50
|
+
}
|
51
|
+
}, "Next"), ___EmotionJSX(Button, {
|
52
|
+
variant: "link",
|
53
|
+
"data-id": "cancel-button",
|
54
|
+
onPress: function onPress() {
|
55
|
+
return alert('Cancel button pressed');
|
56
|
+
}
|
57
|
+
}, "Cancel"));
|
87
58
|
};
|
@@ -1,39 +1,28 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
|
-
import { ButtonBar } from '../..';
|
3
|
+
import { Button, ButtonBar } from '../..';
|
4
4
|
import axeTest from '../../utils/testUtils/testAxe';
|
5
5
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
6
6
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
7
|
var testId = 'test-ButtonBar';
|
8
|
-
var saveButtonProps = {
|
9
|
-
key: 'save button',
|
10
|
-
text: 'Save',
|
11
|
-
onPress: function onPress() {
|
12
|
-
return alert('Save button pressed');
|
13
|
-
}
|
14
|
-
};
|
15
|
-
var cancelButtonProps = {
|
16
|
-
key: 'cancel button',
|
17
|
-
text: 'Cancel',
|
18
|
-
onPress: function onPress() {
|
19
|
-
return alert('Cancel button pressed');
|
20
|
-
}
|
21
|
-
};
|
22
|
-
var refreshButtonProps = {
|
23
|
-
key: 'refresh button',
|
24
|
-
text: 'Refresh',
|
25
|
-
onPress: function onPress() {
|
26
|
-
return alert('Refresh button pressed');
|
27
|
-
}
|
28
|
-
};
|
29
8
|
var defaultProps = {
|
30
|
-
'data-testid': testId
|
31
|
-
saveButtonProps: saveButtonProps,
|
32
|
-
cancelButtonProps: cancelButtonProps
|
9
|
+
'data-testid': testId
|
33
10
|
};
|
34
11
|
var getComponent = function getComponent() {
|
35
12
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
36
|
-
return render(___EmotionJSX(ButtonBar, _extends({}, defaultProps, props)
|
13
|
+
return render(___EmotionJSX(ButtonBar, _extends({}, defaultProps, props), ___EmotionJSX(Button, {
|
14
|
+
variant: "primary",
|
15
|
+
"data-id": "save-button",
|
16
|
+
onPress: function onPress() {
|
17
|
+
return alert('Save button pressed');
|
18
|
+
}
|
19
|
+
}, "Save"), ___EmotionJSX(Button, {
|
20
|
+
variant: "link",
|
21
|
+
"data-id": "cancel-button",
|
22
|
+
onPress: function onPress() {
|
23
|
+
return alert('Cancel button pressed');
|
24
|
+
}
|
25
|
+
}, "Cancel")));
|
37
26
|
};
|
38
27
|
var getComponentCustomChildren = function getComponentCustomChildren() {
|
39
28
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -52,22 +41,11 @@ test('ButtonBar does render', function () {
|
|
52
41
|
var element = screen.getByTestId(testId);
|
53
42
|
expect(element).toBeInTheDocument();
|
54
43
|
});
|
55
|
-
test('renders save and cancel buttons', function () {
|
44
|
+
test('renders child save and cancel buttons', function () {
|
56
45
|
getComponent();
|
57
|
-
var saveButton = screen.getByText(
|
46
|
+
var saveButton = screen.getByText('Save');
|
58
47
|
expect(saveButton).toBeInTheDocument();
|
59
|
-
var cancelButton = screen.getByText(
|
60
|
-
expect(cancelButton).toBeInTheDocument();
|
61
|
-
});
|
62
|
-
test('renders all three buttons', function () {
|
63
|
-
getComponent({
|
64
|
-
refreshButtonProps: refreshButtonProps
|
65
|
-
});
|
66
|
-
var saveButton = screen.getByText(saveButtonProps.text);
|
67
|
-
expect(saveButton).toBeInTheDocument();
|
68
|
-
var refreshButton = screen.getByText(refreshButtonProps.text);
|
69
|
-
expect(refreshButton).toBeInTheDocument();
|
70
|
-
var cancelButton = screen.getByText(cancelButtonProps.text);
|
48
|
+
var cancelButton = screen.getByText('Cancel');
|
71
49
|
expect(cancelButton).toBeInTheDocument();
|
72
50
|
});
|
73
51
|
test('renders custom children', function () {
|
@@ -82,10 +60,29 @@ test('renders custom text', function () {
|
|
82
60
|
var firstText = screen.getByText('custom text');
|
83
61
|
expect(firstText).toBeInTheDocument();
|
84
62
|
});
|
85
|
-
test('
|
63
|
+
test('justify-content right when align prop set to right', function () {
|
86
64
|
getComponent({
|
87
|
-
|
65
|
+
align: 'right'
|
88
66
|
});
|
89
|
-
var
|
90
|
-
expect(
|
67
|
+
var element = screen.getByTestId(testId);
|
68
|
+
expect(element).toHaveStyleRule('justify-content', 'right');
|
69
|
+
});
|
70
|
+
test('justify-content left when align prop is set to left', function () {
|
71
|
+
getComponent({
|
72
|
+
align: 'left'
|
73
|
+
});
|
74
|
+
var element = screen.getByTestId(testId);
|
75
|
+
expect(element).toHaveStyleRule('justify-content', 'left');
|
76
|
+
});
|
77
|
+
test('justify-content left when align prop is excluded', function () {
|
78
|
+
getComponent();
|
79
|
+
var element = screen.getByTestId(testId);
|
80
|
+
expect(element).toHaveStyleRule('justify-content', 'left');
|
81
|
+
});
|
82
|
+
test('an error is thrown when align has invalid prop value', function () {
|
83
|
+
expect(function () {
|
84
|
+
return getComponent({
|
85
|
+
align: 'rihgt'
|
86
|
+
});
|
87
|
+
}).toThrow('Failed prop type');
|
91
88
|
});
|