Added: 'hide' unnecessary navbar items

This commit is contained in:
Llewellyn D'souza
2022-02-02 12:45:35 +05:30
parent d2c2472e29
commit 5e52c90299
2 changed files with 15 additions and 4 deletions

View File

@@ -60,7 +60,6 @@ function Sidenav({ color, brandName, routes, ...rest }) {
const itemParentName = items[1]; const itemParentName = items[1];
const itemName = items[items.length - 1]; const itemName = items[items.length - 1];
let textColor = 'white'; let textColor = 'white';
if (transparentSidenav || (whiteSidenav && !darkMode)) { if (transparentSidenav || (whiteSidenav && !darkMode)) {
@@ -120,9 +119,11 @@ function Sidenav({ color, brandName, routes, ...rest }) {
}; };
// Render the all the collpases from the routes.js // Render the all the collpases from the routes.js
const renderCollapse = (collapses) => const renderCollapse = (collapses) =>
collapses.map(({ name, collapse, route, href, key }) => { collapses.map(({ name, collapse, route, href, key, hide }) => {
let returnValue; let returnValue;
if (hide) return null;
if (collapse) { if (collapse) {
returnValue = ( returnValue = (
<SidenavItem <SidenavItem
@@ -162,9 +163,11 @@ function Sidenav({ color, brandName, routes, ...rest }) {
// Render all the routes from the routes.js (All the visible items on the Sidenav) // Render all the routes from the routes.js (All the visible items on the Sidenav)
const renderRoutes = routes.map( const renderRoutes = routes.map(
({ type, name, icon, title, collapse, noCollapse, key, href }) => { ({ type, name, icon, title, collapse, noCollapse, key, href, hide }) => {
let returnValue; let returnValue;
if (hide) return null;
if (type === 'collapse') { if (type === 'collapse') {
returnValue = href ? ( returnValue = href ? (
<Link <Link
@@ -251,7 +254,13 @@ function Sidenav({ color, brandName, routes, ...rest }) {
width={!brandName && '100%'} width={!brandName && '100%'}
sx={(theme) => sidenavLogoLabel(theme, { miniSidenav })} sx={(theme) => sidenavLogoLabel(theme, { miniSidenav })}
> >
<MDTypography fontSize="2rem" component="h1" variant="button" fontWeight="bold" color={textColor}> <MDTypography
fontSize="2rem"
component="h1"
variant="button"
fontWeight="bold"
color={textColor}
>
{brandName} {brandName}
</MDTypography> </MDTypography>
</MDBox> </MDBox>

View File

@@ -99,12 +99,14 @@ const protectedRoutes = [
type: 'collapse', type: 'collapse',
name: 'Test', name: 'Test',
key: 'Test', key: 'Test',
hide: true,
icon: <Icon fontSize="medium">dashboard</Icon>, icon: <Icon fontSize="medium">dashboard</Icon>,
collapse: [ collapse: [
{ {
name: 'Dashboard', name: 'Dashboard',
key: 'dashboard', key: 'dashboard',
route: '/dashboard', route: '/dashboard',
hide: true,
component: <DashboardScreen /> component: <DashboardScreen />
} }
] ]