@shopgate/pwa-ui-material 7.30.0-alpha.7 → 7.30.0-alpha.8
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/Accordion/components/AccordionContent/index.js +51 -2
- package/Accordion/components/AccordionContent/spec.js +32 -1
- package/Accordion/components/AccordionContent/style.js +9 -1
- package/Accordion/index.js +90 -2
- package/Accordion/spec.js +39 -1
- package/Accordion/style.js +47 -1
- package/AppBar/components/Below/index.js +24 -2
- package/AppBar/components/Center/index.js +24 -2
- package/AppBar/components/Field/index.js +39 -3
- package/AppBar/components/Field/style.js +14 -1
- package/AppBar/components/Icon/index.js +43 -3
- package/AppBar/components/Icon/style.js +14 -1
- package/AppBar/components/Left/index.js +24 -2
- package/AppBar/components/Right/index.js +24 -2
- package/AppBar/components/Title/index.js +37 -3
- package/AppBar/components/Title/style.js +11 -1
- package/AppBar/index.js +87 -3
- package/AppBar/style.js +21 -1
- package/BaseDialog/components/Buttons/index.js +28 -2
- package/BaseDialog/components/Buttons/spec.js +28 -1
- package/BaseDialog/components/Content/index.js +21 -2
- package/BaseDialog/components/Content/spec.js +17 -1
- package/BaseDialog/components/Title/index.js +29 -2
- package/BaseDialog/components/Title/spec.js +17 -1
- package/BaseDialog/index.js +39 -2
- package/BaseDialog/spec.js +39 -1
- package/BaseDialog/style.js +64 -1
- package/FloatingActionButton/index.js +56 -3
- package/FloatingActionButton/style.js +33 -1
- package/NavDrawer/components/Divider/index.js +10 -2
- package/NavDrawer/components/Divider/spec.js +9 -1
- package/NavDrawer/components/Divider/style.js +12 -2
- package/NavDrawer/components/Item/index.js +72 -6
- package/NavDrawer/components/Item/style.js +49 -1
- package/NavDrawer/components/Section/index.js +29 -2
- package/NavDrawer/components/Title/index.js +23 -2
- package/NavDrawer/components/Title/style.js +8 -1
- package/NavDrawer/index.js +132 -10
- package/NavDrawer/spec.js +35 -1
- package/NavDrawer/style.js +26 -1
- package/NavDrawer/transition.js +20 -1
- package/SnackBar/index.js +158 -23
- package/SnackBar/style.js +64 -2
- package/colors.js +4 -1
- package/icons/ShareIcon.js +11 -2
- package/index.js +5 -1
- package/jest.config.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { useSpring, animated } from 'react-spring';
|
|
5
|
+
import useMeasure from 'react-use/lib/useMeasure';
|
|
6
|
+
import * as styles from "./style";
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* The accordion content component.
|
|
3
10
|
* @param {Object} props The component props.
|
|
4
11
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
function AccordionContent(props) {
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
open,
|
|
17
|
+
id,
|
|
18
|
+
className
|
|
19
|
+
} = props;
|
|
20
|
+
const [contentHeight, setContentHeight] = React.useState(0);
|
|
21
|
+
const [ref, {
|
|
22
|
+
height
|
|
23
|
+
}] = useMeasure();
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
setContentHeight(height);
|
|
26
|
+
window.addEventListener('resize', setContentHeight(height));
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener('resize', setContentHeight(height));
|
|
29
|
+
};
|
|
30
|
+
}, [height]);
|
|
31
|
+
const expand = useSpring({
|
|
32
|
+
config: {
|
|
33
|
+
duration: 175,
|
|
34
|
+
tension: 100,
|
|
35
|
+
friction: 20
|
|
36
|
+
},
|
|
37
|
+
height: open ? contentHeight : 0
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/React.createElement(animated.div, {
|
|
40
|
+
className: classnames('ui-material__accordion-content', styles.content),
|
|
41
|
+
style: expand,
|
|
42
|
+
id: id,
|
|
43
|
+
"aria-hidden": !open
|
|
44
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
ref: ref
|
|
46
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: classnames(styles.contentInner, className)
|
|
48
|
+
}, children)));
|
|
49
|
+
}
|
|
50
|
+
AccordionContent.defaultProps = {
|
|
51
|
+
open: false,
|
|
52
|
+
className: null
|
|
53
|
+
};
|
|
54
|
+
export default AccordionContent;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import AccordionContent from "./index";
|
|
4
|
+
jest.mock('react-spring', () => ({
|
|
5
|
+
...jest.requireActual('react-spring'),
|
|
6
|
+
useSpring: jest.fn().mockReturnValue({
|
|
7
|
+
hook: 'useSpring return value'
|
|
8
|
+
})
|
|
9
|
+
}));
|
|
10
|
+
describe('<AccordionContent />', () => {
|
|
11
|
+
it('should render as closed', () => {
|
|
12
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(AccordionContent, {
|
|
13
|
+
id: "some-id"
|
|
14
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
id: "test"
|
|
16
|
+
}, "Some Child")));
|
|
17
|
+
expect(wrapper.find('#test').text()).toEqual('Some Child');
|
|
18
|
+
expect(wrapper.find('div').get(0).props['aria-hidden']).toEqual(true);
|
|
19
|
+
expect(wrapper).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it('should render as open', () => {
|
|
22
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(AccordionContent, {
|
|
23
|
+
open: true,
|
|
24
|
+
id: "some-id"
|
|
25
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
id: "test"
|
|
27
|
+
}, "Some Child")));
|
|
28
|
+
expect(wrapper.find('#test').text()).toEqual('Some Child');
|
|
29
|
+
expect(wrapper.find('div').get(0).props['aria-hidden']).toEqual(false);
|
|
30
|
+
expect(wrapper).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import{css
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
export const content = css({
|
|
3
|
+
overflow: 'hidden',
|
|
4
|
+
willChange: 'height'
|
|
5
|
+
}).toString();
|
|
6
|
+
export const contentInner = css({
|
|
7
|
+
padding: '0 16px 16px',
|
|
8
|
+
overflow: 'hidden'
|
|
9
|
+
}).toString();
|
package/Accordion/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import "core-js/modules/es.string.replace.js";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
import noop from 'lodash/noop';
|
|
7
|
+
import { AccordionContainer, ChevronIcon } from '@shopgate/engage/components';
|
|
8
|
+
import { i18n } from '@shopgate/engage/core/helpers';
|
|
9
|
+
import AccordionContent from "./components/AccordionContent";
|
|
10
|
+
import * as styles from "./style";
|
|
11
|
+
|
|
12
|
+
/**
|
|
2
13
|
* Accordion component
|
|
3
14
|
* @param {Object} props The component props.
|
|
4
15
|
* @param {Function} props.renderLabel Function that returns a React component used as header label
|
|
@@ -16,4 +27,81 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
16
27
|
* @param {Function} props.renderAdditionalHeaderContent optional additional content
|
|
17
28
|
* for the accordion header
|
|
18
29
|
* @returns {JSX.Element}
|
|
19
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
function Accordion(props) {
|
|
32
|
+
const {
|
|
33
|
+
renderLabel,
|
|
34
|
+
handleLabel,
|
|
35
|
+
role,
|
|
36
|
+
children,
|
|
37
|
+
testId,
|
|
38
|
+
className,
|
|
39
|
+
contentClassName,
|
|
40
|
+
chevronClassName,
|
|
41
|
+
openWithChevron,
|
|
42
|
+
startOpened,
|
|
43
|
+
chevronPosition,
|
|
44
|
+
renderAdditionalHeaderContent
|
|
45
|
+
} = props;
|
|
46
|
+
if (!renderLabel || !children) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const controlsId = testId ? `${testId}-content`.replace(/[^\w\s]/gi, '-').replace(' ', '-') : 'accordion-content';
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "ui-material__accordion-container"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(AccordionContainer, {
|
|
53
|
+
open: startOpened
|
|
54
|
+
}, ({
|
|
55
|
+
handleOpen,
|
|
56
|
+
handleClose,
|
|
57
|
+
open
|
|
58
|
+
}) => {
|
|
59
|
+
const clickHandlers = {
|
|
60
|
+
onClick: open ? handleClose : handleOpen,
|
|
61
|
+
onKeyDown: open ? handleClose : handleOpen,
|
|
62
|
+
role
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
className: classnames('ui-material__accordion-title', className, styles.toggle),
|
|
66
|
+
"data-test-id": testId
|
|
67
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, openWithChevron ? {} : clickHandlers, {
|
|
68
|
+
key: "accordion-toggle",
|
|
69
|
+
"aria-expanded": open,
|
|
70
|
+
"aria-controls": controlsId,
|
|
71
|
+
"aria-label": handleLabel,
|
|
72
|
+
className: classnames(styles.labelContainer, {
|
|
73
|
+
[styles.toggleLeftAligned]: chevronPosition === 'left'
|
|
74
|
+
})
|
|
75
|
+
}), renderLabel({
|
|
76
|
+
open
|
|
77
|
+
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
78
|
+
className: classnames(styles.chevronContainer, chevronClassName, {
|
|
79
|
+
[styles.clickable]: openWithChevron
|
|
80
|
+
})
|
|
81
|
+
}, openWithChevron ? clickHandlers : {}, {
|
|
82
|
+
"aria-label": i18n.text(open ? 'favorites.close_list' : 'favorites.open_list')
|
|
83
|
+
}), /*#__PURE__*/React.createElement(ChevronIcon, {
|
|
84
|
+
className: open ? styles.chevronOpen : styles.chevronClosed
|
|
85
|
+
}))), renderAdditionalHeaderContent && /*#__PURE__*/React.createElement("div", null, renderAdditionalHeaderContent())), /*#__PURE__*/React.createElement(AccordionContent, {
|
|
86
|
+
open: open,
|
|
87
|
+
id: controlsId,
|
|
88
|
+
key: controlsId,
|
|
89
|
+
className: contentClassName
|
|
90
|
+
}, children));
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
Accordion.defaultProps = {
|
|
94
|
+
children: null,
|
|
95
|
+
renderAdditionalHeaderContent: null,
|
|
96
|
+
renderLabel: noop,
|
|
97
|
+
className: null,
|
|
98
|
+
contentClassName: null,
|
|
99
|
+
chevronClassName: null,
|
|
100
|
+
handleLabel: null,
|
|
101
|
+
role: 'button',
|
|
102
|
+
testId: null,
|
|
103
|
+
openWithChevron: false,
|
|
104
|
+
chevronPosition: 'right',
|
|
105
|
+
startOpened: false
|
|
106
|
+
};
|
|
107
|
+
export default Accordion;
|
package/Accordion/spec.js
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import Accordion from "./index";
|
|
4
|
+
jest.unmock('@shopgate/pwa-ui-shared');
|
|
5
|
+
jest.mock('@shopgate/engage/components');
|
|
6
|
+
jest.mock('react-spring', () => ({
|
|
7
|
+
...jest.requireActual('react-spring'),
|
|
8
|
+
useSpring: jest.fn().mockReturnValue({
|
|
9
|
+
hook: 'useSpring return value'
|
|
10
|
+
})
|
|
11
|
+
}));
|
|
12
|
+
describe('<Accordion />', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
jest.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
it('should render with renderLabel prop and children', () => {
|
|
17
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(Accordion, {
|
|
18
|
+
renderLabel: () => /*#__PURE__*/React.createElement("div", null),
|
|
19
|
+
testId: "Some Thing"
|
|
20
|
+
}, "Some content."));
|
|
21
|
+
expect(wrapper).toMatchSnapshot();
|
|
22
|
+
expect(wrapper.find('AccordionContent').exists()).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it('should not render without a renderLabel prop', () => {
|
|
25
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(Accordion, {
|
|
26
|
+
testId: "Some Thing"
|
|
27
|
+
}));
|
|
28
|
+
expect(wrapper).toMatchSnapshot();
|
|
29
|
+
expect(wrapper.instance()).toEqual(null);
|
|
30
|
+
});
|
|
31
|
+
it('should not render without children', () => {
|
|
32
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(Accordion, {
|
|
33
|
+
renderLabel: () => {},
|
|
34
|
+
testId: "Some Thing"
|
|
35
|
+
}));
|
|
36
|
+
expect(wrapper).toMatchSnapshot();
|
|
37
|
+
expect(wrapper.instance()).toEqual(null);
|
|
38
|
+
});
|
|
39
|
+
});
|
package/Accordion/style.js
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { responsiveMediaQuery } from '@shopgate/engage/styles';
|
|
3
|
+
export const toggle = css({
|
|
4
|
+
padding: '12px 16px',
|
|
5
|
+
position: 'relative',
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flexDirection: 'row',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'space-between',
|
|
10
|
+
gap: 12
|
|
11
|
+
}).toString();
|
|
12
|
+
export const clickable = css({
|
|
13
|
+
cursor: 'pointer'
|
|
14
|
+
}).toString();
|
|
15
|
+
export const toggleLeftAligned = css({
|
|
16
|
+
flexDirection: 'row-reverse'
|
|
17
|
+
});
|
|
18
|
+
export const chevronContainer = css({
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexShrink: 0,
|
|
21
|
+
fontSize: '1.5rem',
|
|
22
|
+
[responsiveMediaQuery('>sm', {
|
|
23
|
+
webOnly: true
|
|
24
|
+
})]: {
|
|
25
|
+
backgroundColor: 'rgba(0, 0, 0, 0.04)',
|
|
26
|
+
borderRadius: 32,
|
|
27
|
+
padding: 8
|
|
28
|
+
}
|
|
29
|
+
}).toString();
|
|
30
|
+
export const labelContainer = css({
|
|
31
|
+
marginRight: 'auto',
|
|
32
|
+
display: 'flex',
|
|
33
|
+
flex: 1,
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
justifyContent: 'space-between',
|
|
36
|
+
gap: 12
|
|
37
|
+
});
|
|
38
|
+
export const chevron = css({
|
|
39
|
+
transformOrigin: 'center center',
|
|
40
|
+
transition: 'transform 250ms cubic-bezier(0.25, 0.1, 0.25, 1)'
|
|
41
|
+
});
|
|
42
|
+
export const chevronClosed = css(chevron, {
|
|
43
|
+
transform: 'rotateZ(-90deg)'
|
|
44
|
+
}).toString();
|
|
45
|
+
export const chevronOpen = css(chevron, {
|
|
46
|
+
transform: 'rotateZ(90deg)'
|
|
47
|
+
}).toString();
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import React,{Fragment}from'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Portal } from '@shopgate/pwa-common/components';
|
|
4
|
+
import { APP_BAR_BELOW, APP_BAR_BELOW_BEFORE, APP_BAR_BELOW_AFTER } from '@shopgate/pwa-common/constants/Portals';
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* @param {Object} props The component props.
|
|
3
8
|
* @returns {JSX}
|
|
4
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
function Below({
|
|
11
|
+
elements
|
|
12
|
+
}) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
14
|
+
key: "below"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
16
|
+
name: APP_BAR_BELOW_BEFORE
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Portal, {
|
|
18
|
+
name: APP_BAR_BELOW
|
|
19
|
+
}, elements), /*#__PURE__*/React.createElement(Portal, {
|
|
20
|
+
name: APP_BAR_BELOW_AFTER
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
Below.defaultProps = {
|
|
24
|
+
elements: null
|
|
25
|
+
};
|
|
26
|
+
export default Below;
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import React,{Fragment}from'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Portal } from '@shopgate/pwa-common/components';
|
|
4
|
+
import { APP_BAR_CENTER, APP_BAR_CENTER_BEFORE, APP_BAR_CENTER_AFTER } from '@shopgate/pwa-common/constants/Portals';
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* @param {Object} props The component props.
|
|
3
8
|
* @returns {JSX}
|
|
4
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
function Center({
|
|
11
|
+
elements
|
|
12
|
+
}) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
14
|
+
key: "center"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
16
|
+
name: APP_BAR_CENTER_BEFORE
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Portal, {
|
|
18
|
+
name: APP_BAR_CENTER
|
|
19
|
+
}, elements), /*#__PURE__*/React.createElement(Portal, {
|
|
20
|
+
name: APP_BAR_CENTER_AFTER
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
Center.defaultProps = {
|
|
24
|
+
elements: null
|
|
25
|
+
};
|
|
26
|
+
export default Center;
|
|
@@ -1,5 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styles from "./style";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* The AppBarField component.
|
|
3
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
class AppBarField extends PureComponent {
|
|
9
|
+
/**
|
|
4
10
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
render() {
|
|
13
|
+
const {
|
|
14
|
+
fieldRef,
|
|
15
|
+
onChange,
|
|
16
|
+
onSubmit
|
|
17
|
+
} = this.props;
|
|
18
|
+
const {
|
|
19
|
+
__
|
|
20
|
+
} = this.context.i18n();
|
|
21
|
+
return /*#__PURE__*/React.createElement("form", {
|
|
22
|
+
className: styles.form,
|
|
23
|
+
onSubmit: onSubmit
|
|
24
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
25
|
+
className: styles.field,
|
|
26
|
+
onChange: onChange,
|
|
27
|
+
placeholder: __('search.placeholder'),
|
|
28
|
+
ref: fieldRef,
|
|
29
|
+
"data-test-id": "searchInput"
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
AppBarField.defaultProps = {
|
|
34
|
+
fieldRef: null,
|
|
35
|
+
onChange: null,
|
|
36
|
+
onSubmit: null
|
|
37
|
+
};
|
|
38
|
+
AppBarField.contextTypes = {
|
|
39
|
+
i18n: PropTypes.func
|
|
40
|
+
};
|
|
41
|
+
export default AppBarField;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import{css
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
const form = css({
|
|
3
|
+
display: 'flex',
|
|
4
|
+
flexGrow: 1
|
|
5
|
+
});
|
|
6
|
+
const field = css({
|
|
7
|
+
outline: 0,
|
|
8
|
+
padding: '0 16px',
|
|
9
|
+
width: '100%'
|
|
10
|
+
});
|
|
11
|
+
export default {
|
|
12
|
+
form,
|
|
13
|
+
field
|
|
14
|
+
};
|
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styles from "./style";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* The AppBarIcon component.
|
|
3
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
class AppBarIcon extends PureComponent {
|
|
9
|
+
/**
|
|
4
10
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
render() {
|
|
13
|
+
const {
|
|
14
|
+
background,
|
|
15
|
+
badge: Badge,
|
|
16
|
+
color,
|
|
17
|
+
icon: Icon,
|
|
18
|
+
onClick,
|
|
19
|
+
testId,
|
|
20
|
+
'aria-hidden': ariaHidden,
|
|
21
|
+
'aria-label': ariaLabel
|
|
22
|
+
} = this.props;
|
|
23
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
24
|
+
className: styles,
|
|
25
|
+
onClick: onClick,
|
|
26
|
+
style: {
|
|
27
|
+
background,
|
|
28
|
+
color
|
|
29
|
+
},
|
|
30
|
+
"data-test-id": testId,
|
|
31
|
+
"aria-hidden": ariaHidden,
|
|
32
|
+
"aria-label": ariaLabel,
|
|
33
|
+
type: "button"
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Icon, null), Badge && /*#__PURE__*/React.createElement(Badge, null));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
AppBarIcon.defaultProps = {
|
|
38
|
+
'aria-hidden': null,
|
|
39
|
+
'aria-label': null,
|
|
40
|
+
background: 'inherit',
|
|
41
|
+
badge: null,
|
|
42
|
+
color: 'inherit',
|
|
43
|
+
testId: null
|
|
44
|
+
};
|
|
45
|
+
export default AppBarIcon;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
export default css({
|
|
3
|
+
color: 'inherit',
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexShrink: 0,
|
|
6
|
+
fontSize: 24,
|
|
7
|
+
height: 56,
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
outline: 0,
|
|
11
|
+
padding: 0,
|
|
12
|
+
position: 'relative',
|
|
13
|
+
width: 56
|
|
14
|
+
});
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import React,{Fragment}from'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Portal } from '@shopgate/pwa-common/components';
|
|
4
|
+
import { APP_BAR_LEFT, APP_BAR_LEFT_BEFORE, APP_BAR_LEFT_AFTER } from '@shopgate/pwa-common/constants/Portals';
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* @param {Object} props The component props.
|
|
3
8
|
* @returns {JSX}
|
|
4
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
function Left({
|
|
11
|
+
elements
|
|
12
|
+
}) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
14
|
+
key: "left"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
16
|
+
name: APP_BAR_LEFT_BEFORE
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Portal, {
|
|
18
|
+
name: APP_BAR_LEFT
|
|
19
|
+
}, elements), /*#__PURE__*/React.createElement(Portal, {
|
|
20
|
+
name: APP_BAR_LEFT_AFTER
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
Left.defaultProps = {
|
|
24
|
+
elements: null
|
|
25
|
+
};
|
|
26
|
+
export default Left;
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import React,{Fragment}from'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Portal } from '@shopgate/pwa-common/components';
|
|
4
|
+
import { APP_BAR_RIGHT, APP_BAR_RIGHT_BEFORE, APP_BAR_RIGHT_AFTER } from '@shopgate/pwa-common/constants/Portals';
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* @param {Object} props The component props.
|
|
3
8
|
* @returns {JSX}
|
|
4
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
function Right({
|
|
11
|
+
elements
|
|
12
|
+
}) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
14
|
+
key: "right"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
16
|
+
name: APP_BAR_RIGHT_BEFORE
|
|
17
|
+
}), /*#__PURE__*/React.createElement(Portal, {
|
|
18
|
+
name: APP_BAR_RIGHT
|
|
19
|
+
}, elements), /*#__PURE__*/React.createElement(Portal, {
|
|
20
|
+
name: APP_BAR_RIGHT_AFTER
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
Right.defaultProps = {
|
|
24
|
+
elements: null
|
|
25
|
+
};
|
|
26
|
+
export default Right;
|
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The AppBarTitle component.
|
|
3
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
class AppBarTitle extends PureComponent {
|
|
10
|
+
/**
|
|
4
11
|
* @returns {JSX.Element}
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
render() {
|
|
14
|
+
const {
|
|
15
|
+
onClick,
|
|
16
|
+
title
|
|
17
|
+
} = this.props;
|
|
18
|
+
if (!title) return null;
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: classNames(styles, 'theme__app-bar__title'),
|
|
21
|
+
role: "heading",
|
|
22
|
+
"aria-labelledby": "titleLabel",
|
|
23
|
+
"aria-level": "1",
|
|
24
|
+
"data-test-id": `title: ${title}`,
|
|
25
|
+
tabIndex: -1
|
|
26
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
27
|
+
role: "presentation",
|
|
28
|
+
onClick: onClick,
|
|
29
|
+
id: "titleLabel",
|
|
30
|
+
dangerouslySetInnerHTML: {
|
|
31
|
+
__html: title
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
AppBarTitle.defaultProps = {
|
|
37
|
+
onClick: null
|
|
38
|
+
};
|
|
39
|
+
export default AppBarTitle;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
export default css({
|
|
3
|
+
fontSize: 20,
|
|
4
|
+
fontWeight: 500,
|
|
5
|
+
flexGrow: 1,
|
|
6
|
+
lineHeight: '56px',
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
padding: '0 16px',
|
|
9
|
+
textOverflow: 'ellipsis',
|
|
10
|
+
whiteSpace: 'nowrap'
|
|
11
|
+
});
|