feat(clinic): simplify image rendering logic and improve layout handling in List component

This commit is contained in:
hamed
2026-06-19 01:18:28 +03:30
parent 8b23f1f831
commit f6a3082ac8
@@ -6,46 +6,33 @@ function List({ data }) {
const images_clinic = data?.images_clinic || []; const images_clinic = data?.images_clinic || [];
const lengthImgClinics = images_clinic.length; const lengthImgClinics = images_clinic.length;
// عکس اول به‌صورت بزرگ در Images.js نمایش داده می‌شود؛ اینجا بقیه‌ی عکس‌ها را نشان می‌دهیم.
const rest = images_clinic.slice(1);
return ( return (
<div <div
className={`hidden w-full md:grid gap-[16px] lg:gap-[24px] className={`hidden w-full md:grid gap-[16px] lg:gap-[24px]
${lengthImgClinics === 1 ${rest.length === 0
? "md:!hidden" ? "md:!hidden"
: lengthImgClinics === 2 : rest.length === 1
? "grid-cols-1 grid-rows-1" ? "grid-cols-1 grid-rows-1"
: lengthImgClinics === 3 : "grid-cols-2 auto-rows-fr"
? "grid-cols-1 grid-rows-2"
: lengthImgClinics === 4
? "grid-cols-2 grid-rows-2"
: ""
} }
`} `}
> >
{images_clinic.map((img, idx) => {rest.map((img, idx) => (
idx !== 0 ? ( <div key={idx} className="h-full w-full">
<div <CustomLoading width="full" height={190}>
key={idx} <Image
className={`${lengthImgClinics === 3 className="rounded-[8px] overflow-hidden w-full h-full object-cover"
? "h-full" src={imageUrl(img.url, "/assets/images/clinic-img.png")}
: lengthImgClinics === 4 alt="img clinic"
? idx === lengthImgClinics - 1 height={204}
? "w-[calc(200%+16px)] lg:w-[calc(200%+24px)]" width={288}
: "w-full h-full" />
: "h-full w-full" </CustomLoading>
}`} </div>
> ))}
<CustomLoading width="full" height={190}>
<Image
className="rounded-[8px] overflow-hidden w-full h-full object-cover"
src={imageUrl(img.url, "/assets/images/clinic-img.png")}
alt="img clinic"
height={204}
width={288}
/>
</CustomLoading>
</div>
) : undefined
)}
</div> </div>
); );
} }