base structure
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import SideBar from '@/shared/SideBar'
|
||||
import Header from '@/shared/Header'
|
||||
import { Route, Routes, useLocation } from 'react-router-dom'
|
||||
import { Paths } from '@/config/Paths'
|
||||
import { clx } from '@/helpers/utils'
|
||||
import { useSharedStore } from '@/shared/store/sharedStore'
|
||||
import Home from '@/pages/home/Home'
|
||||
import Editor from '@/pages/editor/Editor'
|
||||
|
||||
const MainRouter = () => {
|
||||
const { hasSubMenu } = useSharedStore()
|
||||
const location = useLocation()
|
||||
const hiddenSideBarRoutes = [Paths.editor]
|
||||
const shouldRenderSideBar = !hiddenSideBarRoutes.includes(location.pathname)
|
||||
const routeHasLocalSidebar = location.pathname === Paths.editor
|
||||
const hasSidebarSpace = shouldRenderSideBar || routeHasLocalSidebar
|
||||
const headerSidebarSize = routeHasLocalSidebar ? 'wide' : 'default'
|
||||
|
||||
return (
|
||||
<div className='flex min-h-full flex-col overflow-hidden p-4'>
|
||||
{shouldRenderSideBar ? <SideBar /> : null}
|
||||
<Header hasMainSidebar={hasSidebarSpace} sidebarSize={headerSidebarSize} />
|
||||
<div className={clx(
|
||||
'mt-[68px] flex flex-1 flex-col xl:mt-[81px]',
|
||||
shouldRenderSideBar && 'xl:ms-[269px]',
|
||||
shouldRenderSideBar && hasSubMenu && 'xl:ms-[305px]',
|
||||
routeHasLocalSidebar && 'xl:mr-[374px]',
|
||||
)}>
|
||||
<div className='flex-1 flex flex-col overflow-auto w-full max-h-[calc(100vh-113px)]'>
|
||||
<div className='flex-1 h-full flex'>
|
||||
<Routes>
|
||||
<Route path={Paths.home} element={<Home />} />
|
||||
<Route path={Paths.editor} element={<Editor />} />
|
||||
</Routes>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MainRouter
|
||||
Reference in New Issue
Block a user