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:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user