sidebar
This commit is contained in:
parent
93b83efeb7
commit
f6c7d6db44
@ -17,16 +17,18 @@ const SidebarMenu = ({menuItems = [], children}) => {
|
|||||||
const elements = [];
|
const elements = [];
|
||||||
for (const menuItem of menuItems) {
|
for (const menuItem of menuItems) {
|
||||||
const { label, items: subItems = [], ...rest } = menuItem;
|
const { label, items: subItems = [], ...rest } = menuItem;
|
||||||
|
|
||||||
let subElements = null;
|
let subElements = null;
|
||||||
if (subItems.length) subElements = subItems.map(({ label, to, relative }) => {
|
if (subItems.length) subElements = subItems.map(({ label, to, relative = true }) => {
|
||||||
if(relative) to = `${menuItem.to}${to}`;
|
if(relative) to = `${menuItem.to}${to}`;
|
||||||
return <NavLink className='sidebar-menu-child-item' activeClassName='active' to={to} key={label}>{label}</NavLink>;
|
return <NavLink className='sidebar-menu-child-item' activeClassName='active' to={to} key={label}>{label}</NavLink>;
|
||||||
});
|
});
|
||||||
elements.push(<div key={label} className='parent-menu'>
|
|
||||||
|
elements.push(<div key={label} className={`parent-menu ${subElements ? 'has-children' : ''}`}>
|
||||||
<NavLink className='sidebar-menu-item' activeClassName='active' {...rest} key={label}>{label}</NavLink>
|
<NavLink className='sidebar-menu-item' activeClassName='active' {...rest} key={label}>{label}</NavLink>
|
||||||
<div>
|
{subElements && <div>
|
||||||
{subElements}
|
{subElements}
|
||||||
</div>
|
</div>}
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user