Skip to content

Commit

Permalink
add icons to APP_ROUTES #10
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikHorn committed Feb 27, 2020
1 parent 9943fb9 commit 58601f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const RouteDrawer = (props: RouteDrawerProps) => {
<List>
{APP_ROUTES.map(route => (
<ListItem button={true} key={getLinkForPage(route)}>
{route.icon && <ListItemIcon>{route.icon}</ListItemIcon>}
<Link to={getLinkForPage(route)}>
<ListItemText primary={getLinkDisplayNameForPage(route)} />
</Link>
Expand Down
10 changes: 8 additions & 2 deletions packages/frontend/src/util/approutes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as H from 'history';
import HomeIcon from '@material-ui/icons/Home';
import LinkIcon from '@material-ui/icons/Link';
import * as React from 'react';
import { RouteProps, Redirect } from 'react-router';
import { RouteProps } from 'react-router';
import { HomePage } from '../components/pages/HomePage';
import { LinkPage } from '../components/pages/LinkPage';

Expand All @@ -15,6 +16,9 @@ export interface AppRouteProps extends RouteProps {
// link text (Human readable!)
readonly linkDisplayName?: string;

// optional icon displayed next to the link name
readonly icon?: JSX.Element;

// AppRoutes must have a path - deoptionalize this property
readonly path: string;
}
Expand Down Expand Up @@ -55,13 +59,15 @@ export function getLinkDisplayNameForPath(path: string): string {
export const HOME_PAGE: AppRouteProps = {
path: '/home',
linkDisplayName: 'Home',
icon: <HomeIcon />,
render: props => <HomePage {...props} />,
};

// Page with searchable, useful links for elite-se-degree program
export const LINK_PAGE: AppRouteProps = {
path: '/links',
linkDisplayName: 'Useful Links',
icon: <LinkIcon />,
render: props => <LinkPage {...props} />,
};

Expand Down

0 comments on commit 58601f5

Please sign in to comment.