changed some styles
This commit is contained in:
@@ -61,8 +61,8 @@ export default function ProductCard({
|
||||
images,
|
||||
labels = [],
|
||||
price_color = "#0A0A0A",
|
||||
height = 400,
|
||||
width = 300,
|
||||
// height = 500,
|
||||
// width = 350,
|
||||
button = false,
|
||||
stock,
|
||||
}: ProductCardProps) {
|
||||
@@ -81,8 +81,8 @@ export default function ProductCard({
|
||||
const [isSyncing, setIsSyncing] = useState(false);
|
||||
const [showStockModal, setShowStockModal] = useState(false);
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [isInteracting, setIsInteracting] = useState(false);
|
||||
|
||||
const autoplayRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const debounceTimerRef = useRef<NodeJS.Timeout | undefined>(undefined);
|
||||
const isRequestInFlightRef = useRef<boolean>(false);
|
||||
const pendingQuantityRef = useRef<number | null>(null);
|
||||
@@ -103,18 +103,6 @@ export default function ProductCard({
|
||||
};
|
||||
}, [api]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!api || !hasMultipleImages) return;
|
||||
|
||||
autoplayRef.current = setInterval(() => {
|
||||
api.canScrollNext() ? api.scrollNext() : api.scrollTo(0);
|
||||
}, 3000);
|
||||
|
||||
return () => {
|
||||
if (autoplayRef.current) clearInterval(autoplayRef.current);
|
||||
};
|
||||
}, [api, hasMultipleImages]);
|
||||
|
||||
useEffect(() => {
|
||||
setLocalQuantity(cartItem?.product_quantity || 1);
|
||||
}, [cartItem]);
|
||||
@@ -272,24 +260,27 @@ export default function ProductCard({
|
||||
className="flex justify-center cursor-pointer group"
|
||||
>
|
||||
<Card
|
||||
className="relative bg-white border border-gray-100 shadow-sm hover:shadow-xl transition-all duration-300 p-0 w-full overflow-hidden rounded-lg"
|
||||
style={{ height, maxWidth: width }}
|
||||
className="relative gap-2 bg-white border border-gray-100 shadow-sm hover:shadow-xl transition-all duration-300 p-0 w-full overflow-hidden rounded-lg"
|
||||
// style={{ height, maxWidth: width }}
|
||||
>
|
||||
{/* Image Section */}
|
||||
<div className="relative w-full h-[280px] bg-gradient-to-br from-gray-50 to-gray-100 overflow-hidden">
|
||||
<div className="relative w-full h-full bg-gradient-to-br from-gray-50 to-gray-100 overflow-hidden">
|
||||
<Carousel
|
||||
opts={{ align: "start", loop: true, watchDrag: false }}
|
||||
opts={{ align: "start", loop: true, watchDrag: true }}
|
||||
setApi={setApi}
|
||||
className="w-full h-full"
|
||||
onPointerDown={() => setIsInteracting(true)}
|
||||
onPointerUp={() => setIsInteracting(false)}
|
||||
onPointerCancel={() => setIsInteracting(false)}
|
||||
>
|
||||
<CarouselContent className="h-[280px] ml-0">
|
||||
<CarouselContent className="h-auto ml-0">
|
||||
{images.map((image, idx) => (
|
||||
<CarouselItem key={idx} className="h-[280px] pl-0">
|
||||
<div className="h-full flex items-center justify-center p-3">
|
||||
<CarouselItem key={idx} className="h-auto pl-0">
|
||||
<div className="h-full flex items-center justify-center p-2">
|
||||
<img
|
||||
src={image}
|
||||
alt={`${name} - ${idx + 1}`}
|
||||
className={`max-w-full max-h-full object-contain transition-transform duration-500 ${
|
||||
className={`max-w-full max-h-full object-cover transition-transform duration-500 ${
|
||||
isHovered ? "scale-105" : "scale-100"
|
||||
}`}
|
||||
draggable="false"
|
||||
@@ -317,7 +308,11 @@ export default function ProductCard({
|
||||
|
||||
{/* Image Dots */}
|
||||
{hasMultipleImages && (
|
||||
<div className="absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex gap-1.5">
|
||||
<div
|
||||
className={`absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex gap-1.5 transition-opacity duration-300 ${
|
||||
isHovered || isInteracting ? "opacity-100" : "opacity-0"
|
||||
}`}
|
||||
>
|
||||
{images.map((_, idx) => (
|
||||
<button
|
||||
key={idx}
|
||||
@@ -369,7 +364,7 @@ export default function ProductCard({
|
||||
{/* Content Section */}
|
||||
<CardContent className="p-3 space-y-3">
|
||||
{/* Product Name */}
|
||||
<h3 className="text-gray-900 text-base font-semibold leading-tight line-clamp-2 min-h-[2.5rem]">
|
||||
<h3 className="text-gray-900 text-base font-semibold leading-tight line-clamp-2">
|
||||
{name}
|
||||
</h3>
|
||||
|
||||
@@ -403,7 +398,7 @@ export default function ProductCard({
|
||||
</Button>
|
||||
{/* Action Buttons */}
|
||||
{button && !isOutOfStock && (
|
||||
<div className="pt-2 w-full">
|
||||
<div className="w-full">
|
||||
{!isInCart ? (
|
||||
<Button
|
||||
onClick={handleAddToCart}
|
||||
@@ -418,7 +413,9 @@ export default function ProductCard({
|
||||
) : (
|
||||
<>
|
||||
<ShoppingCart className="h-5 w-5" />
|
||||
<span>{t("add_to_cart")}</span>
|
||||
<span className="hidden md:flex">
|
||||
{t("add_to_cart")}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user