@shopgate/pwa-ui-shared 7.31.4-beta.1 → 7.32.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/ActionButton/spec.js +25 -28
  2. package/AddToCartButton/index.js +14 -14
  3. package/Availability/index.js +11 -28
  4. package/Availability/spec.js +11 -11
  5. package/Button/index.js +6 -9
  6. package/ButtonLink/spec.js +11 -7
  7. package/Card/index.js +5 -8
  8. package/CardList/components/Item/index.js +1 -2
  9. package/CartTotalLine/index.js +8 -12
  10. package/Checkbox/index.js +3 -4
  11. package/Chip/index.js +9 -10
  12. package/ContextMenu/components/Item/index.js +18 -28
  13. package/ContextMenu/index.js +3 -4
  14. package/Dialog/components/HtmlContentDialog/spec.js +7 -1
  15. package/DiscountBadge/index.js +35 -32
  16. package/DiscountBadge/spec.js +5 -5
  17. package/FavoritesButton/connector.js +1 -1
  18. package/FavoritesButton/index.js +26 -23
  19. package/Form/Checkbox/index.js +1 -1
  20. package/Form/InfoField/spec.js +3 -3
  21. package/Form/Password/index.js +3 -7
  22. package/Form/RadioGroup/components/Item/index.js +1 -3
  23. package/Form/Select/index.js +4 -5
  24. package/Form/Select/spec.js +3 -3
  25. package/Form/SelectContextChoices/index.js +8 -8
  26. package/Form/SelectContextChoices/spec.js +3 -3
  27. package/Form/TextField/index.js +3 -5
  28. package/FormElement/components/ErrorText/index.js +7 -8
  29. package/FormElement/components/Label/index.js +2 -2
  30. package/FormElement/components/Placeholder/index.js +3 -3
  31. package/FormElement/components/Underline/index.js +9 -17
  32. package/Glow/index.js +1 -2
  33. package/Glow/spec.js +3 -3
  34. package/IndicatorCircle/index.js +3 -4
  35. package/LoadingIndicator/index.js +3 -3
  36. package/Manufacturer/index.js +2 -2
  37. package/NoResults/components/Icon/index.js +3 -4
  38. package/NoResults/index.js +5 -5
  39. package/Placeholder/index.js +2 -2
  40. package/PlaceholderLabel/index.js +2 -3
  41. package/Price/index.js +4 -3
  42. package/PriceInfo/index.js +3 -4
  43. package/PriceStriked/index.js +3 -4
  44. package/ProgressBar/index.js +7 -12
  45. package/RadioButton/index.js +3 -4
  46. package/RatingStars/index.js +4 -5
  47. package/Ripple/components/RippleAnimation/index.js +1 -2
  48. package/Ripple/index.js +1 -2
  49. package/ScannerOverlay/components/CameraOverlay/index.js +1 -2
  50. package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +4 -4
  51. package/ScannerOverlay/components/ScannerBar/index.js +4 -5
  52. package/Sheet/components/Header/components/SearchBar/index.js +6 -7
  53. package/Sheet/components/Header/index.js +18 -15
  54. package/Sheet/components/Header/spec.js +3 -1
  55. package/Sheet/index.js +6 -7
  56. package/TaxDisclaimer/index.js +11 -10
  57. package/TaxDisclaimer/spec.js +2 -1
  58. package/TextField/components/ErrorText/index.js +7 -7
  59. package/TextField/components/FormElement/index.js +3 -3
  60. package/TextField/components/Hint/index.js +3 -4
  61. package/TextField/components/Label/index.js +2 -2
  62. package/TextField/components/Underline/index.js +9 -17
  63. package/icons/AccountBoxIcon.d.ts +1 -1
  64. package/icons/AccountBoxIcon.d.ts.map +1 -1
  65. package/icons/AddMoreIcon.d.ts +1 -1
  66. package/icons/AddMoreIcon.d.ts.map +1 -1
  67. package/icons/ArrowDropIcon.d.ts +1 -1
  68. package/icons/ArrowDropIcon.d.ts.map +1 -1
  69. package/icons/ArrowIcon.d.ts +1 -1
  70. package/icons/ArrowIcon.d.ts.map +1 -1
  71. package/icons/BarcodeScannerIcon.d.ts +1 -1
  72. package/icons/BarcodeScannerIcon.d.ts.map +1 -1
  73. package/icons/BoxIcon.d.ts +1 -1
  74. package/icons/BoxIcon.d.ts.map +1 -1
  75. package/icons/BrowseIcon.d.ts +2 -1
  76. package/icons/BrowseIcon.d.ts.map +1 -1
  77. package/icons/BurgerIcon.d.ts +1 -1
  78. package/icons/BurgerIcon.d.ts.map +1 -1
  79. package/icons/CalendarIcon.d.ts +2 -1
  80. package/icons/CalendarIcon.d.ts.map +1 -1
  81. package/icons/CartCouponIcon.d.ts +2 -1
  82. package/icons/CartCouponIcon.d.ts.map +1 -1
  83. package/icons/CartIcon.d.ts +2 -1
  84. package/icons/CartIcon.d.ts.map +1 -1
  85. package/icons/CartPlusIcon.d.ts +2 -1
  86. package/icons/CartPlusIcon.d.ts.map +1 -1
  87. package/icons/CheckIcon.d.ts +2 -1
  88. package/icons/CheckIcon.d.ts.map +1 -1
  89. package/icons/CheckedIcon.d.ts +1 -1
  90. package/icons/CheckedIcon.d.ts.map +1 -1
  91. package/icons/ChevronIcon.d.ts +2 -1
  92. package/icons/ChevronIcon.d.ts.map +1 -1
  93. package/icons/CreditCardIcon.d.ts +2 -1
  94. package/icons/CreditCardIcon.d.ts.map +1 -1
  95. package/icons/CrossIcon.d.ts +2 -1
  96. package/icons/CrossIcon.d.ts.map +1 -1
  97. package/icons/DescriptionIcon.d.ts +2 -1
  98. package/icons/DescriptionIcon.d.ts.map +1 -1
  99. package/icons/FilterIcon.d.ts +2 -1
  100. package/icons/FilterIcon.d.ts.map +1 -1
  101. package/icons/FlashDisabledIcon.d.ts +2 -1
  102. package/icons/FlashDisabledIcon.d.ts.map +1 -1
  103. package/icons/FlashEnabledIcon.d.ts +2 -1
  104. package/icons/FlashEnabledIcon.d.ts.map +1 -1
  105. package/icons/GridIcon.d.ts +2 -1
  106. package/icons/GridIcon.d.ts.map +1 -1
  107. package/icons/HeartIcon.d.ts +2 -1
  108. package/icons/HeartIcon.d.ts.map +1 -1
  109. package/icons/HeartOutlineIcon.d.ts +2 -1
  110. package/icons/HeartOutlineIcon.d.ts.map +1 -1
  111. package/icons/HeartPlusIcon.d.ts +2 -1
  112. package/icons/HeartPlusIcon.d.ts.map +1 -1
  113. package/icons/HeartPlusOutlineIcon.d.ts +2 -1
  114. package/icons/HeartPlusOutlineIcon.d.ts.map +1 -1
  115. package/icons/HomeIcon.d.ts +2 -1
  116. package/icons/HomeIcon.d.ts.map +1 -1
  117. package/icons/InfoIcon.d.ts +2 -1
  118. package/icons/InfoIcon.d.ts.map +1 -1
  119. package/icons/InfoOutlineIcon.d.ts +2 -1
  120. package/icons/InfoOutlineIcon.d.ts.map +1 -1
  121. package/icons/ListIcon.d.ts +2 -1
  122. package/icons/ListIcon.d.ts.map +1 -1
  123. package/icons/LocalShippingIcon.d.ts +2 -1
  124. package/icons/LocalShippingIcon.d.ts.map +1 -1
  125. package/icons/LocationIcon.d.ts +2 -1
  126. package/icons/LocationIcon.d.ts.map +1 -1
  127. package/icons/LocatorIcon.d.ts +2 -1
  128. package/icons/LocatorIcon.d.ts.map +1 -1
  129. package/icons/LockIcon.d.ts +2 -1
  130. package/icons/LockIcon.d.ts.map +1 -1
  131. package/icons/LogoutIcon.d.ts +2 -1
  132. package/icons/LogoutIcon.d.ts.map +1 -1
  133. package/icons/MagnifierIcon.d.ts +2 -1
  134. package/icons/MagnifierIcon.d.ts.map +1 -1
  135. package/icons/MapMarkerIcon.d.ts +2 -1
  136. package/icons/MapMarkerIcon.d.ts.map +1 -1
  137. package/icons/MoreIcon.d.ts +2 -1
  138. package/icons/MoreIcon.d.ts.map +1 -1
  139. package/icons/MoreVertIcon.d.ts +2 -1
  140. package/icons/MoreVertIcon.d.ts.map +1 -1
  141. package/icons/NotificationIcon.d.ts +2 -1
  142. package/icons/NotificationIcon.d.ts.map +1 -1
  143. package/icons/PersonIcon.d.ts +2 -1
  144. package/icons/PersonIcon.d.ts.map +1 -1
  145. package/icons/PhoneIcon.d.ts +2 -1
  146. package/icons/PhoneIcon.d.ts.map +1 -1
  147. package/icons/PlaceholderIcon.d.ts +2 -1
  148. package/icons/PlaceholderIcon.d.ts.map +1 -1
  149. package/icons/RadioCheckedIcon.d.ts +2 -1
  150. package/icons/RadioCheckedIcon.d.ts.map +1 -1
  151. package/icons/RadioUncheckedIcon.d.ts +2 -1
  152. package/icons/RadioUncheckedIcon.d.ts.map +1 -1
  153. package/icons/SecurityIcon.d.ts +2 -1
  154. package/icons/SecurityIcon.d.ts.map +1 -1
  155. package/icons/ShippingMethodIcon.d.ts +2 -1
  156. package/icons/ShippingMethodIcon.d.ts.map +1 -1
  157. package/icons/ShoppingCartIcon.d.ts +2 -1
  158. package/icons/ShoppingCartIcon.d.ts.map +1 -1
  159. package/icons/SortIcon.d.ts +2 -1
  160. package/icons/SortIcon.d.ts.map +1 -1
  161. package/icons/StarHalfIcon.d.ts +2 -1
  162. package/icons/StarHalfIcon.d.ts.map +1 -1
  163. package/icons/StarIcon.d.ts +2 -1
  164. package/icons/StarIcon.d.ts.map +1 -1
  165. package/icons/StarOutlineIcon.d.ts +2 -1
  166. package/icons/StarOutlineIcon.d.ts.map +1 -1
  167. package/icons/StopIcon.d.ts +2 -1
  168. package/icons/StopIcon.d.ts.map +1 -1
  169. package/icons/TickIcon.d.ts +2 -1
  170. package/icons/TickIcon.d.ts.map +1 -1
  171. package/icons/TimeIcon.d.ts +2 -1
  172. package/icons/TimeIcon.d.ts.map +1 -1
  173. package/icons/TrashIcon.d.ts +1 -1
  174. package/icons/TrashIcon.d.ts.map +1 -1
  175. package/icons/TrashOutlineIcon.d.ts +2 -1
  176. package/icons/TrashOutlineIcon.d.ts.map +1 -1
  177. package/icons/UncheckedIcon.d.ts +2 -1
  178. package/icons/UncheckedIcon.d.ts.map +1 -1
  179. package/icons/ViewListIcon.d.ts +2 -1
  180. package/icons/ViewListIcon.d.ts.map +1 -1
  181. package/icons/VisibilityIcon.d.ts +2 -1
  182. package/icons/VisibilityIcon.d.ts.map +1 -1
  183. package/icons/VisibilityOffIcon.d.ts +2 -1
  184. package/icons/VisibilityOffIcon.d.ts.map +1 -1
  185. package/icons/WarningIcon.d.ts +2 -1
  186. package/icons/WarningIcon.d.ts.map +1 -1
  187. package/package.json +5 -5
