sidebar
This commit is contained in:
parent
93b83efeb7
commit
f6c7d6db44
@ -17,16 +17,18 @@ const SidebarMenu = ({menuItems = [], children}) => {
|
||||
const elements = [];
|
||||
for (const menuItem of menuItems) {
|
||||
const { label, items: subItems = [], ...rest } = menuItem;
|
||||
|
||||
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}`;
|
||||
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>
|
||||
<div>
|
||||
{subElements && <div>
|
||||
{subElements}
|
||||
</div>
|
||||
</div>}
|
||||
</div>);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user