medusa-ui-home 3.0.2 → 3.0.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
CHANGED
|
@@ -2,21 +2,23 @@ import Image from "next/image"
|
|
|
2
2
|
import LocalizedClientLink from "medusa-ui-common/common/components/localized-client-link"
|
|
3
3
|
import type { HomepageBanner } from "medusa-storefront-data/dynamic-config"
|
|
4
4
|
|
|
5
|
+
export type CatalogHeroCopy = {
|
|
6
|
+
badge?: string
|
|
7
|
+
desktopHeadingLine1?: string
|
|
8
|
+
desktopHeadingHighlight?: string
|
|
9
|
+
description?: string
|
|
10
|
+
primaryCtaLabel?: string
|
|
11
|
+
primaryCtaHref?: string
|
|
12
|
+
secondaryCtaLabel?: string
|
|
13
|
+
secondaryCtaHref?: string
|
|
14
|
+
mobilePrimaryCtaLabel?: string
|
|
15
|
+
mobileSecondaryCtaLabel?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
type CatalogHeroBannerProps = {
|
|
6
19
|
homeBanners?: HomepageBanner[] | null
|
|
7
20
|
appBanners?: HomepageBanner[] | null
|
|
8
|
-
copy?:
|
|
9
|
-
badge?: string
|
|
10
|
-
desktopHeadingLine1?: string
|
|
11
|
-
desktopHeadingHighlight?: string
|
|
12
|
-
description?: string
|
|
13
|
-
primaryCtaLabel?: string
|
|
14
|
-
primaryCtaHref?: string
|
|
15
|
-
secondaryCtaLabel?: string
|
|
16
|
-
secondaryCtaHref?: string
|
|
17
|
-
mobilePrimaryCtaLabel?: string
|
|
18
|
-
mobileSecondaryCtaLabel?: string
|
|
19
|
-
}
|
|
21
|
+
copy?: CatalogHeroCopy
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export default function CatalogHeroBanner({
|
|
@@ -24,23 +26,15 @@ export default function CatalogHeroBanner({
|
|
|
24
26
|
appBanners,
|
|
25
27
|
copy,
|
|
26
28
|
}: CatalogHeroBannerProps) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
title: "Premium Kids Shop",
|
|
30
|
-
subtitle: "Little Trends, Quality Kids Wear",
|
|
31
|
-
description:
|
|
32
|
-
"Shop stylish kids wear for little ones and children of all years - from newborn up to 15 years.",
|
|
33
|
-
buttonName: "Shop Kids Wear",
|
|
34
|
-
buttonLink: "/store",
|
|
35
|
-
}
|
|
29
|
+
const homeBanner = homeBanners?.[0]
|
|
30
|
+
const firstAppBanner = appBanners?.[0]
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
if (!homeBanner?.image) {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
40
35
|
|
|
41
|
-
const homeBannerImage = homeBanner.image || fallbackBanner.image
|
|
42
36
|
const appBanner = {
|
|
43
|
-
image: firstAppBanner?.image ||
|
|
37
|
+
image: firstAppBanner?.image || homeBanner.image,
|
|
44
38
|
title: firstAppBanner?.title || homeBanner.title,
|
|
45
39
|
subtitle: firstAppBanner?.subtitle || homeBanner.subtitle,
|
|
46
40
|
description: firstAppBanner?.description || homeBanner.description,
|
|
@@ -48,35 +42,35 @@ export default function CatalogHeroBanner({
|
|
|
48
42
|
buttonLink: firstAppBanner?.buttonLink || homeBanner.buttonLink,
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
const
|
|
52
|
-
const
|
|
45
|
+
const headlineFromCms = Boolean(homeBanner.subtitle?.trim())
|
|
46
|
+
const heroBadge = homeBanner.title ?? copy?.badge ?? "BEST QUALITY"
|
|
47
|
+
const desktopHeadingLine1 =
|
|
48
|
+
homeBanner.subtitle ?? copy?.desktopHeadingLine1 ?? "Electronics &"
|
|
53
49
|
const desktopHeadingHighlight = copy?.desktopHeadingHighlight ?? "Essentials"
|
|
54
50
|
const heroDescription =
|
|
51
|
+
homeBanner.description ??
|
|
55
52
|
copy?.description ??
|
|
56
53
|
"Discover dependable tools, components, devices, and everyday warehouse-ready stock built for fast-moving stores with large inventories."
|
|
57
|
-
const primaryCtaLabel = copy?.primaryCtaLabel ?? "Add to Cart"
|
|
58
|
-
const primaryCtaHref = copy?.primaryCtaHref ??
|
|
54
|
+
const primaryCtaLabel = homeBanner.buttonName ?? copy?.primaryCtaLabel ?? "Add to Cart"
|
|
55
|
+
const primaryCtaHref = homeBanner.buttonLink ?? copy?.primaryCtaHref ?? "/store"
|
|
59
56
|
const secondaryCtaLabel = copy?.secondaryCtaLabel ?? "Explore categories"
|
|
60
57
|
const secondaryCtaHref = copy?.secondaryCtaHref ?? "/categories"
|
|
61
|
-
const mobilePrimaryCtaLabel =
|
|
58
|
+
const mobilePrimaryCtaLabel =
|
|
59
|
+
homeBanner.buttonName ?? copy?.mobilePrimaryCtaLabel ?? "Shop now"
|
|
62
60
|
const mobileSecondaryCtaLabel = copy?.mobileSecondaryCtaLabel ?? secondaryCtaLabel
|
|
63
61
|
|
|
64
62
|
return (
|
|
65
63
|
<div className="relative w-full overflow-x-hidden">
|
|
66
64
|
<div className="relative hidden sm:block">
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
/>
|
|
77
|
-
) : (
|
|
78
|
-
<div className="h-[420px] w-full bg-white md:h-[520px] lg:h-[580px] xl:h-[620px]" />
|
|
79
|
-
)}
|
|
65
|
+
<Image
|
|
66
|
+
src={homeBanner.image}
|
|
67
|
+
alt={homeBanner.title || "Home Banner"}
|
|
68
|
+
width={1920}
|
|
69
|
+
height={800}
|
|
70
|
+
sizes="100vw"
|
|
71
|
+
className="h-[420px] w-full object-cover md:h-[520px] lg:h-[580px] xl:h-[620px]"
|
|
72
|
+
priority
|
|
73
|
+
/>
|
|
80
74
|
|
|
81
75
|
<div className="absolute inset-y-0 left-0 w-[82%] bg-[linear-gradient(90deg,rgba(255,255,255,0.97)_0%,rgba(255,255,255,0.92)_52%,rgba(255,255,255,0.18)_82%,transparent_100%)] md:w-[72%] lg:w-[64%] xl:w-[60%]" />
|
|
82
76
|
|
|
@@ -89,9 +83,16 @@ export default function CatalogHeroBanner({
|
|
|
89
83
|
</div>
|
|
90
84
|
|
|
91
85
|
<h1 className="max-w-[13ch] text-[clamp(1.8rem,4vw,3.75rem)] font-bold leading-[1.04] text-[#04122C]">
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
{headlineFromCms ? (
|
|
87
|
+
desktopHeadingLine1
|
|
88
|
+
) : (
|
|
89
|
+
<>
|
|
90
|
+
{desktopHeadingLine1}
|
|
91
|
+
<br />
|
|
92
|
+
Hardware{" "}
|
|
93
|
+
<span className="text-[#2A8BFF]">{desktopHeadingHighlight}</span>
|
|
94
|
+
</>
|
|
95
|
+
)}
|
|
95
96
|
</h1>
|
|
96
97
|
|
|
97
98
|
<p className="max-w-[44ch] text-[12px] font-medium leading-relaxed text-[#4B5B76] md:text-sm lg:text-base">
|
|
@@ -155,9 +156,16 @@ export default function CatalogHeroBanner({
|
|
|
155
156
|
</div>
|
|
156
157
|
|
|
157
158
|
<h1 className="max-w-[12ch] text-[clamp(1.9rem,8vw,2.5rem)] font-bold leading-[1.06] text-[#04122C]">
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
{headlineFromCms ? (
|
|
160
|
+
desktopHeadingLine1
|
|
161
|
+
) : (
|
|
162
|
+
<>
|
|
163
|
+
{desktopHeadingLine1}
|
|
164
|
+
<br />
|
|
165
|
+
Hardware{" "}
|
|
166
|
+
<span className="text-[#2A8BFF]">{desktopHeadingHighlight}</span>
|
|
167
|
+
</>
|
|
168
|
+
)}
|
|
161
169
|
</h1>
|
|
162
170
|
|
|
163
171
|
<p className="text-[12px] font-medium leading-relaxed text-[#4B5B76] line-clamp-4">
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import dynamic from "next/dynamic"
|
|
2
|
-
import type { HomepageBanner } from "medusa-storefront-data/dynamic-config"
|
|
3
2
|
import {
|
|
4
3
|
getRegion,
|
|
5
4
|
listCategories,
|
|
@@ -7,13 +6,12 @@ import {
|
|
|
7
6
|
listProductsWithSort,
|
|
8
7
|
getProductsByTag,
|
|
9
8
|
loadStorefrontPageInput,
|
|
10
|
-
getHomeBannersFromPageInput,
|
|
11
|
-
getAppBannersFromPageInput,
|
|
12
9
|
getTestimonialsFromPageInput,
|
|
13
10
|
} from "medusa-storefront-data"
|
|
11
|
+
import { loadHeroSectionData } from "medusa-storefront-data/home/sections/hero"
|
|
14
12
|
import { fetchRatings } from "medusa-reviews-logic/server"
|
|
15
13
|
import { HomePageJsonLd } from "../components/home-page-json-ld"
|
|
16
|
-
import CatalogHeroBanner from "./components/hero-banner"
|
|
14
|
+
import CatalogHeroBanner, { type CatalogHeroCopy } from "./components/hero-banner"
|
|
17
15
|
import TrustStrip from "./components/trust-strip"
|
|
18
16
|
import ShopByCategory from "./components/shop-by-category"
|
|
19
17
|
import ShopByAge from "./components/shop-by-age"
|
|
@@ -23,11 +21,6 @@ const WhyChooseUs = dynamic(() => import("./components/why-choose-us"))
|
|
|
23
21
|
const LovedByMoms = dynamic(() => import("./components/loved-by-moms"))
|
|
24
22
|
const Testimonials = dynamic(() => import("./components/testimonials"))
|
|
25
23
|
|
|
26
|
-
export type CatalogHomeFallbackBanners = {
|
|
27
|
-
home: HomepageBanner
|
|
28
|
-
app: HomepageBanner
|
|
29
|
-
}
|
|
30
|
-
|
|
31
24
|
export type CatalogHomeJsonLd = {
|
|
32
25
|
website: Record<string, unknown>
|
|
33
26
|
organization: Record<string, unknown>
|
|
@@ -35,27 +28,13 @@ export type CatalogHomeJsonLd = {
|
|
|
35
28
|
|
|
36
29
|
export type CatalogHomePageProps = {
|
|
37
30
|
params: Promise<{ countryCode: string }>
|
|
38
|
-
|
|
39
|
-
fallbackBanners: CatalogHomeFallbackBanners
|
|
40
|
-
heroCopy?: {
|
|
41
|
-
badge?: string
|
|
42
|
-
desktopHeadingLine1?: string
|
|
43
|
-
desktopHeadingHighlight?: string
|
|
44
|
-
description?: string
|
|
45
|
-
primaryCtaLabel?: string
|
|
46
|
-
primaryCtaHref?: string
|
|
47
|
-
secondaryCtaLabel?: string
|
|
48
|
-
secondaryCtaHref?: string
|
|
49
|
-
mobilePrimaryCtaLabel?: string
|
|
50
|
-
mobileSecondaryCtaLabel?: string
|
|
51
|
-
}
|
|
31
|
+
heroCopy?: CatalogHeroCopy
|
|
52
32
|
jsonLd: CatalogHomeJsonLd
|
|
53
33
|
className?: string
|
|
54
34
|
}
|
|
55
35
|
|
|
56
36
|
export default async function CatalogHomePage({
|
|
57
37
|
params,
|
|
58
|
-
fallbackBanners,
|
|
59
38
|
heroCopy,
|
|
60
39
|
jsonLd,
|
|
61
40
|
className = "bg-white w-full",
|
|
@@ -69,17 +48,6 @@ export default async function CatalogHomePage({
|
|
|
69
48
|
|
|
70
49
|
const pageInput = await loadStorefrontPageInput()
|
|
71
50
|
|
|
72
|
-
const hero = (() => {
|
|
73
|
-
const home = getHomeBannersFromPageInput(pageInput) ?? []
|
|
74
|
-
const app = getAppBannersFromPageInput(pageInput) ?? []
|
|
75
|
-
const hasHomeImage = home.length > 0 && Boolean(home[0]?.image)
|
|
76
|
-
const hasAppImage = app.length > 0 && Boolean(app[0]?.image)
|
|
77
|
-
return {
|
|
78
|
-
homeBanners: hasHomeImage ? home : [fallbackBanners.home],
|
|
79
|
-
appBanners: hasAppImage ? app : [fallbackBanners.app],
|
|
80
|
-
}
|
|
81
|
-
})()
|
|
82
|
-
|
|
83
51
|
const [
|
|
84
52
|
categories,
|
|
85
53
|
newArrivalsResult,
|
|
@@ -87,6 +55,7 @@ export default async function CatalogHomePage({
|
|
|
87
55
|
testimonialsBlock,
|
|
88
56
|
allRatings,
|
|
89
57
|
collectionsResult,
|
|
58
|
+
hero,
|
|
90
59
|
] = await Promise.all([
|
|
91
60
|
listCategories({ limit: 50 }).catch(() => []),
|
|
92
61
|
listProductsWithSort({
|
|
@@ -106,6 +75,7 @@ export default async function CatalogHomePage({
|
|
|
106
75
|
collections: [],
|
|
107
76
|
count: 0,
|
|
108
77
|
})),
|
|
78
|
+
loadHeroSectionData(countryCode, { pageInput }),
|
|
109
79
|
])
|
|
110
80
|
|
|
111
81
|
const newArrivals =
|