-
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
e8a9bf7
commit 9943fb9
Showing
8 changed files
with
154 additions
and
88 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.
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
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 { getLinkDisplayNameForPath } from '../../../util/approutes'; | ||
|
||
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 || getLinkDisplayNameForPath(h.location.pathname); | ||
|
||
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)} | ||
/> | ||
</> | ||
); | ||
}; |
60 changes: 60 additions & 0 deletions
60
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,60 @@ | ||
import * as React from 'react'; | ||
import { | ||
SwipeableDrawer, | ||
createStyles, | ||
makeStyles, | ||
Theme, | ||
List, | ||
Divider, | ||
ListItem, | ||
ListItemIcon, | ||
ListItemText, | ||
} from '@material-ui/core'; | ||
import InboxIcon from '@material-ui/icons/MoveToInbox'; | ||
import MailIcon from '@material-ui/icons/Mail'; | ||
import { APP_ROUTES, getLinkDisplayNameForPage, getLinkForPage } from '../../../util/approutes'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
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={getLinkForPage(route)}> | ||
<Link to={getLinkForPage(route)}> | ||
<ListItemText primary={getLinkDisplayNameForPage(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 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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import * as React from 'react'; | ||
import { RouteComponentProps } from 'react-router'; | ||
import { LinkDirectory } from './support/LinkDirectory'; | ||
import { Divider } from '@material-ui/core'; | ||
import { FeatureFlag } from 'elite-feature-flags'; | ||
import { NavigationBar } from '../general/navigation/NavigationBar'; | ||
|
||
export interface HomePageProps extends RouteComponentProps {} | ||
|
||
export const HomePage = (props: HomePageProps) => ( | ||
<> | ||
<h1>Main Page</h1> | ||
<FeatureFlag featureName="under-construction-message"> | ||
Elite Sexyz is currently under construction. See discord main channel for more information | ||
</FeatureFlag> | ||
<Divider /> | ||
<LinkDirectory /> | ||
</> | ||
); | ||
export const HomePage = (props: HomePageProps) => { | ||
return ( | ||
<> | ||
<NavigationBar /> | ||
|
||
<FeatureFlag featureName="under-construction-message"> | ||
Elite Sexyz is currently under construction. See discord main channel for more information | ||
</FeatureFlag> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,21 +1,17 @@ | ||
import { Divider, List } from '@material-ui/core'; | ||
import { List } from '@material-ui/core'; | ||
import * as React from 'react'; | ||
import { RouteComponentProps } from 'react-router'; | ||
import { LinkListItem } from '../general/LinkListItem'; | ||
import { LinkDirectory } from './support/LinkDirectory'; | ||
import { NavigationBar } from '../general/navigation/NavigationBar'; | ||
|
||
export interface LinkPageProps extends RouteComponentProps {} | ||
|
||
export const LinkPage = (props: LinkPageProps) => ( | ||
<> | ||
<h1>Useful Links List</h1> | ||
<NavigationBar /> | ||
<List> | ||
<LinkListItem href={'https://elite-se.informatik.uni-augsburg.de'} title={'Main Webpage'} /> | ||
<LinkListItem href={'https://github.com/elite-se/elite-se.protokolle'} title={'Exam Protocols'} /> | ||
</List> | ||
|
||
<Divider /> | ||
|
||
<LinkDirectory /> | ||
</> | ||
); |
13 changes: 0 additions & 13 deletions
13
packages/frontend/src/components/pages/support/LinkDirectory.tsx
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