diff options
Diffstat (limited to 'frontend/src/App.js')
| -rw-r--r-- | frontend/src/App.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/frontend/src/App.js b/frontend/src/App.js new file mode 100644 index 0000000..a8da469 --- /dev/null +++ b/frontend/src/App.js @@ -0,0 +1,58 @@ +import React from 'react'; +import NewPaste from './components/NewPaste' +import ViewPaste from './components/ViewPaste' +import styled from 'styled-components' +import { + BrowserRouter as Router, + Switch, + Route, + useParams +} from "react-router-dom"; +import Raw from './components/renderers/Raw' +import ThemeProvider from './theme/ThemeProvider' +import GlobalStyle from './theme/GlobalStyle' +import {Watermark} from "./components/Watermark"; + +const Main = styled.div` + margin-top: 10vh; + padding: 0 20vw 30px 20vw; +` + +const GetPasteWithParam = () => { + let { hash } = useParams(); + return <ViewPaste hash = {hash} />; +} + +const GetRawWithParam = () => { + let { hash } = useParams(); + return <Raw hash={hash} />; +} + +const App = () => { + return ( + <ThemeProvider> + <GlobalStyle /> + <Router> + <Switch> + <Route path="/raw/:hash"><GetRawWithParam /></Route> + <Route> + <Watermark/> + <Main id="appElement"> + <Switch> + <Route path="/:hash"> + <GetPasteWithParam /> + </Route> + <Route path="/"> + <NewPaste /> + </Route> + </Switch> + </Main> + </Route> + </Switch> + </Router> + </ThemeProvider> + ); +} + + +export default App; |