@shopgate/pwa-ui-shared 7.30.0-alpha.7 → 7.30.0-alpha.9
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 +63 -2
- package/ActionButton/style.js +22 -1
- package/AddToCartButton/index.js +184 -27
- package/AddToCartButton/mock.js +18 -4
- package/AddToCartButton/spec.js +65 -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 +308 -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 +40 -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/NoResults/style.js
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const wrapper = css({
|
|
4
|
+
alignItems: 'center',
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
height: '100%',
|
|
8
|
+
width: '100%',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
textAlign: 'center',
|
|
11
|
+
background: `var(--page-background-color, ${themeConfig.colors.shade8})`
|
|
12
|
+
}).toString();
|
|
13
|
+
const icon = css({
|
|
14
|
+
width: 216,
|
|
15
|
+
color: `var(--color-primary, ${themeConfig.colors.primary})`
|
|
16
|
+
}).toString();
|
|
17
|
+
const headline = css({
|
|
18
|
+
fontSize: '1.25rem',
|
|
19
|
+
fontWeight: 500,
|
|
20
|
+
marginTop: 30
|
|
21
|
+
}).toString();
|
|
22
|
+
const text = css({
|
|
23
|
+
marginTop: themeConfig.variables.gap.big,
|
|
24
|
+
padding: `0 ${themeConfig.variables.gap.big}px`
|
|
25
|
+
}).toString();
|
|
26
|
+
export default {
|
|
27
|
+
wrapper,
|
|
28
|
+
icon,
|
|
29
|
+
headline,
|
|
30
|
+
text
|
|
31
|
+
};
|
package/Placeholder/index.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styles from "./style";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* The placeholder component.
|
|
3
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
class Placeholder extends PureComponent {
|
|
9
|
+
/**
|
|
4
10
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
render() {
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: `${styles} ui-shared__placeholder`,
|
|
15
|
+
style: this.props
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/* eslint-disable react/no-unused-prop-types */
|
|
20
|
+
/* eslint-enable react/no-unused-prop-types */
|
|
21
|
+
Placeholder.defaultProps = {
|
|
22
|
+
height: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
top: 0,
|
|
25
|
+
width: 0
|
|
26
|
+
};
|
|
27
|
+
export default Placeholder;
|
package/Placeholder/style.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const {
|
|
4
|
+
colors: {
|
|
5
|
+
shade7
|
|
6
|
+
}
|
|
7
|
+
} = themeConfig;
|
|
8
|
+
export default css({
|
|
9
|
+
background: `var(--color-background-accent, ${shade7})`,
|
|
10
|
+
position: 'relative'
|
|
11
|
+
});
|
|
@@ -1,5 +1,30 @@
|
|
|
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
|
* Placeholder for one line texts.
|
|
3
7
|
* @param {Object} props The component props.
|
|
4
8
|
* @return {JSX}
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const PlaceholderLabel = ({
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
ready,
|
|
14
|
+
style
|
|
15
|
+
}) => {
|
|
16
|
+
if (!ready) {
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
style: style,
|
|
19
|
+
className: `${styles.label} ${className} ui-shared__placeholder-label`
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return children;
|
|
23
|
+
};
|
|
24
|
+
PlaceholderLabel.defaultProps = {
|
|
25
|
+
children: null,
|
|
26
|
+
className: '',
|
|
27
|
+
style: null,
|
|
28
|
+
ready: false
|
|
29
|
+
};
|
|
30
|
+
export default PlaceholderLabel;
|
package/PlaceholderLabel/spec.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import PlaceholderLabel from "./index";
|
|
4
|
+
describe('<PlaceholderLabel />', () => {
|
|
5
|
+
it('should render placeholder ', () => {
|
|
6
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(PlaceholderLabel, {
|
|
7
|
+
ready: false
|
|
8
|
+
}, /*#__PURE__*/React.createElement("h1", null, "foo")));
|
|
9
|
+
expect(wrapper).toMatchSnapshot();
|
|
10
|
+
expect(wrapper.find('h1').length).toEqual(0);
|
|
11
|
+
});
|
|
12
|
+
it('should render children', () => {
|
|
13
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(PlaceholderLabel, {
|
|
14
|
+
ready: true
|
|
15
|
+
}, /*#__PURE__*/React.createElement("h1", null, "foo")));
|
|
16
|
+
expect(wrapper).toMatchSnapshot();
|
|
17
|
+
expect(wrapper.find('h1').length).toEqual(1);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const label = css({
|
|
4
|
+
background: themeConfig.colors.dark,
|
|
5
|
+
opacity: 0.1,
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: 16,
|
|
8
|
+
marginBottom: 12
|
|
9
|
+
}).toString();
|
|
10
|
+
export default {
|
|
11
|
+
label
|
|
12
|
+
};
|
|
@@ -1,6 +1,40 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import range from 'lodash/range';
|
|
4
|
+
import PlaceholderLabel from "../PlaceholderLabel";
|
|
5
|
+
const widths = [95, 100, 92, 88, 96, 93, 96, 48];
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* The paragraph placeholder component.
|
|
3
9
|
* Creates a simple paragraph out of PlaceholderLabels.
|
|
4
10
|
* @param {Object} props The component props.
|
|
5
11
|
* @return {JSX}
|
|
6
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const PlaceholderParagraph = ({
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
lines,
|
|
17
|
+
ready
|
|
18
|
+
}) => {
|
|
19
|
+
if (ready) {
|
|
20
|
+
return children;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: "ui-shared__placeholder-paragraph"
|
|
24
|
+
}, range(lines).map(num => {
|
|
25
|
+
const width = num % 2 === 0 ? `${widths[(num / 2 + widths.length) % widths.length]}%` : null;
|
|
26
|
+
return /*#__PURE__*/React.createElement(PlaceholderLabel, {
|
|
27
|
+
key: num,
|
|
28
|
+
style: width ? {
|
|
29
|
+
width
|
|
30
|
+
} : null,
|
|
31
|
+
className: className
|
|
32
|
+
});
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
PlaceholderParagraph.defaultProps = {
|
|
36
|
+
className: '',
|
|
37
|
+
lines: 3,
|
|
38
|
+
ready: false
|
|
39
|
+
};
|
|
40
|
+
export default PlaceholderParagraph;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import PlaceholderParagraph from "./index";
|
|
4
|
+
describe('<PlaceholderParagraph />', () => {
|
|
5
|
+
it('should render placeholder ', () => {
|
|
6
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(PlaceholderParagraph, {
|
|
7
|
+
ready: false
|
|
8
|
+
}, /*#__PURE__*/React.createElement("h1", null, "foo")));
|
|
9
|
+
expect(wrapper).toMatchSnapshot();
|
|
10
|
+
expect(wrapper.find('h1').length).toEqual(0);
|
|
11
|
+
});
|
|
12
|
+
it('should render children', () => {
|
|
13
|
+
const wrapper = mount(/*#__PURE__*/React.createElement(PlaceholderParagraph, {
|
|
14
|
+
ready: true
|
|
15
|
+
}, /*#__PURE__*/React.createElement("h1", null, "foo")));
|
|
16
|
+
expect(wrapper).toMatchSnapshot();
|
|
17
|
+
expect(wrapper.find('h1').length).toEqual(1);
|
|
18
|
+
});
|
|
19
|
+
});
|
package/Price/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.string.replace.js";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { I18n } from '@shopgate/engage/components';
|
|
6
|
+
import showTaxDisclaimer from '@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';
|
|
7
|
+
import { useWidgetSettings } from '@shopgate/engage/core/hooks/useWidgetSettings';
|
|
8
|
+
import styles from "./style";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* The Price component
|
|
3
12
|
* @param {Object} props The component props
|
|
4
13
|
* @param {string} [props.className] CSS classes
|
|
@@ -8,12 +17,84 @@ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj
|
|
|
8
17
|
* @param {boolean} props.discounted Tells if the pice is discounted
|
|
9
18
|
* @param {Object} context The component context.
|
|
10
19
|
* @return {JSX.Element}
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
*/
|
|
21
|
+
const Price = (props, context) => {
|
|
22
|
+
// Added with PWA 6 - CCP-2372
|
|
23
|
+
const {
|
|
24
|
+
show,
|
|
25
|
+
hint
|
|
26
|
+
} = useWidgetSettings('@shopgate/engage/components/TaxDisclaimer');
|
|
27
|
+
|
|
28
|
+
// use widget setting if set to true/false, otherwise use market logic
|
|
29
|
+
const showDisclaimer = typeof show === 'boolean' ? show : showTaxDisclaimer;
|
|
30
|
+
const containerClasses = classNames(styles.container, props.className, {
|
|
31
|
+
[styles.discounted]: props.discounted
|
|
32
|
+
}, 'price', props.discounted ? 'ui-shared__price-discounted' : 'ui-shared__price');
|
|
33
|
+
const {
|
|
34
|
+
__,
|
|
35
|
+
_p
|
|
36
|
+
} = context.i18n();
|
|
37
|
+
let ariaPrice;
|
|
38
|
+
const showFromPrice = useMemo(() => {
|
|
39
|
+
// unitPriceMin is falsy so we don't have a price range
|
|
40
|
+
if (!props.unitPriceMin) return false;
|
|
41
|
+
// Only show 'from' if we have a price range (both prices are available and different)
|
|
42
|
+
return props.unitPriceMin !== props.unitPriceMax;
|
|
43
|
+
}, [props.unitPriceMax, props.unitPriceMin]);
|
|
44
|
+
if (showFromPrice) {
|
|
45
|
+
ariaPrice = __('price.from', {
|
|
46
|
+
price: _p(props.unitPriceMin, props.currency, props.fractions)
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
ariaPrice = _p(props.unitPrice, props.currency, props.fractions);
|
|
50
|
+
}
|
|
51
|
+
ariaPrice = ariaPrice.replace('-', '\u2212');
|
|
52
|
+
|
|
53
|
+
/**
|
|
16
54
|
* A unitPriceMin > 0 means, that the product has child products with different prices.
|
|
17
55
|
* The unitPriceMin contains the lowest of these prices and will be
|
|
18
56
|
* displayed with a 'From' prefix.
|
|
19
|
-
*/
|
|
57
|
+
*/
|
|
58
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: containerClasses,
|
|
60
|
+
"data-test-id": `minPrice: ${props.unitPriceMin} price: ${props.unitPrice} currency: ${props.currency}`
|
|
61
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
62
|
+
"aria-label": __('price.label', {
|
|
63
|
+
price: ariaPrice
|
|
64
|
+
})
|
|
65
|
+
}, showFromPrice ? /*#__PURE__*/React.createElement(I18n.Text, {
|
|
66
|
+
"aria-hidden": true,
|
|
67
|
+
string: "price.from"
|
|
68
|
+
}, /*#__PURE__*/React.createElement(I18n.Price, {
|
|
69
|
+
currency: props.currency,
|
|
70
|
+
fractions: props.fractions,
|
|
71
|
+
forKey: "price",
|
|
72
|
+
price: props.unitPriceMin
|
|
73
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, props.allowFree && props.unitPrice === 0 ? /*#__PURE__*/React.createElement(I18n.Text, {
|
|
74
|
+
string: "price.free"
|
|
75
|
+
}) : /*#__PURE__*/React.createElement(I18n.Price, {
|
|
76
|
+
currency: props.currency,
|
|
77
|
+
fractions: props.fractions,
|
|
78
|
+
price: props.unitPrice
|
|
79
|
+
}))), props.taxDisclaimer && showDisclaimer ? /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: styles.disclaimer
|
|
81
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
82
|
+
"aria-hidden": true
|
|
83
|
+
}, hint || '*'), /*#__PURE__*/React.createElement("span", {
|
|
84
|
+
className: "sr-only",
|
|
85
|
+
"aria-label": hint || __('product.tax_disclaimer_aria')
|
|
86
|
+
}, __('product.tax_disclaimer_aria'))) : null);
|
|
87
|
+
};
|
|
88
|
+
Price.defaultProps = {
|
|
89
|
+
className: '',
|
|
90
|
+
unitPriceMin: 0,
|
|
91
|
+
unitPriceMax: undefined,
|
|
92
|
+
discounted: false,
|
|
93
|
+
fractions: true,
|
|
94
|
+
taxDisclaimer: false,
|
|
95
|
+
allowFree: false
|
|
96
|
+
};
|
|
97
|
+
Price.contextTypes = {
|
|
98
|
+
i18n: PropTypes.func
|
|
99
|
+
};
|
|
100
|
+
export default Price;
|
package/Price/style.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const container = css({
|
|
4
|
+
display: 'flex',
|
|
5
|
+
position: 'relative',
|
|
6
|
+
whiteSpace: 'nowrap'
|
|
7
|
+
}).toString();
|
|
8
|
+
const disclaimer = css({
|
|
9
|
+
color: 'initial',
|
|
10
|
+
fontSize: 14,
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
right: -10,
|
|
13
|
+
top: 0
|
|
14
|
+
}).toString();
|
|
15
|
+
const discounted = css({
|
|
16
|
+
color: `var(--color-primary, ${themeConfig.colors.primary})`
|
|
17
|
+
}).toString();
|
|
18
|
+
export default {
|
|
19
|
+
container,
|
|
20
|
+
disclaimer,
|
|
21
|
+
discounted
|
|
22
|
+
};
|
package/PriceInfo/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 price info component
|
|
3
7
|
* @param {Object} props The component props
|
|
4
8
|
* @param {string} props.text The price info string e.g. 12,00 € / l
|
|
5
9
|
* @param {string} [props.className] CSS classes
|
|
6
10
|
* @return {JSX}
|
|
7
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const PriceInfo = ({
|
|
13
|
+
className,
|
|
14
|
+
text
|
|
15
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: `${styles} ${className} ui-shared__price-info`,
|
|
17
|
+
dangerouslySetInnerHTML: {
|
|
18
|
+
__html: text
|
|
19
|
+
},
|
|
20
|
+
"data-test-id": `priceInfo: ${text}`
|
|
21
|
+
});
|
|
22
|
+
PriceInfo.defaultProps = {
|
|
23
|
+
className: ''
|
|
24
|
+
};
|
|
25
|
+
export default PriceInfo;
|
package/PriceInfo/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: themeConfig.colors.shade3
|
|
5
|
+
}).toString();
|
package/PriceStriked/index.js
CHANGED
|
@@ -1,29 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
4
|
+
import styles from "./style";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* Calculates the angle for the strike-through line
|
|
3
8
|
* @param {HTMLElement} element The price element
|
|
4
9
|
* @returns {number} the calculated angle
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const calcAngle = element => {
|
|
12
|
+
/**
|
|
6
13
|
* If the element is in a hidden container the browser won't calculate it's size.
|
|
7
14
|
* In that case we clone in into a visible container and then remove it again.
|
|
8
|
-
*/
|
|
9
|
-
|
|
15
|
+
*/
|
|
16
|
+
const cloned = element.cloneNode(true);
|
|
17
|
+
document.body.appendChild(cloned);
|
|
18
|
+
const width = cloned.offsetWidth;
|
|
19
|
+
const height = cloned.offsetHeight;
|
|
20
|
+
document.body.removeChild(cloned);
|
|
21
|
+
|
|
22
|
+
// Calculate the correct angle for the strike-through line
|
|
23
|
+
return Math.round(90 - Math.atan(width / height) * (180 / Math.PI));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
10
27
|
* The price striked component
|
|
11
28
|
* @param {Object} props The component props
|
|
12
29
|
* @param {number} props.value The striked price of the product
|
|
13
30
|
* @param {string} props.currency The currency of the price
|
|
14
31
|
* @param {string} [props.className] CSS classes
|
|
15
32
|
* @return {JSX}
|
|
16
|
-
*/
|
|
33
|
+
*/
|
|
34
|
+
class PriceStriked extends Component {
|
|
35
|
+
/**
|
|
17
36
|
* Constructor
|
|
18
37
|
* @param {Object} props The component props
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
*/
|
|
39
|
+
constructor(props) {
|
|
40
|
+
super(props);
|
|
41
|
+
/**
|
|
42
|
+
* Sets the calculated angle for the DOM element
|
|
43
|
+
* and returns true if succeeded.
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
this.setAngle = () => {
|
|
47
|
+
if (this.element) {
|
|
48
|
+
this.angle = calcAngle(this.element);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
this.angle = null;
|
|
54
|
+
this.element = null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
24
58
|
* Updates the component one more time with the calculated angle
|
|
25
59
|
* based on the DOM element.
|
|
26
|
-
*/
|
|
60
|
+
*/
|
|
61
|
+
componentDidMount() {
|
|
62
|
+
if (this.setAngle()) {
|
|
63
|
+
this.forceUpdate();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
27
67
|
* Renders the component.
|
|
28
68
|
* @returns {JSX.Element}
|
|
29
|
-
*/
|
|
69
|
+
*/
|
|
70
|
+
render() {
|
|
71
|
+
const {
|
|
72
|
+
__,
|
|
73
|
+
_p
|
|
74
|
+
} = this.context.i18n();
|
|
75
|
+
const angleStyle = this.angle ? styles.getAngleStyle(this.angle) : '';
|
|
76
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: `${styles.basic} ${this.props.className} ${angleStyle} price-striked ui-shared__price-striked`
|
|
78
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
79
|
+
"aria-hidden": true,
|
|
80
|
+
ref: ref => {
|
|
81
|
+
this.element = ref;
|
|
82
|
+
},
|
|
83
|
+
"data-test-id": `strikedPrice: ${this.props.value}`
|
|
84
|
+
}, /*#__PURE__*/React.createElement(I18n.Price, {
|
|
85
|
+
price: this.props.value,
|
|
86
|
+
currency: this.props.currency
|
|
87
|
+
}))), /*#__PURE__*/React.createElement("span", {
|
|
88
|
+
className: "sr-only"
|
|
89
|
+
}, __('price.label_old_price', {
|
|
90
|
+
price: _p(this.props.value, this.props.currency, true)
|
|
91
|
+
})));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
PriceStriked.defaultProps = {
|
|
95
|
+
className: ''
|
|
96
|
+
};
|
|
97
|
+
PriceStriked.contextTypes = {
|
|
98
|
+
i18n: PropTypes.func
|
|
99
|
+
};
|
|
100
|
+
export default PriceStriked;
|
package/PriceStriked/style.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
import{css}from'glamor';
|
|
2
|
-
|
|
1
|
+
import { css } from 'glamor';
|
|
2
|
+
import { themeColors } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
+
const basic = css({
|
|
4
|
+
whiteSpace: 'nowrap',
|
|
5
|
+
'& span': {
|
|
6
|
+
position: 'relative',
|
|
7
|
+
':before': {
|
|
8
|
+
// The strike-through effect is achieved by using the :before pseudo-class.
|
|
9
|
+
borderColor: 'currentColor',
|
|
10
|
+
content: '""',
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
left: 0,
|
|
13
|
+
right: 0,
|
|
14
|
+
top: '50%'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
color: themeColors.shade11
|
|
18
|
+
}).toString();
|
|
19
|
+
|
|
20
|
+
/**
|
|
3
21
|
* Returns a class for the rotated strike-through line.
|
|
4
22
|
* @param {number} angle The calculated angle for the strike-through line.
|
|
5
23
|
* @returns {string} Classname
|
|
6
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
const getAngleStyle = angle => css({
|
|
26
|
+
'& span': {
|
|
27
|
+
':before': {
|
|
28
|
+
borderTop: '1px solid',
|
|
29
|
+
transform: `rotate(-${angle}deg)`
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}).toString();
|
|
33
|
+
export default {
|
|
34
|
+
basic,
|
|
35
|
+
getAngleStyle
|
|
36
|
+
};
|
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import React from'react';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import Ellipsis from '@shopgate/pwa-common/components/Ellipsis';
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* The Product Properties component.
|
|
3
8
|
* @param {Object} props The component props.
|
|
4
9
|
* @returns {JSX}
|
|
5
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const Properties = ({
|
|
12
|
+
lineClamp,
|
|
13
|
+
properties,
|
|
14
|
+
className
|
|
15
|
+
}) => {
|
|
16
|
+
if (!properties.length) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /*#__PURE__*/React.createElement("ul", {
|
|
20
|
+
className: classNames(className, 'ui-shared__product-properties')
|
|
21
|
+
}, properties.map(({
|
|
22
|
+
label,
|
|
23
|
+
value
|
|
24
|
+
}) => /*#__PURE__*/React.createElement("li", {
|
|
25
|
+
key: `${label}-${value}`
|
|
26
|
+
}, lineClamp && /*#__PURE__*/React.createElement(Ellipsis, {
|
|
27
|
+
rows: lineClamp
|
|
28
|
+
}, `${label}: ${value}`), !lineClamp && `${label}: ${value}`)));
|
|
29
|
+
};
|
|
30
|
+
Properties.defaultProps = {
|
|
31
|
+
className: null,
|
|
32
|
+
lineClamp: null,
|
|
33
|
+
properties: []
|
|
34
|
+
};
|
|
35
|
+
export default Properties;
|