@rebuy/rebuy-hydrogen 3.0.0-beta.2 → 3.0.0-beta.3
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/package.json +64 -35
- package/src/components/AddToCartBtn/AddToCartBtn.tsx +0 -45
- package/src/components/AddToCartBtn/HydrogenAddToCartBtn.tsx +0 -43
- package/src/components/AddToCartBtn/HydrogenReactAddToCartBtn.tsx +0 -35
- package/src/components/AddToCartBtn/index.ts +0 -1
- package/src/components/AddToCartBtn/types.ts +0 -27
- package/src/components/ProductCard/ProductCard.tsx +0 -70
- package/src/components/ProductCard/index.ts +0 -1
- package/src/components/ProductCard/types.ts +0 -10
- package/src/components/ProductPrice/ProductPrice.tsx +0 -49
- package/src/components/ProductPrice/index.ts +0 -1
- package/src/components/Title/Title.tsx +0 -19
- package/src/components/Title/index.ts +0 -1
- package/src/components/Title/types.ts +0 -7
- package/src/components/VariantSelect/VariantSelect.tsx +0 -45
- package/src/components/VariantSelect/index.ts +0 -1
- package/src/components/VariantSelect/types.ts +0 -6
- package/src/context/RebuyContext.tsx +0 -9
- package/src/hooks/titleLevel.tsx +0 -42
- package/src/index.ts +0 -7
- package/src/providers/RebuyHydrogenContextProvider.tsx +0 -112
- package/src/providers/RebuyHydrogenReactContextProvider.tsx +0 -192
- package/src/providers/types.ts +0 -58
- package/src/queries/cart.queries.ts +0 -467
- package/src/types/common.ts +0 -8
- package/src/types/css.d.ts +0 -11
- package/src/types/env.d.ts +0 -12
- package/src/types/rebuy.d.ts +0 -31
- package/src/types/rebuyCustom.ts +0 -263
- package/src/types/rebuySmartCart.ts +0 -188
- package/src/types/shopify.ts +0 -142
- package/src/types/widgets.ts +0 -29
- package/src/utils/convertToRebuyProduct.tsx +0 -319
- package/src/utils/createContextParameters.ts +0 -142
- package/src/utils/getEncodedAttributes.ts +0 -11
- package/src/utils/getRebuyConfig.ts +0 -31
- package/src/widgetContainer/RebuyWidgetContainer.tsx +0 -183
- package/src/widgets/RebuyCompleteTheLook/RebuyCompleteTheLook.tsx +0 -50
- package/src/widgets/RebuyCompleteTheLook/index.ts +0 -1
- package/src/widgets/RebuyCompleteTheLook/types.ts +0 -5
- package/src/widgets/RebuyDynamicBundleProducts/BundleImages.tsx +0 -62
- package/src/widgets/RebuyDynamicBundleProducts/BundlePrice.tsx +0 -93
- package/src/widgets/RebuyDynamicBundleProducts/BundleSelection.tsx +0 -65
- package/src/widgets/RebuyDynamicBundleProducts/RebuyDynamicBundleProducts.tsx +0 -118
- package/src/widgets/RebuyDynamicBundleProducts/Select.tsx +0 -41
- package/src/widgets/RebuyDynamicBundleProducts/index.ts +0 -1
- package/src/widgets/RebuyDynamicBundleProducts/types.ts +0 -23
- package/src/widgets/RebuyProductAddOns/RebuyProductAddOnCard.tsx +0 -66
- package/src/widgets/RebuyProductAddOns/RebuyProductAddOns.tsx +0 -218
- package/src/widgets/RebuyProductAddOns/index.ts +0 -1
- package/src/widgets/RebuyProductAddOns/types.ts +0 -24
- package/src/widgets/RebuyProductRecommendations/RebuyProductRecommendations.tsx +0 -50
- package/src/widgets/RebuyProductRecommendations/index.ts +0 -1
- package/src/widgets/RebuyProductRecommendations/types.ts +0 -5
package/package.json
CHANGED
@@ -1,35 +1,60 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rebuy/rebuy-hydrogen",
|
3
|
+
"version": "3.0.0-beta.3",
|
3
4
|
"description": "This is the default library for Rebuy + Shopify Hydrogen",
|
4
|
-
"
|
5
|
+
"homepage": "https://bitbucket.org/rebuyengine/npm-rebuy-hydrogen#readme",
|
6
|
+
"bugs": {
|
7
|
+
"url": "https://bitbucket.org/rebuyengine/npm-rebuy-hydrogen/issues"
|
8
|
+
},
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "git+ssh://git@bitbucket.org/rebuyengine/npm-rebuy-hydrogen.git"
|
12
|
+
},
|
5
13
|
"license": "MIT",
|
6
14
|
"author": "Rebuy, Inc.",
|
15
|
+
"type": "module",
|
7
16
|
"main": "./dist/index.js",
|
8
17
|
"module": "./dist/index.mjs",
|
9
18
|
"types": "./dist/index.d.ts",
|
10
|
-
"type": "module",
|
11
|
-
"publishConfig": {
|
12
|
-
"access": "public"
|
13
|
-
},
|
14
19
|
"files": [
|
15
20
|
"dist",
|
16
|
-
"README.md"
|
17
|
-
"**/*.d.ts",
|
18
|
-
"**/*.ts",
|
19
|
-
"**/*.tsx"
|
21
|
+
"README.md"
|
20
22
|
],
|
21
23
|
"scripts": {
|
22
|
-
"clean": "rm -rf dist",
|
23
|
-
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
24
|
-
"build:code": "node esbuild.config.mjs",
|
25
24
|
"build": "npm run clean && npm run build:types && npm run build:code",
|
25
|
+
"build:code": "node esbuild.config.mjs",
|
26
|
+
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
26
27
|
"build:watch": "npm run clean && npm run build:types && node esbuild.config.mjs --watch",
|
27
|
-
"
|
28
|
-
"
|
28
|
+
"check-types": "tsc --noEmit",
|
29
|
+
"clean": "rm -rf dist",
|
30
|
+
"dev": "npm run clean && concurrently \"npm run types:watch\" \"npm run build:watch\"",
|
31
|
+
"format": "npm run lint -- --fix && npm run lint:css -- --fix",
|
32
|
+
"lint": "eslint --ext .js,.jsx,.json,.mjs,.ts,.tsx ./src",
|
33
|
+
"lint:css": "stylelint './src/**/*.{css,scss}'",
|
34
|
+
"lint:css-skip-warn": "npm run lint:css -- --quiet",
|
35
|
+
"lint:skip-warn": "npm run lint -- --quiet",
|
29
36
|
"prepare": "husky install",
|
37
|
+
"sort-package": "sort-package-json",
|
30
38
|
"test": "echo \"Error: no test specified\" && exit 1",
|
31
|
-
"types:watch": "tsc --emitDeclarationOnly --outDir dist --watch"
|
32
|
-
|
39
|
+
"types:watch": "tsc --emitDeclarationOnly --outDir dist --watch"
|
40
|
+
},
|
41
|
+
"lint-staged": {
|
42
|
+
"*.css": [
|
43
|
+
"stylelint --fix",
|
44
|
+
"prettier --write"
|
45
|
+
],
|
46
|
+
"*.{ts,tsx}": [
|
47
|
+
"npm run check-types",
|
48
|
+
"eslint --fix",
|
49
|
+
"prettier --write"
|
50
|
+
],
|
51
|
+
"*.{js,jsx,mjs,json}": [
|
52
|
+
"eslint --fix",
|
53
|
+
"prettier --write"
|
54
|
+
],
|
55
|
+
"package.json": [
|
56
|
+
"npm run sort-package"
|
57
|
+
]
|
33
58
|
},
|
34
59
|
"config": {
|
35
60
|
"commitizen": {
|
@@ -39,14 +64,13 @@
|
|
39
64
|
"config": ".cz-config.cjs"
|
40
65
|
}
|
41
66
|
},
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
|
46
|
-
|
47
|
-
"
|
67
|
+
"dependencies": {
|
68
|
+
"@rebuy/rebuy": "^1.5.1",
|
69
|
+
"classnames": "^2.5.1",
|
70
|
+
"dompurify": "^3.2.5",
|
71
|
+
"lodash-es": "^4.17.21",
|
72
|
+
"zustand": "^5.0.4"
|
48
73
|
},
|
49
|
-
"homepage": "https://bitbucket.org/rebuyengine/npm-rebuy-hydrogen#readme",
|
50
74
|
"devDependencies": {
|
51
75
|
"@commitlint/cli": "^19.8.0",
|
52
76
|
"@commitlint/config-conventional": "^19.8.0",
|
@@ -57,7 +81,9 @@
|
|
57
81
|
"@semantic-release/release-notes-generator": "^14.0.3",
|
58
82
|
"@shopify/hydrogen": ">=2025.0.1",
|
59
83
|
"@shopify/hydrogen-react": ">=2025.0.1",
|
60
|
-
"@types/
|
84
|
+
"@types/dompurify": "^3.0.5",
|
85
|
+
"@types/lodash-es": "^4.17.12",
|
86
|
+
"@types/react": "^18.3.3",
|
61
87
|
"@types/three": "^0.175.0",
|
62
88
|
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
63
89
|
"@typescript-eslint/parser": "^8.26.1",
|
@@ -68,33 +94,36 @@
|
|
68
94
|
"esbuild": "0.25.2",
|
69
95
|
"eslint": "^8.57.0",
|
70
96
|
"eslint-config-prettier": "^10.1.1",
|
97
|
+
"eslint-import-resolver-typescript": "^4.3.4",
|
71
98
|
"eslint-plugin-import": "^2.31.0",
|
99
|
+
"eslint-plugin-jsdoc": "^50.2.4",
|
72
100
|
"eslint-plugin-json": "^4.0.1",
|
73
101
|
"eslint-plugin-prettier": "^5.2.3",
|
74
102
|
"eslint-plugin-react": "^7.37.4",
|
75
|
-
"eslint-plugin-react-hooks": "^
|
103
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
76
104
|
"eslint-plugin-sort-destructure-keys": "^2.0.0",
|
77
105
|
"eslint-plugin-sort-keys": "^2.3.5",
|
78
106
|
"eslint-plugin-typescript-sort-keys": "^3.3.0",
|
107
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
79
108
|
"husky": "^9.1.7",
|
80
109
|
"lint-staged": "^15.5.0",
|
81
110
|
"prettier": "^3.5.2",
|
82
|
-
"react": "^18.
|
111
|
+
"react": "^18.3.1",
|
83
112
|
"semantic-release": "^24.2.3",
|
113
|
+
"sort-package-json": "^2.10.0",
|
114
|
+
"stylelint": "^16.19.1",
|
115
|
+
"stylelint-config-css-modules": "^4.4.0",
|
116
|
+
"stylelint-config-standard": "^36.0.1",
|
84
117
|
"typescript": "^5.8.2"
|
85
118
|
},
|
86
|
-
"dependencies": {
|
87
|
-
"@rebuy/rebuy": "^1.5.1"
|
88
|
-
},
|
89
119
|
"peerDependencies": {
|
90
120
|
"@remix-run/react": ">=2.10.0",
|
91
121
|
"@shopify/hydrogen": ">=2025.0.1",
|
92
|
-
"@shopify/hydrogen-react": ">=2025.0.1"
|
122
|
+
"@shopify/hydrogen-react": ">=2025.0.1",
|
123
|
+
"react": ">=18.2.0",
|
124
|
+
"react-dom": ">=18.2.0"
|
93
125
|
},
|
94
|
-
"
|
95
|
-
"
|
96
|
-
"npm run format",
|
97
|
-
"prettier --write"
|
98
|
-
]
|
126
|
+
"publishConfig": {
|
127
|
+
"access": "public"
|
99
128
|
}
|
100
129
|
}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import { HydrogenAddToCartBtn } from './HydrogenAddToCartBtn';
|
2
|
-
import { HydrogenReactAddToCartBtn } from './HydrogenReactAddToCartBtn';
|
3
|
-
|
4
|
-
import type { AddToCartBtnProps } from '~/components/AddToCartBtn/types';
|
5
|
-
|
6
|
-
export const AddToCartBtn = ({
|
7
|
-
addToCartBtnText,
|
8
|
-
addToCartCallback,
|
9
|
-
disabled,
|
10
|
-
isHydrogenReact,
|
11
|
-
moneyData,
|
12
|
-
selectedVariants,
|
13
|
-
}: AddToCartBtnProps) => {
|
14
|
-
const linesToAdd = selectedVariants.map((variant) => ({
|
15
|
-
attributes: [
|
16
|
-
{ key: '_source', value: 'Rebuy' },
|
17
|
-
{ key: '_attribution', value: 'Rebuy Product Recommendations' },
|
18
|
-
],
|
19
|
-
merchandiseId: variant.id,
|
20
|
-
quantity: 1,
|
21
|
-
selectedVariant: variant,
|
22
|
-
}));
|
23
|
-
|
24
|
-
if (isHydrogenReact) {
|
25
|
-
return (
|
26
|
-
<HydrogenReactAddToCartBtn
|
27
|
-
addToCartBtnText={addToCartBtnText}
|
28
|
-
addToCartCallback={addToCartCallback}
|
29
|
-
disabled={disabled}
|
30
|
-
linesToAdd={linesToAdd}
|
31
|
-
moneyData={moneyData}
|
32
|
-
/>
|
33
|
-
);
|
34
|
-
}
|
35
|
-
|
36
|
-
return (
|
37
|
-
<HydrogenAddToCartBtn
|
38
|
-
addToCartBtnText={addToCartBtnText}
|
39
|
-
addToCartCallback={addToCartCallback}
|
40
|
-
disabled={disabled}
|
41
|
-
linesToAdd={linesToAdd}
|
42
|
-
moneyData={moneyData}
|
43
|
-
/>
|
44
|
-
);
|
45
|
-
};
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { type FetcherWithComponents } from '@remix-run/react';
|
2
|
-
import { CartForm, Money } from '@shopify/hydrogen';
|
3
|
-
|
4
|
-
import styles from './AddToCartBtn.module.css';
|
5
|
-
|
6
|
-
import type { btnProps } from '~/components/AddToCartBtn/types';
|
7
|
-
|
8
|
-
export const HydrogenAddToCartBtn = ({
|
9
|
-
addToCartBtnText,
|
10
|
-
addToCartCallback,
|
11
|
-
disabled,
|
12
|
-
linesToAdd,
|
13
|
-
moneyData,
|
14
|
-
}: btnProps) => {
|
15
|
-
return (
|
16
|
-
<CartForm
|
17
|
-
action={CartForm.ACTIONS.LinesAdd}
|
18
|
-
inputs={{
|
19
|
-
lines: linesToAdd,
|
20
|
-
}}
|
21
|
-
route="/cart"
|
22
|
-
>
|
23
|
-
{(fetcher: FetcherWithComponents<unknown>) => (
|
24
|
-
<>
|
25
|
-
<button
|
26
|
-
className={styles.button}
|
27
|
-
disabled={disabled || fetcher.state !== 'idle'}
|
28
|
-
onClick={addToCartCallback}
|
29
|
-
type="submit"
|
30
|
-
>
|
31
|
-
{addToCartBtnText}
|
32
|
-
{moneyData && (
|
33
|
-
<>
|
34
|
-
<span> | </span>
|
35
|
-
<Money data={moneyData} withoutTrailingZeros />
|
36
|
-
</>
|
37
|
-
)}
|
38
|
-
</button>
|
39
|
-
</>
|
40
|
-
)}
|
41
|
-
</CartForm>
|
42
|
-
);
|
43
|
-
};
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { Money, useCart } from '@shopify/hydrogen-react';
|
2
|
-
|
3
|
-
import styles from './AddToCartBtn.module.css';
|
4
|
-
|
5
|
-
import type { btnProps } from '~/components/AddToCartBtn/types';
|
6
|
-
|
7
|
-
export const HydrogenReactAddToCartBtn = ({
|
8
|
-
addToCartBtnText,
|
9
|
-
addToCartCallback,
|
10
|
-
disabled,
|
11
|
-
linesToAdd,
|
12
|
-
moneyData,
|
13
|
-
}: btnProps) => {
|
14
|
-
const { linesAdd } = useCart();
|
15
|
-
const handleAddToCart = () => {
|
16
|
-
linesAdd(linesToAdd);
|
17
|
-
addToCartCallback?.();
|
18
|
-
};
|
19
|
-
return (
|
20
|
-
<button
|
21
|
-
className={styles.button}
|
22
|
-
disabled={disabled}
|
23
|
-
onClick={handleAddToCart}
|
24
|
-
type="button"
|
25
|
-
>
|
26
|
-
{addToCartBtnText}
|
27
|
-
{moneyData && (
|
28
|
-
<>
|
29
|
-
<span> | </span>
|
30
|
-
<Money data={moneyData} withoutTrailingZeros />
|
31
|
-
</>
|
32
|
-
)}
|
33
|
-
</button>
|
34
|
-
);
|
35
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './AddToCartBtn';
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import type { MoneyV2 } from '@shopify/hydrogen-react/storefront-api-types';
|
2
|
-
import type { RebuyProductVariant } from '~/types/rebuyCustom';
|
3
|
-
|
4
|
-
export type btnProps = {
|
5
|
-
addToCartBtnText?: string;
|
6
|
-
addToCartCallback?: () => void;
|
7
|
-
disabled?: boolean;
|
8
|
-
linesToAdd: {
|
9
|
-
attributes: {
|
10
|
-
key: string;
|
11
|
-
value: string;
|
12
|
-
}[];
|
13
|
-
merchandiseId: string;
|
14
|
-
quantity: number;
|
15
|
-
selectedVariant: unknown;
|
16
|
-
}[];
|
17
|
-
moneyData?: MoneyV2;
|
18
|
-
};
|
19
|
-
|
20
|
-
export type AddToCartBtnProps = {
|
21
|
-
addToCartBtnText?: string;
|
22
|
-
addToCartCallback?: () => void;
|
23
|
-
disabled?: boolean;
|
24
|
-
isHydrogenReact?: boolean;
|
25
|
-
moneyData?: MoneyV2;
|
26
|
-
selectedVariants: RebuyProductVariant[];
|
27
|
-
};
|
@@ -1,70 +0,0 @@
|
|
1
|
-
import { Link } from '@remix-run/react';
|
2
|
-
import { Image } from '@shopify/hydrogen';
|
3
|
-
import { useState } from 'react';
|
4
|
-
|
5
|
-
import styles from './ProductCard.module.css';
|
6
|
-
|
7
|
-
import type { ProductCardProps } from '~/components/ProductCard/types';
|
8
|
-
import type { RebuyProduct } from '~/types/rebuyCustom';
|
9
|
-
|
10
|
-
import { AddToCartBtn } from '~/components/AddToCartBtn';
|
11
|
-
import { RebuyProductPrice } from '~/components/ProductPrice/ProductPrice';
|
12
|
-
import { Title } from '~/components/Title';
|
13
|
-
import { VariantSelect } from '~/components/VariantSelect';
|
14
|
-
|
15
|
-
export const ProductCard = ({
|
16
|
-
addToCartBtnText,
|
17
|
-
addToCartCallback,
|
18
|
-
isHydrogenReact,
|
19
|
-
product,
|
20
|
-
productCardTitleLevel,
|
21
|
-
}: ProductCardProps) => {
|
22
|
-
const [selectedVariant, setSelectedVariant] = useState(
|
23
|
-
product.variants.nodes[0]
|
24
|
-
);
|
25
|
-
|
26
|
-
const { image } = selectedVariant;
|
27
|
-
const handleSelectedVariant = (
|
28
|
-
product: RebuyProduct,
|
29
|
-
variant_id: string
|
30
|
-
) => {
|
31
|
-
const updatedVariant = product.variants.nodes.find(
|
32
|
-
(variant) => variant.id === variant_id
|
33
|
-
);
|
34
|
-
if (updatedVariant) {
|
35
|
-
setSelectedVariant(updatedVariant);
|
36
|
-
}
|
37
|
-
};
|
38
|
-
return (
|
39
|
-
<div className={styles.container}>
|
40
|
-
<div>
|
41
|
-
<Link to={`/products/${product.handle}`}>
|
42
|
-
<Image
|
43
|
-
alt={image?.altText ?? `Picture of ${product.title}`}
|
44
|
-
data={image}
|
45
|
-
sizes="(max-width: 320px) 280px, (max-width: 768px) 720px, 1440px"
|
46
|
-
/>
|
47
|
-
</Link>
|
48
|
-
<div className={styles.productInfo}>
|
49
|
-
<Link to={`/products/${product.handle}`}>
|
50
|
-
<Title
|
51
|
-
level={productCardTitleLevel}
|
52
|
-
text={product.title}
|
53
|
-
/>
|
54
|
-
</Link>
|
55
|
-
<RebuyProductPrice selectedVariant={selectedVariant} />
|
56
|
-
<VariantSelect
|
57
|
-
handleSelectedVariant={handleSelectedVariant}
|
58
|
-
product={product}
|
59
|
-
/>
|
60
|
-
</div>
|
61
|
-
</div>
|
62
|
-
<AddToCartBtn
|
63
|
-
addToCartBtnText={addToCartBtnText}
|
64
|
-
addToCartCallback={addToCartCallback}
|
65
|
-
isHydrogenReact={isHydrogenReact}
|
66
|
-
selectedVariants={[selectedVariant]}
|
67
|
-
/>
|
68
|
-
</div>
|
69
|
-
);
|
70
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './ProductCard';
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { ProductCardTitleLevel } from '~/types/common';
|
2
|
-
import type { RebuyProduct } from '~/types/rebuyCustom';
|
3
|
-
|
4
|
-
export type ProductCardProps = {
|
5
|
-
addToCartBtnText?: string;
|
6
|
-
addToCartCallback?: () => void; // to allow for custom add to cart logic/opening the cart drawer
|
7
|
-
isHydrogenReact?: boolean;
|
8
|
-
product: RebuyProduct;
|
9
|
-
productCardTitleLevel: ProductCardTitleLevel;
|
10
|
-
};
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { Money } from '@shopify/hydrogen';
|
2
|
-
|
3
|
-
import styles from './ProductPrice.module.css';
|
4
|
-
|
5
|
-
import type { MoneyV2 } from '@shopify/hydrogen-react/storefront-api-types';
|
6
|
-
import type { RebuyProductVariant } from '~/types/rebuyCustom';
|
7
|
-
|
8
|
-
export const RebuyProductPrice = ({
|
9
|
-
selectedVariant,
|
10
|
-
}: {
|
11
|
-
selectedVariant: RebuyProductVariant;
|
12
|
-
}) => {
|
13
|
-
if (!selectedVariant) return null;
|
14
|
-
const { compareAtPriceV2: compareAtPrice, priceV2: price } =
|
15
|
-
selectedVariant;
|
16
|
-
|
17
|
-
const isDiscounted = (
|
18
|
-
price: MoneyV2 | null,
|
19
|
-
compareAtPrice: MoneyV2 | null
|
20
|
-
) => Number(compareAtPrice?.amount) > Number(price?.amount);
|
21
|
-
|
22
|
-
const CompareAtPrice = ({
|
23
|
-
data: compareAtPrice,
|
24
|
-
}: {
|
25
|
-
data: MoneyV2 | null;
|
26
|
-
}) => {
|
27
|
-
return (
|
28
|
-
compareAtPrice && (
|
29
|
-
<Money
|
30
|
-
as="span"
|
31
|
-
className={styles.compareAtPrice}
|
32
|
-
data={compareAtPrice}
|
33
|
-
withoutTrailingZeros
|
34
|
-
/>
|
35
|
-
)
|
36
|
-
);
|
37
|
-
};
|
38
|
-
|
39
|
-
return (
|
40
|
-
price && (
|
41
|
-
<div className={styles.priceContainer}>
|
42
|
-
<Money data={price} withoutTrailingZeros />
|
43
|
-
{compareAtPrice && isDiscounted(price, compareAtPrice) && (
|
44
|
-
<CompareAtPrice data={compareAtPrice} />
|
45
|
-
)}
|
46
|
-
</div>
|
47
|
-
)
|
48
|
-
);
|
49
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './ProductPrice';
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { TitleProps } from '~/components/Title/types';
|
2
|
-
|
3
|
-
export const Title = ({ level, style, text }: TitleProps) => {
|
4
|
-
switch (level) {
|
5
|
-
case 'h1':
|
6
|
-
return <h1 style={style}>{text}</h1>;
|
7
|
-
default:
|
8
|
-
case 'h2':
|
9
|
-
return <h2 style={style}>{text}</h2>;
|
10
|
-
case 'h3':
|
11
|
-
return <h3 style={style}>{text}</h3>;
|
12
|
-
case 'h4':
|
13
|
-
return <h4 style={style}>{text}</h4>;
|
14
|
-
case 'h5':
|
15
|
-
return <h5 style={style}>{text}</h5>;
|
16
|
-
case 'h6':
|
17
|
-
return <h6 style={style}>{text}</h6>;
|
18
|
-
}
|
19
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './Title';
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import styles from './VariantSelect.module.css';
|
2
|
-
|
3
|
-
import type { VariantSelectProps } from '~/components/VariantSelect/types';
|
4
|
-
import type { RebuyProduct } from '~/types/rebuyCustom';
|
5
|
-
|
6
|
-
export const VariantSelect = ({
|
7
|
-
handleSelectedVariant,
|
8
|
-
product,
|
9
|
-
}: VariantSelectProps) => {
|
10
|
-
const getOptionsLabel = (product: RebuyProduct) => {
|
11
|
-
const options = product.variants.nodes[0].selectedOptions;
|
12
|
-
const optionsFromKeys = options ? Object.keys(options[0]) : [];
|
13
|
-
const optionsFromValues = options
|
14
|
-
? options.map((option) => option.name)
|
15
|
-
: [];
|
16
|
-
const useValues = optionsFromKeys.every((key) =>
|
17
|
-
['name', 'value'].includes(key)
|
18
|
-
);
|
19
|
-
|
20
|
-
// Return delimited label for available option(s) e.g. Color / Size, Scent, etc
|
21
|
-
return (useValues ? optionsFromValues : optionsFromKeys).join(' / ');
|
22
|
-
};
|
23
|
-
|
24
|
-
return (
|
25
|
-
product?.variants.nodes.length > 1 && (
|
26
|
-
<div>
|
27
|
-
<select
|
28
|
-
aria-label="select variant"
|
29
|
-
className={styles.select}
|
30
|
-
onChange={(e) =>
|
31
|
-
handleSelectedVariant(product, e.target.value)
|
32
|
-
}
|
33
|
-
>
|
34
|
-
<optgroup label={getOptionsLabel(product)}>
|
35
|
-
{product.variants.nodes.map(({ id, title }) => (
|
36
|
-
<option key={id + '-variant'} value={id}>
|
37
|
-
{title}
|
38
|
-
</option>
|
39
|
-
))}
|
40
|
-
</optgroup>
|
41
|
-
</select>
|
42
|
-
</div>
|
43
|
-
)
|
44
|
-
);
|
45
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './VariantSelect';
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { createContext } from 'react';
|
2
|
-
|
3
|
-
import { type ContextParameters } from '~/types/rebuyCustom';
|
4
|
-
|
5
|
-
export type RebuyContextType = {
|
6
|
-
contextParameters: ContextParameters;
|
7
|
-
};
|
8
|
-
|
9
|
-
export const RebuyContext = createContext<RebuyContextType | null>(null);
|
package/src/hooks/titleLevel.tsx
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
import { ProductCardTitleLevel } from '~/types/common';
|
2
|
-
|
3
|
-
// Convert the string header level to enum
|
4
|
-
export const getTitleLevel = (
|
5
|
-
level: string,
|
6
|
-
decreaseLevel: boolean = false
|
7
|
-
): ProductCardTitleLevel => {
|
8
|
-
switch (level) {
|
9
|
-
case 'h1':
|
10
|
-
if (decreaseLevel) {
|
11
|
-
return ProductCardTitleLevel.H2;
|
12
|
-
}
|
13
|
-
return ProductCardTitleLevel.H1;
|
14
|
-
case 'h2':
|
15
|
-
if (decreaseLevel) {
|
16
|
-
return ProductCardTitleLevel.H3;
|
17
|
-
}
|
18
|
-
return ProductCardTitleLevel.H2;
|
19
|
-
case 'h3':
|
20
|
-
if (decreaseLevel) {
|
21
|
-
return ProductCardTitleLevel.H4;
|
22
|
-
}
|
23
|
-
return ProductCardTitleLevel.H3;
|
24
|
-
case 'h4':
|
25
|
-
if (decreaseLevel) {
|
26
|
-
return ProductCardTitleLevel.H5;
|
27
|
-
}
|
28
|
-
return ProductCardTitleLevel.H4;
|
29
|
-
case 'h5':
|
30
|
-
if (decreaseLevel) {
|
31
|
-
return ProductCardTitleLevel.H6;
|
32
|
-
}
|
33
|
-
return ProductCardTitleLevel.H5;
|
34
|
-
case 'h6':
|
35
|
-
if (decreaseLevel) {
|
36
|
-
return ProductCardTitleLevel.H6;
|
37
|
-
}
|
38
|
-
return ProductCardTitleLevel.H6;
|
39
|
-
default:
|
40
|
-
return ProductCardTitleLevel.H2;
|
41
|
-
}
|
42
|
-
};
|
package/src/index.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
export * from './providers/RebuyHydrogenContextProvider';
|
2
|
-
export * from './providers/RebuyHydrogenReactContextProvider';
|
3
|
-
export * from './widgetContainer/RebuyWidgetContainer';
|
4
|
-
export * from './widgets/RebuyCompleteTheLook';
|
5
|
-
export * from './widgets/RebuyDynamicBundleProducts';
|
6
|
-
export * from './widgets/RebuyProductAddOns';
|
7
|
-
export * from './widgets/RebuyProductRecommendations';
|