File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react' ;
2+ import { Dialog } from '../../base' ;
3+
4+ interface ImageComponentProps {
5+ src : string ;
6+ alt ?: string ;
7+ width ?: number | string ;
8+ height ?: number | string ;
9+ loading ?: undefined | 'eager' | 'lazy' ;
10+ decoding ?: 'sync' | 'async' | 'auto' ;
11+ crossOrigin ?: 'anonymous' | 'use-credentials' | '' ;
12+ sizes ?: string ;
13+ srcSet ?: string ;
14+ className ?: string ;
15+ style ?: React . CSSProperties ;
16+ onClick ?: ( event : React . MouseEvent < HTMLImageElement , MouseEvent > ) => void ;
17+ }
18+
19+ const CustomImage : React . FC < ImageComponentProps > = ( { src, alt, ...props } ) => {
20+ const [ isZoomed , setIsZoomed ] = useState ( false ) ;
21+
22+ const handleZoomClick = ( ) => {
23+ setIsZoomed ( true ) ;
24+ } ;
25+
26+ const handleZoomClose = ( ) => {
27+ setIsZoomed ( false ) ;
28+ } ;
29+
30+ return (
31+ < >
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+ />
45+ < Dialog
46+ open = { isZoomed }
47+ onClose = { handleZoomClose }
48+ style = { {
49+ backgroundColor : 'rgba(0, 0, 0, 0.8)'
50+ } }
51+ PaperProps = { {
52+ style : {
53+ background : 'transparent' ,
54+ boxShadow : 'none' ,
55+ overflow : 'auto' ,
56+ maxWidth : '60rem'
57+ }
58+ } }
59+ >
60+ < img
61+ src = { src }
62+ alt = { alt }
63+ style = { {
64+ objectFit : 'contain' ,
65+ maxWidth : '100%' ,
66+ maxHeight : '100%'
67+ } }
68+ />
69+ </ Dialog >
70+ </ >
71+ ) ;
72+ } ;
73+
74+ export default CustomImage ;
Original file line number Diff line number Diff line change 1+ import CustomImage from './CustomImage' ;
2+ export { CustomImage } ;
Original file line number Diff line number Diff line change 88 CustomColumnVisibilityControl ,
99 CustomColumnVisibilityControlProps
1010} from './CustomColumnVisibilityControl/CustomColumnVisibilityControl' ;
11+ import { CustomImage } from './CustomImage' ;
1112import { CustomTooltip , InfoTooltip } from './CustomTooltip' ;
1213import {
1314 CustomDialog ,
@@ -54,6 +55,7 @@ export {
5455 ConnectionChip ,
5556 CustomColumnVisibilityControl ,
5657 CustomDialog ,
58+ CustomImage ,
5759 CustomTooltip ,
5860 EmptyState ,
5961 ErrorBoundary ,
You can’t perform that action at this time.
0 commit comments