@cullsin/lnc-menu 3.0.6 → 3.0.7
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/dist/index.d.ts +1 -1
- package/dist/index.js +2 -163
- package/dist/src/SideMenu.js +80 -0
- package/dist/src/sidemenu.scss +119 -0
- package/package.json +11 -19
- package/dist/index.css +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import AppBar from "@mui/material/AppBar";
|
|
4
|
+
import Box from "@mui/material/Box";
|
|
5
|
+
import Drawer from "@mui/material/Drawer";
|
|
6
|
+
import List from "@mui/material/List";
|
|
7
|
+
import ListItem from "@mui/material/ListItem";
|
|
8
|
+
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
9
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
10
|
+
import Menu from "@mui/material/Menu";
|
|
11
|
+
import MenuItem from "@mui/material/MenuItem";
|
|
12
|
+
import DashboardOutlinedIcon from "@mui/icons-material/DashboardOutlined";
|
|
13
|
+
import RecentActorsOutlinedIcon from "@mui/icons-material/RecentActorsOutlined";
|
|
14
|
+
import ArticleOutlinedIcon from "@mui/icons-material/ArticleOutlined";
|
|
15
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
16
|
+
function SideMenu({ useDrawer, SampleMgmtIcon, navigate }) {
|
|
17
|
+
const [selectedMainMenu, setSelectedMainMenu] = React.useState(null); // Track selected main menu
|
|
18
|
+
const { isDrawerOpen, toggleDrawer } = useDrawer();
|
|
19
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
20
|
+
const handleMenuOpen = (event, index) => {
|
|
21
|
+
setAnchorEl(event.currentTarget);
|
|
22
|
+
};
|
|
23
|
+
const handleMenuClose = () => {
|
|
24
|
+
setAnchorEl(null);
|
|
25
|
+
};
|
|
26
|
+
const handleSubMenuItemClick = (path, parentText) => {
|
|
27
|
+
setSelectedMainMenu(parentText); // Set the main menu selected when a submenu item is clicked
|
|
28
|
+
handleMenuClose();
|
|
29
|
+
if (isDrawerOpen) {
|
|
30
|
+
toggleDrawer();
|
|
31
|
+
}
|
|
32
|
+
console.log('redirecting', path);
|
|
33
|
+
console.log(navigate);
|
|
34
|
+
navigate(path);
|
|
35
|
+
};
|
|
36
|
+
const menuItems = [
|
|
37
|
+
{ text: "Dashboard", icon: _jsx(DashboardOutlinedIcon, {}) },
|
|
38
|
+
{
|
|
39
|
+
text: "Patient Management",
|
|
40
|
+
icon: _jsx(RecentActorsOutlinedIcon, {}),
|
|
41
|
+
subMenu: [
|
|
42
|
+
{ text: "Patient", path: "/patient/patient-listing" },
|
|
43
|
+
{ text: "Family", path: "/patient/family-listing" },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{ text: "Sample Management", icon: _jsx(SampleMgmtIcon, {}) },
|
|
47
|
+
{ text: "Reports", icon: _jsx(ArticleOutlinedIcon, {}) },
|
|
48
|
+
];
|
|
49
|
+
return (_jsxs(Box, { sx: { flexGrow: 1 }, children: [_jsx(AppBar, { sx: { position: "fixed", top: 0 } }), _jsx(Drawer, { open: isDrawerOpen, variant: "permanent", className: "parent-container", sx: {
|
|
50
|
+
width: isDrawerOpen ? 230 : 64,
|
|
51
|
+
flexShrink: 0,
|
|
52
|
+
"& .MuiDrawer-paper": {
|
|
53
|
+
width: isDrawerOpen ? 230 : 64,
|
|
54
|
+
transition: "width 0.3s ease",
|
|
55
|
+
top: "64px",
|
|
56
|
+
bottom: "0",
|
|
57
|
+
borderRight: "1px solid #B1BECB",
|
|
58
|
+
},
|
|
59
|
+
}, children: _jsx(List, { children: menuItems.map((item, index) => (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: item.text, arrow: true, placement: "bottom", disableHoverListener: isDrawerOpen, children: _jsxs(ListItem, { button: true, selected: selectedMainMenu === item.text, className: selectedMainMenu === item.text ? "selected" : "", onClick: (event) => {
|
|
60
|
+
if (item.subMenu) {
|
|
61
|
+
handleMenuOpen(event, index);
|
|
62
|
+
setSelectedMainMenu(item.text); // Set selected when main menu is clicked
|
|
63
|
+
}
|
|
64
|
+
else if (item.onClick) {
|
|
65
|
+
item.onClick();
|
|
66
|
+
setSelectedMainMenu(item.text); // Set selected when a menu is clicked
|
|
67
|
+
}
|
|
68
|
+
}, children: [_jsx(ListItemIcon, { children: item.icon }), isDrawerOpen && _jsx(ListItemText, { primary: item.text })] }) }), item.subMenu && anchorEl && (_jsxs(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleMenuClose, anchorOrigin: {
|
|
69
|
+
vertical: "top",
|
|
70
|
+
horizontal: "left",
|
|
71
|
+
}, transformOrigin: {
|
|
72
|
+
vertical: "top",
|
|
73
|
+
horizontal: "left",
|
|
74
|
+
}, PaperProps: {
|
|
75
|
+
style: {
|
|
76
|
+
marginLeft: isDrawerOpen ? 230 : 65,
|
|
77
|
+
},
|
|
78
|
+
}, children: [_jsx("span", { className: "submenu-title", children: !isDrawerOpen ? item.text : "" }), item.subMenu.map((subItem) => (_jsx(MenuItem, { onClick: () => handleSubMenuItemClick(subItem.path, item.text), children: subItem.text }, subItem.text)))] }))] }, index))) }) })] }));
|
|
79
|
+
}
|
|
80
|
+
export default SideMenu;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
//overwritten the default MUI css
|
|
2
|
+
|
|
3
|
+
.MuiBox-root .MuiList-root {
|
|
4
|
+
background: linear-gradient(to bottom, #1e2f97, #0b1659) !important;
|
|
5
|
+
color: #fff;
|
|
6
|
+
height: 100%;
|
|
7
|
+
bottom: 0; // Ensure drawer stretches till bottom
|
|
8
|
+
padding: 20px 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.MuiList-root {
|
|
12
|
+
&.MuiMenu-list {
|
|
13
|
+
background: linear-gradient(to bottom, #586d81, #3e4f60) !important;
|
|
14
|
+
color: #fff;
|
|
15
|
+
width: 175px;
|
|
16
|
+
padding: 10px;
|
|
17
|
+
position: relative;
|
|
18
|
+
overflow: visible;
|
|
19
|
+
|
|
20
|
+
.submenu-title {
|
|
21
|
+
text-transform: uppercase;
|
|
22
|
+
font: 12px / 18px "OpenSans-Regular";
|
|
23
|
+
color: #efffff;
|
|
24
|
+
padding: 0 0 5px 10px;
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.MuiMenuItem-root {
|
|
29
|
+
&.Mui-focusVisible {
|
|
30
|
+
background-color: transparent;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
font: 16px/24px "OpenSans-SemiBold";
|
|
35
|
+
background: #374451;
|
|
36
|
+
border-radius: 6px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.MuiListItem-root {
|
|
42
|
+
padding: 15px;
|
|
43
|
+
&.selected {
|
|
44
|
+
padding: 7px;
|
|
45
|
+
|
|
46
|
+
.MuiListItemIcon-root {
|
|
47
|
+
background: linear-gradient(to bottom, #7ad4f7, #20a9ef) !important;
|
|
48
|
+
color: #1e2f97;
|
|
49
|
+
padding: 10px;
|
|
50
|
+
min-width: 25px;
|
|
51
|
+
border-top-left-radius: 5px;
|
|
52
|
+
border-bottom-left-radius: 5px;
|
|
53
|
+
|
|
54
|
+
&:only-of-type {
|
|
55
|
+
border-top-right-radius: 5px;
|
|
56
|
+
border-bottom-right-radius: 5px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.MuiListItemText-root {
|
|
61
|
+
span {
|
|
62
|
+
background: linear-gradient(to bottom, #7ad4f7, #20a9ef) !important;
|
|
63
|
+
color: #1e2f97;
|
|
64
|
+
padding: 10px 0;
|
|
65
|
+
min-width: 25px;
|
|
66
|
+
border-top-right-radius: 5px;
|
|
67
|
+
border-bottom-right-radius: 5px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.MuiListItemIcon-root {
|
|
73
|
+
color: #fff;
|
|
74
|
+
min-width: 30px;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.MuiListItemText-root {
|
|
79
|
+
margin-top: 0;
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
.MuiTypography-root {
|
|
82
|
+
font: 14px/24px "OpenSans-SemiBold";
|
|
83
|
+
color: #fff;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
white-space: nowrap;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
ul.MuiList-root {
|
|
92
|
+
&:has(.submenu-title) {
|
|
93
|
+
&::before {
|
|
94
|
+
content: "";
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 15px;
|
|
97
|
+
left: -8px;
|
|
98
|
+
width: 0;
|
|
99
|
+
height: 0;
|
|
100
|
+
border-top: 8px solid transparent;
|
|
101
|
+
border-bottom: 8px solid transparent;
|
|
102
|
+
border-right: 8px solid #516578;
|
|
103
|
+
z-index: 2;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.MuiPopover-root {
|
|
109
|
+
.MuiPaper-root {
|
|
110
|
+
overflow: visible;
|
|
111
|
+
position: relative;
|
|
112
|
+
width: max-content;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.MuiList-root.MuiMenu-list {
|
|
117
|
+
border-radius: 5px;
|
|
118
|
+
}
|
|
119
|
+
|
package/package.json
CHANGED
|
@@ -1,45 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cullsin/lnc-menu",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "Reusable SideMenu component for MedGenome LNC platform using MUI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
7
|
"files": [
|
|
15
8
|
"dist"
|
|
16
9
|
],
|
|
17
10
|
"scripts": {
|
|
18
|
-
"build": "
|
|
11
|
+
"build": "tsc && npm run copy-scss",
|
|
12
|
+
"copy-scss": "cpy src/sidemenu.scss dist"
|
|
19
13
|
},
|
|
20
14
|
"license": "MIT",
|
|
21
15
|
"publishConfig": {
|
|
22
16
|
"access": "public"
|
|
23
17
|
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
20
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
21
|
+
"react-router-dom": "^6.0.0",
|
|
22
|
+
"sass": "^1.0.0"
|
|
23
|
+
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@mui/icons-material": "^5.14.0",
|
|
26
26
|
"@mui/material": "^5.14.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"
|
|
30
|
-
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
31
|
-
"@rollup/plugin-typescript": "^11.1.2",
|
|
32
|
-
"rollup": "^3.0.0",
|
|
33
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
34
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
35
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
36
|
-
"sass": "^1.70.0",
|
|
37
|
-
"tslib": "^2.8.1",
|
|
29
|
+
"cpy-cli": "^5.0.0",
|
|
38
30
|
"typescript": "^5.0.0"
|
|
39
31
|
},
|
|
40
32
|
"repository": {
|
|
41
33
|
"type": "git",
|
|
42
34
|
"url": "https://github.com/cullsin/lnc-menu"
|
|
43
35
|
},
|
|
44
|
-
"author": "
|
|
36
|
+
"author": "Your Name <you@example.com>"
|
|
45
37
|
}
|
package/dist/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.MuiBox-root .MuiList-root{background:linear-gradient(180deg,#1e2f97,#0b1659)!important;bottom:0;color:#fff;height:100%;padding:20px 0}.MuiList-root.MuiMenu-list{background:linear-gradient(180deg,#586d81,#3e4f60)!important;color:#fff;overflow:visible;padding:10px;position:relative;width:175px}.MuiList-root.MuiMenu-list .submenu-title{color:#efffff;display:block;font:12px/18px OpenSans-Regular;padding:0 0 5px 10px;text-transform:uppercase}.MuiList-root.MuiMenu-list .MuiMenuItem-root.Mui-focusVisible{background-color:transparent}.MuiList-root.MuiMenu-list .MuiMenuItem-root:hover{background:#374451;border-radius:6px;font:16px/24px OpenSans-SemiBold}.MuiList-root .MuiListItem-root{padding:15px}.MuiList-root .MuiListItem-root.selected{padding:7px}.MuiList-root .MuiListItem-root.selected .MuiListItemIcon-root{background:linear-gradient(180deg,#7ad4f7,#20a9ef)!important;border-bottom-left-radius:5px;border-top-left-radius:5px;color:#1e2f97;min-width:25px;padding:10px}.MuiList-root .MuiListItem-root.selected .MuiListItemIcon-root:only-of-type{border-bottom-right-radius:5px;border-top-right-radius:5px}.MuiList-root .MuiListItem-root.selected .MuiListItemText-root span{background:linear-gradient(180deg,#7ad4f7,#20a9ef)!important;border-bottom-right-radius:5px;border-top-right-radius:5px;color:#1e2f97;min-width:25px;padding:10px 0}.MuiList-root .MuiListItem-root .MuiListItemIcon-root{color:#fff;cursor:pointer;min-width:30px}.MuiList-root .MuiListItem-root .MuiListItemText-root{margin-bottom:0;margin-top:0}.MuiList-root .MuiListItem-root .MuiListItemText-root .MuiTypography-root{color:#fff;cursor:pointer;font:14px/24px OpenSans-SemiBold;white-space:nowrap}ul.MuiList-root:has(.submenu-title):before{border-bottom:8px solid transparent;border-right:8px solid #516578;border-top:8px solid transparent;content:"";height:0;left:-8px;position:absolute;top:15px;width:0;z-index:2}.MuiPopover-root .MuiPaper-root{overflow:visible;position:relative;width:max-content}.MuiList-root.MuiMenu-list{border-radius:5px}
|