Skip to content

Commit afbdd1d

Browse files
committed
Merge branch 'master' of https://github.com/sudhanshutech/sistent into yash/addShareModal
2 parents a8561ac + f6abad9 commit afbdd1d

File tree

42 files changed

+2057
-647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2057
-647
lines changed

package-lock.json

Lines changed: 1357 additions & 570 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
"@reduxjs/toolkit": "^2.2.5",
4747
"@testing-library/react": "^14.1.2",
4848
"@types/jest": "^29.5.11",
49+
"@types/lodash": "^4.17.7",
4950
"@types/react": "^18.2.45",
5051
"@types/react-dom": "^18.2.18",
52+
"@types/react-redux": "^7.1.33",
5153
"@typescript-eslint/eslint-plugin": "^6.12.0",
5254
"@typescript-eslint/parser": "^6.12.0",
5355
"commitizen": "^4.3.0",
@@ -67,10 +69,13 @@
6769
"prettier-plugin-organize-imports": "^3.2.3",
6870
"react-error-boundary": "^4.0.12",
6971
"react-markdown": "^8.0.7",
72+
"react-redux": "^8.1.1",
73+
"redux": "^5.0.1",
7074
"rehype-raw": "^6.1.1",
7175
"remark-gfm": "^3.0.1",
7276
"ts-jest": "^29.1.1",
73-
"tsup": "^8.0.1",
77+
"@types/lodash": "^4.17.7",
78+
"tsup": "^8.2.4",
7479
"typescript": "^5.3.3"
7580
},
7681
"peerDependencies": {
@@ -79,12 +84,16 @@
7984
"@mui/material": "^5.15.11",
8085
"@types/mui-datatables": "*",
8186
"@xstate/react": "^4.1.1",
87+
"lodash": "^4.17.21",
8288
"mui-datatables": "*",
8389
"react": ">=17",
8490
"react-dom": ">=17",
8591
"xstate": "^5.13.0"
8692
},
8793
"peerDependenciesMeta": {
94+
"lodash": {
95+
"optional": true
96+
},
8897
"@emotion/react": {
8998
"optional": true
9099
},
@@ -106,5 +115,8 @@
106115
},
107116
"publishConfig": {
108117
"access": "public"
118+
},
119+
"dependencies": {
120+
"lodash": "^4.17.21"
109121
}
110122
}

src/custom/CatalogCard/CatalogCard.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type CatalogCardProps = {
3838
cardWidth: string;
3939
cardStyles: React.CSSProperties;
4040
type: string;
41+
onCardClick?: () => void;
4142
};
4243

