x
This commit is contained in:
1 parent
08045eabff
commit
ce4502d123
2 files changed
+17
-55
No files matched your search
@@ -145,33 +145,14 @@ export default function ProductCard({ product }: ProductCardProps) {
|
||||
{colorSwatches.length > 0 || (product.variants && product.variants.length > 1) ? (
|
||||
colorSwatches.length > 0 ? (
|
||||
<div className="mb-1 mt-2 flex items-center gap-1.5 flex-wrap">
|
||||
{colorSwatches.slice(0, 5).map(({ colorCode, variant, label }) => {
|
||||
const isSelected = selectedVariant?.id === variant.id || selectedVariant?.colorCode === colorCode
|
||||
return (
|
||||
<button
|
||||
key={variant.id || colorCode}
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
setSelectedVariant(variant)
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
if (variant.imageUrl) {
|
||||
setSelectedVariant(variant)
|
||||
}
|
||||
}}
|
||||
className={`relative h-4 w-4 rounded-full border border-black/15 dark:border-white/20 transition-all duration-200 hover:scale-125 focus:outline-none ${
|
||||
isSelected
|
||||
? 'ring-2 ring-text-main ring-offset-2 ring-offset-surface-card scale-110 shadow-sm'
|
||||
: 'opacity-85 hover:opacity-100'
|
||||
}`}
|
||||
style={{ backgroundColor: colorCode }}
|
||||
title={label || colorCode}
|
||||
aria-label={label || `Color ${colorCode}`}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
{colorSwatches.slice(0, 5).map(({ colorCode, variant, label }) => (
|
||||
<span
|
||||
key={variant.id || colorCode}
|
||||
className="relative h-3.5 w-3.5 rounded-full border border-black/15 dark:border-white/20 shadow-sm shrink-0"
|
||||
style={{ backgroundColor: colorCode }}
|
||||
title={label || colorCode}
|
||||
/>
|
||||
))}
|
||||
{colorSwatches.length > 5 && (
|
||||
<span className="text-[10px] font-semibold text-muted-text pl-0.5">
|
||||
+{colorSwatches.length - 5}
|
||||
|
||||
Reference in new issue
Block a user