| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { formatPrice } from '../theme';
- import type { ProductGridSection } from '../types';
- import { Container, ImagePlaceholder, SectionHeading } from '../ui';
-
- export function ProductGrid({ section }: { section: ProductGridSection }) {
- const { heading, subheading, items } = section.content;
- const minimal = section.variant === 'minimal';
-
- return (
- <section id={section.id} className="scroll-mt-20 py-16 md:py-20">
- <Container>
- <SectionHeading
- heading={heading}
- subheading={subheading}
- align={minimal ? 'center' : 'left'}
- />
-
- <ul className="mt-10 grid grid-cols-2 gap-x-5 gap-y-9 lg:grid-cols-4">
- {items.map((item, index) => (
- <li key={item.name + index} className="group">
- <div className="relative">
- <ImagePlaceholder
- seed={index}
- label={item.name}
- className="aspect-[4/5] w-full"
- />
- {item.badge && (
- <span className="absolute top-3 left-3 rounded-(--sf-radius) bg-(--sf-fg) px-2.5 py-1 text-xs font-semibold text-(--sf-bg)">
- {item.badge}
- </span>
- )}
- </div>
- <div
- className={
- minimal
- ? 'mt-4 text-center'
- : 'mt-4 flex flex-col gap-1 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3'
- }
- >
- <h3 className="font-medium">{item.name}</h3>
- <p className="text-sm text-(--sf-muted) tabular-nums">
- {formatPrice(item.price)}
- </p>
- </div>
- </li>
- ))}
- </ul>
- </Container>
- </section>
- );
- }
|