@shopgate/pwa-ui-shared 7.30.0-alpha.6 → 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/AccordionContainer/index.js +39 -5
- package/AccordionContainer/spec.js +25 -2
- package/ActionButton/index.js +63 -7
- package/ActionButton/spec.js +59 -2
- package/ActionButton/style.js +22 -1
- package/AddToCartButton/index.js +184 -27
- package/AddToCartButton/mock.js +18 -4
- package/AddToCartButton/spec.js +51 -2
- package/AddToCartButton/style.js +127 -11
- package/Availability/index.js +34 -2
- package/Availability/spec.js +41 -1
- package/Availability/style.js +19 -1
- package/Button/index.js +76 -5
- package/Button/spec.js +33 -1
- package/Button/style.js +130 -21
- package/ButtonLink/connector.js +11 -2
- package/ButtonLink/index.js +44 -6
- package/ButtonLink/spec.js +23 -1
- package/Card/index.js +19 -2
- package/Card/style.js +11 -1
- package/CardList/components/Item/index.js +26 -2
- package/CardList/components/Item/style.js +7 -1
- package/CardList/index.js +34 -3
- package/CartTotalLine/components/Amount/index.js +28 -2
- package/CartTotalLine/components/Amount/style.js +8 -1
- package/CartTotalLine/components/Hint/index.js +23 -2
- package/CartTotalLine/components/Hint/style.js +12 -1
- package/CartTotalLine/components/Label/index.js +36 -2
- package/CartTotalLine/components/Label/style.js +17 -1
- package/CartTotalLine/components/Spacer/index.js +16 -2
- package/CartTotalLine/index.js +39 -2
- package/CartTotalLine/style.js +31 -1
- package/Checkbox/index.js +31 -2
- package/Checkbox/style.js +18 -1
- package/Chip/index.js +61 -2
- package/Chip/spec.js +24 -1
- package/Chip/style.js +71 -3
- package/ContextMenu/ContextMenu.hooks.js +6 -2
- package/ContextMenu/ContextMenuProvider.context.js +9 -3
- package/ContextMenu/ContextMenuProvider.js +21 -2
- package/ContextMenu/components/Item/index.js +67 -5
- package/ContextMenu/components/Item/style.js +32 -3
- package/ContextMenu/components/Position/index.js +61 -10
- package/ContextMenu/components/Position/style.js +11 -1
- package/ContextMenu/index.js +124 -3
- package/ContextMenu/spec.js +101 -2
- package/ContextMenu/style.js +45 -1
- package/Dialog/components/BasicDialog/index.js +5 -1
- package/Dialog/components/HtmlContentDialog/index.js +22 -2
- package/Dialog/components/HtmlContentDialog/spec.js +59 -1
- package/Dialog/components/PipelineErrorDialog/index.js +114 -25
- package/Dialog/components/PipelineErrorDialog/spec.js +92 -12
- package/Dialog/components/TextMessageDialog/index.js +28 -2
- package/Dialog/components/TextMessageDialog/spec.js +59 -1
- package/Dialog/components/VariantSelectModal/connector.js +11 -2
- package/Dialog/components/VariantSelectModal/index.js +65 -6
- package/Dialog/components/VariantSelectModal/spec.js +51 -2
- package/Dialog/constants.js +6 -1
- package/Dialog/index.js +114 -7
- package/Dialog/spec.js +81 -3
- package/DiscountBadge/index.js +30 -2
- package/DiscountBadge/spec.js +19 -1
- package/DiscountBadge/style.js +34 -2
- package/FavoritesButton/connector.js +18 -3
- package/FavoritesButton/index.js +118 -15
- package/FavoritesButton/mock.js +50 -4
- package/FavoritesButton/spec.js +120 -2
- package/FavoritesButton/style.js +26 -1
- package/Form/Builder/builders/buildCountryList.js +40 -6
- package/Form/Builder/builders/buildFormDefaults.js +35 -6
- package/Form/Builder/builders/buildFormElements.js +68 -10
- package/Form/Builder/builders/buildProvinceList.js +19 -2
- package/Form/Builder/builders/buildValidationErrorList.js +7 -2
- package/Form/Builder/classes/ActionListener/constants.js +22 -2
- package/Form/Builder/classes/ActionListener/index.js +441 -93
- package/Form/Builder/classes/ActionListener/spec.js +321 -19
- package/Form/Builder/components/CheckboxElement.js +35 -3
- package/Form/Builder/components/CountryElement.js +40 -3
- package/Form/Builder/components/ProvinceElement.js +40 -3
- package/Form/Builder/components/RadioElement.js +41 -3
- package/Form/Builder/components/SelectElement.js +39 -3
- package/Form/Builder/components/TextElement.js +49 -4
- package/Form/Builder/elementTypes.js +11 -1
- package/Form/Builder/index.js +298 -52
- package/Form/Builder/iso-3166-2.js +4943 -1
- package/Form/Builder/spec.js +300 -16
- package/Form/Checkbox/index.js +66 -4
- package/Form/Checkbox/style.js +25 -2
- package/Form/InfoField/index.js +50 -2
- package/Form/InfoField/spec.js +9 -1
- package/Form/InfoField/style.js +11 -1
- package/Form/Password/index.js +51 -6
- package/Form/Password/spec.js +34 -1
- package/Form/Password/style.js +11 -1
- package/Form/RadioGroup/components/Item/index.js +59 -3
- package/Form/RadioGroup/components/Item/style.js +32 -2
- package/Form/RadioGroup/index.js +101 -9
- package/Form/RadioGroup/spec.js +83 -3
- package/Form/RadioGroup/style.js +18 -2
- package/Form/Select/index.js +158 -10
- package/Form/Select/spec.js +36 -5
- package/Form/Select/style.js +27 -1
- package/Form/SelectContextChoices/index.js +77 -3
- package/Form/SelectContextChoices/spec.js +33 -4
- package/Form/SelectContextChoices/style.js +23 -1
- package/Form/TextField/index.js +92 -8
- package/Form/TextField/spec.js +110 -1
- package/Form/TextField/style.js +66 -8
- package/Form/index.js +54 -13
- package/FormElement/components/ErrorText/index.js +31 -2
- package/FormElement/components/ErrorText/style.js +13 -1
- package/FormElement/components/Label/index.js +35 -2
- package/FormElement/components/Label/style.js +76 -8
- package/FormElement/components/Placeholder/index.js +26 -2
- package/FormElement/components/Placeholder/style.js +48 -6
- package/FormElement/components/Underline/index.js +18 -2
- package/FormElement/components/Underline/style.js +51 -4
- package/FormElement/index.js +91 -6
- package/FormElement/spec.js +67 -2
- package/FormElement/style.js +13 -2
- package/Glow/index.js +90 -7
- package/Glow/spec.js +9 -1
- package/Glow/style.js +18 -1
- package/IndicatorCircle/index.js +33 -3
- package/IndicatorCircle/spec.js +28 -1
- package/IndicatorCircle/style.js +57 -3
- package/LoadingIndicator/index.js +29 -2
- package/LoadingIndicator/style.js +20 -1
- package/Manufacturer/index.js +20 -2
- package/Manufacturer/style.js +5 -1
- package/MessageBar/index.js +36 -2
- package/MessageBar/spec.js +79 -1
- package/MessageBar/style.js +38 -1
- package/NoResults/components/Icon/index.js +130 -2
- package/NoResults/components/Icon/style.js +17 -1
- package/NoResults/index.js +46 -2
- package/NoResults/style.js +31 -1
- package/Placeholder/index.js +25 -3
- package/Placeholder/style.js +11 -1
- package/PlaceholderLabel/index.js +27 -2
- package/PlaceholderLabel/spec.js +19 -1
- package/PlaceholderLabel/style.js +12 -1
- package/PlaceholderParagraph/index.js +36 -2
- package/PlaceholderParagraph/spec.js +19 -1
- package/Price/index.js +88 -7
- package/Price/style.js +22 -1
- package/PriceInfo/index.js +20 -2
- package/PriceInfo/style.js +5 -1
- package/PriceStriked/index.js +83 -12
- package/PriceStriked/style.js +33 -3
- package/ProductProperties/index.js +32 -2
- package/ProgressBar/index.js +101 -13
- package/ProgressBar/spec.js +13 -1
- package/ProgressBar/style.js +83 -2
- package/RadioButton/index.js +18 -2
- package/RadioButton/spec.js +21 -1
- package/RadioButton/style.js +21 -1
- package/RatingNumber/index.js +29 -2
- package/RatingStars/constants.js +2 -1
- package/RatingStars/index.js +130 -12
- package/RatingStars/spec.js +90 -3
- package/RatingStars/style.js +51 -2
- package/Ripple/components/RippleAnimation/index.js +88 -6
- package/Ripple/index.js +218 -40
- package/Ripple/style.js +18 -1
- package/RippleButton/index.js +52 -5
- package/RippleButton/spec.js +45 -1
- package/ScannerOverlay/components/CameraOverlay/index.js +13 -2
- package/ScannerOverlay/components/CameraOverlay/style.js +41 -1
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +34 -2
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/style.js +28 -1
- package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +11 -2
- package/ScannerOverlay/components/ScannerBar/index.js +31 -2
- package/ScannerOverlay/components/ScannerBar/style.js +20 -1
- package/ScannerOverlay/index.js +47 -7
- package/Sheet/components/Header/components/SearchBar/index.js +46 -2
- package/Sheet/components/Header/components/SearchBar/spec.js +21 -3
- package/Sheet/components/Header/components/SearchBar/style.js +47 -1
- package/Sheet/components/Header/index.js +75 -7
- package/Sheet/components/Header/spec.js +14 -1
- package/Sheet/components/Header/style.js +50 -1
- package/Sheet/index.js +170 -17
- package/Sheet/spec.js +85 -5
- package/Sheet/style.js +143 -2
- package/TaxDisclaimer/index.js +34 -4
- package/TaxDisclaimer/spec.js +31 -3
- package/TaxDisclaimer/style.js +9 -1
- package/TextField/components/ErrorText/index.js +33 -2
- package/TextField/components/ErrorText/style.js +25 -3
- package/TextField/components/FormElement/index.js +19 -2
- package/TextField/components/FormElement/style.js +32 -4
- package/TextField/components/Hint/index.js +21 -2
- package/TextField/components/Hint/style.js +40 -5
- package/TextField/components/Label/index.js +32 -3
- package/TextField/components/Label/style.js +68 -8
- package/TextField/components/Underline/index.js +19 -2
- package/TextField/components/Underline/style.js +51 -4
- package/TextField/index.js +189 -27
- package/TextField/spec.js +128 -3
- package/TextField/style.js +34 -4
- package/ToggleIcon/index.js +58 -8
- package/ToggleIcon/spec.js +35 -1
- package/icons/AccountBoxIcon.js +11 -2
- package/icons/AddMoreIcon.js +11 -2
- package/icons/ArrowDropIcon.js +11 -2
- package/icons/ArrowIcon.js +21 -2
- package/icons/BarcodeScannerIcon.js +11 -2
- package/icons/BoxIcon.js +11 -2
- package/icons/BrowseIcon.js +11 -2
- package/icons/BurgerIcon.js +11 -2
- package/icons/CalendarIcon.js +15 -3
- package/icons/CartCouponIcon.js +72 -2
- package/icons/CartIcon.js +11 -2
- package/icons/CartPlusIcon.js +11 -2
- package/icons/CheckIcon.js +11 -2
- package/icons/CheckedIcon.js +11 -2
- package/icons/ChevronIcon.js +11 -2
- package/icons/CreditCardIcon.js +11 -2
- package/icons/CrossIcon.js +11 -2
- package/icons/DescriptionIcon.js +11 -2
- package/icons/FilterIcon.js +11 -2
- package/icons/FlashDisabledIcon.js +11 -2
- package/icons/FlashEnabledIcon.js +11 -2
- package/icons/GridIcon.js +11 -2
- package/icons/HeartIcon.js +11 -2
- package/icons/HeartOutlineIcon.js +11 -2
- package/icons/HeartPlusIcon.js +12 -2
- package/icons/HeartPlusOutlineIcon.js +12 -2
- package/icons/HomeIcon.js +11 -2
- package/icons/InfoIcon.js +11 -2
- package/icons/InfoOutlineIcon.js +11 -2
- package/icons/ListIcon.js +11 -2
- package/icons/LocalShippingIcon.js +11 -2
- package/icons/LocationIcon.js +13 -3
- package/icons/LocatorIcon.js +11 -2
- package/icons/LockIcon.js +11 -2
- package/icons/LogoutIcon.js +11 -2
- package/icons/MagnifierIcon.js +11 -2
- package/icons/MapMarkerIcon.js +24 -3
- package/icons/MoreIcon.js +11 -2
- package/icons/MoreVertIcon.js +11 -2
- package/icons/NotificationIcon.js +14 -3
- package/icons/PersonIcon.js +12 -2
- package/icons/PhoneIcon.js +13 -3
- package/icons/PlaceholderIcon.js +11 -2
- package/icons/RadioCheckedIcon.js +11 -2
- package/icons/RadioUncheckedIcon.js +11 -2
- package/icons/SecurityIcon.js +11 -2
- package/icons/ShippingMethodIcon.js +18 -3
- package/icons/ShoppingCartIcon.js +11 -2
- package/icons/SortIcon.js +11 -2
- package/icons/StarHalfIcon.js +18 -2
- package/icons/StarIcon.js +18 -2
- package/icons/StarOutlineIcon.js +11 -2
- package/icons/StopIcon.js +11 -2
- package/icons/TickIcon.js +11 -2
- package/icons/TimeIcon.js +14 -3
- package/icons/TrashIcon.js +11 -2
- package/icons/TrashOutlineIcon.js +12 -2
- package/icons/UncheckedIcon.js +11 -2
- package/icons/ViewListIcon.js +11 -2
- package/icons/VisibilityIcon.js +11 -2
- package/icons/VisibilityOffIcon.js +11 -2
- package/icons/WarningIcon.js +11 -2
- package/index.js +13 -1
- package/package.json +5 -5
package/IndicatorCircle/index.js
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The circle indicator component.
|
|
3
8
|
* @param {Object} props The component props.
|
|
4
9
|
* @param {Object} props.size Width and height of the circle.
|
|
5
10
|
* @param {Object} props.color Color of the circle.
|
|
6
11
|
* @param {Object} props.strokeWidth Stroke width of the circle.
|
|
7
|
-
* @param {
|
|
12
|
+
* @param {boolean} props.paused Animation should be paused.
|
|
8
13
|
* @returns {JSX}
|
|
9
|
-
*/
|
|
14
|
+
*/
|
|
15
|
+
const IndicatorCircle = ({
|
|
16
|
+
size,
|
|
17
|
+
color,
|
|
18
|
+
strokeWidth,
|
|
19
|
+
paused
|
|
20
|
+
}) => /*#__PURE__*/React.createElement("svg", {
|
|
21
|
+
className: `${styles.spinner(paused)} ui-shared__indicator-circle`,
|
|
22
|
+
viewBox: "25 25 50 50",
|
|
23
|
+
width: size,
|
|
24
|
+
height: size,
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
26
|
+
"data-test-id": "loadingIndicator"
|
|
27
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
28
|
+
className: styles.circle(color, strokeWidth, paused),
|
|
29
|
+
cx: "50",
|
|
30
|
+
cy: "50",
|
|
31
|
+
r: "20"
|
|
32
|
+
}));
|
|
33
|
+
IndicatorCircle.defaultProps = {
|
|
34
|
+
color: `var(--color-secondary, ${themeConfig.colors.accent})`,
|
|
35
|
+
paused: false,
|
|
36
|
+
size: themeConfig.variables.loadingIndicator.size,
|
|
37
|
+
strokeWidth: themeConfig.variables.loadingIndicator.strokeWidth
|
|
38
|
+
};
|
|
39
|
+
export default IndicatorCircle;
|
package/IndicatorCircle/spec.js
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow, mount } from 'enzyme';
|
|
3
|
+
import IndicatorCircle from "./index";
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
describe('<IndicatorCircle />', () => {
|
|
6
|
+
it('should apply the given size', () => {
|
|
7
|
+
const wrapper = shallow(/*#__PURE__*/React.createElement(IndicatorCircle, {
|
|
8
|
+
size: 32
|
|
9
|
+
}));
|
|
10
|
+
expect(wrapper).toMatchSnapshot();
|
|
11
|
+
const svg = wrapper.find('svg');
|
|
12
|
+
expect(svg.props().width).toBe(32);
|
|
13
|
+
expect(svg.props().height).toBe(32);
|
|
14
|
+
});
|
|
15
|
+
it('should apply the given color', () => {
|
|
16
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(IndicatorCircle, {
|
|
17
|
+
size: 32,
|
|
18
|
+
color: "#fff",
|
|
19
|
+
strokeWidth: 4
|
|
20
|
+
}));
|
|
21
|
+
expect(wrapper).toMatchSnapshot();
|
|
22
|
+
const correctCssClass = styles.circle('#fff', 4, false);
|
|
23
|
+
const wrongCssClass = styles.circle('#000', 0);
|
|
24
|
+
const circleHtml = wrapper.find('circle');
|
|
25
|
+
expect(circleHtml.html().indexOf(correctCssClass)).toBeGreaterThanOrEqual(0);
|
|
26
|
+
expect(circleHtml.html().indexOf(wrongCssClass)).toBe(-1);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/IndicatorCircle/style.js
CHANGED
|
@@ -1,11 +1,65 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
const rotate = css.keyframes({
|
|
3
|
+
'100%': {
|
|
4
|
+
transform: 'rotate(360deg)'
|
|
5
|
+
}
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* Styles for spinner.
|
|
3
10
|
* @param {boolean} paused Animation should be paused.
|
|
4
11
|
* @returns {string}
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const spinner = paused => {
|
|
14
|
+
const styles = {
|
|
15
|
+
margin: 'auto',
|
|
16
|
+
transformOrigin: 'center center',
|
|
17
|
+
maxWidth: '100%',
|
|
18
|
+
maxHeight: '100%'
|
|
19
|
+
};
|
|
20
|
+
if (!paused) {
|
|
21
|
+
styles.animation = `${rotate} 1.6s linear infinite`;
|
|
22
|
+
}
|
|
23
|
+
return css(styles).toString();
|
|
24
|
+
};
|
|
25
|
+
const dash = css.keyframes({
|
|
26
|
+
'0%': {
|
|
27
|
+
strokeDasharray: '1, 200',
|
|
28
|
+
strokeDashoffset: '0'
|
|
29
|
+
},
|
|
30
|
+
'50%': {
|
|
31
|
+
strokeDasharray: '89, 200',
|
|
32
|
+
strokeDashoffset: '-35px'
|
|
33
|
+
},
|
|
34
|
+
'100%': {
|
|
35
|
+
strokeDasharray: '89, 200',
|
|
36
|
+
strokeDashoffset: '-124px'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
6
41
|
* Styles for the rotating circle.
|
|
7
42
|
* @param {string} color The color of the circle. Default color is "accent".
|
|
8
43
|
* @param {string} strokeWidth The stroke width of the circle.
|
|
9
44
|
* @param {boolean} paused Animation should be paused.
|
|
10
45
|
* @return {string} CSS class name.
|
|
11
|
-
*/
|
|
46
|
+
*/
|
|
47
|
+
const circle = (color, strokeWidth, paused) => {
|
|
48
|
+
const styles = {
|
|
49
|
+
fill: 'none',
|
|
50
|
+
stroke: color,
|
|
51
|
+
strokeDasharray: '1, 200',
|
|
52
|
+
strokeDashoffset: 0,
|
|
53
|
+
strokeLinecap: 'round',
|
|
54
|
+
strokeMiterlimit: 10,
|
|
55
|
+
strokeWidth
|
|
56
|
+
};
|
|
57
|
+
if (!paused) {
|
|
58
|
+
styles.animation = `${dash} 1.2s ease-in-out infinite`;
|
|
59
|
+
}
|
|
60
|
+
return css(styles).toString();
|
|
61
|
+
};
|
|
62
|
+
export default {
|
|
63
|
+
spinner,
|
|
64
|
+
circle
|
|
65
|
+
};
|
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { themeConfig } from '@shopgate/engage';
|
|
5
|
+
import IndicatorCircle from "../IndicatorCircle";
|
|
6
|
+
import { container, imgContainer } from "./style";
|
|
7
|
+
const {
|
|
8
|
+
loadingIndicator: {
|
|
9
|
+
imgSrc: loadingImageSrc
|
|
10
|
+
} = {}
|
|
11
|
+
} = themeConfig.variables;
|
|
12
|
+
|
|
13
|
+
/**
|
|
2
14
|
* Renders a loading indicator.
|
|
3
15
|
* @returns {JSX}
|
|
4
|
-
*/
|
|
16
|
+
*/
|
|
17
|
+
const LoadingIndicator = ({
|
|
18
|
+
className
|
|
19
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: classNames(className, {
|
|
21
|
+
[container]: !loadingImageSrc,
|
|
22
|
+
[imgContainer]: !!loadingImageSrc
|
|
23
|
+
}, 'loading-indicator', 'ui-shared__loading-indicator')
|
|
24
|
+
}, loadingImageSrc ? /*#__PURE__*/React.createElement("img", {
|
|
25
|
+
src: loadingImageSrc,
|
|
26
|
+
alt: ""
|
|
27
|
+
}) : /*#__PURE__*/React.createElement(IndicatorCircle, null));
|
|
28
|
+
LoadingIndicator.defaultProps = {
|
|
29
|
+
className: null
|
|
30
|
+
};
|
|
31
|
+
export default LoadingIndicator;
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const {
|
|
4
|
+
colors
|
|
5
|
+
} = themeConfig;
|
|
6
|
+
export const container = css({
|
|
7
|
+
display: 'block',
|
|
8
|
+
padding: '1em',
|
|
9
|
+
textAlign: 'center',
|
|
10
|
+
fontSize: '1.5em',
|
|
11
|
+
color: `var(--color-secondary, ${colors.accent})`
|
|
12
|
+
});
|
|
13
|
+
export const imgContainer = css({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
' img': {
|
|
17
|
+
maxWidth: '50vw',
|
|
18
|
+
maxHeight: '50vh'
|
|
19
|
+
}
|
|
20
|
+
});
|
package/Manufacturer/index.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styles from "./style";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* The manufacturer component.
|
|
3
7
|
* @param {Object} props The component props.
|
|
4
8
|
* @param {string} props.text The manufacturer name.
|
|
5
9
|
* @param {string} [props.className] CSS classes.
|
|
6
10
|
* @return {JSX}
|
|
7
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const Manufacturer = ({
|
|
13
|
+
className,
|
|
14
|
+
text
|
|
15
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: `${styles} ${className} ui-shared__manufacturer`
|
|
17
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
18
|
+
dangerouslySetInnerHTML: {
|
|
19
|
+
__html: text
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
Manufacturer.defaultProps = {
|
|
23
|
+
className: ''
|
|
24
|
+
};
|
|
25
|
+
export default Manufacturer;
|
package/Manufacturer/style.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
export default css({
|
|
4
|
+
color: `var(--color-primary, ${themeConfig.colors.primary})`
|
|
5
|
+
}).toString();
|
package/MessageBar/index.js
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
|
-
import React,{memo}
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { i18n } from '@shopgate/engage/core';
|
|
5
|
+
import styles from "./style";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* The MessageBar component.
|
|
3
9
|
* @param {Object} props The component props.
|
|
4
10
|
* @param {Array} props.messages The message content.
|
|
5
11
|
* @param {Object} props.classNames Styling.
|
|
6
12
|
* @returns {JSX}
|
|
7
13
|
* @deprecated Please import from `@shopgate/engage/components` instead.
|
|
8
|
-
*/
|
|
14
|
+
*/
|
|
15
|
+
const MessageBar = /*#__PURE__*/memo(({
|
|
16
|
+
messages,
|
|
17
|
+
classNames
|
|
18
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: classnames(styles.container, classNames.container, 'ui-shared__message-bar'),
|
|
20
|
+
role: messages.length > 0 ? 'alert' : null
|
|
21
|
+
}, messages.map(item => {
|
|
22
|
+
const {
|
|
23
|
+
type = 'info',
|
|
24
|
+
message,
|
|
25
|
+
messageParams = null,
|
|
26
|
+
translated
|
|
27
|
+
} = item;
|
|
28
|
+
const messageOutput = !translated ? i18n.text(message, messageParams) : message;
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
key: `${type}-${message}`,
|
|
31
|
+
className: classnames(classNames.message, styles[type])
|
|
32
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
33
|
+
"aria-hidden": true
|
|
34
|
+
}, messageOutput));
|
|
35
|
+
})));
|
|
36
|
+
MessageBar.defaultProps = {
|
|
37
|
+
classNames: {
|
|
38
|
+
container: null,
|
|
39
|
+
message: null
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export default MessageBar;
|
package/MessageBar/spec.js
CHANGED
|
@@ -1 +1,79 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import MessageBar from "./index";
|
|
4
|
+
const MESSAGE1 = 'This is some information';
|
|
5
|
+
const MESSAGE2 = 'This is an error that happened here.';
|
|
6
|
+
const MESSAGE3 = 'This is just a warning. Nothing to freak out about.';
|
|
7
|
+
const MESSAGE4 = 'Normal pre-translated message.';
|
|
8
|
+
const MESSAGE5 = 'Normal pre-translated message two.';
|
|
9
|
+
const MESSAGE6 = 'some.translation.string';
|
|
10
|
+
const MESSAGE7 = 'Message with messageParams';
|
|
11
|
+
describe('<MessageBar />', () => {
|
|
12
|
+
describe('General rendering', () => {
|
|
13
|
+
it('should be empty if no messages have been set', () => {
|
|
14
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(MessageBar, {
|
|
15
|
+
messages: []
|
|
16
|
+
}));
|
|
17
|
+
expect(wrapper).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
it('should render a message as info if type is missing', () => {
|
|
20
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(MessageBar, {
|
|
21
|
+
messages: [{
|
|
22
|
+
message: 'something'
|
|
23
|
+
}]
|
|
24
|
+
}));
|
|
25
|
+
expect(wrapper).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('Multiple messages rendering', () => {
|
|
29
|
+
it('should render messages without frontend translation', () => {
|
|
30
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(MessageBar, {
|
|
31
|
+
messages: [{
|
|
32
|
+
type: 'info',
|
|
33
|
+
message: MESSAGE1
|
|
34
|
+
}, {
|
|
35
|
+
type: 'error',
|
|
36
|
+
message: MESSAGE2
|
|
37
|
+
}, {
|
|
38
|
+
type: 'warning',
|
|
39
|
+
message: MESSAGE3
|
|
40
|
+
}, {
|
|
41
|
+
message: MESSAGE4,
|
|
42
|
+
translated: null
|
|
43
|
+
}, {
|
|
44
|
+
message: MESSAGE5,
|
|
45
|
+
translated: true
|
|
46
|
+
}]
|
|
47
|
+
}));
|
|
48
|
+
expect(wrapper).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
it('should translate and render all given messages', () => {
|
|
51
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(MessageBar, {
|
|
52
|
+
messages: [{
|
|
53
|
+
message: MESSAGE6,
|
|
54
|
+
translated: false
|
|
55
|
+
}, {
|
|
56
|
+
message: MESSAGE7,
|
|
57
|
+
messageParams: {
|
|
58
|
+
myCustomParam1: '-> TEST-VALUE #1 <-',
|
|
59
|
+
myCustomParam2: '-> TEST-VALUE #2 <-'
|
|
60
|
+
},
|
|
61
|
+
translated: false
|
|
62
|
+
}]
|
|
63
|
+
}));
|
|
64
|
+
expect(wrapper).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
it('should render with custom classNames', () => {
|
|
67
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(MessageBar, {
|
|
68
|
+
messages: [{
|
|
69
|
+
message: MESSAGE1
|
|
70
|
+
}],
|
|
71
|
+
classNames: {
|
|
72
|
+
container: 'cls-container',
|
|
73
|
+
message: 'cls-message'
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
expect(wrapper).toMatchSnapshot();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
package/MessageBar/style.js
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
import{css
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const {
|
|
4
|
+
colors,
|
|
5
|
+
variables
|
|
6
|
+
} = themeConfig;
|
|
7
|
+
const container = css({
|
|
8
|
+
background: colors.background,
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
flexShrink: 0
|
|
12
|
+
}).toString();
|
|
13
|
+
const messageBase = {
|
|
14
|
+
padding: `${variables.gap.small}px ${variables.gap.big}px`,
|
|
15
|
+
fontSize: '0.875rem',
|
|
16
|
+
fontWeight: 500,
|
|
17
|
+
':not(:last-child)': {
|
|
18
|
+
marginBottom: variables.gap.small * 0.5
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const info = css(messageBase, {
|
|
22
|
+
background: `var(--color-secondary, ${colors.accent})`,
|
|
23
|
+
color: `var(--color-secondary-contrast, ${colors.accentContrast})`
|
|
24
|
+
}).toString();
|
|
25
|
+
const error = css(messageBase, {
|
|
26
|
+
background: colors.error,
|
|
27
|
+
color: colors.light
|
|
28
|
+
}).toString();
|
|
29
|
+
const warning = css(messageBase, {
|
|
30
|
+
background: colors.warning,
|
|
31
|
+
color: colors.light
|
|
32
|
+
}).toString();
|
|
33
|
+
export default {
|
|
34
|
+
container,
|
|
35
|
+
info,
|
|
36
|
+
error,
|
|
37
|
+
warning
|
|
38
|
+
};
|
|
@@ -1,5 +1,133 @@
|
|
|
1
|
-
import React,{useMemo}
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import CryptoJs from 'crypto-js';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The no search results icon component.
|
|
3
8
|
* @param {Object} props Props of the component
|
|
4
9
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const NoResultIcon = props => {
|
|
12
|
+
const filterId = useMemo(() => {
|
|
13
|
+
const prefix = 'no-search-results-shadow';
|
|
14
|
+
const hash = CryptoJs.MD5(`${prefix}-${Date.now() + Math.random()}`).toString();
|
|
15
|
+
return `${prefix}-${hash}`;
|
|
16
|
+
}, []);
|
|
17
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
18
|
+
className: props.className,
|
|
19
|
+
viewBox: "-2698 6977 216 216",
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
21
|
+
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("filter", {
|
|
22
|
+
id: filterId,
|
|
23
|
+
height: "130%"
|
|
24
|
+
}, /*#__PURE__*/React.createElement("feGaussianBlur", {
|
|
25
|
+
in: "SourceAlpha",
|
|
26
|
+
stdDeviation: "3"
|
|
27
|
+
}), /*#__PURE__*/React.createElement("feOffset", {
|
|
28
|
+
dx: "2",
|
|
29
|
+
dy: "2",
|
|
30
|
+
result: "offsetblur"
|
|
31
|
+
}), /*#__PURE__*/React.createElement("feComponentTransfer", null, /*#__PURE__*/React.createElement("feFuncA", {
|
|
32
|
+
type: "linear",
|
|
33
|
+
slope: "0.1"
|
|
34
|
+
})), /*#__PURE__*/React.createElement("feMerge", null, /*#__PURE__*/React.createElement("feMergeNode", null), /*#__PURE__*/React.createElement("feMergeNode", {
|
|
35
|
+
in: "SourceGraphic"
|
|
36
|
+
})))), /*#__PURE__*/React.createElement("g", {
|
|
37
|
+
transform: "translate(-2770 6819)"
|
|
38
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
39
|
+
transform: "translate(0 46)"
|
|
40
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
41
|
+
className: styles.background,
|
|
42
|
+
cx: "104",
|
|
43
|
+
cy: "104",
|
|
44
|
+
r: "104",
|
|
45
|
+
transform: "translate(76 116)"
|
|
46
|
+
})), /*#__PURE__*/React.createElement("g", {
|
|
47
|
+
transform: "translate(-4 42)"
|
|
48
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
49
|
+
className: styles.background,
|
|
50
|
+
cx: "108",
|
|
51
|
+
cy: "108",
|
|
52
|
+
r: "108",
|
|
53
|
+
transform: "translate(76 116)"
|
|
54
|
+
})), /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("circle", {
|
|
55
|
+
className: styles.circle,
|
|
56
|
+
cx: "104",
|
|
57
|
+
cy: "104",
|
|
58
|
+
r: "104",
|
|
59
|
+
transform: "translate(76 162)"
|
|
60
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
61
|
+
className: styles.circle,
|
|
62
|
+
cx: "92",
|
|
63
|
+
cy: "92",
|
|
64
|
+
r: "92",
|
|
65
|
+
transform: "translate(88 174)"
|
|
66
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
67
|
+
className: styles.circle,
|
|
68
|
+
cx: "80",
|
|
69
|
+
cy: "80",
|
|
70
|
+
r: "80",
|
|
71
|
+
transform: "translate(100 186)"
|
|
72
|
+
})), /*#__PURE__*/React.createElement("g", {
|
|
73
|
+
name: "cloud",
|
|
74
|
+
filter: `url(#${filterId})`,
|
|
75
|
+
transform: "translate(83.6 235.124)"
|
|
76
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
77
|
+
transform: "matrix(1, 0, 0, 1, 2686.4, -7054.12)"
|
|
78
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
79
|
+
className: styles.background,
|
|
80
|
+
d: "M90.216,116.652a24.732,24.732,0,0,1-20.61-10.992,13.394,13.394,0,0,1-7.263-1.374,20,20,0,0,1-7.655,1.767,20.473,20.473,0,0,1-18.255-10.6,20.009,20.009,0,0,1-6.478.981A23.584,23.584,0,0,1,6.4,73.076c0-10.6,6.085-19.236,15.507-22.181V50.11A13.07,13.07,0,0,1,34.862,37.155a13.905,13.905,0,0,1,2.748.2A18.6,18.6,0,0,1,52.724,29.7,19.248,19.248,0,0,1,65.876,35,14.4,14.4,0,0,1,75.1,31.659a13.191,13.191,0,0,1,6.281,1.963,24.851,24.851,0,0,1,40.239,1.767,21.962,21.962,0,0,1,20.61,5.3c.393-.2.589-.393.981-.589a16.9,16.9,0,0,1,7.459-1.963,15.491,15.491,0,0,1,15.311,13.937A22.951,22.951,0,0,1,181.49,64.439c2.944,6.478,2.355,13.544-1.57,20.218a21.266,21.266,0,0,1-18.059,10.011h-.2c-4.122,0-7.459-.785-10.207-2.552a13.109,13.109,0,0,1-7.263.393,24.871,24.871,0,0,1-15.311,15.114,24.1,24.1,0,0,1-18.451-.981A25.762,25.762,0,0,1,90.216,116.652Z",
|
|
81
|
+
transform: "translate(-2686.4 7054.12)"
|
|
82
|
+
}))), /*#__PURE__*/React.createElement("g", {
|
|
83
|
+
name: "magnifier",
|
|
84
|
+
filter: `url(#${filterId})`
|
|
85
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
86
|
+
transform: "matrix(1, 0, 0, 1, 2770, -6819)"
|
|
87
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
88
|
+
className: styles.magnifier,
|
|
89
|
+
width: "13.003",
|
|
90
|
+
height: "3.855",
|
|
91
|
+
transform: "matrix(0.53, 0.85, -0.85, 0.53, -2613.92, 7029.38)"
|
|
92
|
+
})), /*#__PURE__*/React.createElement("g", {
|
|
93
|
+
transform: "matrix(1, 0, 0, 1, 2770, -6819)"
|
|
94
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
95
|
+
className: styles.magnifier,
|
|
96
|
+
width: "3.855",
|
|
97
|
+
height: "13.003",
|
|
98
|
+
transform: "translate(-2566.07 7029.56) rotate(37.01)"
|
|
99
|
+
})), /*#__PURE__*/React.createElement("g", {
|
|
100
|
+
transform: "matrix(1, 0, 0, 1, 2770, -6819)"
|
|
101
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
102
|
+
className: styles.magnifier,
|
|
103
|
+
width: "3.856",
|
|
104
|
+
height: "13.002",
|
|
105
|
+
transform: "translate(-2592.67 7023)"
|
|
106
|
+
})), /*#__PURE__*/React.createElement("circle", {
|
|
107
|
+
className: styles.background,
|
|
108
|
+
cx: "34",
|
|
109
|
+
cy: "34",
|
|
110
|
+
r: "34",
|
|
111
|
+
transform: "translate(147 223)"
|
|
112
|
+
}), /*#__PURE__*/React.createElement("g", {
|
|
113
|
+
transform: "translate(136 -7)"
|
|
114
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
115
|
+
transform: "translate(10.699 229.942)"
|
|
116
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
117
|
+
transform: "translate(0 0)"
|
|
118
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
119
|
+
transform: "matrix(1, 0, 0, 1, 2623.3, -7041.94)"
|
|
120
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
121
|
+
className: styles.magnifier,
|
|
122
|
+
d: "M83.335,33.853a34.228,34.228,0,1,0-1.494,49.8l4.482,4.482L84.63,89.829a1.926,1.926,0,0,0,0,2.789l17.032,16.932a1.926,1.926,0,0,0,2.789,0l5.677-5.677a1.926,1.926,0,0,0,0-2.789L93.1,84.152a1.926,1.926,0,0,0-2.789,0l-1.1,1.1-4.482-4.482A34.352,34.352,0,0,0,83.335,33.853Zm22.51,68.625-2.789,2.789L88.912,91.124,91.7,88.335ZM37.718,79.47a30.214,30.214,0,1,1,42.729,0A30.3,30.3,0,0,1,37.718,79.47Z",
|
|
123
|
+
transform: "translate(-2648.22 7018.1)"
|
|
124
|
+
})), /*#__PURE__*/React.createElement("path", {
|
|
125
|
+
className: styles.magnifier,
|
|
126
|
+
d: "M111.291,55.583a1.972,1.972,0,1,0,2.789-2.789,28.585,28.585,0,0,0-40.338-.1,1.972,1.972,0,0,0,2.789,2.789A24.557,24.557,0,0,1,111.291,55.583Z",
|
|
127
|
+
transform: "translate(-59.748 -38.701)"
|
|
128
|
+
})))))));
|
|
129
|
+
};
|
|
130
|
+
NoResultIcon.defaultProps = {
|
|
131
|
+
className: ''
|
|
132
|
+
};
|
|
133
|
+
export default NoResultIcon;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeColors } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const magnifier = css({
|
|
4
|
+
fill: 'currentColor'
|
|
5
|
+
}).toString();
|
|
6
|
+
const background = css({
|
|
7
|
+
fill: themeColors.light
|
|
8
|
+
}).toString();
|
|
9
|
+
const circle = css({
|
|
10
|
+
fill: 'currentColor',
|
|
11
|
+
opacity: 0.065
|
|
12
|
+
}).toString();
|
|
13
|
+
export default {
|
|
14
|
+
magnifier,
|
|
15
|
+
background,
|
|
16
|
+
circle
|
|
17
|
+
};
|
package/NoResults/index.js
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
import React,{useMemo}
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
5
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
6
|
+
import { svgToDataUrl } from '@shopgate/engage/core';
|
|
7
|
+
import Icon from "./components/Icon";
|
|
8
|
+
import styles from "./style";
|
|
9
|
+
const {
|
|
10
|
+
svgImages = {}
|
|
11
|
+
} = themeConfig || {};
|
|
12
|
+
const {
|
|
13
|
+
noResultsImage = ''
|
|
14
|
+
} = svgImages || {};
|
|
15
|
+
|
|
16
|
+
/**
|
|
2
17
|
* The NoResults component.
|
|
3
18
|
* @param {Object} props The component props.
|
|
4
19
|
* @returns {JSX.Element}
|
|
5
|
-
*/
|
|
20
|
+
*/
|
|
21
|
+
const NoResults = props => {
|
|
22
|
+
const imageSRC = useMemo(() => svgToDataUrl(noResultsImage), []);
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: classNames(styles.wrapper, props.className, ' ui-shared__no-results'),
|
|
25
|
+
"data-test-id": "noResults"
|
|
26
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: classNames(styles.icon, 'no-results__image')
|
|
28
|
+
}, noResultsImage ? /*#__PURE__*/React.createElement("img", {
|
|
29
|
+
src: imageSRC,
|
|
30
|
+
alt: ""
|
|
31
|
+
}) : /*#__PURE__*/React.createElement(Icon, null)), /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
role: "alert",
|
|
33
|
+
"aria-atomic": "true"
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: styles.headline
|
|
36
|
+
}, /*#__PURE__*/React.createElement(I18n.Text, {
|
|
37
|
+
string: props.headlineText,
|
|
38
|
+
params: props
|
|
39
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: styles.text
|
|
41
|
+
}, /*#__PURE__*/React.createElement(I18n.Text, {
|
|
42
|
+
string: props.bodyText,
|
|
43
|
+
params: props
|
|
44
|
+
}))));
|
|
45
|
+
};
|
|
46
|
+
NoResults.defaultProps = {
|
|
47
|
+
className: null
|
|
48
|
+
};
|
|
49
|
+
export default NoResults;
|