@@ -5,14 +5,16 @@ import {X} from 'react-feather';
5
5
import * as Dialog from '@radix-ui/react-dialog' ;
6
6
import Image from 'next/image' ;
7
7
8
- interface ImageLightboxProps {
8
+ interface ImageLightboxProps
9
+ extends Omit <
10
+ React . HTMLProps < HTMLImageElement > ,
11
+ 'ref' | 'src' | 'width' | 'height' | 'alt'
12
+ > {
9
13
alt : string ;
10
14
height : number ;
11
15
imgPath : string ;
12
16
src : string ;
13
17
width : number ;
14
- className ?: string ;
15
- style ?: React . CSSProperties ;
16
18
}
17
19
18
20
export function ImageLightbox ( {
@@ -23,6 +25,7 @@ export function ImageLightbox({
23
25
imgPath,
24
26
style,
25
27
className,
28
+ ...props
26
29
} : ImageLightboxProps ) {
27
30
const [ open , setOpen ] = useState ( false ) ;
28
31
@@ -61,6 +64,13 @@ export function ImageLightbox({
61
64
}
62
65
} ;
63
66
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
+
64
74
// Render the appropriate image component based on dimension validity
65
75
const renderImage = ( ) => {
66
76
if ( isValidDimensions ) {
@@ -76,6 +86,7 @@ export function ImageLightbox({
76
86
} }
77
87
className = { className }
78
88
alt = { alt }
89
+ { ...imageCompatibleProps }
79
90
/>
80
91
) ;
81
92
}
@@ -90,6 +101,7 @@ export function ImageLightbox({
90
101
...style ,
91
102
} }
92
103
className = { className }
104
+ { ...props }
93
105
/>
94
106
) ;
95
107
} ;
@@ -132,6 +144,7 @@ export function ImageLightbox({
132
144
height : 'auto' ,
133
145
} }
134
146
priority
147
+ { ...imageCompatibleProps }
135
148
/>
136
149
) : (
137
150
/* eslint-disable-next-line @next/next/no-img-element */
@@ -143,6 +156,7 @@ export function ImageLightbox({
143
156
width : 'auto' ,
144
157
height : 'auto' ,
145
158
} }
159
+ { ...props }
146
160
/>
147
161
) }
148
162
</ div >
0 commit comments