import { useEffect } from 'react'; import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom'; import { isHomeView } from './lib/utils/view-utils'; import useIsMobile from './hooks/use-is-mobile'; import useTheme from './hooks/use-theme'; import styles from './app.module.css'; import Board from './views/board'; import Catalog from './views/catalog'; import Home from './views/home'; import NotFound from './views/not-found'; import PendingPost from './views/pending-post'; import PostPage from './views/post-page'; import { DesktopBoardButtons, MobileBoardButtons } from './components/board-buttons'; import BoardHeader from './components/board-header'; import ChallengeModal from './components/challenge-modal'; import PostForm from './components/post-form'; import SubplebbitStats from './components/subplebbit-stats'; import TopBar from './components/topbar'; const BoardLayout = () => { const { accountCommentIndex, subplebbitAddress } = useParams(); const location = useLocation(); const isMobile = useIsMobile(); const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0); if (!isValidAccountCommentIndex) { return ; } // force rerender of post form when navigating between pages const key = `${subplebbitAddress}-${location.pathname}`; return (
{isMobile ? ( <> ) : ( <> {subplebbitAddress && } )}
); }; const App = () => { const location = useLocation(); const isInHomeView = isHomeView(location.pathname); const [theme] = useTheme(); useEffect(() => { document.body.classList.forEach((className) => document.body.classList.remove(className)); const classToAdd = isInHomeView ? 'yotsuba' : theme; document.body.classList.add(classToAdd); }, [theme, isInHomeView]); const globalLayout = ( <> ); return (
} /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } />
); }; export default App;