@pradip1995/segment-bestsellers-carousel 0.2.1 → 0.3.0

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 (2) hide show
  1. package/package.json +4 -4
  2. 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.1",
3
+ "version": "0.3.0",
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.2.0",
25
- "@pradip1995/segment-product-card": "0.2.1",
26
- "@pradip1995/segment-tokens": "0.2.1"
24
+ "@pradip1995/segment-primitives": "0.3.0",
25
+ "@pradip1995/segment-product-card": "0.3.0",
26
+ "@pradip1995/segment-tokens": "0.3.0"
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 ProductScroll from "@pradip1995/segment-product-card/product-scroll"
3
- import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
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="bestsellers w-full py-8 md:py-12 bg-surface-muted">
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
- <div className="home-section-header">
40
- <h2 className="home-section-header__title">{title}</h2>
41
- <LocalizedLink href="/store?sortBy=bestsellers" className="home-section-header__link">
42
- {viewAllLink}
43
- </LocalizedLink>
44
- </div>
45
- <ProductScroll products={list} region={region} ratings={ratings} />
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
  )