@@ -13,35 +13,61 @@ interface ImageComponentProps {
1313 srcSet ?: string ;
1414 className ?: string ;
1515 style ?: React . CSSProperties ;
16+ caption ?: string ;
17+ align ?: 'left' | 'center' | 'right' ;
1618 onClick ?: ( event : React . MouseEvent < HTMLImageElement , MouseEvent > ) => void ;
1719}
1820
19- const CustomImage : React . FC < ImageComponentProps > = ( { src, alt, ...props } ) => {
21+ const CustomImage : React . FC < ImageComponentProps > = ( {
22+ src,
23+ alt,
24+ caption,
25+ align = 'left' ,
26+ ...props
27+ } ) => {
2028 const [ isZoomed , setIsZoomed ] = useState ( false ) ;
21-
2229 const handleZoomClick = ( ) => {
2330 setIsZoomed ( true ) ;
2431 } ;
25-
2632 const handleZoomClose = ( ) => {
2733 setIsZoomed ( false ) ;
2834 } ;
29-
35+
36+ const figureStyle : React . CSSProperties = {
37+ margin : '1rem 0' ,
38+ textAlign : align ,
39+ width : '100%' ,
40+ ...props . style
41+ } ;
42+
43+ const captionStyle : React . CSSProperties = {
44+ fontSize : '0.9rem' ,
45+ color : '#666' ,
46+ marginTop : '0.5rem' ,
47+ textAlign : align
48+ } ;
49+
3050 return (
3151 < >
32- < img
33- src = { src }
34- alt = { alt }
35- loading = "lazy"
36- onClick = { handleZoomClick }
37- { ...props }
38- style = { {
39- cursor : 'pointer' ,
40- maxWidth : '100%' ,
41- height : 'auto' ,
42- ...props . style
43- } }
44- />
52+ < figure style = { figureStyle } >
53+ < img
54+ src = { src }
55+ alt = { alt || caption || '' }
56+ loading = "lazy"
57+ onClick = { handleZoomClick }
58+ { ...props }
59+ style = { {
60+ cursor : 'pointer' ,
61+ maxWidth : '100%' ,
62+ height : 'auto' ,
63+ boxShadow : 'rgba(149, 157, 165, 0.2) 0px 8px 24px' ,
64+ borderRadius : '15px' ,
65+ width : '50%'
66+ } }
67+ />
68+ { caption && < figcaption style = { captionStyle } > { caption } </ figcaption > }
69+ </ figure >
70+
4571 < Dialog
4672 open = { isZoomed }
4773 onClose = { handleZoomClose }
@@ -59,7 +85,7 @@ const CustomImage: React.FC<ImageComponentProps> = ({ src, alt, ...props }) => {
5985 >
6086 < img
6187 src = { src }
62- alt = { alt }
88+ alt = { alt || caption || '' }
6389 onClick = { handleZoomClose }
6490 style = { {
6591 objectFit : 'contain' ,
0 commit comments