Skip to content

Commit 6710d9b

Browse files
committed
feat: add new image and catalog empty card
Signed-off-by: Amit Amrutiya <amitamrutiya2210@gmail.com>
1 parent d5104dd commit 6710d9b

8 files changed

Lines changed: 178 additions & 3 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import React, { useState } from 'react';
2+
import { Dialog } from '../../base';
3+
import { DesignIcon, MesheryFilterIcon } from '../../icons';
4+
5+
interface CatalogCardDesignLogoProps {
6+
zoomEffect?: boolean;
7+
imgURL?: string[];
8+
type: { type: string };
9+
width: string;
10+
height: string;
11+
style?: React.CSSProperties;
12+
}
13+
14+
const CatalogCardDesignLogo: React.FC<CatalogCardDesignLogoProps> = ({
15+
zoomEffect = false,
16+
imgURL,
17+
type,
18+
width,
19+
height,
20+
style = {}
21+
}) => {
22+
const [imgError, setImgError] = useState(false);
23+
const [isZoomed, setIsZoomed] = useState(false);
24+
25+
const handleZoomClick = () => {
26+
if (zoomEffect) {
27+
setIsZoomed(true);
28+
}
29+
};
30+
31+
const handleZoomClose = () => {
32+
setIsZoomed(false);
33+
};
34+
35+
const SvgComponent: React.FC<{ type: { type: string } }> = ({ type }) => {
36+
return type.type === 'filter' ? (
37+
<MesheryFilterIcon width={width} height={height} style={style} />
38+
) : (
39+
<DesignIcon width={width} height={height} style={style} />
40+
);
41+
};
42+
43+
return (
44+
<>
45+
{imgURL && imgURL.length > 0 ? (
46+
<div style={{ width: '100%', height: '7.5rem', position: 'relative' }}>
47+
{!imgError ? (
48+
<>
49+
<img
50+
src={imgURL[0]}
51+
alt="Design SnapShot"
52+
loading="lazy"
53+
onClick={handleZoomClick}
54+
onError={() => setImgError(true)}
55+
style={{
56+
cursor: 'pointer',
57+
width: '100%',
58+
height: '100%',
59+
objectFit: 'cover'
60+
}}
61+
/>
62+
<Dialog
63+
open={isZoomed}
64+
onClose={handleZoomClose}
65+
style={{
66+
backgroundColor: 'rgba(0, 0, 0, 0.8)'
67+
}}
68+
PaperProps={{
69+
style: {
70+
background: 'transparent',
71+
boxShadow: 'none',
72+
overflow: 'hidden',
73+
maxWidth: '60vw'
74+
}
75+
}}
76+
>
77+
<img
78+
src={imgURL[0]}
79+
alt="Zoomed Design SnapShot"
80+
style={{ objectFit: 'contain', maxWidth: '100%', maxHeight: '100%' }}
81+
/>
82+
</Dialog>
83+
</>
84+
) : (
85+
<SvgComponent type={type} />
86+
)}
87+
</div>
88+
) : (
89+
<SvgComponent type={type} />
90+
)}
91+
</>
92+
);
93+
};
94+
95+
export default CatalogCardDesignLogo;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ const CustomCatalogCard: React.FC<CatalogCardProps> = ({
160160

161161
setAvailableTechnologies(validSvgPaths);
162162
};
163+
163164
useEffect(() => {
164165
handleImage();
165166
// eslint-disable-next-line react-hooks/exhaustive-deps
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useTheme } from '@mui/material';
2+
import { FC } from 'react';
3+
import { EmptyStyleIcon } from '../../icons/EmptyStyle';
4+
import { CatalogEmptyStateDiv } from './style';
5+
6+
const EmptyStateCard: FC = () => {
7+
const theme = useTheme();
8+
return (
9+
<CatalogEmptyStateDiv>
10+
<EmptyStyleIcon fill={theme.palette.secondary.contrastText} width="100px" height="100px" />
11+
<h3 style={{ color: theme.palette.secondary.contrastText }}>No match found</h3>
12+
</CatalogEmptyStateDiv>
13+
);
14+
};
15+
16+
export default EmptyStateCard;

src/custom/CustomCatalog/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
import CustomCatalogCard from './custom-card';
1+
import CatalogCardDesignLogo from './CatalogCardDesignLogo';
2+
import CustomCatalogCard from './CustomCard';
3+
import EmptyStateCard from './EmptyStateCard';
24

3-
export { CustomCatalogCard };
5+
export { CatalogCardDesignLogo, CustomCatalogCard, EmptyStateCard };

src/custom/CustomCatalog/style.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,30 @@ export const DesignAuthorName = styled('div')(() => ({
398398
height: 'max-content'
399399
}
400400
}));
401+
402+
export const CatalogEmptyStateDiv = styled('div')(({ theme }) => ({
403+
backgroundColor: theme.palette.common.white,
404+
textAlign: 'center',
405+
borderRadius: '1rem',
406+
width: '15rem',
407+
height: '18rem',
408+
display: 'flex',
409+
flexDirection: 'column',
410+
justifyContent: 'center',
411+
alignItems: 'center',
412+
[theme.breakpoints.down('lg')]: {
413+
height: '18.75rem'
414+
}
415+
}));
416+
417+
export const EmptyStateDiv = styled('div')(({ theme }) => ({
418+
backgroundColor: theme.palette.common.white,
419+
textAlign: 'center',
420+
borderRadius: '1rem',
421+
width: '100%',
422+
padding: '1.5rem',
423+
display: 'flex',
424+
flexDirection: 'column',
425+
justifyContent: 'center',
426+
alignItems: 'center'
427+
}));

src/custom/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BookmarkNotification } from './BookmarkNotification';
33
import CatalogFilter, { CatalogFilterProps } from './CatalogFilter/CatalogFilter';
44
import { ChapterCard } from './ChapterCard';
55
import { ConnectionChip } from './ConnectionChip';
6-
import { CustomCatalogCard } from './CustomCatalog';
6+
import { CatalogCardDesignLogo, CustomCatalogCard, EmptyStateCard } from './CustomCatalog';
77
import {
88
CustomColumn,
99
CustomColumnVisibilityControl,
@@ -58,6 +58,7 @@ export { Terminal } from './Terminal';
5858
export {
5959
ActionButton,
6060
BookmarkNotification,
61+
CatalogCardDesignLogo,
6162
CatalogFilter,
6263
ChapterCard,
6364
ConnectionChip,
@@ -68,6 +69,7 @@ export {
6869
CustomTooltip,
6970
DataTableEllipsisMenu,
7071
EmptyState,
72+
EmptyStateCard,
7173
ErrorBoundary,
7274
Fallback,
7375
FeedbackButton,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { CSSProperties, FC } from 'react';
2+
3+
interface EmptyStyleIconProps {
4+
width?: string;
5+
height?: string;
6+
fill?: string;
7+
style?: CSSProperties;
8+
onClick?: () => void;
9+
}
10+
11+
const EmptyStyleIcon: FC<EmptyStyleIconProps> = ({
12+
width = '24px',
13+
height = '24px',
14+
fill,
15+
style = {},
16+
onClick = () => {}
17+
}) => (
18+
<svg
19+
style={style}
20+
xmlns="http://www.w3.org/2000/svg"
21+
height={height}
22+
viewBox="0 -960 960 960"
23+
width={width}
24+
fill={fill}
25+
onClick={onClick}
26+
>
27+
<path d="m159-168-34-14q-31-13-41.5-45t3.5-63l72-156v278Zm160 88q-33 0-56.5-23.5T239-160v-240l106 294q3 7 6 13.5t8 12.5h-40Zm206-4q-32 12-62-3t-42-47L243-622q-12-32 2-62.5t46-41.5l302-110q32-12 62 3t42 47l178 488q12 32-2 62.5T827-194L525-84Zm-86-476q17 0 28.5-11.5T479-600q0-17-11.5-28.5T439-640q-17 0-28.5 11.5T399-600q0 17 11.5 28.5T439-560Z" />
28+
</svg>
29+
);
30+
31+
export default EmptyStyleIcon;

src/icons/EmptyStyle/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as EmptyStyleIcon } from './EmptyStyleIcon';

0 commit comments

Comments
 (0)