generated from bcgov/EPIC.scaffold
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from bcgov/feature/menu-hover
Show menu drawer on app menu hover when its on collapsed state
- Loading branch information
Showing
6 changed files
with
73 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 50 additions & 29 deletions
79
compliance-web/src/components/Shared/SideNav/MenuItemIconsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,62 @@ | ||
import { theme } from "@/styles/theme"; | ||
import { ListItem, Box, List } from "@mui/material"; | ||
import { Fragment } from "react/jsx-runtime"; | ||
import { ListItem, Box, List, Drawer } from "@mui/material"; | ||
import RouteItemsList, { RouteMenuItem } from "./RouteItemsList"; | ||
import { useMenuStore } from "@/store/menuStore"; | ||
import MenuItemsList from "./MenuItemsList"; | ||
import { useState } from "react"; | ||
import { APP_SIDE_NAV_WIDTH } from "@/utils/constants"; | ||
|
||
export default function MenuItemIconsList() { | ||
const routeMenuItems: RouteMenuItem[] = RouteItemsList(); | ||
|
||
const { toggleMenu } = useMenuStore(); | ||
const { appHeaderHeight } = useMenuStore(); | ||
|
||
const [hoverMenu, setHoverMenu] = useState<boolean>(false); | ||
|
||
const renderMenuIcons = () => { | ||
return routeMenuItems.map((route) => { | ||
return ( | ||
<Fragment key={route.routeName}> | ||
<ListItem | ||
key={route.routeName} | ||
onClick={() => toggleMenu(route.routeName)} | ||
disablePadding | ||
sx={{ cursor: "pointer" }} | ||
> | ||
<Box | ||
sx={{ | ||
color: theme.palette.common.white, | ||
width: "100%", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
padding: "1rem", | ||
}} | ||
> | ||
{route.icon ?? route.icon} | ||
</Box> | ||
</ListItem> | ||
</Fragment> | ||
); | ||
}); | ||
return routeMenuItems.map((route) => ( | ||
<ListItem | ||
key={route.routeName} | ||
onMouseEnter={() => setHoverMenu(true)} | ||
disablePadding | ||
sx={{ cursor: "pointer" }} | ||
> | ||
<Box | ||
sx={{ | ||
color: theme.palette.common.white, | ||
width: "100%", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
padding: "1rem", | ||
}} | ||
> | ||
{route.icon ?? route.icon} | ||
</Box> | ||
</ListItem> | ||
)); | ||
}; | ||
|
||
return <List>{renderMenuIcons()}</List>; | ||
return ( | ||
<> | ||
<List>{renderMenuIcons()}</List> | ||
<Drawer | ||
open={hoverMenu} | ||
variant="persistent" | ||
onMouseLeave={() => setHoverMenu(false)} | ||
sx={{ | ||
flexShrink: 0, | ||
[`& .MuiDrawer-paper`]: { | ||
width: APP_SIDE_NAV_WIDTH, | ||
boxSizing: "border-box", | ||
background: theme.palette.primary.main, | ||
height: `calc(100vh - ${appHeaderHeight}px)`, | ||
top: appHeaderHeight, | ||
}, | ||
}} | ||
> | ||
<MenuItemsList /> | ||
</Drawer> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
// App Constants should go here | ||
|
||
export const APP_SIDE_NAV_WIDTH = 260; | ||
export const APP_SIDE_NAV_WIDTH_COLLAPSED = 68; |