This commit is contained in:
Your Name committed 2026-10-06 18:16:25 +07:00
1 parent 08045eabff
commit ce4502d123
2 files changed
+17 -55

No files matched your search

+9 -28
View File
@@ -150,34 +150,15 @@ export default function ProductCard({ product, enableQuickShop = false, category
{colorSwatches.length > 0 || (enableQuickShop && product.variants && product.variants.length > 1) ? (
colorSwatches.length > 0 ? (
<div className="mb-1 mt-2 flex items-center gap-1.5 flex-wrap" onClick={(e) => e.stopPropagation()}>
{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 transition-all duration-200 hover:scale-125 focus:outline-none ${
isSelected
? 'ring-2 ring-pop-black ring-offset-2 scale-110 shadow-sm'
: 'opacity-85 hover:opacity-100'
}`}
style={{ backgroundColor: colorCode }}
title={label || colorCode}
aria-label={label || `Color ${colorCode}`}
/>
);
})}
<div className="mb-1 mt-2 flex items-center gap-1.5 flex-wrap">
{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 shadow-sm shrink-0"
style={{ backgroundColor: colorCode }}
title={label || colorCode}
/>
))}
{colorSwatches.length > 5 && (
<span className="text-[10px] font-semibold text-pop-black/60 pl-0.5">
+{colorSwatches.length - 5}