fix: don't show carousel buttons when only one image is present and image dimensions
This commit is contained in:
parent
fb399734c0
commit
68eed4e5fd
1 changed files with 20 additions and 16 deletions
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue