@pradip1995/segment-bestsellers-carousel 0.2.1 → 0.3.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.
- package/package.json +4 -4
- package/src/segment.tsx +21 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pradip1995/segment-bestsellers-carousel",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@pradip1995/commerce-core": "^4.0.0",
|
|
24
|
-
"@pradip1995/segment-primitives": "0.
|
|
25
|
-
"@pradip1995/segment-product-card": "0.
|
|
26
|
-
"@pradip1995/segment-tokens": "0.
|
|
24
|
+
"@pradip1995/segment-primitives": "0.3.0",
|
|
25
|
+
"@pradip1995/segment-product-card": "0.3.0",
|
|
26
|
+
"@pradip1995/segment-tokens": "0.3.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@pradip1995/plugin-sdk": "^0.2.0",
|
package/src/segment.tsx
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { getProductsByTag } from "@pradip1995/commerce-core/data/products"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import type { ProductRailVariant } from "@pradip1995/segment-primitives/section-variants"
|
|
3
|
+
import { resolveVariant } from "@pradip1995/segment-primitives/section-variants"
|
|
4
4
|
import type { HttpTypes } from "@medusajs/types"
|
|
5
|
+
import { ProductRailByVariant } from "@pradip1995/segment-product-card/product-rail-variants"
|
|
5
6
|
|
|
6
7
|
export default async function BestsellersCarousel({
|
|
7
8
|
products: fallbackProducts,
|
|
8
9
|
region,
|
|
9
10
|
ratings,
|
|
11
|
+
countryCode: countryCodeProp,
|
|
10
12
|
title = "Best sellers",
|
|
11
13
|
viewAllLink = "View all",
|
|
14
|
+
variant,
|
|
12
15
|
}: {
|
|
13
16
|
products?: HttpTypes.StoreProduct[]
|
|
14
17
|
region?: HttpTypes.StoreRegion | null
|
|
15
18
|
ratings?: Array<{ product_id?: string; rating?: number }>
|
|
19
|
+
countryCode?: string
|
|
16
20
|
title?: string
|
|
17
21
|
viewAllLink?: string
|
|
22
|
+
variant?: ProductRailVariant
|
|
18
23
|
}) {
|
|
19
24
|
const countryCode =
|
|
25
|
+
countryCodeProp?.toLowerCase() ??
|
|
20
26
|
region?.countries?.[0]?.iso_2?.toLowerCase() ??
|
|
21
27
|
process.env.NEXT_PUBLIC_DEFAULT_REGION?.toLowerCase() ??
|
|
22
28
|
"in"
|
|
@@ -33,16 +39,21 @@ export default async function BestsellersCarousel({
|
|
|
33
39
|
const list = products.slice(0, 12)
|
|
34
40
|
if (list.length === 0) return null
|
|
35
41
|
|
|
42
|
+
const layout = resolveVariant(variant, "carousel")
|
|
43
|
+
|
|
36
44
|
return (
|
|
37
|
-
<section className=
|
|
45
|
+
<section className={`product-rail product-rail--${layout} bestsellers w-full py-8 md:py-12 bg-surface-muted`}>
|
|
38
46
|
<div className="mx-auto px-2 sm:px-3 lg:px-4" style={{ maxWidth: "var(--container-max)" }}>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
<ProductRailByVariant
|
|
48
|
+
variant={layout}
|
|
49
|
+
products={list}
|
|
50
|
+
region={region ?? undefined}
|
|
51
|
+
ratings={ratings}
|
|
52
|
+
countryCode={countryCode}
|
|
53
|
+
title={title}
|
|
54
|
+
viewAllLink={viewAllLink}
|
|
55
|
+
href="/store?sortBy=bestsellers"
|
|
56
|
+
/>
|
|
46
57
|
</div>
|
|
47
58
|
</section>
|
|
48
59
|
)
|