feat(35-02): add loading=lazy and onLoad prop to GearImage

- Add optional onLoad prop to GearImageProps interface
- Destructure onLoad in function signature
- Forward loading="lazy" and onLoad to all three img render paths (cover, hasCrop, default)
This commit is contained in:
2026-04-19 19:45:01 +02:00
parent 58d6b47c6f
commit 2d2259a0db

View File

@@ -7,6 +7,7 @@ interface GearImageProps {
cropY?: number | null; cropY?: number | null;
className?: string; className?: string;
cover?: boolean; cover?: boolean;
onLoad?: () => void;
} }
export function GearImage({ export function GearImage({
@@ -18,6 +19,7 @@ export function GearImage({
cropY, cropY,
className = "", className = "",
cover = false, cover = false,
onLoad,
}: GearImageProps) { }: GearImageProps) {
const hasCrop = cropZoom != null && cropZoom > 1; const hasCrop = cropZoom != null && cropZoom > 1;
const bgStyle = dominantColor const bgStyle = dominantColor
@@ -29,6 +31,8 @@ export function GearImage({
<img <img
src={src} src={src}
alt={alt} alt={alt}
loading="lazy"
onLoad={onLoad}
className={`w-full h-full object-cover ${className}`} className={`w-full h-full object-cover ${className}`}
/> />
); );
@@ -40,6 +44,8 @@ export function GearImage({
<img <img
src={src} src={src}
alt={alt} alt={alt}
loading="lazy"
onLoad={onLoad}
className={`w-full h-full object-cover ${className}`} className={`w-full h-full object-cover ${className}`}
style={{ style={{
transform: `scale(${cropZoom}) translate(${cropX ?? 0}%, ${cropY ?? 0}%)`, transform: `scale(${cropZoom}) translate(${cropX ?? 0}%, ${cropY ?? 0}%)`,
@@ -58,6 +64,8 @@ export function GearImage({
<img <img
src={src} src={src}
alt={alt} alt={alt}
loading="lazy"
onLoad={onLoad}
className={`w-full h-full object-contain ${className}`} className={`w-full h-full object-contain ${className}`}
/> />
</div> </div>