Skip to content

Commit 356d095

Browse files
Merge pull request #677 from rishabhsharma1997/master
chore: added render markdown in note component
2 parents 4d49584 + 22f1e0b commit 356d095

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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;

src/custom/CustomImage/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import CustomImage from './CustomImage';
2+
export { CustomImage };

src/custom/Note/Note.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { styled } from '@mui/material';
22
import { FC } from 'react';
3+
import { RenderMarkdownTooltip } from '../Markdown';
34

45
interface AlertProps {
56
type?: 'success' | 'warning' | 'note';
67
title?: string;
7-
content?: string;
8+
content: string;
89
}
910

1011
const NoteWrapper = styled('div')<NoteWrapperProps>(({ type, theme }) => ({
@@ -40,7 +41,9 @@ const Note: FC<AlertProps> = ({ type = 'note', title, content }) => {
4041
return (
4142
<NoteWrapper type={type}>
4243
<NoteHeading type={type}>{title}</NoteHeading>
43-
<NoteContent>{content}</NoteContent>
44+
<NoteContent>
45+
<RenderMarkdownTooltip content={content} />
46+
</NoteContent>
4447
</NoteWrapper>
4548
);
4649
};

src/custom/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
CustomColumnVisibilityControl,
99
CustomColumnVisibilityControlProps
1010
} from './CustomColumnVisibilityControl/CustomColumnVisibilityControl';
11+
import { CustomImage } from './CustomImage';
1112
import { CustomTooltip, InfoTooltip } from './CustomTooltip';
1213
import {
1314
CustomDialog,
@@ -54,6 +55,7 @@ export {
5455
ConnectionChip,
5556
CustomColumnVisibilityControl,
5657
CustomDialog,
58+
CustomImage,
5759
CustomTooltip,
5860
EmptyState,
5961
ErrorBoundary,

0 commit comments

Comments
 (0)