Chloe 78a79a44b7
fix: update PLP display
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
2024-05-08 14:11:16 +07:00

47 lines
1.3 KiB
TypeScript

import { PhotoIcon } from '@heroicons/react/24/outline';
import clsx from 'clsx';
import Image from 'next/image';
import Label from '../label';
export function GridTileImage({
active,
label,
...props
}: {
active?: boolean;
label?: {
title: string;
amount: string;
currencyCode: string;
};
} & React.ComponentProps<typeof Image>) {
return (
<div className="group">
<div
className={clsx(
'aspect-h-1 aspect-w-1 relative overflow-hidden rounded-lg bg-gray-200 group-hover:opacity-75',
{
'border-2 border-secondary': active,
'border-neutral-200': !active
}
)}
>
{props.src ? (
// eslint-disable-next-line jsx-a11y/alt-text -- `alt` is inherited from `props`, which is being enforced with TypeScript
<Image className={clsx('h-full w-full object-cover object-center')} {...props} />
) : (
<div
className="flex h-full w-full items-center justify-center text-gray-400"
title="Missing product image"
>
<PhotoIcon className="size-7" />
</div>
)}
</div>
{label ? (
<Label title={label.title} amount={label.amount} currencyCode={label.currencyCode} />
) : null}
</div>
);
}