style: center images in image-viewer component
might make the actual dialog change height based on the image
This commit is contained in:
parent
febb83a164
commit
b369d1f5c7
2 changed files with 4 additions and 4 deletions
|
|
@ -51,7 +51,7 @@ export default function Carousel({ images, className }: Props) {
|
||||||
<div className={`overflow-hidden rounded-xl bg-zinc-300 border-2 border-zinc-300 ${className ?? ""}`} ref={emblaRef}>
|
<div className={`overflow-hidden rounded-xl bg-zinc-300 border-2 border-zinc-300 ${className ?? ""}`} ref={emblaRef}>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
{images.map((src, index) => (
|
{images.map((src, index) => (
|
||||||
<div key={index} className="flex-[0_0_100%]">
|
<div key={index} className="flex-shrink-0 w-full">
|
||||||
<ImageViewer src={src} alt="mii image" width={480} height={320} className="w-full h-auto aspect-[3/2] object-contain" images={images} />
|
<ImageViewer src={src} alt="mii image" width={480} height={320} className="w-full h-auto aspect-[3/2] object-contain" images={images} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export default function ImageViewer({ src, alt, width, height, className, images
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!emblaApi) return;
|
if (!emblaApi) return;
|
||||||
|
|
||||||
// Keep order of images whilst opening on src
|
// Keep order of images whilst opening at src prop
|
||||||
const index = images.indexOf(src);
|
const index = images.indexOf(src);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
emblaApi.scrollTo(index);
|
emblaApi.scrollTo(index);
|
||||||
|
|
@ -111,8 +111,8 @@ export default function ImageViewer({ src, alt, width, height, className, images
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{images.map((image, index) => (
|
{images.map((image, index) => (
|
||||||
<div key={index} className="flex-[0_0_100%]">
|
<div key={index} className="flex-shrink-0 w-full">
|
||||||
<Image src={image} alt={alt} width={576} height={576} className="w-full" />
|
<Image src={image} alt={alt} width={576} height={576} className="w-full h-full object-contain" />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue