diff --git a/src/core/components/Header.tsx b/src/core/components/Header.tsx index 11ab0b6937a7686ab6ed43ab54b8bf72f824ca90..fef7cc09770da760fa21d9477d1a207269712d44 100644 --- a/src/core/components/Header.tsx +++ b/src/core/components/Header.tsx @@ -1,5 +1,105 @@ -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; diff --git a/src/core/components/MainRouting.tsx b/src/core/components/MainRouting.tsx index a0d9961a47602cc02116b78fc21e066d50e60b21..10d1ee86a868ff0ed9ef2e06119013b0366cd61e 100644 --- a/src/core/components/MainRouting.tsx +++ b/src/core/components/MainRouting.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Route, Switch } from 'react-router'; import { ProfileButton } from './ProfileButton'; -const Main = () => ( +const MainRouting: React.FC = () => ( <Switch> <Route path="/" exact> <ProfileButton /> @@ -11,4 +11,4 @@ const Main = () => ( </Switch> ); -export default Main; +export default MainRouting; diff --git a/src/index.css b/src/index.css index a58f3f11c4eaa26a84ec74c55006b5bb0c0c5c35..65137f8e0fbdd391412f19afdcaf81fe8ac5375b 100644 --- a/src/index.css +++ b/src/index.css @@ -1,6 +1,7 @@ html, body, #root { + margin: 0; height: 100%; margin: 0; }