File tree Expand file tree Collapse file tree 4 files changed +31
-10
lines changed Expand file tree Collapse file tree 4 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,13 @@ const imagesArray = [
43
43
{
44
44
id : crypto . randomUUID ( ) ,
45
45
alt : "Image7's alt text" ,
46
- caption : "Image7's description" ,
47
46
src : "https://cdn.pixabay.com/photo/2023/05/25/22/07/river-8018379_1280.jpg" ,
48
47
smallSrc :
49
48
"https://cdn.pixabay.com/photo/2023/05/25/22/07/river-8018379_640.jpg" ,
50
49
} ,
51
50
{
52
51
id : crypto . randomUUID ( ) ,
53
52
alt : "Image8's alt text" ,
54
- caption : "Image8's description" ,
55
53
src : "https://cdn.pixabay.com/photo/2023/05/21/11/45/flowers-8008392_1280.jpg" ,
56
54
smallSrc :
57
55
"https://cdn.pixabay.com/photo/2023/05/21/11/45/flowers-8008392_640.jpg" ,
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export function ImageGallery({
38
38
const modalToolbarBtnStyle = galleryStyles . modalToolbarBtnStyle ;
39
39
const modalSlideShowSectionStyle = galleryStyles . modalSlideShowSectionStyle ;
40
40
const modalThumbnailSectionStyle = galleryStyles . modalThumbnailSectionStyle ;
41
+ const modalImageContainerStyle = galleryStyles . modalImageContainerStyle ;
41
42
const modalImageStyle = galleryStyles . modalImageStyle ;
42
43
const modalSlideBtnStyle = galleryStyles . modalSlideBtnStyle ;
43
44
@@ -277,14 +278,31 @@ export function ImageGallery({
277
278
/>
278
279
) }
279
280
</ button >
280
- < img
281
- src = { imageSrc }
282
- alt = { imagesInfoArray [ slideNumber - 1 ] . alt }
283
- style = { {
284
- height : showThumbnails ? "80vh" : "100vh" ,
285
- ...modalImageStyle ,
286
- } }
287
- />
281
+ < figure
282
+ style = { modalImageContainerStyle }
283
+ onMouseEnter = { ( e ) =>
284
+ fixedCaption ? undefined : handleImageContainerMouseEnter ( e )
285
+ }
286
+ onMouseLeave = { ( e ) =>
287
+ fixedCaption ? undefined : handleImageContainerMouseLeave ( e )
288
+ }
289
+ >
290
+ < img
291
+ src = { imageSrc }
292
+ alt = { imagesInfoArray [ slideNumber - 1 ] . alt }
293
+ style = { {
294
+ height : showThumbnails ? "80vh" : "100vh" ,
295
+ ...modalImageStyle ,
296
+ } }
297
+ />
298
+ { imagesInfoArray [ slideNumber - 1 ] . caption ? (
299
+ < figcaption style = { imageCaptionStyle } >
300
+ { imagesInfoArray [ slideNumber - 1 ] . caption }
301
+ </ figcaption >
302
+ ) : (
303
+ ""
304
+ ) }
305
+ </ figure >
288
306
< button
289
307
type = "button"
290
308
aria-label = "Next image"
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export interface ImageGalleryStylesType {
10
10
modalToolbarBtnStyle ?: React . CSSProperties ;
11
11
modalSlideShowSectionStyle ?: React . CSSProperties ;
12
12
modalThumbnailSectionStyle ?: React . CSSProperties ;
13
+ modalImageContainerStyle ?: React . CSSProperties ;
13
14
modalImageStyle ?: React . CSSProperties ;
14
15
modalSlideBtnStyle ?: React . CSSProperties ;
15
16
}
Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ export function imageGalleryStyles(
92
92
width : "inherit" ,
93
93
transition : "height .7s linear" ,
94
94
} ;
95
+ const modalImageContainerStyle : React . CSSProperties = {
96
+ width : "inherit" ,
97
+ } ;
95
98
const modalImageStyle : React . CSSProperties = {
96
99
margin : "auto" ,
97
100
maxWidth : "100vw" ,
@@ -128,6 +131,7 @@ export function imageGalleryStyles(
128
131
modalToolbarBtnStyle,
129
132
modalSlideShowSectionStyle,
130
133
modalThumbnailSectionStyle,
134
+ modalImageContainerStyle,
131
135
modalImageStyle,
132
136
modalSlideBtnStyle,
133
137
} ;
You can’t perform that action at this time.
0 commit comments