aboutsummaryrefslogtreecommitdiff
path: root/src/index.js
blob: 725d270299baa64b2bb26c3b0261813575abac23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState } from 'react';
import ReactDOM from 'react-dom';

import {
  Typography,
  Paper,
  Container,
} from "@material-ui/core";

import styled from 'styled-components';
import CssBaseline from '@material-ui/core/CssBaseline'

import Header from './components/Header/Header';
import Timer from './components/Timer/Timer';
import Scoreboard from "./components/Scoreboard/Scoreboard";


const App = () => {

  const [page, setPage] = useState('app');

  const getPageComponent = page => {
    switch (page) {
      case 'app':
        return (<Timer/>);
      case 'scoreboard':
        return (<Scoreboard/>);
      default:
        return (
          <p>
            This text is rendered outside of <code>Header</code> component, but
            interacting with <code>Header</code> can influence content of this page!
          </p>
        )
    }
  };

  return (
    <Root>
      <CssBaseline/>
      <Header setPage={setPage} />
      <Container maxWidth="xl">
        <Paper elevation={4} style={{backgroundColor: "bisque"}}>
          <Typography variant="h4"> This is the {page} page! </Typography>
          { getPageComponent(page) }
        </Paper>
      </Container>
    </Root>
);
};
const Root = styled.div`
  background: cornsilk;
  padding-bottom: 25px;
`;


ReactDOM.render(<App />, document.getElementById('root'));