@@ -5,14 +5,16 @@ import {X} from 'react-feather';
55import * as Dialog from '@radix-ui/react-dialog' ;
66import Image from 'next/image' ;
77
8- interface ImageLightboxProps {
8+ interface ImageLightboxProps
9+ extends Omit <
10+ React . HTMLProps < HTMLImageElement > ,
11+ 'ref' | 'src' | 'width' | 'height' | 'alt'
12+ > {
913 alt : string ;
1014 height : number ;
1115 imgPath : string ;
1216 src : string ;
1317 width : number ;
14- className ?: string ;
15- style ?: React . CSSProperties ;
1618}
1719
1820export function ImageLightbox ( {
@@ -23,6 +25,7 @@ export function ImageLightbox({
2325 imgPath,
2426 style,
2527 className,
28+ ...props
2629} : ImageLightboxProps ) {
2730 const [ open , setOpen ] = useState ( false ) ;
2831
@@ -61,6 +64,13 @@ export function ImageLightbox({
6164 }
6265 } ;
6366
67+ // Filter out props that are incompatible with Next.js Image component
68+ // Next.js Image has stricter typing for certain props like 'placeholder'
69+ const {
70+ placeholder : _placeholder ,
71+ ...imageCompatibleProps
72+ } = props ;
73+
6474 // Render the appropriate image component based on dimension validity
6575 const renderImage = ( ) => {
6676 if ( isValidDimensions ) {
@@ -76,6 +86,7 @@ export function ImageLightbox({
7686 } }
7787 className = { className }
7888 alt = { alt }
89+ { ...imageCompatibleProps }
7990 />
8091 ) ;
8192 }
@@ -90,6 +101,7 @@ export function ImageLightbox({
90101 ...style ,
91102 } }
92103 className = { className }
104+ { ...props }
93105 />
94106 ) ;
95107 } ;
@@ -132,6 +144,7 @@ export function ImageLightbox({
132144 height : 'auto' ,
133145 } }
134146 priority
147+ { ...imageCompatibleProps }
135148 />
136149 ) : (
137150 /* eslint-disable-next-line @next/next/no-img-element */
@@ -143,6 +156,7 @@ export function ImageLightbox({
143156 width : 'auto' ,
144157 height : 'auto' ,
145158 } }
159+ { ...props }
146160 />
147161 ) }
148162 </ div >
0 commit comments