diff --git a/packages/frontend/src/components/App.tsx b/packages/frontend/src/components/App.tsx index 6f3b327..7a1d8e5 100644 --- a/packages/frontend/src/components/App.tsx +++ b/packages/frontend/src/components/App.tsx @@ -7,7 +7,7 @@ import history from '../util/history'; import { FeatureFlagsProvider } from 'elite-feature-flags'; import { Configuration } from 'elite-types'; import { getConfiguration } from 'elite-configuration'; -import { NavigationBar } from './general/NavigationBar'; +import { NavigationBar } from './general/navigation/NavigationBar'; const configuration: Configuration = getConfiguration(); @@ -16,10 +16,7 @@ export const AppComponent = () => ( {APP_ROUTES.map((routeProps, index) => ( - <> - - - + ))} } /> diff --git a/packages/frontend/src/components/general/NavigationBar.tsx b/packages/frontend/src/components/general/NavigationBar.tsx deleted file mode 100644 index 5cad539..0000000 --- a/packages/frontend/src/components/general/NavigationBar.tsx +++ /dev/null @@ -1,51 +0,0 @@ -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'; - -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(); - - return ( -
- - - - - - - {props.title} - - - - -
- ); -}; diff --git a/packages/frontend/src/components/general/navigation/NavigationBar.tsx b/packages/frontend/src/components/general/navigation/NavigationBar.tsx new file mode 100644 index 0000000..a182352 --- /dev/null +++ b/packages/frontend/src/components/general/navigation/NavigationBar.tsx @@ -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 ( + <> +
+ + + setRouteDrawerOpen(true)} + > + + + + {title} + + + + +
+ + setRouteDrawerOpen(true)} + onClose={() => setRouteDrawerOpen(false)} + /> + + ); +}; diff --git a/packages/frontend/src/components/general/navigation/RouteDrawer.tsx b/packages/frontend/src/components/general/navigation/RouteDrawer.tsx new file mode 100644 index 0000000..7ae6303 --- /dev/null +++ b/packages/frontend/src/components/general/navigation/RouteDrawer.tsx @@ -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 ( + +
+ + {APP_ROUTES.map(route => ( + + + + + + ))} + + {/** TODO: bellow is testing code */} + {/* + {['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => ( + + {index % 2 === 0 ? : } + + + ))} */} +
+
+ ); +}; diff --git a/packages/frontend/src/components/pages/HomePage.tsx b/packages/frontend/src/components/pages/HomePage.tsx index f3e3656..7ae43ba 100644 --- a/packages/frontend/src/components/pages/HomePage.tsx +++ b/packages/frontend/src/components/pages/HomePage.tsx @@ -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) => ( - <> -

Main Page

- - Elite Sexyz is currently under construction. See discord main channel for more information - - - - -); +export const HomePage = (props: HomePageProps) => { + return ( + <> + + + + Elite Sexyz is currently under construction. See discord main channel for more information + + + ); +}; diff --git a/packages/frontend/src/components/pages/LinkPage.tsx b/packages/frontend/src/components/pages/LinkPage.tsx index ef63230..68da9fa 100644 --- a/packages/frontend/src/components/pages/LinkPage.tsx +++ b/packages/frontend/src/components/pages/LinkPage.tsx @@ -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) => ( <> -

Useful Links List

+ - - - - ); diff --git a/packages/frontend/src/components/pages/support/LinkDirectory.tsx b/packages/frontend/src/components/pages/support/LinkDirectory.tsx deleted file mode 100644 index b896837..0000000 --- a/packages/frontend/src/components/pages/support/LinkDirectory.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as React from 'react'; -import { Link } from 'react-router-dom'; -import { APP_ROUTES, getLinkDisplayNameForPage, getLinkForPage } from '../../../util/approutes'; - -export const LinkDirectory = () => ( -
    - {APP_ROUTES.map((route, index) => ( -
  • - {getLinkDisplayNameForPage(route)} -
  • - ))} -
-); diff --git a/packages/frontend/src/util/approutes.tsx b/packages/frontend/src/util/approutes.tsx index 3cf3c87..5a76294 100644 --- a/packages/frontend/src/util/approutes.tsx +++ b/packages/frontend/src/util/approutes.tsx @@ -38,6 +38,13 @@ export function getLinkDisplayNameForPage(route: AppRouteProps): string { return route.linkDisplayName || getLinkForPage(route); } +// TODO: remove this and replace with function from routing-decorator branch +export function getLinkDisplayNameForPath(path: string): string { + const route = APP_ROUTES.find(route => route.path == path); + if (!route) return 'ERROR'; + return getLinkDisplayNameForPage(route); +} + /** * Specify all pages in this file by defining * a pages route props and adding it to the