@campxdev/react-blueprint 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +11 -21
- package/src/components/Assets/Icons/IconComponents/CampxFullLogoIcon.tsx +46 -40
- package/src/components/Assets/Icons/IconComponents/CampxIcon.tsx +14 -12
- package/src/components/Assets/Icons/IconComponents/CheckedCheckBoxIcon.tsx +13 -32
- package/src/components/Assets/Icons/IconComponents/Comfortable.tsx +21 -0
- package/src/components/Assets/Icons/IconComponents/CompactIcon.tsx +23 -0
- package/src/components/Assets/Icons/IconComponents/ConfigureIcon.tsx +35 -0
- package/src/components/Assets/Icons/IconComponents/FilterViewIcon.tsx +32 -0
- package/src/components/Assets/Icons/IconComponents/StandardIcon.tsx +22 -0
- package/src/components/Assets/Icons/IconComponents/UncheckCheckBoxIcon.tsx +10 -16
- package/src/components/Assets/Icons/IconComponents/VisibiityOffIcon.tsx +6 -13
- package/src/components/Assets/Icons/IconComponents/VisibilityIcon.tsx +14 -19
- package/src/components/Assets/Icons/Icons.tsx +10 -0
- package/src/components/DataDisplay/Card/Card.tsx +11 -3
- package/src/components/DataDisplay/SidePanel/SidePanel.tsx +1 -1
- package/src/components/DataDisplay/SidePanel/styles.tsx +1 -1
- package/src/components/Input/SingleCheckBox/SIngleCheckBox.tsx +10 -2
- package/src/components/Navigation/Breadcrumbs/Breadcrumbs.tsx +4 -4
- package/src/components/Navigation/DropDownMenu/DropDownMenu.tsx +41 -8
- package/src/components/Navigation/ManageFilters/ManageFilters.tsx +112 -0
- package/src/components/Navigation/Sidebar/Components.tsx +40 -2
- package/src/components/Navigation/Sidebar/MenuItem.tsx +21 -9
- package/src/components/Navigation/Sidebar/Sidebar.tsx +26 -12
- package/src/components/Navigation/Sidebar/SubMenuItem.tsx +5 -1
- package/src/components/Navigation/Sidebar/interfaces.ts +2 -0
- package/src/components/Navigation/Sidebar/styles.tsx +18 -18
- package/src/components/Navigation/TableColumnFilters/TableColumnFilters.tsx +108 -0
- package/src/components/Navigation/TableDensityFilter/TableDensityFilter.tsx +104 -0
- package/src/components/Navigation/export.ts +3 -0
- package/src/stories/Input/Password.stories.tsx +1 -4
- package/src/stories/Navigation/ColumnFilters.stories.tsx +82 -0
- package/src/stories/Navigation/ManageFilters.stories.tsx +117 -0
- package/src/stories/Navigation/TableDensityFilter.stories.tsx +45 -0
- package/src/themes/commonTheme.ts +16 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FormControlLabel,
|
|
3
|
+
FormControlLabelProps,
|
|
3
4
|
Checkbox as MuiCheckbox,
|
|
4
5
|
CheckboxProps as MuiCheckboxProps,
|
|
5
6
|
useTheme,
|
|
@@ -9,7 +10,10 @@ import { Typography } from '../../DataDisplay/Typography/Typography';
|
|
|
9
10
|
import { Icons } from '../../export';
|
|
10
11
|
|
|
11
12
|
export type CheckboxProps = {
|
|
13
|
+
checkedIcon?: ReactNode;
|
|
14
|
+
icon?: ReactNode;
|
|
12
15
|
label: ReactNode;
|
|
16
|
+
formControlLabelProps?: Omit<FormControlLabelProps, 'control' | 'label'>;
|
|
13
17
|
} & MuiCheckboxProps;
|
|
14
18
|
|
|
15
19
|
export const SingleCheckBox = ({
|
|
@@ -17,6 +21,9 @@ export const SingleCheckBox = ({
|
|
|
17
21
|
label,
|
|
18
22
|
onChange,
|
|
19
23
|
required,
|
|
24
|
+
checkedIcon = <Icons.CheckedCheckboxIcon />,
|
|
25
|
+
icon = <Icons.UnCheckedCheckboxIcon />,
|
|
26
|
+
formControlLabelProps,
|
|
20
27
|
...rest
|
|
21
28
|
}: CheckboxProps) => {
|
|
22
29
|
const theme = useTheme();
|
|
@@ -25,8 +32,8 @@ export const SingleCheckBox = ({
|
|
|
25
32
|
control={
|
|
26
33
|
<MuiCheckbox
|
|
27
34
|
checked={checked}
|
|
28
|
-
checkedIcon={
|
|
29
|
-
icon={
|
|
35
|
+
checkedIcon={checkedIcon}
|
|
36
|
+
icon={icon}
|
|
30
37
|
onChange={onChange}
|
|
31
38
|
{...rest}
|
|
32
39
|
/>
|
|
@@ -41,6 +48,7 @@ export const SingleCheckBox = ({
|
|
|
41
48
|
)}
|
|
42
49
|
</Typography>
|
|
43
50
|
}
|
|
51
|
+
{...formControlLabelProps}
|
|
44
52
|
/>
|
|
45
53
|
);
|
|
46
54
|
};
|
|
@@ -8,7 +8,7 @@ import { Link } from 'react-router-dom';
|
|
|
8
8
|
import { Typography } from '../../export';
|
|
9
9
|
|
|
10
10
|
export type BreadcrumbsProps = {
|
|
11
|
-
|
|
11
|
+
pathTrimCount: number;
|
|
12
12
|
} & MuiBreadcrumbsProps;
|
|
13
13
|
|
|
14
14
|
const getBreadcrumbsCharacter = () => {
|
|
@@ -25,15 +25,15 @@ const getBreadcrumbsCharacter = () => {
|
|
|
25
25
|
return s;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export const Breadcrumbs = ({
|
|
28
|
+
export const Breadcrumbs = ({ pathTrimCount, ...rest }: BreadcrumbsProps) => {
|
|
29
29
|
const specialCharacter = getBreadcrumbsCharacter();
|
|
30
30
|
const currentPathArray = window.location.pathname.split('/');
|
|
31
31
|
|
|
32
32
|
let basePath =
|
|
33
33
|
window.location.origin +
|
|
34
|
-
currentPathArray.slice(0,
|
|
34
|
+
currentPathArray.slice(0, pathTrimCount + 1).join('/');
|
|
35
35
|
|
|
36
|
-
currentPathArray.splice(0,
|
|
36
|
+
currentPathArray.splice(0, pathTrimCount + 1);
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<Stack direction={'row'} alignItems={'center'}>
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Divider,
|
|
3
|
+
Menu,
|
|
4
|
+
MenuListProps,
|
|
5
|
+
MenuProps,
|
|
6
|
+
Stack,
|
|
7
|
+
StackProps,
|
|
8
|
+
useTheme,
|
|
9
|
+
} from '@mui/material';
|
|
2
10
|
import { Fragment, ReactNode, useState } from 'react';
|
|
3
11
|
|
|
4
12
|
export type DropdownMenuProps = {
|
|
5
13
|
anchor: (props: { open: (e: any) => void }) => ReactNode;
|
|
6
|
-
menu: ReactNode[];
|
|
14
|
+
menu: ReactNode[] | ((props: { close: () => void }) => ReactNode[]);
|
|
7
15
|
menuProps?: Omit<MenuProps, 'open'>;
|
|
8
16
|
menuListProps?: MenuListProps;
|
|
17
|
+
menuListContainerSx?: StackProps['sx'];
|
|
18
|
+
menuHeader?: ReactNode;
|
|
9
19
|
};
|
|
10
20
|
|
|
11
21
|
export const DropdownMenu = ({
|
|
12
22
|
menuProps,
|
|
13
23
|
menu = [],
|
|
14
24
|
menuListProps,
|
|
25
|
+
menuHeader,
|
|
26
|
+
menuListContainerSx,
|
|
15
27
|
anchor,
|
|
16
28
|
}: DropdownMenuProps) => {
|
|
17
29
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
18
30
|
const [open, setOpen] = useState(false);
|
|
31
|
+
const theme = useTheme();
|
|
19
32
|
|
|
20
33
|
const handleClick = (event: any) => {
|
|
21
34
|
setAnchorEl(event.currentTarget);
|
|
@@ -27,6 +40,9 @@ export const DropdownMenu = ({
|
|
|
27
40
|
setOpen(false);
|
|
28
41
|
};
|
|
29
42
|
|
|
43
|
+
const menuItems =
|
|
44
|
+
typeof menu === 'function' ? menu({ close: handleClose }) : menu;
|
|
45
|
+
|
|
30
46
|
return (
|
|
31
47
|
<>
|
|
32
48
|
{anchor({ open: handleClick })}
|
|
@@ -52,12 +68,29 @@ export const DropdownMenu = ({
|
|
|
52
68
|
}}
|
|
53
69
|
{...menuProps}
|
|
54
70
|
>
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
{menuHeader}
|
|
72
|
+
<Stack
|
|
73
|
+
direction={'column'}
|
|
74
|
+
sx={{
|
|
75
|
+
...menuListContainerSx,
|
|
76
|
+
'&::-webkit-scrollbar': {
|
|
77
|
+
width: '0.5em',
|
|
78
|
+
height: '0.5em',
|
|
79
|
+
},
|
|
80
|
+
'&::-webkit-scrollbar-thumb': {
|
|
81
|
+
backgroundColor: theme.palette.surface.paperBackground,
|
|
82
|
+
borderRadius: '3px',
|
|
83
|
+
},
|
|
84
|
+
padding: '2px',
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
{menuItems.map((item, index) => (
|
|
88
|
+
<Fragment key={index}>
|
|
89
|
+
{item}
|
|
90
|
+
<Divider flexItem sx={{ margin: '0 !important' }} />
|
|
91
|
+
</Fragment>
|
|
92
|
+
))}
|
|
93
|
+
</Stack>
|
|
61
94
|
</Menu>
|
|
62
95
|
</>
|
|
63
96
|
);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { MenuListProps, MenuProps, Typography, useTheme } from '@mui/material';
|
|
2
|
+
import { ReactNode, useState } from 'react';
|
|
3
|
+
import { Button, Icons, SearchBar, SingleCheckBox } from '../../export';
|
|
4
|
+
import { DropdownMenu } from '../export';
|
|
5
|
+
|
|
6
|
+
type Options = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ManageFiltersProps = {
|
|
12
|
+
options: Options[];
|
|
13
|
+
onChange: (values: ReactNode[]) => void;
|
|
14
|
+
menuProps?: Omit<MenuProps, 'open'>;
|
|
15
|
+
menuListProps?: MenuListProps;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const ManageFilters = ({
|
|
19
|
+
options,
|
|
20
|
+
onChange,
|
|
21
|
+
...props
|
|
22
|
+
}: ManageFiltersProps) => {
|
|
23
|
+
const [values, setValues] = useState<Options[]>([]);
|
|
24
|
+
const [search, setSearch] = useState<string>('');
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
|
|
27
|
+
const filteredOptions = options.filter((option) =>
|
|
28
|
+
option.label.toLowerCase().includes(search.toLowerCase()),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const handleCheckboxChange = (
|
|
32
|
+
value: ReactNode,
|
|
33
|
+
label: string,
|
|
34
|
+
checked: boolean,
|
|
35
|
+
) => {
|
|
36
|
+
const updatedValues = checked
|
|
37
|
+
? [...values, { label, value }]
|
|
38
|
+
: values.filter((v) => v.label !== label);
|
|
39
|
+
setValues(updatedValues);
|
|
40
|
+
onChange(updatedValues.map((v) => v.value));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<DropdownMenu
|
|
45
|
+
menuListProps={{
|
|
46
|
+
sx: {
|
|
47
|
+
padding: '12px',
|
|
48
|
+
width: '250px',
|
|
49
|
+
},
|
|
50
|
+
...props.menuListProps,
|
|
51
|
+
}}
|
|
52
|
+
anchor={({ open }: { open: (e: any) => void }) => (
|
|
53
|
+
<Button onClick={open} sx={{ gap: '1px' }} variant="text">
|
|
54
|
+
{<Icons.ConfigureIcon />} Manage Filters
|
|
55
|
+
</Button>
|
|
56
|
+
)}
|
|
57
|
+
menuProps={{ ...props.menuProps }}
|
|
58
|
+
menuHeader={
|
|
59
|
+
<SearchBar
|
|
60
|
+
fullWidth
|
|
61
|
+
size="small"
|
|
62
|
+
placeholder="Search"
|
|
63
|
+
onSearch={(value) => {
|
|
64
|
+
setSearch(value);
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
}
|
|
68
|
+
menuListContainerSx={{
|
|
69
|
+
margin: '10px 2px 0px 2px',
|
|
70
|
+
gap: 1,
|
|
71
|
+
maxHeight: '350px',
|
|
72
|
+
overflow: 'scroll',
|
|
73
|
+
}}
|
|
74
|
+
menu={filteredOptions.map((item, index) => (
|
|
75
|
+
<SingleCheckBox
|
|
76
|
+
key={index}
|
|
77
|
+
checked={values.map((s) => s.label).includes(item.label)}
|
|
78
|
+
label={<Typography variant="subtitle3">{item.label}</Typography>}
|
|
79
|
+
onChange={(e) => {
|
|
80
|
+
handleCheckboxChange(item.value, item.label, e.target.checked);
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
))}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// const FilterAnchorContainer = styled(Box)(({ theme }) => ({
|
|
89
|
+
// height: '40px',
|
|
90
|
+
// width: '40px',
|
|
91
|
+
// backgroundColor: theme.palette.secondary.main,
|
|
92
|
+
// borderRadius: '5px',
|
|
93
|
+
// display: 'flex',
|
|
94
|
+
// alignItems: 'center',
|
|
95
|
+
// justifyContent: 'center',
|
|
96
|
+
// }));
|
|
97
|
+
|
|
98
|
+
/* <DropDownIcon
|
|
99
|
+
icon={{
|
|
100
|
+
icon: (
|
|
101
|
+
<Badge
|
|
102
|
+
overlap="circular"
|
|
103
|
+
variant={values.length > 0 ? 'dot' : 'standard'}
|
|
104
|
+
>
|
|
105
|
+
<FilterAnchorContainer>
|
|
106
|
+
<FilterViewIcon />
|
|
107
|
+
</FilterAnchorContainer>
|
|
108
|
+
</Badge>
|
|
109
|
+
),
|
|
110
|
+
}}
|
|
111
|
+
handleClick={open}
|
|
112
|
+
/>; */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Box, Stack } from '@mui/material';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { LeftIcon } from '../../Assets/Icons/IconComponents/LeftIcon';
|
|
3
4
|
import { Icons, Tooltip, Typography } from '../../export';
|
|
4
5
|
import {
|
|
5
6
|
DefaultButtonProps,
|
|
@@ -9,9 +10,22 @@ import {
|
|
|
9
10
|
} from './interfaces';
|
|
10
11
|
import { createSidebarStyles } from './styles';
|
|
11
12
|
|
|
12
|
-
export const TooltipIcon = ({
|
|
13
|
+
export const TooltipIcon = ({
|
|
14
|
+
name,
|
|
15
|
+
icon,
|
|
16
|
+
collapsed,
|
|
17
|
+
setCollapsed,
|
|
18
|
+
}: TooltipIconProps) => {
|
|
19
|
+
const handleClick = () => {
|
|
20
|
+
if (collapsed && setCollapsed) {
|
|
21
|
+
setCollapsed(!collapsed);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
13
24
|
return (
|
|
14
|
-
<Tooltip
|
|
25
|
+
<Tooltip
|
|
26
|
+
title={<Typography variant="label2">{name}</Typography>}
|
|
27
|
+
onClick={() => handleClick()}
|
|
28
|
+
>
|
|
15
29
|
{icon}
|
|
16
30
|
</Tooltip>
|
|
17
31
|
);
|
|
@@ -57,9 +71,11 @@ export const InternalMenuButton = ({
|
|
|
57
71
|
<StyledListItemIcon collapsed={collapsed}>{icon}</StyledListItemIcon>
|
|
58
72
|
<Typography variant="button1">{name}</Typography>
|
|
59
73
|
</Stack>
|
|
74
|
+
{/*
|
|
60
75
|
<HoverIcon display={'flex'} className="hoverIcon">
|
|
61
76
|
<Icons.RedoIcon size={18} />
|
|
62
77
|
</HoverIcon>
|
|
78
|
+
*/}
|
|
63
79
|
</Stack>
|
|
64
80
|
</StyledListItemButton>
|
|
65
81
|
);
|
|
@@ -95,3 +111,25 @@ export const SubMenuButton = ({
|
|
|
95
111
|
</StyledListItemButton>
|
|
96
112
|
);
|
|
97
113
|
};
|
|
114
|
+
|
|
115
|
+
export const CollapseMenuButton = ({ collapsed }: { collapsed: boolean }) => {
|
|
116
|
+
const { StyledListItemIcon } = useMemo(
|
|
117
|
+
() => createSidebarStyles(collapsed),
|
|
118
|
+
[collapsed],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Box
|
|
123
|
+
sx={{
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
whiteSpace: 'nowrap',
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<StyledListItemIcon collapsed={collapsed}>
|
|
130
|
+
<LeftIcon size={32} />
|
|
131
|
+
</StyledListItemIcon>
|
|
132
|
+
<Typography variant="button1">Collapse Menu</Typography>
|
|
133
|
+
</Box>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
@@ -16,12 +16,14 @@ import { SidebarSubMenuItem } from './SubMenuItem';
|
|
|
16
16
|
export const SideBarMenuItem = ({
|
|
17
17
|
index,
|
|
18
18
|
collapsed,
|
|
19
|
+
setCollapsed,
|
|
19
20
|
menuItem,
|
|
20
21
|
currentMenuPath,
|
|
21
22
|
internalMenuClickHandler,
|
|
22
23
|
}: {
|
|
23
24
|
index: number;
|
|
24
25
|
collapsed: boolean;
|
|
26
|
+
setCollapsed: any;
|
|
25
27
|
currentMenuPath: string | null;
|
|
26
28
|
menuItem: SideMenuItemProps;
|
|
27
29
|
internalMenuClickHandler: (params: InternalMenuClickHandlerProps) => void;
|
|
@@ -33,12 +35,12 @@ export const SideBarMenuItem = ({
|
|
|
33
35
|
let resolved = useResolvedPath(newPath);
|
|
34
36
|
let match = useMatch({ path: resolved.pathname, end: false });
|
|
35
37
|
|
|
36
|
-
let [expanded, setExpanded] = useState(
|
|
38
|
+
let [expanded, setExpanded] = useState(!collapsed && !!match);
|
|
37
39
|
const subMenuButtonClickHandler = () => {
|
|
38
40
|
setExpanded(!expanded);
|
|
39
41
|
};
|
|
40
42
|
|
|
41
|
-
const { StyledListItem, StyledLinkButton,
|
|
43
|
+
const { StyledListItem, StyledLinkButton, StyledSubMenuBox } = useMemo(
|
|
42
44
|
() => createSidebarStyles(collapsed),
|
|
43
45
|
[collapsed],
|
|
44
46
|
);
|
|
@@ -52,7 +54,7 @@ export const SideBarMenuItem = ({
|
|
|
52
54
|
>
|
|
53
55
|
{internalMenu && internalMenu.length > 0 && (
|
|
54
56
|
<StyledListItem key={index} disablePadding className="listItem">
|
|
55
|
-
<
|
|
57
|
+
<StyledSubMenuBox
|
|
56
58
|
match={match}
|
|
57
59
|
onClick={() =>
|
|
58
60
|
internalMenuClickHandler({
|
|
@@ -63,7 +65,12 @@ export const SideBarMenuItem = ({
|
|
|
63
65
|
}
|
|
64
66
|
>
|
|
65
67
|
{collapsed ? (
|
|
66
|
-
<TooltipIcon
|
|
68
|
+
<TooltipIcon
|
|
69
|
+
name={name}
|
|
70
|
+
icon={Icon}
|
|
71
|
+
collapsed={collapsed}
|
|
72
|
+
setCollapsed={setCollapsed}
|
|
73
|
+
/>
|
|
67
74
|
) : (
|
|
68
75
|
<InternalMenuButton
|
|
69
76
|
name={name}
|
|
@@ -71,17 +78,22 @@ export const SideBarMenuItem = ({
|
|
|
71
78
|
collapsed={collapsed}
|
|
72
79
|
/>
|
|
73
80
|
)}
|
|
74
|
-
</
|
|
81
|
+
</StyledSubMenuBox>
|
|
75
82
|
</StyledListItem>
|
|
76
83
|
)}
|
|
77
84
|
{subMenu && subMenu.length > 0 && (
|
|
78
85
|
<StyledListItem key={index} disablePadding className="listItem">
|
|
79
|
-
<
|
|
80
|
-
match={match}
|
|
86
|
+
<StyledSubMenuBox
|
|
87
|
+
match={match && collapsed}
|
|
81
88
|
onClick={() => subMenuButtonClickHandler()}
|
|
82
89
|
>
|
|
83
90
|
{collapsed ? (
|
|
84
|
-
<TooltipIcon
|
|
91
|
+
<TooltipIcon
|
|
92
|
+
name={name}
|
|
93
|
+
icon={Icon}
|
|
94
|
+
collapsed={collapsed}
|
|
95
|
+
setCollapsed={setCollapsed}
|
|
96
|
+
/>
|
|
85
97
|
) : (
|
|
86
98
|
<SubMenuButton
|
|
87
99
|
name={name}
|
|
@@ -90,7 +102,7 @@ export const SideBarMenuItem = ({
|
|
|
90
102
|
collapsed={collapsed}
|
|
91
103
|
/>
|
|
92
104
|
)}
|
|
93
|
-
</
|
|
105
|
+
</StyledSubMenuBox>
|
|
94
106
|
</StyledListItem>
|
|
95
107
|
)}
|
|
96
108
|
{expanded && !collapsed && subMenu && subMenu.length > 0 && (
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { Box } from '@mui/material';
|
|
1
2
|
import { motion } from 'framer-motion';
|
|
2
3
|
import { ReactElement, useEffect, useMemo, useState } from 'react';
|
|
3
4
|
import { CampxFullLogoIcon } from '../../Assets/Icons/IconComponents/CampxFullLogoIcon';
|
|
4
5
|
import { CampxIcon } from '../../Assets/Icons/IconComponents/CampxIcon';
|
|
5
|
-
import { LeftIcon } from '../../Assets/Icons/IconComponents/LeftIcon';
|
|
6
6
|
import { RightIcon } from '../../Assets/Icons/IconComponents/RightIcon';
|
|
7
7
|
import { Typography } from '../../DataDisplay/Typography/Typography';
|
|
8
8
|
import { Icons } from '../../export';
|
|
9
|
+
import { CollapseMenuButton } from './Components';
|
|
9
10
|
import { SideBarMenuItem } from './MenuItem';
|
|
10
11
|
import {
|
|
11
12
|
GetActiveMenuProps,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
MenuState,
|
|
14
15
|
} from './interfaces';
|
|
15
16
|
import { createSidebarStyles } from './styles';
|
|
16
|
-
import { Box } from '@mui/material';
|
|
17
17
|
|
|
18
18
|
export const Sidebar = ({
|
|
19
19
|
menu,
|
|
@@ -67,6 +67,7 @@ export const Sidebar = ({
|
|
|
67
67
|
const prev = history && history.length > 0 && history.pop();
|
|
68
68
|
|
|
69
69
|
if (prev && prev.menu) {
|
|
70
|
+
setCollapsed(false);
|
|
70
71
|
setCurrentMenuState({
|
|
71
72
|
menu: prev.menu,
|
|
72
73
|
title: prev.title,
|
|
@@ -149,6 +150,7 @@ export const Sidebar = ({
|
|
|
149
150
|
StyledMenuBar,
|
|
150
151
|
StyledCollapsibleSection,
|
|
151
152
|
StyledMenuHeaderButton,
|
|
153
|
+
StyledListItemIcon,
|
|
152
154
|
} = useMemo(() => createSidebarStyles(collapsed), [collapsed, menuPosition]);
|
|
153
155
|
|
|
154
156
|
return (
|
|
@@ -183,27 +185,34 @@ export const Sidebar = ({
|
|
|
183
185
|
}}
|
|
184
186
|
>
|
|
185
187
|
<StyledMenuBar>
|
|
186
|
-
{
|
|
188
|
+
{currentMenuState.title && (
|
|
187
189
|
<StyledMenuHeaderButton
|
|
188
190
|
direction="row"
|
|
191
|
+
justifyContent={collapsed ? 'center' : 'flex-start'}
|
|
189
192
|
onClick={() => previousMenuClickHandler()}
|
|
190
193
|
>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
{collapsed ? (
|
|
195
|
+
<Icons.ArrowBackIcon size={20} />
|
|
196
|
+
) : (
|
|
197
|
+
<>
|
|
198
|
+
<Icons.ArrowBackIcon size={20} />
|
|
199
|
+
<Typography variant="button1">
|
|
200
|
+
{currentMenuState.title}
|
|
201
|
+
</Typography>
|
|
202
|
+
</>
|
|
203
|
+
)}
|
|
196
204
|
</StyledMenuHeaderButton>
|
|
197
205
|
)}
|
|
198
206
|
{currentMenuState.menu &&
|
|
199
207
|
currentMenuState.menu.length > 0 &&
|
|
200
208
|
currentMenuState.menu?.map((item: any, index: number) => (
|
|
201
209
|
<SideBarMenuItem
|
|
202
|
-
currentMenuPath={currentMenuState.path}
|
|
203
|
-
menuItem={item}
|
|
204
|
-
index={index}
|
|
205
210
|
key={index}
|
|
211
|
+
index={index}
|
|
206
212
|
collapsed={collapsed}
|
|
213
|
+
setCollapsed={setCollapsed}
|
|
214
|
+
menuItem={item}
|
|
215
|
+
currentMenuPath={currentMenuState.path}
|
|
207
216
|
internalMenuClickHandler={internalMenuClickHandler}
|
|
208
217
|
/>
|
|
209
218
|
))}
|
|
@@ -212,8 +221,13 @@ export const Sidebar = ({
|
|
|
212
221
|
<StyledCollapsibleSection
|
|
213
222
|
className="collapsibleSection"
|
|
214
223
|
onClick={toggleSidebar}
|
|
224
|
+
collapsed={collapsed}
|
|
215
225
|
>
|
|
216
|
-
{collapsed ?
|
|
226
|
+
{collapsed ? (
|
|
227
|
+
<RightIcon size={32} />
|
|
228
|
+
) : (
|
|
229
|
+
<CollapseMenuButton collapsed={collapsed} />
|
|
230
|
+
)}
|
|
217
231
|
</StyledCollapsibleSection>
|
|
218
232
|
</StyledSidebarContainer>
|
|
219
233
|
</motion.div>
|
|
@@ -25,7 +25,11 @@ export const SidebarSubMenuItem = ({
|
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<StyledListItem key={index} disablePadding className="listItem">
|
|
28
|
-
<StyledLinkButton
|
|
28
|
+
<StyledLinkButton
|
|
29
|
+
to={newPath}
|
|
30
|
+
match={match}
|
|
31
|
+
sx={{ margin: '5px 8px 5px 36px' }}
|
|
32
|
+
>
|
|
29
33
|
<StyledListItemButton collapsed={collapsed}>
|
|
30
34
|
<Typography variant="button1">{name}</Typography>
|
|
31
35
|
</StyledListItemButton>
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Box,
|
|
3
|
-
Button,
|
|
4
|
-
IconButton,
|
|
5
3
|
ListItem,
|
|
6
4
|
ListItemButton,
|
|
7
5
|
ListItemIcon,
|
|
@@ -24,8 +22,8 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
24
22
|
({ theme, collapsed }: { theme?: any; collapsed: boolean }) => ({
|
|
25
23
|
display: 'flex',
|
|
26
24
|
alignItems: 'center',
|
|
27
|
-
justifyContent: 'center',
|
|
28
|
-
padding: collapsed ? '0px' : '
|
|
25
|
+
justifyContent: collapsed ? 'center' : 'flex-start',
|
|
26
|
+
padding: collapsed ? '0px' : '19px 16px',
|
|
29
27
|
backgroundColor: theme.palette.surface.paperBackground,
|
|
30
28
|
height: '60px',
|
|
31
29
|
borderRadius: '8px',
|
|
@@ -38,14 +36,17 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
38
36
|
backgroundColor: theme.palette.surface.paperBackground,
|
|
39
37
|
}));
|
|
40
38
|
|
|
41
|
-
const StyledCollapsibleSection = styled(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
const StyledCollapsibleSection = styled(Box)<StyledListItemButtonProps>(
|
|
40
|
+
({ theme, collapsed }) => ({
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
justifyContent: collapsed ? 'center' : 'flex-start',
|
|
45
|
+
padding: '19px 8px',
|
|
46
|
+
borderRadius: '8px',
|
|
47
|
+
backgroundColor: theme.palette.surface.paperBackground,
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
49
50
|
|
|
50
51
|
interface StyledLinkButtonProps {
|
|
51
52
|
match: any;
|
|
@@ -65,7 +66,6 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
65
66
|
textDecoration: 'none',
|
|
66
67
|
display: 'flex',
|
|
67
68
|
margin: collapsed ? '5px 0px 0px 0px' : '5px 8px',
|
|
68
|
-
|
|
69
69
|
backgroundColor: match ? theme.palette.secondary.main : 'none',
|
|
70
70
|
justifyContent: 'center',
|
|
71
71
|
'&:hover': {
|
|
@@ -94,8 +94,8 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
94
94
|
display: 'flex',
|
|
95
95
|
alignItems: 'center',
|
|
96
96
|
justifyContent: collapsed ? 'center' : 'flex-start',
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
whiteSpace: 'nowrap',
|
|
98
|
+
padding: '5px 8px',
|
|
99
99
|
width: '100%',
|
|
100
100
|
borderRadius: '5px',
|
|
101
101
|
'&:hover .hoverIcon': {
|
|
@@ -107,7 +107,7 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
107
107
|
display: 'none',
|
|
108
108
|
}));
|
|
109
109
|
|
|
110
|
-
const
|
|
110
|
+
const StyledSubMenuBox = styled(Box)<StyledLinkButtonProps>(
|
|
111
111
|
({ theme, match }) => ({
|
|
112
112
|
width: collapsed ? 'auto' : '100%',
|
|
113
113
|
textDecoration: 'none',
|
|
@@ -123,7 +123,7 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
123
123
|
);
|
|
124
124
|
|
|
125
125
|
const StyledMenuHeaderButton = styled(Stack)(({ theme }) => ({
|
|
126
|
-
alignItems: '
|
|
126
|
+
alignItems: 'center',
|
|
127
127
|
height: '50px',
|
|
128
128
|
width: '100%',
|
|
129
129
|
padding: '12px 16px',
|
|
@@ -141,7 +141,7 @@ export const createSidebarStyles = (collapsed: boolean) => {
|
|
|
141
141
|
StyledLinkButton,
|
|
142
142
|
StyledListItemButton,
|
|
143
143
|
StyledListItemIcon,
|
|
144
|
-
|
|
144
|
+
StyledSubMenuBox,
|
|
145
145
|
StyledMenuHeaderButton,
|
|
146
146
|
HoverIcon,
|
|
147
147
|
};
|