2024-02-28 21:18:37 +01:00
|
|
|
import { useEffect } from 'react';
|
2024-03-17 16:27:15 +01:00
|
|
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
2024-02-27 17:58:08 +01:00
|
|
|
import Home from './views/home';
|
|
|
|
|
import styles from './app.module.css';
|
2024-02-28 21:18:37 +01:00
|
|
|
import useTheme from './hooks/use-theme';
|
2024-03-17 16:27:15 +01:00
|
|
|
import Subplebbit from './views/subplebbit';
|
|
|
|
|
import { isHomeView } from './lib/utils/view-utils';
|
2024-02-27 17:58:08 +01:00
|
|
|
|
|
|
|
|
const App = () => {
|
2024-02-28 21:18:37 +01:00
|
|
|
const [theme] = useTheme();
|
2024-03-17 16:27:15 +01:00
|
|
|
const location = useLocation();
|
|
|
|
|
const isInHomeView = isHomeView(location.pathname);
|
2024-02-28 21:18:37 +01:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
document.body.classList.forEach((className) => document.body.classList.remove(className));
|
|
|
|
|
document.body.classList.add(theme);
|
|
|
|
|
}, [theme]);
|
|
|
|
|
|
2024-03-17 21:47:16 +01:00
|
|
|
// const globalLayout = (
|
|
|
|
|
// <>
|
|
|
|
|
// <ChallengeModal />
|
|
|
|
|
// <Outlet />
|
|
|
|
|
// </>
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// const boardLayout = (
|
|
|
|
|
// <>
|
|
|
|
|
// <TopNav />
|
|
|
|
|
// <ImageBanner />
|
|
|
|
|
// <PostForm />
|
|
|
|
|
// <Stats />
|
|
|
|
|
// <Outlet />
|
|
|
|
|
// </>
|
|
|
|
|
// );
|
|
|
|
|
|
2024-02-27 17:58:08 +01:00
|
|
|
return (
|
2024-03-17 16:27:15 +01:00
|
|
|
<div className={`${styles.app} ${isInHomeView ? 'yotsuba' : theme}`}>
|
2024-02-27 17:58:08 +01:00
|
|
|
<Routes>
|
|
|
|
|
<Route path='/' element={<Home />} />
|
2024-03-17 16:27:15 +01:00
|
|
|
<Route path='/p/:subplebbitAddress' element={<Subplebbit />} />
|
2024-02-27 17:58:08 +01:00
|
|
|
</Routes>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default App;
|