Files
5chan/src/app.tsx
T

30 lines
895 B
TypeScript

import { useEffect } from 'react';
import { Route, Routes, useLocation } from 'react-router-dom';
import Home from './views/home';
import styles from './app.module.css';
import useTheme from './hooks/use-theme';
import Subplebbit from './views/subplebbit';
import { isHomeView } from './lib/utils/view-utils';
const App = () => {
const [theme] = useTheme();
const location = useLocation();
const isInHomeView = isHomeView(location.pathname);
useEffect(() => {
document.body.classList.forEach((className) => document.body.classList.remove(className));
document.body.classList.add(theme);
}, [theme]);
return (
<div className={`${styles.app} ${isInHomeView ? 'yotsuba' : theme}`}>
<Routes>
<Route path='/' element={<Home />} />
<Route path='/p/:subplebbitAddress' element={<Subplebbit />} />
</Routes>
</div>
);
};
export default App;