Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move layout logic to separate component #257

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 4 additions & 34 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useCallback, useEffect } from 'react'
import 'antd/dist/antd.min.css'
import './App.scss'
import { ConfigProvider, Layout } from 'antd'
import { ConfigProvider } from 'antd'
import 'leaflet/dist/leaflet.css'
import styled from 'styled-components'
import heIL from 'antd/es/locale/he_IL'
import { BrowserRouter as Router, useSearchParams } from 'react-router-dom'
import { PageSearchState, SearchContext } from './model/pageState'
import moment from 'moment'
import { useSessionStorage } from 'usehooks-ts'

import { useLocation } from 'react-router-dom'
import ReactGA from 'react-ga4'
import { CacheProvider } from '@emotion/react'
Expand All @@ -21,25 +19,9 @@ import { ThemeProvider, createTheme } from '@mui/material'
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment'
import { LocalizationProvider } from '@mui/x-date-pickers'

import RoutesList, { PAGES } from './routes'
import MainHeader from './layout/header/Header'
import SideBar from './layout/sidebar/SideBar'
import LayoutContext from './layout/LayoutContext'
import { PAGES } from './routes'
import { EasterEgg } from './pages/EasterEgg/EasterEgg'
const { Content } = Layout

const StyledLayout = styled(Layout)`
height: 100vh;
`
const StyledContent = styled(Content)`
margin: 24px 16px 0;
overflow: auto;
`

const StyledBody = styled.div`
padding: 24px;
min-height: 360px;
`
import MainLayout from './layout'

const theme = createTheme(
{
Expand Down Expand Up @@ -110,19 +92,7 @@ const App = () => {
<ThemeProvider theme={theme}>
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="he">
<ConfigProvider direction="rtl" locale={heIL}>
<StyledLayout className="main">
<LayoutContext>
<SideBar />
<Layout>
<MainHeader />
<StyledContent>
<StyledBody>
<RoutesList />
</StyledBody>
</StyledContent>
</Layout>
</LayoutContext>
</StyledLayout>
<MainLayout />
</ConfigProvider>
</LocalizationProvider>
</ThemeProvider>
Expand Down
40 changes: 40 additions & 0 deletions src/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Layout } from 'antd'
import MainHeader from './header/Header'
import SideBar from './sidebar/SideBar'
import styled from 'styled-components'
import LayoutContext from './LayoutContext'
import RoutesList from '../routes'

const { Content } = Layout

const StyledLayout = styled(Layout)`
height: 100vh;
`
const StyledContent = styled(Content)`
margin: 24px 16px 0;
overflow: auto;
`
const StyledBody = styled.div`
padding: 24px;
min-height: 360px;
`

function MainLayout() {
return (
<StyledLayout className="main">
<LayoutContext>
<SideBar />
<Layout>
<MainHeader />
<StyledContent>
<StyledBody>
<RoutesList />
</StyledBody>
</StyledContent>
</Layout>
</LayoutContext>
</StyledLayout>
)
}

export default MainLayout
Loading