diff options
author | Eugene <eug-vs@keemail.me> | 2020-01-02 10:39:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 10:39:08 +0000 |
commit | 7b8dd0a9a222323d52cb22e93518430c793353f5 (patch) | |
tree | eb73c125f30e86b87824756ba68dcc5451d16564 | |
parent | 800992d6322897acb5829ee40728bc5adee455e5 (diff) | |
parent | 3524a41fc77b5fa3e6708cb3067d269d9fe62999 (diff) | |
download | chrono-cube-ui-7b8dd0a9a222323d52cb22e93518430c793353f5.tar.gz |
Merge pull request #9 from Eug-VS/header
Implement Header functionality
-rw-r--r-- | src/components/Header.js | 15 | ||||
-rw-r--r-- | src/components/Header/Header.js | 42 | ||||
-rw-r--r-- | src/index.js | 30 |
3 files changed, 62 insertions, 25 deletions
diff --git a/src/components/Header.js b/src/components/Header.js deleted file mode 100644 index 47da527..0000000 --- a/src/components/Header.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; - -const Header = () => ( - <div> - <span> ChronoCube </span> - <ul> - <li> Home </li> - <li> App </li> - <li> Scoreboard </li> - <li> News </li> - </ul> - </div> -); - -export default Header; diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js new file mode 100644 index 0000000..9bfe5c4 --- /dev/null +++ b/src/components/Header/Header.js @@ -0,0 +1,42 @@ +import React from "react"; +import { + AppBar, + Tabs, + Tab, + Typography +} from "@material-ui/core"; +import styled from 'styled-components'; + +const Header = ({ setPage }) => { + + const handleChange = (event, newPage) => { + setPage(newPage); + }; + + return ( + <AppBar position="static"> + <TabsWrapper onChange={handleChange}> + <Typography variant="h4" id="logo"> ChronoCube </Typography> + <Tab label="App" value="app"/> + <Tab label="Profile" value="profile"/> + <Tab label="Scoreboard" value="scoreboard"/> + <Tab label="News" value="news"/> + </TabsWrapper> + </AppBar> + ); +}; + +const TabsWrapper = styled(Tabs)` + border-bottom: 1px solid black; + & .MuiTab-wrapper { + padding: 10px; + } + & .MuiTypography-root { + font-weight: bold; + padding: 10px; + margin-right: 50px; + margin-left: 30px; + } +`; + +export default Header; diff --git a/src/index.js b/src/index.js index 512d416..5c657f9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,22 +1,32 @@ -import React from 'react'; +import React, { useState } from 'react'; import ReactDOM from 'react-dom'; import styled from 'styled-components'; import CssBaseline from '@material-ui/core/CssBaseline' -import Header from "./components/Header"; +import Header from './components/Header/Header'; -const App = () => ( - <Root> - <CssBaseline/> - <Header/> - <p> Page content here </p> - </Root> -); +const App = () => { + + const [page, setPage] = useState('app'); + + return ( + <Root> + <CssBaseline/> + <Header setPage={setPage} /> + <h1> This is the {page} page! </h1> + <p> + This text is rendered outside of <code>Header</code> component, but + interacting with <code>Header</code> can influence content of this page! + </p> + </Root> + ); +}; const Root = styled.div` - background: lightgrey; + background: cornsilk; + padding-bottom: 25px; `; |