aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/App.js
blob: 3b147dbbc7b2c7c2e9efed2ab1e3b81e4d72b1bc (plain) (blame)
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
58
59
60
61
62
63
import React from 'react';
import NewPaste from './NewPaste'
import ViewPaste from './ViewPaste'
import Footer from './Footer'
import styled from 'styled-components'
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link,
  useParams
} from "react-router-dom";

const SpacedTitle = styled.div`
    margin-top: 10vh
`

const Desc = () => {
  return (
    <h3>a modern, <a href="https://github.com/jackyzha0/ctrl-v" target="_blank" rel="noopener noreferrer">open-source</a> pastebin with latex and markdown rendering support</h3>
  );
}

const GetPasteWithParam = () => {
  let { hash } = useParams();

  return (
    <ViewPaste hash = {hash} />
  );
}

function App() {
  return (
    <Router>
      <div className="lt-content-column">
        <SpacedTitle>
          <nav>
            <h1 className="mainLogo">
              <span role="img" aria-label="clipboard">📋&nbsp;</span>
              <Link to="/">ctrl-v</Link>
            </h1>
            <Desc />
          </nav>
        </SpacedTitle>

        <main id="appElement">
          <Switch>
            <Route path="/:hash" 
              children={<GetPasteWithParam />} 
            />
            <Route path="/">
              <NewPaste />
            </Route>
          </Switch>
        </main>

        <Footer />
      </div>
    </Router>
  );
}

export default App;