@@ -1,57 +1,54 @@
1
1
  import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import IndicatorCircle from "../IndicatorCircle";
4
- import RippleButton from "../RippleButton";
2
+ import { fireEvent, render, screen } from '@testing-library/react';
5
3
  import ActionButton from "./index";
6
4
  import { jsx as _jsx } from "react/jsx-runtime";
7
5
  describe('<ActionButton />', () => {
8
- let renderedElement;
9
- let mockOnClick;
10
- jest.useFakeTimers();
11
-
12
- /**
13
- * Renders the component.
14
- * @param {Object} props The component props.
15
- */
16
- const renderComponent = (props = {}) => {
17
- renderedElement = shallow(/*#__PURE__*/_jsx(ActionButton, {
18
- ...props,
19
- children: "Action Button"
20
- }));
21
- };
6
+ const renderComponent = (props = {}) => render(/*#__PURE__*/_jsx(ActionButton, {
7
+ ...props,
8
+ children: "Action Button"
9
+ }));
22
10
  describe('Given the component was mounted to the DOM', () => {
11
+ let renderedElement;
12
+ let mockOnClick;
23
13
  beforeEach(() => {
14
+ jest.useFakeTimers();
24
15
  mockOnClick = jest.fn();
25
- renderComponent({
16
+ renderedElement = renderComponent({
26
17
  onClick: mockOnClick
27
18
  });
28
19
  });
20
+ afterEach(() => {
21
+ jest.clearAllTimers();
22
+ jest.useRealTimers();
23
+ });
29
24
  it('should match snapshot', () => {
30
- expect(renderedElement).toMatchSnapshot();
25
+ expect(renderedElement.container.firstChild).toMatchSnapshot();
31
26
  });
32
27
  it('should not show the loading indicator by default', () => {
33
- const indicator = renderedElement.find(IndicatorCircle);
34
- expect(indicator.length).toBe(0);
28
+ const indicator = renderedElement.container.querySelector('[data-test-id="loadingIndicator"]');
29
+ expect(indicator).toBeNull();
35
30
  });
36
31
  describe('Given the loading prop is set to true', () => {
37
32
  beforeEach(() => {
38
- renderedElement.setProps({
39
- loading: true
40
- });
33
+ renderedElement.rerender(/*#__PURE__*/_jsx(ActionButton, {
34
+ onClick: mockOnClick,
35
+ loading: true,
36
+ children: "Action Button"
37
+ }));
41
38
  });
42
39
  it('should match snapshot', () => {
43
- expect(renderedElement).toMatchSnapshot();
40
+ expect(renderedElement.container.firstChild).toMatchSnapshot();
44
41
  });
45
42
  it('should show the loading indicator', () => {
46
- const indicator = renderedElement.find(IndicatorCircle);
47
- expect(indicator.length).toBe(1);
43
+ const indicator = renderedElement.container.querySelector('[data-test-id="loadingIndicator"]');
44
+ expect(indicator).toBeTruthy();
48
45
  });
49
46
  });
50
47
  describe('Given the component gets clicked', () => {
51
48
  let timeoutSpy;
52
49
  beforeEach(() => {
53
50
  timeoutSpy = jest.spyOn(global, 'setTimeout');
54
- renderedElement.find(RippleButton).simulate('click');
51
+ fireEvent.click(screen.getByRole('button'));
55
52
  });
56
53
  afterEach(() => {
57
54
  timeoutSpy.mockRestore();
@@ -1,9 +1,8 @@
1
1
  import React, { useCallback, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import spring from 'css-spring';
4
- import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
4
  import { withForwardedRef } from '@shopgate/engage/core';
6
- import { keyframes, makeStyles } from '@shopgate/engage/styles';
5
+ import { keyframes, makeStyles, useTheme } from '@shopgate/engage/styles';
7
6
  import CartPlusIcon from "../icons/CartPlusIcon";
8
7
  import TickIcon from "../icons/TickIcon";
9
8
  import IndicatorCircle from "../IndicatorCircle";
@@ -34,7 +33,7 @@ const springToBottomKeyframes = keyframes(spring({
34
33
  }, {
35
34
  transform: 'translate3d(0, -300%, 0)'
36
35
  }, springOptions));
37
- const useStyles = makeStyles()({
36
+ const useStyles = makeStyles()(theme => ({
38
37
  springFromBottom: {
39
38
  animation: `${springFromBottomKeyframes} 600ms`
40
39
  },
@@ -55,23 +54,23 @@ const useStyles = makeStyles()({
55
54
  spinnerIcon: {
56
55
  left: '50%',
57
56
  top: '50%',
58
- marginTop: -themeConfig.variables.loadingIndicator.size / 2,
59
- marginLeft: -themeConfig.variables.loadingIndicator.size / 2
57
+ marginTop: -32 / 2,
58
+ marginLeft: -32 / 2
60
59
  },
61
60
  buttonReady: {
62
- background: `var(--color-button-cta, ${themeConfig.colors.cta})`,
63
- color: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`
61
+ background: theme.components.ctaButton.background,
62
+ color: theme.contrastColor(theme.components.ctaButton.background)
64
63
  },
65
64
  buttonSuccess: {
66
- background: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`,
67
- color: `var(--color-button-cta, ${themeConfig.colors.cta})`
65
+ background: theme.contrastColor(theme.components.ctaButton.background),
66
+ color: theme.components.ctaButton.background
68
67
  },
69
68
  buttonDisabled: {
70
- background: themeConfig.colors.shade5,
71
- color: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`,
72
- boxShadow: themeConfig.shadows.buttons.disabled
69
+ background: theme.palette.action.disabledBackground,
70
+ color: theme.contrastColor(theme.palette.action.disabledBackground),
71
+ boxShadow: '0 3px 4px rgba(0, 0, 0, 0.13)'
73
72
  }
74
- });
73
+ }));
75
74
 
76
75
  /**
77
76
  * @param {number} bSize .
@@ -114,6 +113,7 @@ const AddToCartButton = ({
114
113
  classes,
115
114
  cx
116
115
  } = useStyles();
116
+ const theme = useTheme();
117
117
  const [showCheckmark, setShowCheckmark] = useState(null);
118
118
 
119
119
  /**
@@ -216,7 +216,7 @@ const AddToCartButton = ({
216
216
  className: cx(classes.icon, classes.spinnerIcon),
217
217
  style: spinnerInlineStyle,
218
218
  children: /*#__PURE__*/_jsx(IndicatorCircle, {
219
- color: themeConfig.colors.primaryContrast,
219
+ color: theme.contrastColor(theme.components.ctaButton.background),
220
220
  strokeWidth: 5,
221
221
  paused: !isLoading
222
222
  })
@@ -1,22 +1,13 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { AVAILABILITY_STATE_OK, AVAILABILITY_STATE_WARNING, AVAILABILITY_STATE_ALERT } from '@shopgate/pwa-common-commerce/product/constants';
4
- import { makeStyles } from '@shopgate/engage/styles';
4
+ import { Typography } from '@shopgate/engage/components';
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- const useStyles = makeStyles()(theme => ({
7
- base: {
8
- fontSize: '0.875rem'
9
- },
10
- stateOk: {
11
- color: theme.palette.success.main
12
- },
13
- stateWarning: {
14
- color: theme.palette.warning.main
15
- },
16
- stateAlert: {
17
- color: theme.palette.error.main
18
- }
19
- }));
6
+ const stateColorMap = {
7
+ [AVAILABILITY_STATE_OK]: 'success',
8
+ [AVAILABILITY_STATE_WARNING]: 'warning',
9
+ [AVAILABILITY_STATE_ALERT]: 'error'
10
+ };
20
11
 
21
12
  /**
22
13
  * This component renders the availability text for a product
@@ -34,22 +25,14 @@ const Availability = ({
34
25
  showWhenAvailable = false,
35
26
  className = null
36
27
  }) => {
37
- const {
38
- classes,
39
- cx
40
- } = useStyles();
41
28
  if (!text || state === AVAILABILITY_STATE_OK && !showWhenAvailable) {
42
29
  return null;
43
30
  }
44
- let stateClass = classes.stateOk;
45
- if (state === AVAILABILITY_STATE_WARNING) {
46
- stateClass = classes.stateWarning;
47
- }
48
- if (state === AVAILABILITY_STATE_ALERT) {
49
- stateClass = classes.stateAlert;
50
- }
51
- return /*#__PURE__*/_jsx("div", {
52
- className: cx('ui-shared__availability', classes.base, stateClass, className),
31
+ return /*#__PURE__*/_jsx(Typography, {
32
+ variant: "body2",
33
+ component: "div",
34
+ color: stateColorMap[state],
35
+ className: `ui-shared__availability${className ? ` ${className}` : ''}`,
53
36
  "data-test-id": `availabilityText: ${text}`,
54
37
  children: text
55
38
  });
@@ -1,42 +1,42 @@
1
1
  import React from 'react';
2
- import { mount } from 'enzyme';
2
+ import { render } from '@testing-library/react';
3
3
  import { AVAILABILITY_STATE_OK, AVAILABILITY_STATE_WARNING, AVAILABILITY_STATE_ALERT } from '@shopgate/pwa-common-commerce/product/constants';
4
4
  import Availability from "./index";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
6
  describe('<Availability />', () => {
7
7
  it('should not render when text is empty', () => {
8
- const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
8
+ const wrapper = render(/*#__PURE__*/_jsx(Availability, {
9
9
  text: ""
10
10
  }));
11
- expect(wrapper).toMatchSnapshot();
11
+ expect(wrapper.asFragment()).toMatchSnapshot();
12
12
  });
13
13
  it('should not render by default if state is "ok"', () => {
14
- const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
14
+ const wrapper = render(/*#__PURE__*/_jsx(Availability, {
15
15
  state: AVAILABILITY_STATE_OK,
16
16
  text: "Available"
17
17
  }));
18
- expect(wrapper).toMatchSnapshot();
18
+ expect(wrapper.asFragment()).toMatchSnapshot();
19
19
  });
20
20
  it('should render if state is "ok" when "showWhenAvailable" is set', () => {
21
- const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
21
+ const wrapper = render(/*#__PURE__*/_jsx(Availability, {
22
22
  state: AVAILABILITY_STATE_OK,
23
23
  text: "Available",
24
24
  showWhenAvailable: true
25
25
  }));
26
- expect(wrapper).toMatchSnapshot();
26
+ expect(wrapper.asFragment()).toMatchSnapshot();
27
27
  });
28
28
  it('should render if state is "warning"', () => {
29
- const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
29
+ const wrapper = render(/*#__PURE__*/_jsx(Availability, {
30
30
  state: AVAILABILITY_STATE_WARNING,
31
31
  text: "Only 5 left"
32
32
  }));
33
- expect(wrapper).toMatchSnapshot();
33
+ expect(wrapper.asFragment()).toMatchSnapshot();
34
34
  });
35
35
  it('should render if state is "warning"', () => {
36
- const wrapper = mount(/*#__PURE__*/_jsx(Availability, {
36
+ const wrapper = render(/*#__PURE__*/_jsx(Availability, {
37
37
  state: AVAILABILITY_STATE_ALERT,
38
38
  text: "Out of stock"
39
39
  }));
40
- expect(wrapper).toMatchSnapshot();
40
+ expect(wrapper.asFragment()).toMatchSnapshot();
41
41
  });
42
42
  });
package/Button/index.js CHANGED
@@ -4,9 +4,6 @@ import BaseButton from '@shopgate/pwa-common/components/Button';
4
4
  import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
5
  import { makeStyles } from '@shopgate/engage/styles';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- const {
8
- colors
9
- } = themeConfig;
10
7
  /**
11
8
  * @param {string} text Text color.
12
9
  * @param {string|null} background Fill color.
@@ -55,21 +52,21 @@ const useStyles = makeStyles()((theme, {
55
52
  };
56
53
  }
57
54
  if (type === 'simple') {
58
- return disabled ? pairFromColors(themeConfig.colors.shade4, themeConfig.colors.shade7, theme) : pairFromColors(themeConfig.colors.dark, themeConfig.colors.shade7, theme);
55
+ return disabled ? pairFromColors(theme.palette.action.disabled, theme.palette.action.disabledBackground, theme) : pairFromColors(theme.palette.common.black, theme.palette.grey.light, theme);
59
56
  }
60
57
  if (type === 'regular') {
61
- return disabled ? pairFromColors(colors.shade4, null, theme) : pairFromColors(colors.dark, null, theme);
58
+ return disabled ? pairFromColors(theme.palette.action.disabled, null, theme) : pairFromColors(theme.palette.common.black, null, theme);
62
59
  }
63
60
  if (type === 'secondary') {
64
61
  if (!flat) {
65
- return disabled ? pairFromColors(colors.shade4, colors.shade7, theme) : pairFromColors('var(--color-primary-contrast)', 'var(--color-primary)', theme);
62
+ return disabled ? pairFromColors(theme.palette.action.disabled, theme.palette.action.disabledBackground, theme) : pairFromColors(theme.palette.primary.contrastText, theme.palette.primary.main, theme);
66
63
  }
67
- return disabled ? pairFromColors(colors.shade4, null, theme) : pairFromColors('var(--color-primary)', null, theme);
64
+ return disabled ? pairFromColors(theme.palette.action.disabled, null, theme) : pairFromColors(theme.palette.primary.main, null, theme);
68
65
  }
69
66
  if (!flat) {
70
- return disabled ? pairFromColors(colors.shade4, colors.shade7, theme) : pairFromColors('var(--color-secondary-contrast)', 'var(--color-secondary)', theme);
67
+ return disabled ? pairFromColors(theme.palette.action.disabled, theme.palette.action.disabledBackground, theme) : pairFromColors(theme.palette.secondary.contrastText, theme.palette.secondary.main, theme);
71
68
  }
72
- return disabled ? pairFromColors(colors.shade4, null, theme) : pairFromColors('var(--color-secondary)', null, theme);
69
+ return disabled ? pairFromColors(theme.palette.action.disabled, null, theme) : pairFromColors(theme.palette.secondary.main, null, theme);
73
70
  });
74
71
 
75
72
  /**
@@ -1,23 +1,27 @@
1
1
  import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import ActionButton from "../ActionButton";
2
+ import { fireEvent, render } from '@testing-library/react';
4
3
  import { UnwrappedButtonLink as ButtonLink } from "./index";
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  describe('<ButtonLink>', () => {
7
6
  describe('On click action', () => {
8
- beforeAll(() => {
9
- ActionButton.clickDelay = 0;
7
+ beforeEach(() => {
8
+ jest.useFakeTimers();
9
+ });
10
+ afterEach(() => {
11
+ jest.runOnlyPendingTimers();
12
+ jest.useRealTimers();
10
13
  });
11
14
  it('should create component and open page on click', () => {
12
15
  const mockedNavigate = jest.fn();
13
16
  const link = 'https://example.com';
14
- const component = shallow(/*#__PURE__*/_jsx(ButtonLink, {
17
+ const component = render(/*#__PURE__*/_jsx(ButtonLink, {
15
18
  href: link,
16
19
  navigate: mockedNavigate,
17
20
  children: "Text inside"
18
21
  }));
19
- expect(component).toMatchSnapshot();
20
- component.simulate('click');
22
+ expect(component.container.firstChild).toMatchSnapshot();
23
+ fireEvent.click(component.container.querySelector('button'));
24
+ jest.runOnlyPendingTimers();
21
25
  expect(mockedNavigate).toHaveBeenCalledTimes(1);
22
26
  expect(mockedNavigate).toHaveBeenCalledWith(link);
23
27
  });
package/Card/index.js CHANGED
@@ -1,20 +1,17 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import React from 'react';
3
2
  import PropTypes from 'prop-types';
4
- import { themeConfig, themeName } from '@shopgate/pwa-common/helpers/config';
5
3
  import { makeStyles } from '@shopgate/engage/styles';
6
4
  import { jsx as _jsx } from "react/jsx-runtime";
7
- const isIOS = themeName.includes('ios');
8
- const useStyles = makeStyles()({
5
+ const useStyles = makeStyles()(theme => ({
9
6
  root: {
10
- boxShadow: themeConfig.shadows.productCard,
7
+ boxShadow: '0 4px 8px rgba(0,0,0,0.16)',
11
8
  margin: '5px 5px 10px',
12
- borderRadius: isIOS ? 10 : 2,
13
- background: themeConfig.colors.light,
9
+ borderRadius: 10,
10
+ background: theme.palette.background.surface,
14
11
  overflow: 'hidden',
15
12
  position: 'relative'
16
13
  }
17
- });
14
+ }));
18
15
 
19
16
  /**
20
17
  * Renders the card component.
@@ -1,12 +1,11 @@
1
1
  import React, { Children } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import ListItem from '@shopgate/pwa-common/components/List/components/Item';
4
- import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
4
  import { makeStyles } from '@shopgate/engage/styles';
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  const useStyles = makeStyles()(theme => ({
8
7
  root: {
9
- background: themeConfig.colors.light,
8
+ background: theme.palette.background.surface,
10
9
  marginBottom: theme.spacing(0.5),
11
10
  position: 'relative'
12
11
  }
@@ -1,36 +1,32 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { themeConfig } from '@shopgate/pwa-common/helpers/config';
4
3
  import { makeStyles } from '@shopgate/engage/styles';
5
4
  import Label from "./components/Label";
6
5
  import Amount from "./components/Amount";
7
6
  import Hint from "./components/Hint";
8
7
  import Spacer from "./components/Spacer";
9
8
  import { jsx as _jsx } from "react/jsx-runtime";
10
- const {
11
- colors
12
- } = themeConfig;
13
- const useStyles = makeStyles()({
9
+ const useStyles = makeStyles()(theme => ({
14
10
  line: {
15
11
  display: 'flex',
16
12
  justifyContent: 'space-between',
17
- fontSize: '0.875rem',
13
+ fontSize: theme.typography.body2.fontSize,
18
14
  alignItems: 'baseline'
19
15
  },
20
16
  disabled: {
21
- color: `${colors.shade4} !important`
17
+ color: `${theme.palette.action.disabled} !important`
22
18
  },
23
19
  base: {
24
- color: colors.shade9
20
+ color: theme.palette.text.secondary
25
21
  },
26
22
  subTotal: {
27
- color: `${colors.dark}`
23
+ color: theme.palette.text.primary
28
24
  },
29
25
  grandTotal: {
30
- color: `${colors.dark}`,
31
- fontSize: '1rem !important'
26
+ color: theme.palette.text.primary,
27
+ fontSize: `${theme.typography.body1.fontSize} !important`
32
28
  }
33
- });
29
+ }));
34
30
 
35
31
  /**
36
32
  * @returns {JSX}
package/Checkbox/index.js CHANGED
@@ -1,22 +1,21 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { makeStyles } from '@shopgate/engage/styles';
4
- import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
4
  import BaseCheckbox from '@shopgate/pwa-common/components/Checkbox';
6
5
  import CheckedIcon from "../icons/CheckedIcon";
7
6
  import UncheckedIcon from "../icons/UncheckedIcon";
8
7
  import { jsx as _jsx } from "react/jsx-runtime";
9
- const useStyles = makeStyles()(() => ({
8
+ const useStyles = makeStyles()(theme => ({
10
9
  icon: {
11
10
  width: 24,
12
11
  height: 24,
13
12
  flexShrink: 0
14
13
  },
15
14
  checkedIcon: {
16
- color: 'var(--color-secondary)'
15
+ color: theme.palette.secondary.main
17
16
  },
18
17
  uncheckedIcon: {
19
- color: themeConfig.colors.shade6
18
+ color: theme.palette.grey.dark
20
19
  }
21
20
  }));
22
21
 
package/Chip/index.js CHANGED
@@ -32,12 +32,12 @@ const useStyles = makeStyles()((theme, {
32
32
  chip: {
33
33
  ...chipBase(removable, theme),
34
34
  ...(hasNewServices() ? {
35
- backgroundColor: invert ? 'var(--color-primary)' : 'var(--color-primary-contrast)',
36
- color: invert ? 'var(--color-primary-contrast)' : 'var(--color-primary)'
35
+ backgroundColor: invert ? theme.palette.primary.main : theme.palette.primary.contrastText,
36
+ color: invert ? theme.palette.primary.contrastText : theme.palette.primary.main
37
37
  } : {
38
- backgroundColor: invert ? 'var(--color-secondary)' : 'var(--color-secondary-contrast)',
39
- color: invert ? 'var(--color-secondary-contrast)' : 'var(--color-secondary)',
40
- '--color-text-high-emphasis': invert ? 'var(--color-secondary-contrast)' : 'var(--color-secondary)'
38
+ backgroundColor: invert ? theme.palette.secondary.main : theme.palette.secondary.contrastText,
39
+ color: invert ? theme.palette.secondary.contrastText : theme.palette.secondary.main,
40
+ '--color-text-high-emphasis': invert ? theme.palette.secondary.contrastText : theme.palette.secondary.main
41
41
  })
42
42
  },
43
43
  removeButton: {
@@ -47,7 +47,7 @@ const useStyles = makeStyles()((theme, {
47
47
  webOnly: true
48
48
  })]: {
49
49
  padding: '0 5px',
50
- fontSize: '1.125rem'
50
+ fontSize: theme.typography.h4.fontSize
51
51
  }
52
52
  },
53
53
  name: {
@@ -55,19 +55,18 @@ const useStyles = makeStyles()((theme, {
55
55
  paddingRight: theme.spacing(0.5),
56
56
  paddingTop: 3,
57
57
  paddingBottom: 3,
58
- fontSize: 12,
59
- fontWeight: 500,
58
+ fontSize: theme.typography.caption.fontSize,
59
+ fontWeight: theme.typography.fontWeightMedium,
60
60
  textOverflow: 'ellipsis',
61
61
  maxWidth: '100%',
62
62
  whiteSpace: 'nowrap',
63
63
  overflow: 'hidden',
64
64
  display: 'block',
65
- lineHeight: '1',
66
65
  color: 'inherit',
67
66
  [responsiveMediaQuery('>xs', {
68
67
  webOnly: true
69
68
  })]: {
70
- fontSize: '0.875rem',
69
+ fontSize: theme.typography.body2.fontSize,
71
70
  lineHeight: '1.25rem',
72
71
  padding: '6px 8px 6px 0'
73
72
  }
@@ -1,41 +1,31 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import noop from 'lodash/noop';
4
- import Color from 'color';
5
- import { themeConfig } from '@shopgate/pwa-common/helpers/config';
6
- import { getCSSCustomProp, makeStyles } from '@shopgate/engage/styles';
4
+ import { makeStyles } from '@shopgate/engage/styles';
7
5
  import Glow from "../../../Glow";
8
6
  import { useContextMenu } from "../../ContextMenu.hooks";
9
7
  import { jsx as _jsx } from "react/jsx-runtime";
10
8
  const CLOSE_DELAY = 250;
11
9
  const useStyles = makeStyles()((theme, {
12
10
  disabled
13
- }) => {
14
- let background = themeConfig.colors.shade8;
15
- const customPropColor = getCSSCustomProp('--color-primary');
16
- if (customPropColor) {
17
- background = Color(customPropColor).alpha(0.04).toString();
11
+ }) => ({
12
+ root: {
13
+ position: 'relative',
14
+ whiteSpace: 'nowrap',
15
+ marginBottom: 2,
16
+ padding: theme.spacing(1.25, 2.75),
17
+ zIndex: 1,
18
+ color: disabled ? theme.palette.text.secondary : 'inherit',
19
+ ...(!disabled ? {
20
+ cursor: 'pointer',
21
+ '&:hover': {
22
+ background: theme.alpha(theme.palette.primary.main, 0.04)
23
+ }
24
+ } : {
25
+ cursor: 'default'
26
+ })
18
27
  }
19
- return {
20
- root: {
21
- position: 'relative',
22
- whiteSpace: 'nowrap',
23
- marginBottom: 2,
24
- padding: theme.spacing(1.75, 2.75),
25
- lineHeight: 1,
26
- zIndex: 1,
27
- color: disabled ? theme.palette.text.secondary : 'inherits',
28
- ...(!disabled ? {
29
- cursor: 'pointer',
30
- '&:hover': {
31
- background
32
- }
33
- } : {
34
- cursor: 'default'
35
- })
36
- }
37
- };
38
- });
28
+ }));
39
29
 
40
30
  /**
41
31
  * The Context Menu Item component.
@@ -4,7 +4,6 @@ import { ConnectedReactPortal } from '@shopgate/engage/components';
4
4
  import Backdrop from '@shopgate/pwa-common/components/Backdrop';
5
5
  import { FocusTrap } from '@shopgate/engage/a11y/components';
6
6
  import { i18n } from '@shopgate/engage/core/helpers';
7
- import { themeConfig } from '@shopgate/pwa-common/helpers/config';
8
7
  import { makeStyles } from '@shopgate/engage/styles';
9
8
  import MoreVertIcon from "../icons/MoreVertIcon";
10
9
  import Position from "./components/Position";
@@ -17,7 +16,7 @@ const useStyles = makeStyles()(theme => ({
17
16
  },
18
17
  button: {
19
18
  display: 'block',
20
- fontSize: '1.5rem',
19
+ fontSize: theme.components.icon.medium,
21
20
  outline: 0,
22
21
  padding: 0,
23
22
  color: 'inherit'
@@ -39,9 +38,9 @@ const useStyles = makeStyles()(theme => ({
39
38
  left: 0,
40
39
  padding: theme.spacing(1, 0),
41
40
  minWidth: 130,
42
- background: themeConfig.colors.light,
41
+ background: theme.palette.background.surface,
43
42
  borderRadius: 2,
44
- boxShadow: themeConfig.shadows.contextMenu
43
+ boxShadow: '0 2px 6px rgba(0, 0, 0, .4)'
45
44
  },
46
45
  scrollable: {
47
46
  maxHeight: '30vh',
@@ -38,10 +38,16 @@ jest.mock('@shopgate/engage/components', () => {
38
38
  className
39
39
  }, children);
40
40
  }
41
+ function Typography({
42
+ children
43
+ }) {
44
+ return mockReact.createElement('span', null, children);
45
+ }
41
46
  return {
42
47
  I18n,
43
48
  Ellipsis,
44
- Button
49
+ Button,
50
+ Typography
45
51
  };
46
52
  });
47
53
  describe('<HtmlContentDialog />', () => {