2023-03-05 14:26:40 +01:00
|
|
|
import React, { useState, 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-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-02-08 21:49:36 +01:00
|
|
|
import { createGlobalStyle } from 'styled-components';
|
2023-02-28 16:34:33 +01:00
|
|
|
import 'react-tooltip/dist/react-tooltip.css';
|
2023-03-05 14:26:40 +01:00
|
|
|
import preloadImages from './utils/preloadImages';
|
2023-02-08 21:49:36 +01:00
|
|
|
|
2023-02-09 19:08:15 +01:00
|
|
|
export const BoardContext = React.createContext();
|
2023-02-08 21:49:36 +01:00
|
|
|
|
|
|
|
|
const GlobalStyle = createGlobalStyle`
|
|
|
|
|
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-02-09 19:08:15 +01:00
|
|
|
export default function App() {
|
2023-02-08 21:49:36 +01:00
|
|
|
const [bodyStyle, setBodyStyle] = useState({
|
2023-02-16 14:05:48 +01:00
|
|
|
background: "#ffe url(/assets/fade.png) top repeat-x",
|
2023-02-08 21:49:36 +01:00
|
|
|
color: "maroon",
|
|
|
|
|
fontFamily: "Helvetica, Arial, sans-serif"
|
|
|
|
|
});
|
|
|
|
|
|
2023-02-09 19:08:15 +01:00
|
|
|
const [selectedTitle, setSelectedTitle] = useState('');
|
|
|
|
|
const [selectedAddress, setSelectedAddress] = useState('');
|
2023-02-20 22:17:04 +01:00
|
|
|
const [selectedThread, setSelectedThread] = useState('');
|
2023-02-13 12:05:10 +01:00
|
|
|
const [selectedStyle, setSelectedStyle] = useState('Yotsuba');
|
2023-02-09 19:08:15 +01:00
|
|
|
|
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-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-20 22:17:04 +01:00
|
|
|
<BoardContext.Provider value={{ selectedTitle, setSelectedTitle, selectedAddress, setSelectedAddress, selectedThread, setSelectedThread, selectedStyle, setSelectedStyle }}>
|
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-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-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-02-19 16:48:46 +01:00
|
|
|
</Route>
|
2023-02-09 19:08:15 +01:00
|
|
|
</Routes>
|
|
|
|
|
</BoardContext.Provider>
|
2023-02-01 13:30:32 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|