Skip to content

Commit

Permalink
Merge pull request layer5io#677 from rishabhsharma1997/master
Browse files Browse the repository at this point in the history
chore: added render markdown in note component
  • Loading branch information
captain-Akshay authored Jul 15, 2024
2 parents 4d49584 + 22f1e0b commit 356d095
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
74 changes: 74 additions & 0 deletions src/custom/CustomImage/CustomImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React, { useState } from 'react';
import { Dialog } from '../../base';

interface ImageComponentProps {
src: string;
alt?: string;
width?: number | string;
height?: number | string;
loading?: undefined | 'eager' | 'lazy';
decoding?: 'sync' | 'async' | 'auto';
crossOrigin?: 'anonymous' | 'use-credentials' | '';
sizes?: string;
srcSet?: string;
className?: string;
style?: React.CSSProperties;
onClick?: (event: React.MouseEvent<HTMLImageElement, MouseEvent>) => void;
}

const CustomImage: React.FC<ImageComponentProps> = ({ src, alt, ...props }) => {
const [isZoomed, setIsZoomed] = useState(false);

const handleZoomClick = () => {
setIsZoomed(true);
};

const handleZoomClose = () => {
setIsZoomed(false);
};

return (
<>
<img
src={src}
alt={alt}
loading="lazy"
onClick={handleZoomClick}
{...props}
style={{
cursor: 'pointer',
maxWidth: '100%',
height: 'auto',
...props.style
}}
/>
<Dialog
open={isZoomed}
onClose={handleZoomClose}
style={{
backgroundColor: 'rgba(0, 0, 0, 0.8)'
}}
PaperProps={{
style: {
background: 'transparent',
boxShadow: 'none',
overflow: 'auto',
maxWidth: '60rem'
}
}}
>
<img
src={src}
alt={alt}
style={{
objectFit: 'contain',
maxWidth: '100%',
maxHeight: '100%'
}}
/>
</Dialog>
</>
);
};

export default CustomImage;
2 changes: 2 additions & 0 deletions src/custom/CustomImage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import CustomImage from './CustomImage';
export { CustomImage };
7 changes: 5 additions & 2 deletions src/custom/Note/Note.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { styled } from '@mui/material';
import { FC } from 'react';
import { RenderMarkdownTooltip } from '../Markdown';

interface AlertProps {
type?: 'success' | 'warning' | 'note';
title?: string;
content?: string;
content: string;
}

const NoteWrapper = styled('div')<NoteWrapperProps>(({ type, theme }) => ({
Expand Down Expand Up @@ -40,7 +41,9 @@ const Note: FC<AlertProps> = ({ type = 'note', title, content }) => {
return (
<NoteWrapper type={type}>
<NoteHeading type={type}>{title}</NoteHeading>
<NoteContent>{content}</NoteContent>
<NoteContent>
<RenderMarkdownTooltip content={content} />
</NoteContent>
</NoteWrapper>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/custom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CustomColumnVisibilityControl,
CustomColumnVisibilityControlProps
} from './CustomColumnVisibilityControl/CustomColumnVisibilityControl';
import { CustomImage } from './CustomImage';
import { CustomTooltip, InfoTooltip } from './CustomTooltip';
import {
CustomDialog,
Expand Down Expand Up @@ -54,6 +55,7 @@ export {
ConnectionChip,
CustomColumnVisibilityControl,
CustomDialog,
CustomImage,
CustomTooltip,
EmptyState,
ErrorBoundary,
Expand Down

0 comments on commit 356d095

Please sign in to comment.