@shopgate/pwa-ui-shared 7.32.0-beta.14 → 7.32.0-beta.16

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.
@@ -7,7 +7,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const useStyles = makeStyles()(theme => {
8
8
  const badgeBase = {
9
9
  background: theme.components.discountBadge.background,
10
- borderRadius: 2,
10
+ borderRadius: theme.shape.borderRadius,
11
11
  color: theme.contrastColor(theme.components.discountBadge.background),
12
12
  padding: 5,
13
13
  width: '100%',
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import type { IconButtonSize } from '@shopgate/engage/components/v2';
3
+ export interface FavoritesButtonOwnProps {
4
+ /**
5
+ * Whether the product is on a favorites list.
6
+ * @default false
7
+ */
8
+ active?: boolean;
9
+ /**
10
+ * Hides the button from assistive technology, for a surface that exposes the action elsewhere.
11
+ */
12
+ 'aria-hidden'?: boolean;
13
+ /**
14
+ * Custom class name for the button.
15
+ */
16
+ className?: string;
17
+ /**
18
+ * If `true`, the button reacts to the first click only.
19
+ * @default false
20
+ */
21
+ once?: boolean;
22
+ /**
23
+ * The product the button toggles.
24
+ */
25
+ productId?: string | null;
26
+ /**
27
+ * Milliseconds to wait before a product is removed again.
28
+ * @default 0
29
+ */
30
+ removeThrottle?: number;
31
+ /**
32
+ * Whether removing the product also removes the favorites of its variants.
33
+ * @default false
34
+ */
35
+ removeWithRelatives?: boolean;
36
+ /**
37
+ * The size of the button.
38
+ * @default 'small'
39
+ */
40
+ size?: IconButtonSize;
41
+ }
42
+ /**
43
+ * The props the connector provides. Optional, so that the defaults apply to a button that is
44
+ * rendered without it.
45
+ */
46
+ interface FavoritesButtonConnectedProps {
47
+ addFavorites?: (productId: string) => void;
48
+ removeFavorites?: (productId: string, removeWithRelatives?: boolean) => void;
49
+ loadWishlistOnAppStartEnabled?: boolean;
50
+ wishlistItemQuantityEnabled?: boolean;
51
+ }
52
+ export type FavoritesButtonProps = FavoritesButtonOwnProps & FavoritesButtonConnectedProps;
53
+ /**
54
+ * The favorites button toggles whether a product is on a favorites list, and shows which of the
55
+ * two states it is in. It renders nothing at all in a shop without the favorites feature.
56
+ */
57
+ declare const FavoritesButtonComponent: import("react-redux").ConnectedComponent<React.MemoExoticComponent<({ active, addFavorites, "aria-hidden": ariaHidden, className, loadWishlistOnAppStartEnabled, once, productId, removeFavorites, removeThrottle, removeWithRelatives, size, wishlistItemQuantityEnabled, }: FavoritesButtonProps) => React.JSX.Element | null>, {
58
+ className?: string | undefined;
59
+ size?: IconButtonSize | undefined;
60
+ active?: boolean | undefined;
61
+ addFavorites?: ((productId: string) => void) | undefined;
62
+ 'aria-hidden'?: boolean | undefined;
63
+ loadWishlistOnAppStartEnabled?: boolean | undefined;
64
+ once?: boolean | undefined;
65
+ productId?: string | null | undefined;
66
+ removeFavorites?: ((productId: string, removeWithRelatives?: boolean) => void) | undefined;
67
+ removeThrottle?: number | undefined;
68
+ removeWithRelatives?: boolean | undefined;
69
+ wishlistItemQuantityEnabled?: boolean | undefined;
70
+ context?: import("react-redux/es/components/Context").ReactReduxContextInstance | undefined;
71
+ store?: import("redux").Store | undefined;
72
+ }>;
73
+ export default FavoritesButtonComponent;
74
+ //# sourceMappingURL=FavoritesButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FavoritesButton.d.ts","sourceRoot":"","sources":["../../FavoritesButton/FavoritesButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAEN,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAiGrE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED;;;GAGG;AACH,UAAU,6BAA6B;IACrC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7E,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,GAAG,6BAA6B,CAAC;AAE3F;;;GAGG;AACH,QAAA,MAAM,wBAAwB,gRAnI3B,oBAAoB;gBAuFT,MAAM;WAwBX,cAAc;aAhCZ,OAAO;oBAwCD,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI;oBApC1B,OAAO;oCAsCS,OAAO;WA7BhC,OAAO;gBAIF,MAAM,GAAG,IAAI;uBAwBP,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,OAAO,KAAK,IAAI;qBAnB3D,MAAM;0BAKD,OAAO;kCAgBC,OAAO;;;EASwB,CAAC;AAEhE,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,87 @@
1
+ import React, { useCallback, useRef, useMemo, memo } from 'react';
2
+ import classNames from 'classnames';
3
+ import appConfig from '@shopgate/pwa-common/helpers/config';
4
+ import { i18n } from '@shopgate/engage/core/helpers';
5
+ import { IconButton } from '@shopgate/engage/components/v2';
6
+ import HeartIcon from "../icons/HeartIcon";
7
+ import HeartOutlineIcon from "../icons/HeartOutlineIcon";
8
+ import HeartPlusOutlineIcon from "../icons/HeartPlusOutlineIcon";
9
+ import HeartPlus from "../icons/HeartPlusIcon";
10
+ import connect from "./connector";
11
+
12
+ /**
13
+ * Renders the button. Exported through `FavoritesButtonComponent`, which carries the public docs.
14
+ */
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ const FavoritesButton = ({
17
+ active = false,
18
+ addFavorites,
19
+ 'aria-hidden': ariaHidden,
20
+ className = '',
21
+ loadWishlistOnAppStartEnabled = true,
22
+ once = false,
23
+ productId = null,
24
+ removeFavorites,
25
+ removeThrottle = 0,
26
+ removeWithRelatives = false,
27
+ size = 'small',
28
+ wishlistItemQuantityEnabled = false
29
+ }) => {
30
+ const clickedOnceRef = useRef(false);
31
+ const handleClick = useCallback(event => {
32
+ event.preventDefault();
33
+ event.stopPropagation();
34
+ if (once && clickedOnceRef.current) {
35
+ return;
36
+ }
37
+ clickedOnceRef.current = true;
38
+ if (!productId) {
39
+ return;
40
+ }
41
+ if (!active || wishlistItemQuantityEnabled) {
42
+ addFavorites?.(productId);
43
+ } else {
44
+ setTimeout(() => {
45
+ removeFavorites?.(productId, removeWithRelatives);
46
+ }, removeThrottle);
47
+ }
48
+ }, [once, productId, active, wishlistItemQuantityEnabled, addFavorites, removeFavorites, removeWithRelatives, removeThrottle]);
49
+ const icon = useMemo(() => {
50
+ if (!loadWishlistOnAppStartEnabled || wishlistItemQuantityEnabled && !active) {
51
+ return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
52
+ }
53
+ if (wishlistItemQuantityEnabled && active) {
54
+ return /*#__PURE__*/_jsx(HeartPlus, {});
55
+ }
56
+ if (active) {
57
+ return /*#__PURE__*/_jsx(HeartIcon, {});
58
+ }
59
+ return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
60
+ }, [loadWishlistOnAppStartEnabled, wishlistItemQuantityEnabled, active]);
61
+ if (!appConfig.hasFavorites) {
62
+ return null;
63
+ }
64
+ return /*#__PURE__*/_jsx(IconButton, {
65
+ "aria-label": i18n.text(active ? 'favorites.remove' : 'favorites.add'),
66
+ "aria-hidden": ariaHidden,
67
+ variant: "surface",
68
+ color: "secondary",
69
+ size: size,
70
+ className: classNames('ui-shared__favorites-button', className),
71
+ onClick: handleClick,
72
+ testId: "favoriteButton",
73
+ children: icon
74
+ });
75
+ };
76
+
77
+ /**
78
+ * The props the connector provides. Optional, so that the defaults apply to a button that is
79
+ * rendered without it.
80
+ */
81
+
82
+ /**
83
+ * The favorites button toggles whether a product is on a favorites list, and shows which of the
84
+ * two states it is in. It renders nothing at all in a shop without the favorites feature.
85
+ */
86
+ const FavoritesButtonComponent = connect(/*#__PURE__*/memo(FavoritesButton));
87
+ export default FavoritesButtonComponent;
@@ -0,0 +1,3 @@
1
+ declare const _default: import("react-redux").InferableComponentEnhancerWithProps<Function & Object, {}>;
2
+ export default _default;
3
+ //# sourceMappingURL=connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../FavoritesButton/connector.js"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { default } from './FavoritesButton';
2
+ export type { FavoritesButtonOwnProps, FavoritesButtonProps } from './FavoritesButton';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../FavoritesButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,134 +1 @@
1
- import React, { useCallback, useRef, useMemo, memo } from 'react';
2
- import PropTypes from 'prop-types';
3
- import appConfig from '@shopgate/pwa-common/helpers/config';
4
- import { i18n } from '@shopgate/engage/core/helpers';
5
- import { makeStyles } from '@shopgate/engage/styles';
6
- import HeartIcon from "../icons/HeartIcon";
7
- import HeartOutlineIcon from "../icons/HeartOutlineIcon";
8
- import HeartPlusOutlineIcon from "../icons/HeartPlusOutlineIcon";
9
- import HeartPlus from "../icons/HeartPlusIcon";
10
- import Ripple from "../Ripple";
11
- import connect from "./connector";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const useStyles = makeStyles()(theme => {
14
- const buttonProto = {
15
- display: 'flex',
16
- alignItems: 'center',
17
- justifyContent: 'center',
18
- position: 'relative',
19
- background: theme.palette.common.white,
20
- borderRadius: '50%',
21
- padding: 0,
22
- fontSize: theme.components.icon.small,
23
- color: theme.palette.secondary.main,
24
- outline: 0
25
- };
26
- return {
27
- buttonFlat: {
28
- ...buttonProto
29
- },
30
- button: {
31
- ...buttonProto,
32
- boxShadow: '0 8px 13px rgba(0, 0, 0, 0.25)'
33
- },
34
- ripple: {
35
- padding: 6
36
- }
37
- };
38
- });
39
-
40
- /**
41
- * The favorites button component.
42
- * @param {Object} props Props.
43
- * @returns {JSX.Element|null}
44
- */
45
- const FavoritesButton = ({
46
- active,
47
- addFavorites,
48
- 'aria-hidden': ariaHidden,
49
- className,
50
- loadWishlistOnAppStartEnabled,
51
- noShadow,
52
- once,
53
- onRippleComplete,
54
- productId,
55
- removeFavorites,
56
- removeThrottle,
57
- removeWithRelatives,
58
- rippleClassName,
59
- wishlistItemQuantityEnabled
60
- }) => {
61
- const {
62
- classes,
63
- cx
64
- } = useStyles();
65
- const clickedOnceRef = useRef(false);
66
- const handleRippleComplete = useCallback(() => {
67
- onRippleComplete(active);
68
- }, [onRippleComplete, active]);
69
- const handleClick = useCallback(event => {
70
- event.preventDefault();
71
- event.stopPropagation();
72
- if (once && clickedOnceRef.current) {
73
- return;
74
- }
75
- clickedOnceRef.current = true;
76
- if (!productId) {
77
- return;
78
- }
79
- if (!active || wishlistItemQuantityEnabled) {
80
- addFavorites(productId);
81
- } else {
82
- setTimeout(() => {
83
- removeFavorites(productId, removeWithRelatives);
84
- }, removeThrottle);
85
- }
86
- }, [once, productId, active, wishlistItemQuantityEnabled, addFavorites, removeFavorites, removeWithRelatives, removeThrottle]);
87
- const icon = useMemo(() => {
88
- if (!loadWishlistOnAppStartEnabled || wishlistItemQuantityEnabled && !active) {
89
- return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
90
- }
91
- if (wishlistItemQuantityEnabled && active) {
92
- return /*#__PURE__*/_jsx(HeartPlus, {});
93
- }
94
- if (active) {
95
- return /*#__PURE__*/_jsx(HeartIcon, {});
96
- }
97
- return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
98
- }, [loadWishlistOnAppStartEnabled, wishlistItemQuantityEnabled, active]);
99
- if (!appConfig.hasFavorites) {
100
- return null;
101
- }
102
- const buttonClass = noShadow ? classes.buttonFlat : classes.button;
103
- const ariaLabel = i18n.text(active ? 'favorites.remove' : 'favorites.add');
104
- return /*#__PURE__*/_jsx("button", {
105
- "aria-label": ariaLabel,
106
- "aria-hidden": ariaHidden,
107
- className: cx('ui-shared__favorites-button', buttonClass, className),
108
- onClick: handleClick,
109
- "data-test-id": "favoriteButton",
110
- type: "button",
111
- children: /*#__PURE__*/_jsx(Ripple, {
112
- className: cx(classes.ripple, rippleClassName),
113
- onComplete: handleRippleComplete,
114
- children: icon
115
- })
116
- });
117
- };
118
- FavoritesButton.defaultProps = {
119
- active: false,
120
- addFavorites: () => {},
121
- 'aria-hidden': null,
122
- className: '',
123
- noShadow: false,
124
- once: false,
125
- onRippleComplete: () => {},
126
- productId: null,
127
- removeFavorites: () => {},
128
- removeThrottle: 0,
129
- removeWithRelatives: false,
130
- rippleClassName: '',
131
- wishlistItemQuantityEnabled: false,
132
- loadWishlistOnAppStartEnabled: true
133
- };
134
- export default connect(/*#__PURE__*/memo(FavoritesButton));
1
+ export { default } from "./FavoritesButton";
package/Price/index.js CHANGED
@@ -7,11 +7,15 @@ import { makeStyles } from '@shopgate/engage/styles';
7
7
  import showTaxDisclaimer from '@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';
8
8
  import { useWidgetSettings } from '@shopgate/engage/core/hooks/useWidgetSettings';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const useStyles = makeStyles()({
10
+ const useStyles = makeStyles()(theme => ({
11
11
  container: {
12
12
  display: 'flex',
13
13
  position: 'relative',
14
- whiteSpace: 'nowrap'
14
+ whiteSpace: 'nowrap',
15
+ color: theme.components.price.default,
16
+ fontFamily: theme.components.price.fontFamily,
17
+ fontWeight: theme.components.price.fontWeight,
18
+ fontSize: theme.components.price.fontSize
15
19
  },
16
20
  disclaimer: {
17
21
  color: 'initial',
@@ -20,9 +24,9 @@ const useStyles = makeStyles()({
20
24
  top: 0
21
25
  },
22
26
  discounted: {
23
- color: 'var(--color-primary)'
27
+ color: theme.components.price.sale
24
28
  }
25
- });
29
+ }));
26
30
 
27
31
  /**
28
32
  * The Price component
@@ -25,7 +25,10 @@ const calcAngle = element => {
25
25
  const useStyles = makeStyles()(theme => ({
26
26
  root: {
27
27
  whiteSpace: 'nowrap',
28
- color: theme.palette.grey.dark,
28
+ color: theme.components.price.striked,
29
+ fontFamily: theme.components.price.fontFamily,
30
+ fontWeight: theme.components.price.fontWeight,
31
+ fontSize: `calc(${theme.components.price.fontSize} * 0.75)`,
29
32
  '& span': {
30
33
  position: 'relative',
31
34
  '&::before': {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-ui-shared",
3
- "version": "7.32.0-beta.14",
3
+ "version": "7.32.0-beta.16",
4
4
  "description": "Shopgate's shared UI components.",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
- "@shopgate/pwa-ui-ios": "7.32.0-beta.14",
9
- "@shopgate/pwa-ui-material": "7.32.0-beta.14"
8
+ "@shopgate/pwa-ui-ios": "7.32.0-beta.16",
9
+ "@shopgate/pwa-ui-material": "7.32.0-beta.16"
10
10
  },
11
11
  "devDependencies": {
12
- "@shopgate/pwa-common": "7.32.0-beta.14",
13
- "@shopgate/pwa-common-commerce": "7.32.0-beta.14",
12
+ "@shopgate/pwa-common": "7.32.0-beta.16",
13
+ "@shopgate/pwa-common-commerce": "7.32.0-beta.16",
14
14
  "classnames": "2.5.1",
15
15
  "react": "^17.0.2"
16
16
  },