mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 19:21:23 +00:00
Update to new design. (#1103)
This commit is contained in:
@@ -2,7 +2,7 @@ import clsx from 'clsx';
|
||||
|
||||
function Grid(props: React.ComponentProps<'ul'>) {
|
||||
return (
|
||||
<ul {...props} className={clsx('grid grid-flow-row gap-4 py-5', props.className)}>
|
||||
<ul {...props} className={clsx('grid grid-flow-row gap-4', props.className)}>
|
||||
{props.children}
|
||||
</ul>
|
||||
);
|
||||
@@ -10,17 +10,12 @@ function Grid(props: React.ComponentProps<'ul'>) {
|
||||
|
||||
function GridItem(props: React.ComponentProps<'li'>) {
|
||||
return (
|
||||
<li
|
||||
{...props}
|
||||
className={clsx(
|
||||
'relative aspect-square h-full w-full overflow-hidden transition-opacity',
|
||||
props.className
|
||||
)}
|
||||
>
|
||||
<li {...props} className={clsx('aspect-square transition-opacity', props.className)}>
|
||||
{props.children}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
Grid.Item = GridItem;
|
||||
|
||||
export default Grid;
|
||||
|
@@ -3,15 +3,7 @@ import { getCollectionProducts } from 'lib/shopify';
|
||||
import type { Product } from 'lib/shopify/types';
|
||||
import Link from 'next/link';
|
||||
|
||||
function ThreeItemGridItem({
|
||||
item,
|
||||
size,
|
||||
background
|
||||
}: {
|
||||
item: Product;
|
||||
size: 'full' | 'half';
|
||||
background: 'white' | 'pink' | 'purple' | 'black';
|
||||
}) {
|
||||
function ThreeItemGridItem({ item, size }: { item: Product; size: 'full' | 'half' }) {
|
||||
return (
|
||||
<div
|
||||
className={size === 'full' ? 'lg:col-span-4 lg:row-span-2' : 'lg:col-span-2 lg:row-span-1'}
|
||||
@@ -22,9 +14,9 @@ function ThreeItemGridItem({
|
||||
width={size === 'full' ? 1080 : 540}
|
||||
height={size === 'full' ? 1080 : 540}
|
||||
priority={true}
|
||||
background={background}
|
||||
alt={item.title}
|
||||
labels={{
|
||||
label={{
|
||||
position: size === 'full' ? 'center' : 'bottom',
|
||||
title: item.title as string,
|
||||
amount: item.priceRange.maxVariantPrice.amount,
|
||||
currencyCode: item.priceRange.maxVariantPrice.currencyCode
|
||||
@@ -46,10 +38,10 @@ export async function ThreeItemGrid() {
|
||||
const [firstProduct, secondProduct, thirdProduct] = homepageItems;
|
||||
|
||||
return (
|
||||
<section className="lg:grid lg:grid-cols-6 lg:grid-rows-2" data-testid="homepage-products">
|
||||
<ThreeItemGridItem size="full" item={firstProduct} background="purple" />
|
||||
<ThreeItemGridItem size="half" item={secondProduct} background="black" />
|
||||
<ThreeItemGridItem size="half" item={thirdProduct} background="pink" />
|
||||
<section className="mx-auto max-w-screen-2xl gap-4 pb-4 lg:grid lg:grid-cols-6 lg:grid-rows-2">
|
||||
<ThreeItemGridItem size="full" item={firstProduct} />
|
||||
<ThreeItemGridItem size="half" item={secondProduct} />
|
||||
<ThreeItemGridItem size="half" item={thirdProduct} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
@@ -1,69 +1,49 @@
|
||||
import clsx from 'clsx';
|
||||
import Image from 'next/image';
|
||||
|
||||
import Price from 'components/price';
|
||||
import Label from '../label';
|
||||
|
||||
export function GridTileImage({
|
||||
isInteractive = true,
|
||||
background,
|
||||
active,
|
||||
labels,
|
||||
label,
|
||||
...props
|
||||
}: {
|
||||
isInteractive?: boolean;
|
||||
background?: 'white' | 'pink' | 'purple' | 'black' | 'purple-dark' | 'blue' | 'cyan' | 'gray';
|
||||
active?: boolean;
|
||||
labels?: {
|
||||
label?: {
|
||||
title: string;
|
||||
amount: string;
|
||||
currencyCode: string;
|
||||
isSmall?: boolean;
|
||||
position?: 'bottom' | 'center';
|
||||
};
|
||||
} & React.ComponentProps<typeof Image>) {
|
||||
return (
|
||||
<div
|
||||
className={clsx('relative flex h-full w-full items-center justify-center overflow-hidden', {
|
||||
'bg-white dark:bg-white': background === 'white',
|
||||
'bg-[#ff0080] dark:bg-[#ff0080]': background === 'pink',
|
||||
'bg-[#7928ca] dark:bg-[#7928ca]': background === 'purple',
|
||||
'bg-gray-900 dark:bg-gray-900': background === 'black',
|
||||
'bg-violetDark dark:bg-violetDark': background === 'purple-dark',
|
||||
'bg-blue-500 dark:bg-blue-500': background === 'blue',
|
||||
'bg-cyan-500 dark:bg-cyan-500': background === 'cyan',
|
||||
'bg-gray-100 dark:bg-gray-100': background === 'gray',
|
||||
'bg-gray-100 dark:bg-gray-900': !background,
|
||||
relative: labels
|
||||
})}
|
||||
className={clsx(
|
||||
'flex h-full w-full items-center justify-center overflow-hidden rounded-lg border bg-white hover:border-blue-600 dark:bg-black',
|
||||
{
|
||||
relative: label,
|
||||
'border-2 border-blue-600': active,
|
||||
'border-neutral-200 dark:border-neutral-800': !active
|
||||
}
|
||||
)}
|
||||
>
|
||||
{active !== undefined && active ? (
|
||||
<span className="absolute h-full w-full bg-white opacity-25"></span>
|
||||
) : null}
|
||||
{props.src ? (
|
||||
// eslint-disable-next-line jsx-a11y/alt-text -- `alt` is inherited from `props`, which is being enforced with TypeScript
|
||||
<Image
|
||||
className={clsx('relative h-full w-full object-contain', {
|
||||
'transition duration-300 ease-in-out hover:scale-105': isInteractive
|
||||
})}
|
||||
{...props}
|
||||
alt={props.title || ''}
|
||||
/>
|
||||
) : null}
|
||||
{labels ? (
|
||||
<div className="absolute left-0 top-0 w-3/4 text-black dark:text-white">
|
||||
<h3
|
||||
data-testid="product-name"
|
||||
className={clsx(
|
||||
'inline bg-white box-decoration-clone py-3 pl-5 font-semibold leading-loose shadow-[1.25rem_0_0] shadow-white dark:bg-black dark:shadow-black',
|
||||
!labels.isSmall ? 'text-3xl' : 'text-lg'
|
||||
)}
|
||||
>
|
||||
{labels.title}
|
||||
</h3>
|
||||
<Price
|
||||
className="w-fit bg-white px-5 py-3 text-sm font-semibold dark:bg-black dark:text-white"
|
||||
amount={labels.amount}
|
||||
currencyCode={labels.currencyCode}
|
||||
/>
|
||||
</div>
|
||||
{label ? (
|
||||
<Label
|
||||
title={label.title}
|
||||
amount={label.amount}
|
||||
currencyCode={label.currencyCode}
|
||||
position={label.position}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user