4344
export const ClassToIconMap = {
@@ -63,15 +64,16 @@ const CatalogCard: React.FC<CatalogCardProps> = ({
6364
cardHeight,
6465
cardWidth,
6566
cardStyles,
66-
cardLink
67+
cardLink,
68+
onCardClick
6769
}) => {
6870
const outerStyles = {
6971
height: cardHeight,
7072
width: cardWidth,
7173
...cardStyles
7274
};
7375
return (
74-
<DesignCardUrl href={cardLink} target="_blank" rel="noreferrer">
76+
<DesignCardUrl href={cardLink} onClick={onCardClick} target="_blank" rel="noreferrer">
7577
<DesignCard outerStyles={outerStyles}>
7678
<DesignInnerCard className="innerCard">
7779
<ClassWrap catalogClassName={pattern?.catalog_data?.content_class} />

src/custom/CatalogCard/style.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const DesignInnerCard = styled('div')(({ theme }) => ({
6666
height: '100%',
6767
textAlign: 'center',
6868
transition: 'transform 0.6s',
69+
background: theme.palette.background.default,
6970
boxShadow: `2px 2px 3px 0px ${theme.palette.background.brand?.default}`,
7071
borderRadius: '0.9375rem'
7172
}));

src/custom/ChapterCard/style.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { styled } from '@mui/material';
2-
import { ALABASTER_WHITE, KEPPEL, MIDNIGHT_BLACK } from '../../theme';
2+
import { ALABASTER_WHITE, MIDNIGHT_BLACK } from '../../theme';
33

44
// Styled component for ChapterCardWrapper
55
export const ChapterCardWrapper = styled('div')(({ theme }) => ({
@@ -13,7 +13,7 @@ export const ChapterCardWrapper = styled('div')(({ theme }) => ({
1313
}`,
1414
justifyContent: 'space-between',
1515
'&:hover': {
16-
border: `1px solid ${KEPPEL}`,
16+
border: `1px solid ${theme.palette.background.brand?.default}`,
1717
transition:
1818
'background 150ms ease-out 0s, border 150ms ease-out 0s, transform 150ms ease-out 0s',
1919
transform: 'translate3d(0px, -3px, 0px)',

src/custom/CustomColumnVisibilityControl/CustomColumnVisibilityControl.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTheme } from '@mui/material';
12
import React from 'react';
23
import { Box } from '../../base/Box';
34
import { Card } from '../../base/Card';
@@ -30,6 +31,7 @@ export function CustomColumnVisibilityControl({
3031
}: CustomColumnVisibilityControlProps): JSX.Element {
3132
const [open, setOpen] = React.useState(false);
3233
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
34+
const theme = useTheme();
3335

3436
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
3537
setAnchorEl(event.currentTarget);
@@ -54,7 +56,7 @@ export function CustomColumnVisibilityControl({
5456
<TooltipIcon
5557
title="View Columns"
5658
onClick={handleOpen}
57-
icon={<ColumnIcon fill="#3c494f" />}
59+
icon={<ColumnIcon fill={theme.palette.icon.default} />}
5860
arrow
5961
/>
6062
<PopperListener
@@ -87,7 +89,7 @@ export function CustomColumnVisibilityControl({
8789
flexDirection: 'column',
8890
padding: '1rem',
8991
boxShadow: open ? '0px 4px 8px rgba(0, 0, 0, 0.2)' : 'none',
90-
background: '#f4f5f7'
92+
background: theme.palette.background.surfaces
9193
}}
9294
>
9395
{columns.map((col) => (
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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: '100%'
57+
}
58+
}}
59+
>
60+
<img
61+
src={src}
62+
alt={alt}
63+
onClick={handleZoomClose}
64+
style={{
65+
objectFit: 'contain',
66+
maxWidth: '100%',
67+
maxHeight: '100%'
68+
}}
69+
/>
70+
</Dialog>
71+
</>
72+
);
73+
};
74+
75+
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 };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { ColView, updateVisibleColumns } from './responsive-column';
2+
3+
export { updateVisibleColumns };
4+
export type { ColView };
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// colViews screen size reference
2+
/*
3+
na: Not visible at any screen width
4+
xs: width < 585,
5+
s: width > 585 && width < 690,
6+
m: width > 690 && width < 775,
7+
l: width > 775 && width < 915,
8+
xl: width > 915 && width < 1140
9+
All columns except "na" are visible for width > 1140
10+
*/
11+
12+
export interface ColView {
13+
0: string; // column name
14+
1: 'na' | 'xs' | 's' | 'm' | 'l' | 'xl'; // screen size
15+
}
16+
17+
export const updateVisibleColumns = (
18+
colViews: ColView[],
19+
width: number
20+
): Record<string, boolean> => {
21+
// showCols object contains key value pairs that represent whether a column is visible or hidden.
22+
// i.e, Here, key = column name, and value = true/false where true means visible and false means hidden
23+
const showCols: Record<string, boolean> = {};
24+
25+
// colViews is a 2D array where each element is an array of 2 elements namely,
26+
// column name and the screen size till which they are visible
27+
colViews.forEach((col) => {
28+
// Hide the columns for any screen size
29+
if (col[1] === 'na') {
30+
showCols[col[0]] = false;
31+
} else if (width > 1140) {
32+
// Display all columns above width 1140
33+
showCols[col[0]] = true;
34+
} else if (width >= 915 && width < 1140) {
35+
if (['xs', 's', 'm', 'l', 'xl'].includes(col[1])) {
36+
showCols[col[0]] = true;
37+
} else {
38+
showCols[col[0]] = false;
39+
}
40+
} else if (width >= 775 && width < 915) {
41+
if (['xs', 's', 'm', 'l'].includes(col[1])) {
42+
showCols[col[0]] = true;
43+
} else {
44+
showCols[col[0]] = false;
45+
}
46+
} else if (width >= 690 && width < 775) {
47+
if (['xs', 's', 'm'].includes(col[1])) {
48+
showCols[col[0]] = true;
49+
} else {
50+
showCols[col[0]] = false;
51+
}
52+
} else if (width >= 585 && width < 690) {
53+
if (['xs', 's'].includes(col[1])) {
54+
showCols[col[0]] = true;
55+
} else {
56+
showCols[col[0]] = false;
57+
}
58+
} else if (width < 585) {
59+
if (col[1] === 'xs') {
60+
showCols[col[0]] = true;
61+
} else {
62+
showCols[col[0]] = false;
63+
}
64+
}
65+
});
66+
67+
return showCols;
68+
};

0 commit comments

Comments
 (0)