fix: don't show carousel buttons when only one image is present and image dimensions

This commit is contained in:
trafficlunar 2025-04-01 21:37:01 +01:00
parent fb399734c0
commit 68eed4e5fd

View file

@ -30,12 +30,14 @@ export default function Carousel({ images, className }: Props) {
<div className="flex">
{images.map((src, index) => (
<div key={index} className="flex-[0_0_100%]">
<img src={src} alt="" className="w-full h-auto" />
<img src={src} alt="" className="w-full h-auto aspect-[3/2] object-contain" />
</div>
))}
</div>
</div>
{images.length > 1 && (
<>
<button onClick={scrollPrev} className="absolute left-2 top-1/2 -translate-y-1/2 bg-white p-1 rounded-full shadow text-xl cursor-pointer">
<Icon icon="ic:round-chevron-left" />
</button>
@ -52,6 +54,8 @@ export default function Carousel({ images, className }: Props) {
/>
))}
</div>
</>
)}
</div>
);
}