Files
5chan/src/App.js
T

93 lines
3.0 KiB
JavaScript
Raw Normal View History

2023-03-13 14:29:34 +01:00
import React, { useEffect } from 'react';
2023-01-31 23:08:57 +01:00
import { Route, Routes } from 'react-router-dom';
2023-02-01 13:30:32 +01:00
import { Helmet } from 'react-helmet-async';
2023-03-13 14:29:34 +01:00
import useBoardStore from './useBoardStore';
2023-01-31 23:08:57 +01:00
import Home from './components/Home';
import Board from './components/Board';
2023-02-12 21:20:08 +01:00
import Thread from './components/Thread';
2023-02-19 16:48:46 +01:00
import Catalog from './components/Catalog';
2023-03-06 18:38:33 +01:00
import NotFound from './components/NotFound';
2023-03-13 22:15:57 +01:00
import styled, { createGlobalStyle } from 'styled-components';
2023-02-28 16:34:33 +01:00
import 'react-tooltip/dist/react-tooltip.css';
2023-03-13 22:15:57 +01:00
import 'react-toastify/dist/ReactToastify.css';
2023-03-05 14:26:40 +01:00
import preloadImages from './utils/preloadImages';
2023-03-13 22:15:57 +01:00
import { ToastContainer } from 'react-toastify';
2023-02-08 21:49:36 +01:00
const GlobalStyle = createGlobalStyle`
2023-03-16 14:21:30 +01:00
*:focus {
outline: none;
}
2023-02-08 21:49:36 +01:00
body {
margin: 0;
padding: 0;
background: ${props => props.background};
color: ${props => props.color};
font-family: ${props => props.fontFamily};
}
2023-03-01 16:51:30 +01:00
.tooltip {
border-radius: 0;
max-width: 40%;
font-size: 11px;
padding: 3px;
opacity: 100%;
}
2023-02-08 21:49:36 +01:00
`;
2023-01-31 23:08:57 +01:00
2023-03-13 22:15:57 +01:00
const StyledContainer = styled(ToastContainer)`
.Toastify__toast {
border-radius: 0px;
font-size: 11pt;
2023-03-14 11:12:46 +01:00
animation-duration: 0s;
border: 1px solid #fee9cd;
2023-03-15 17:34:31 +01:00
color: #c5c8c6;
2023-03-13 22:15:57 +01:00
}
`;
2023-02-09 19:08:15 +01:00
2023-03-13 14:29:34 +01:00
export default function App() {
const { bodyStyle, setBodyStyle } = useBoardStore(state => state);
2023-03-05 14:26:40 +01:00
const imageUrls = Array.from({ length: 14 }, (_, index) => `/assets/banners/banner-${index + 1}.jpg`);
useEffect(() => {
preloadImages([...imageUrls]);
}, []);
2023-03-11 17:27:46 +01:00
2023-02-01 13:30:32 +01:00
return (
<div>
<Helmet>
2023-02-16 14:05:48 +01:00
<link rel="apple-touch-icon" sizes="180x180" href="/assets/logo/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/assets/logo/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/assets/logo/favicon-16x16.png" />
2023-02-01 13:30:32 +01:00
<link rel="manifest" href="/site.webmanifest" />
<meta name="msapplication-TileColor" content="#fee9cd" />
<meta name="theme-color" content="#ffffff" />
</Helmet>
2023-02-08 21:49:36 +01:00
<GlobalStyle
background={bodyStyle.background}
color={bodyStyle.color}
fontFamily={bodyStyle.fontFamily}
/>
2023-02-09 19:08:15 +01:00
<Routes>
2023-02-13 12:05:10 +01:00
<Route exact path='/' element={<Home setBodyStyle={setBodyStyle} />} />
2023-03-02 21:51:06 +01:00
<Route path={`/:subplebbitAddress`} element={<Board setBodyStyle={setBodyStyle} />}>
2023-02-19 22:08:18 +01:00
<Route path='post' element={<Board />} />
2023-03-15 15:25:09 +01:00
<Route path='settings' element={<Board />} />
2023-02-12 21:20:08 +01:00
</Route>
2023-03-02 21:51:06 +01:00
<Route path={`/:subplebbitAddress/thread/:threadCid`} element={<Thread setBodyStyle={setBodyStyle} />}>
2023-02-19 22:08:18 +01:00
<Route path='post' element={<Thread />} />
2023-03-15 15:25:09 +01:00
<Route path='settings' element={<Thread />} />
2023-02-11 22:00:13 +01:00
</Route>
2023-03-02 21:51:06 +01:00
<Route path={`/:subplebbitAddress/catalog`} element={<Catalog setBodyStyle={setBodyStyle} /> }>
2023-02-19 22:08:18 +01:00
<Route path='post' element={<Catalog />} />
2023-03-15 15:25:09 +01:00
<Route path='settings' element={<Catalog />} />
2023-02-19 16:48:46 +01:00
</Route>
2023-03-17 17:49:30 +01:00
<Route path='*' element={<NotFound setBodyStyle={setBodyStyle} />} />
2023-02-09 19:08:15 +01:00
</Routes>
2023-03-13 22:15:57 +01:00
<StyledContainer />
2023-02-01 13:30:32 +01:00
</div>
2023-03-11 17:27:46 +01:00
)}