1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02:00

feat: support internal routes

This commit is contained in:
Ivar Conradi Østhus 2020-05-12 20:41:03 +02:00
parent eefc0cf44c
commit ae8fd61ea4

View File

@ -14,6 +14,33 @@ function getIcon(name) {
} }
} }
function renderLink(link) {
if (link.path) {
return (
<NavLink
key={link.path}
to={link.path}
className={[styles.navigationLink, 'mdl-color-text--grey-900'].join(' ')}
activeClassName={[styles.navigationLink, 'mdl-color-text--black', 'mdl-color--blue-grey-100'].join(' ')}
>
{getIcon(link.icon)} {link.value}
</NavLink>
);
} else {
return (
<a
href={link.href}
key={link.href}
target="_blank"
className={[styles.navigationLink, 'mdl-color-text--grey-900'].join(' ')}
title={link.title}
>
{getIcon(link.icon)} {link.value}
</a>
);
}
}
export const DrawerMenu = ({ links = [] }) => ( export const DrawerMenu = ({ links = [] }) => (
<Drawer className="mdl-color--white"> <Drawer className="mdl-color--white">
<span className={[styles.drawerTitle, 'mdl-layout-title'].join(' ')}> <span className={[styles.drawerTitle, 'mdl-layout-title'].join(' ')}>
@ -36,19 +63,7 @@ export const DrawerMenu = ({ links = [] }) => (
))} ))}
</Navigation> </Navigation>
<hr /> <hr />
<Navigation className={styles.navigation}> <Navigation className={styles.navigation}>{links.map(renderLink)}</Navigation>
{links.map(link => (
<a
href={link.href}
key={link.href}
target="_blank"
className={[styles.navigationLink, 'mdl-color-text--grey-900'].join(' ')}
title={link.title}
>
{getIcon(link.icon)} {link.value}
</a>
))}
</Navigation>
</Drawer> </Drawer>
); );