-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement swipeable bottom drawer for APP_ROUTES #10
- Loading branch information
1 parent
b1fa0df
commit c9ed65f
Showing
7 changed files
with
134 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
packages/frontend/src/components/general/NavigationBar.tsx
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
packages/frontend/src/components/general/navigation/NavigationBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from 'react'; | ||
import { | ||
AppBar, | ||
Toolbar, | ||
makeStyles, | ||
fade, | ||
IconButton, | ||
Theme, | ||
createStyles, | ||
Typography, | ||
Button, | ||
} from '@material-ui/core'; | ||
import MenuIcon from '@material-ui/icons/Menu'; | ||
import { RouteDrawer } from './RouteDrawer'; | ||
import h from '../../../util/history'; | ||
import { getLinkForPath } from 'util/routes'; | ||
import { AppPath } from 'elite-types'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
flexGrow: 1, | ||
}, | ||
menuButton: { | ||
marginRight: theme.spacing(2), | ||
}, | ||
title: { | ||
flexGrow: 1, | ||
}, | ||
}), | ||
); | ||
|
||
export interface NavigationBarProps { | ||
readonly title?: string; | ||
} | ||
|
||
export const NavigationBar = (props: NavigationBarProps) => { | ||
const classes = useStyles(); | ||
const [routeDrawerOpen, setRouteDrawerOpen] = React.useState(false); | ||
const title = props.title || getLinkForPath(h.location.pathname as AppPath); | ||
|
||
return ( | ||
<> | ||
<div className={classes.root}> | ||
<AppBar position={'static'}> | ||
<Toolbar> | ||
<IconButton | ||
edge={'start'} | ||
className={classes.menuButton} | ||
color={'inherit'} | ||
aria-label={'open drawer'} | ||
onClick={() => setRouteDrawerOpen(true)} | ||
> | ||
<MenuIcon /> | ||
</IconButton> | ||
<Typography className={classes.title} variant={'h6'} noWrap> | ||
{title} | ||
</Typography> | ||
<Button color={'inherit'}>Login</Button> | ||
</Toolbar> | ||
</AppBar> | ||
</div> | ||
|
||
<RouteDrawer | ||
isOpen={routeDrawerOpen} | ||
onOpen={() => setRouteDrawerOpen(true)} | ||
onClose={() => setRouteDrawerOpen(false)} | ||
/> | ||
</> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
packages/frontend/src/components/general/navigation/RouteDrawer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { createStyles, List, ListItem, ListItemText, makeStyles, SwipeableDrawer, Theme } from '@material-ui/core'; | ||
import * as React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { APP_ROUTES, getLinkForRoute, getDisplayNameForRoute } from 'util/routes'; | ||
|
||
export interface RouteDrawerProps { | ||
readonly isOpen: boolean; | ||
readonly onOpen: () => void; | ||
readonly onClose: () => void; | ||
} | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
list: { | ||
width: 250, | ||
}, | ||
fullList: { | ||
width: 'auto', | ||
}, | ||
}), | ||
); | ||
|
||
export const RouteDrawer = (props: RouteDrawerProps) => { | ||
const classes = useStyles(); | ||
return ( | ||
<SwipeableDrawer anchor={'bottom'} open={props.isOpen} onClose={props.onClose} onOpen={props.onOpen}> | ||
<div className={classes.fullList} role={'presentation'} onClick={props.onClose} onKeyDown={props.onClose}> | ||
<List> | ||
{APP_ROUTES.map(route => ( | ||
<ListItem button={true} key={getLinkForRoute(route)}> | ||
<Link to={getLinkForRoute(route)}> | ||
<ListItemText primary={getDisplayNameForRoute(route)} /> | ||
</Link> | ||
</ListItem> | ||
))} | ||
</List> | ||
{/** TODO: bellow is testing code */} | ||
{/* <Divider /> | ||
{['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => ( | ||
<ListItem button={true} key={text}> | ||
<ListItemIcon>{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}</ListItemIcon> | ||
<ListItemText primary={text} /> | ||
</ListItem> | ||
))} */} | ||
</div> | ||
</SwipeableDrawer> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters