@cullsin/lnc-menu 6.6.0 → 6.8.0

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.
@@ -10,6 +10,7 @@ interface SideMenuProps {
10
10
  navigate: NavigateFunction;
11
11
  location: Location;
12
12
  language?: Language;
13
+ module?: 'sample' | 'patient';
13
14
  }
14
- declare function SideMenu({ useDrawer, SampleMgmtIcon, location, language }: SideMenuProps): import("react/jsx-runtime").JSX.Element;
15
+ declare function SideMenu({ useDrawer, SampleMgmtIcon, location, language, module }: SideMenuProps): import("react/jsx-runtime").JSX.Element;
15
16
  export default SideMenu;
@@ -9,7 +9,7 @@ import ListItemText from "@mui/material/ListItemText";
9
9
  import Tooltip from "@mui/material/Tooltip";
10
10
  import * as React from "react";
11
11
  import { getTranslations } from "./translations";
12
- function SideMenu({ useDrawer, SampleMgmtIcon, location, language = 'en' }) {
12
+ function SideMenu({ useDrawer, SampleMgmtIcon, location, language = 'en', module }) {
13
13
  const [selectedMainMenu, setSelectedMainMenu] = React.useState(null);
14
14
  const { isDrawerOpen } = useDrawer();
15
15
  const t = React.useMemo(() => getTranslations(language), [language]);
@@ -25,8 +25,19 @@ function SideMenu({ useDrawer, SampleMgmtIcon, location, language = 'en' }) {
25
25
  path: `/sample/${language}/sample-listing`,
26
26
  },
27
27
  ], [SampleMgmtIcon, t, language]);
28
- // Sync selection with current path using regex to extract first path segment
28
+ // Sync selection with module prop or current path
29
29
  React.useEffect(() => {
30
+ // If module prop is provided, use it to set the selection
31
+ if (module) {
32
+ if (module === 'sample') {
33
+ setSelectedMainMenu(t.menu.sampleManagement);
34
+ }
35
+ else if (module === 'patient') {
36
+ setSelectedMainMenu(t.menu.patientManagement);
37
+ }
38
+ return;
39
+ }
40
+ // Fall back to path-based detection
30
41
  const currentPath = location.pathname;
31
42
  const pathMatch = currentPath.match(/^\/([^/]+)/);
32
43
  if (pathMatch) {
@@ -44,7 +55,7 @@ function SideMenu({ useDrawer, SampleMgmtIcon, location, language = 'en' }) {
44
55
  else {
45
56
  setSelectedMainMenu(null);
46
57
  }
47
- }, [location.pathname, t.menu.sampleManagement, t.menu.patientManagement]);
58
+ }, [module, location.pathname, t.menu.sampleManagement, t.menu.patientManagement]);
48
59
  const handleMenuClick = (item) => {
49
60
  setSelectedMainMenu(item.text);
50
61
  window.location.href = item.path;
@@ -63,7 +74,6 @@ function SideMenu({ useDrawer, SampleMgmtIcon, location, language = 'en' }) {
63
74
  overflowY: "auto",
64
75
  zIndex: 100,
65
76
  },
66
- }, children: _jsx(List, { children: menuItems.map((item, index) => (_jsx(Tooltip, { title: item.text, placement: "right", disableHoverListener: isDrawerOpen, children: _jsxs(ListItem, { button: true, selected: true, className: "selected" // DEBUG: Force selected class for all items
67
- , onClick: () => handleMenuClick(item), children: [_jsx(ListItemIcon, { children: item.icon }), isDrawerOpen && _jsx(ListItemText, { primary: item.text })] }) }, index))) }) }) }));
77
+ }, children: _jsx(List, { children: menuItems.map((item, index) => (_jsx(Tooltip, { title: item.text, placement: "right", disableHoverListener: isDrawerOpen, children: _jsxs(ListItem, { button: true, className: isDrawerOpen ? "menu-open" : "menu-closed", onClick: () => handleMenuClick(item), children: [_jsx(ListItemIcon, { children: item.icon }), isDrawerOpen && _jsx(ListItemText, { primary: item.text })] }) }, index))) }) }) }));
68
78
  }
69
79
  export default SideMenu;
@@ -18,14 +18,33 @@
18
18
  .MuiList-root {
19
19
  .MuiListItem-root {
20
20
  // Apply capsule layout with gradient permanently for testing
21
- padding: 10px 15px;
22
- margin: 4px 12px;
23
- border-radius: 20px;
21
+ padding: 8px 12px;
22
+ margin: 12px 6px 0px 6px;
23
+ border-radius: 15px;
24
24
  display: flex;
25
25
  align-items: center;
26
26
  justify-content: center;
27
27
  background: linear-gradient(to bottom, #7ad4f7, #20a9ef) !important;
28
28
 
29
+ // Width based on menu open/closed state
30
+ &.menu-closed {
31
+ width: 52px;
32
+ }
33
+
34
+ &.menu-open {
35
+ width: 218px;
36
+ }
37
+
38
+ // Hover design - override the default background on hover
39
+ &:hover {
40
+ background: linear-gradient(to bottom, #7ad4f7, #20a9ef) !important;
41
+ }
42
+
43
+ // Default state (not hovered) - transparent background
44
+ &:not(:hover) {
45
+ background: transparent !important;
46
+ }
47
+
29
48
  // Normalize all icons (MUI icons and custom SVGs)
30
49
  .MuiListItemIcon-root {
31
50
  color: #1e2f97;
@@ -47,6 +66,15 @@
47
66
  }
48
67
  }
49
68
 
69
+ // Icon color changes on hover
70
+ &:not(:hover) .MuiListItemIcon-root {
71
+ svg,
72
+ .MuiSvgIcon-root {
73
+ fill: #fff;
74
+ color: #fff;
75
+ }
76
+ }
77
+
50
78
  // Add margin-right to icon only when text is visible
51
79
  .MuiListItemIcon-root + .MuiListItemText-root {
52
80
  margin-left: 8px;
@@ -62,6 +90,11 @@
62
90
  white-space: nowrap;
63
91
  }
64
92
  }
93
+
94
+ // Text color changes on hover
95
+ &:not(:hover) .MuiListItemText-root .MuiTypography-root {
96
+ color: #fff;
97
+ }
65
98
  }
66
99
  }
67
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cullsin/lnc-menu",
3
- "version": "6.6.0",
3
+ "version": "6.8.0",
4
4
  "description": "Reusable SideMenu component for MedGenome LNC platform using MUI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",