Skip to content

Commit d320be6

Browse files
add custom product toggle
1 parent bbc5e49 commit d320be6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

components/productBanner.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default function ProductBanner({ content }) {
99
<div className="h-[500px] visual-builder__empty-block-parent" {...content?.$?.products} >
1010
</div>
1111
}
12+
{content?.display_custom_products === false ? (
1213
<div className="mt-16 grid grid-cols-2 md:grid-cols-4 gap-6" {...content?.$?.products}>
1314
{content?.products?.map((item, index) => (
1415
<div key={index} {...cslp(content, 'products__', index)}>
@@ -27,6 +28,26 @@ export default function ProductBanner({ content }) {
2728
</div>
2829
))}
2930
</div>
31+
): (
32+
<div className="mt-16 grid grid-cols-2 md:grid-cols-4 gap-6" {...content?.$?.custom_products}>
33+
{content?.custom_products?.map((item, index) => (
34+
<div key={index} {...cslp(content, 'products__', index)}>
35+
{!item.image?.url &&
36+
<div className="h-[200px] w-[300px] flex items-center justify-center bg-gray-200" {...item?.$?.image}>
37+
<svg className="w-10 h-10 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 18">
38+
<path d="M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z" />
39+
</svg>
40+
</div>
41+
}
42+
{item.image?.url &&
43+
<img src={item.image?.url} {...item.image?.$?.url}/>
44+
}
45+
<p className="font-oswald text-[24px] lg:text-[32px] mt-2 tracking-tight" {...item.$?.name}>{item.name}</p>
46+
<p className="font-work font-medium mt-3" {...item.$?.price}>{item.price}</p>
47+
</div>
48+
))}
49+
</div>
50+
)}
3051
<a
3152
href={content?.page?.length > 0 ? content.page[0].url : "#"}
3253
className="group border relative border-black mt-24 lg:mt-32 py-6 px-10 overflow-hidden block max-w-min text-nowrap">

0 commit comments

Comments
 (0)