-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
568 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import React from 'react'; | ||
import React, { Suspense } from 'react'; | ||
import { LayoutProps } from 'react-admin'; | ||
import { Box, CircularProgress } from '@mui/material'; | ||
import { styled } from '@mui/material/styles'; | ||
import { useLayoutContext } from '../../layouts/LayoutContext'; | ||
|
||
const FullPageBox = styled(Box)(() => ({ | ||
width: '100vw', | ||
height: '100vh', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
})); | ||
|
||
const BaseLayout = (props: LayoutProps) => { | ||
const { Layout } = useLayoutContext(); | ||
return <Layout {...props} />; | ||
|
||
return ( | ||
<Suspense | ||
fallback={ | ||
<FullPageBox> | ||
<CircularProgress /> | ||
</FullPageBox> | ||
} | ||
> | ||
<Layout {...props} /> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default BaseLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { ShowButton, EditButton, useResourceDefinition, useRecordContext } from 'react-admin'; | ||
import { Box, Typography } from '@mui/material'; | ||
import { useLayoutContext } from '../../layouts/LayoutContext'; | ||
|
||
const MobileMapPopupContent = () => { | ||
const record = useRecordContext(); | ||
const resourceDefinition = useResourceDefinition({}); | ||
const layout = useLayoutContext(); | ||
|
||
if (!record) return null; | ||
|
||
return ( | ||
<Box sx={{ paddingBottom: layout.name === 'topMenu' ? '56px' : 0 }}> | ||
{record.label && <Typography variant="h5">{record.label}</Typography>} | ||
{record.description && ( | ||
<Typography> | ||
{record.description.length > 150 ? `${record.description.substring(0, 150)}...` : record.description} | ||
</Typography> | ||
)} | ||
{resourceDefinition.hasShow && <ShowButton />} | ||
{resourceDefinition.hasEdit && <EditButton />} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default MobileMapPopupContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { LayoutContext, LayoutOptions } from './LayoutContext'; | ||
|
||
import leftMenu from './leftMenu'; | ||
import topMenu from './topMenu'; | ||
|
||
const layoutsComponents = { | ||
leftMenu, | ||
topMenu, | ||
}; | ||
|
||
type LayoutProviderProps = PropsWithChildren<{ | ||
layoutOptions: LayoutOptions; | ||
}>; | ||
|
||
export const LayoutProvider = ({ children, layoutOptions }: LayoutProviderProps) => { | ||
const layoutComponents = layoutsComponents[layoutOptions.name]; | ||
|
||
if (!layoutComponents) { | ||
return null; | ||
} | ||
|
||
return <LayoutContext.Provider value={{ ...layoutOptions, ...layoutComponents }}>{children}</LayoutContext.Provider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
import { AppBar as MuiAppBar, Box, Button, Stack, Toolbar, Typography, Link } from '@mui/material'; | ||
import { styled } from '@mui/material/styles'; | ||
import { Link as RRLink } from 'react-router-dom'; | ||
import config from '../../config/config'; | ||
import UserMenu from './UserMenu'; | ||
import ResourcesMenu from './ResourcesMenu'; | ||
import { useLayoutContext } from '../LayoutContext'; | ||
import { LayoutOptions } from '.'; | ||
|
||
const AppTitle = styled(Typography)(({ theme }) => ({ | ||
textWrap: 'balance', | ||
lineHeight: '1.1', | ||
[theme.breakpoints.down('lg')]: { | ||
fontSize: '1rem', | ||
textAlign: 'center', | ||
}, | ||
})) as typeof Typography; | ||
|
||
const AppBar = () => { | ||
const layout = useLayoutContext<LayoutOptions>(); | ||
const logo = layout.options.logo; | ||
|
||
return ( | ||
<MuiAppBar position="fixed" sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}> | ||
<Toolbar> | ||
{logo && ( | ||
<Box sx={{ marginRight: { xs: 0, lg: 1 } }}> | ||
<Link component={RRLink} to="/" color="inherit" underline="none"> | ||
<Box | ||
height={'48px'} | ||
component={'img'} | ||
src={typeof logo === 'string' ? logo : logo.url} | ||
alt={typeof logo === 'string' ? 'Logo' : logo.alt} | ||
sx={{ paddingTop: '5px', boxSizing: 'content-box' }} | ||
/> | ||
</Link> | ||
</Box> | ||
)} | ||
|
||
{!(layout.options.title === false) && ( | ||
<> | ||
{(typeof layout.options.title === 'function' && layout.options.title?.()) || ( | ||
<AppTitle component="h1" variant="h6"> | ||
<Link component={RRLink} to="/" color="inherit" underline="none"> | ||
{config.title} | ||
</Link> | ||
</AppTitle> | ||
)} | ||
</> | ||
)} | ||
|
||
<Box sx={{ flexGrow: 1 }} /> | ||
|
||
<Stack sx={{ display: { xs: 'none', md: 'block' } }} spacing={2} direction="row"> | ||
{(layout.options.mainMenu || []).map((item) => ( | ||
<Button | ||
key={item.label} | ||
color="inherit" | ||
size="large" | ||
startIcon={item.icon ? <item.icon /> : undefined} | ||
component={RRLink} | ||
to={item.link} | ||
> | ||
{item.label} | ||
</Button> | ||
))} | ||
</Stack> | ||
|
||
<Box sx={{ flexGrow: 1 }} /> | ||
|
||
<ResourcesMenu /> | ||
|
||
<UserMenu /> | ||
</Toolbar> | ||
</MuiAppBar> | ||
); | ||
}; | ||
|
||
export default AppBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { PropsWithChildren, useState } from 'react'; | ||
import { Box, Drawer, Fab, Toolbar, useMediaQuery } from '@mui/material'; | ||
import { styled, useTheme } from '@mui/material/styles'; | ||
import TuneIcon from '@mui/icons-material/Tune'; | ||
import { useLayoutContext } from '../LayoutContext'; | ||
import { LayoutOptions } from '.'; | ||
|
||
const asideWidth = '300px'; | ||
|
||
const ContentBox = styled(Box)(({ theme }) => ({ | ||
minWidth: asideWidth, | ||
padding: 16, | ||
boxSizing: 'border-box', | ||
[theme.breakpoints.down('md')]: { | ||
paddingBottom: 56 + 16, | ||
}, | ||
})); | ||
|
||
const Aside = ({ children }: PropsWithChildren) => { | ||
const theme = useTheme(); | ||
const isMobile = useMediaQuery(theme.breakpoints.down('sm')); | ||
const [isAsideOpen, setAsideOpen] = useState(false); | ||
|
||
const layout = useLayoutContext<LayoutOptions>(); | ||
const side = layout.options.sideBarPlacement; | ||
|
||
return ( | ||
<> | ||
{isMobile && ( | ||
<Fab | ||
variant="extended" | ||
color="primary" | ||
sx={{ | ||
position: 'fixed', | ||
bottom: 64, | ||
left: 10, | ||
}} | ||
onClick={() => setAsideOpen(true)} | ||
> | ||
<TuneIcon sx={{ mr: 1 }} /> | ||
Filtres | ||
</Fab> | ||
)} | ||
<Drawer | ||
sx={{ | ||
width: asideWidth, | ||
flexShrink: 0, | ||
'& .MuiDrawer-paper': { | ||
width: asideWidth, | ||
boxSizing: 'border-box', | ||
}, | ||
}} | ||
variant={isMobile ? 'temporary' : 'permanent'} | ||
open={isAsideOpen} | ||
anchor={side} | ||
onClose={() => setAsideOpen(false)} | ||
> | ||
<Toolbar /> | ||
<ContentBox>{children}</ContentBox> | ||
</Drawer> | ||
</> | ||
); | ||
}; | ||
|
||
export default Aside; |
Oops, something went wrong.