blob: f28a220ed3c6bfe3fdc282c7ae8a9ca75f1ddbd5 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
|
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,
useParams
} from "react-router-dom";
import Raw from './renderers/Raw'
const Logo = styled.div`
position: absolute;
bottom: 1.5em;
left: 2em;
opacity: 0.3;
& h1 {
font-size: 3rem;
}
`
const Main = styled.main`
margin-top: 10vh;
`
const GetPasteWithParam = () => {
let { hash } = useParams();
return <ViewPaste hash = {hash} />;
}
const GetRawWithParam = () => {
let { hash } = useParams();
return <Raw hash={hash} />;
}
const App = () => {
return (
<Router>
<Switch>
<Route path="/raw/:hash"
children={<GetRawWithParam />}
/>
<Route>
<div className="lt-content-column">
<Logo>
<nav>
<h1 className="mainLogo">
<a href="https://github.com/jackyzha0/ctrl-v">ctrl-v</a>
</h1>
</nav>
</Logo>
<Main id="appElement">
<Switch>
<Route path="/:hash"
children={<GetPasteWithParam />}
/>
<Route path="/">
<NewPaste />
</Route>
</Switch>
</Main>
<Footer />
</div>
</Route>
</Switch>
</Router>
);
}
export default App;
|