Skip to content
Snippets Groups Projects
Commit c6f6df0e authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

Merge branch 'add-header' into Feature/profile

parents fd9957ad 78125397
No related branches found
No related tags found
2 merge requests!7update master to dev,!4Feature/profile
import React from 'react'; import {
AppBar,
Button,
Grid,
makeStyles,
Tab,
Tabs,
Toolbar,
Typography,
} from '@material-ui/core';
import React, { useState } from 'react';
import { useHistory } from 'react-router';
const Header = () => <div>Header</div>; interface AppBarMenuItem {
id: number;
title: string;
redirectTo: string;
}
const MENU_ITEMS: AppBarMenuItem[] = [
{
id: 0,
title: 'News',
redirectTo: '/news',
},
{
id: 1,
title: 'About',
redirectTo: '/about',
},
{
id: 2,
title: 'FAQ',
redirectTo: '/faq',
},
];
const useStyles = makeStyles((theme) => ({
appBar: {
backgroundColor: '#E5BD2F',
padding: theme.spacing(1),
},
tab: {
fontWeight: 600,
padding: '0px',
},
indicator: {
backgroundColor: 'white',
},
navItem: {
flex: 1,
alignItems: 'center',
'&:first-child': {
marginRight: 'auto;',
},
'&:last-child': {
marginRight: 'auto;',
},
},
}));
const Header: React.FC = () => {
const classes = useStyles();
const history = useHistory();
const [value, setValue] = useState(
MENU_ITEMS.find((item) => history.location.pathname === item.redirectTo)?.id ?? 0,
);
return (
<AppBar className={classes.appBar} position="static">
<Toolbar>
<Grid container>
<Grid className={classes.navItem} item container justify="flex-start">
<Tabs
value={value}
onChange={(event, val) => {
setValue(val);
}}
TabIndicatorProps={{ className: classes.indicator }}
>
{MENU_ITEMS.map((item) => (
<Tab
key={item.id}
className={classes.tab}
label={item.title}
onClick={() => {
history.push(item.redirectTo);
}}
/>
))}
</Tabs>
</Grid>
<Grid className={classes.navItem} item container justify="center">
<Typography variant="h4">SCH-BODY</Typography>
</Grid>
<Grid className={classes.navItem} item container justify="flex-end">
<Button>Login</Button>
</Grid>
</Grid>
</Toolbar>
</AppBar>
);
};
export default Header; export default Header;
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { Route, Switch } from 'react-router'; import { Route, Switch } from 'react-router';
import { ProfileButton } from './ProfileButton'; import { ProfileButton } from './ProfileButton';
const Main = () => ( const MainRouting: React.FC = () => (
<Switch> <Switch>
<Route path="/" exact> <Route path="/" exact>
<ProfileButton /> <ProfileButton />
...@@ -11,4 +11,4 @@ const Main = () => ( ...@@ -11,4 +11,4 @@ const Main = () => (
</Switch> </Switch>
); );
export default Main; export default MainRouting;
html, html,
body, body,
#root { #root {
margin: 0;
height: 100%; height: 100%;
margin: 0; margin: 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment