Files
firegex-traffic-viewer/frontend/src/components/MainLayout.tsx

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-10-13 01:50:52 +02:00
import { useEffect } from 'react';
2023-09-24 05:48:54 +02:00
import { ActionIcon, Container, Menu, Space } from '@mantine/core';
import { AppShell } from '@mantine/core';
import NavBar from './NavBar';
import HeaderPage from './Header';
2024-10-13 01:50:52 +02:00
import { getMainPath } from '../js/utils';
2022-07-22 00:34:57 +02:00
import { useLocation } from 'react-router-dom';
import { RiMenu5Fill } from 'react-icons/ri';
2024-10-13 01:50:52 +02:00
import { useNavbarStore } from '../js/store';
2022-06-11 21:57:50 +02:00
function MainLayout({ children }:{ children:any }) {
2024-10-13 01:50:52 +02:00
const { navOpened } = useNavbarStore()
2022-07-22 00:34:57 +02:00
const location = useLocation()
useEffect(()=>{
if (location.pathname !== "/"){
2024-10-13 01:50:52 +02:00
sessionStorage.setItem('home_section', getMainPath())
2022-07-22 00:34:57 +02:00
}
},[location.pathname])
2024-10-13 01:50:52 +02:00
return <AppShell
header={{ height: 70 }}
navbar={{ width: 300 , breakpoint: "md", collapsed: { mobile: !navOpened } }}
p="md"
>
2024-10-13 01:50:52 +02:00
<HeaderPage />
<NavBar />
<AppShell.Main>
<Container size="lg">
{children}
</Container>
</AppShell.Main>
<Space h="lg" />
</AppShell>
2022-06-11 21:57:50 +02:00
}
export default MainLayout;
export const MenuDropDownWithButton = ({children}:{children:any}) => <Menu withArrow>
<Menu.Target>
<ActionIcon variant='transparent'>
2024-10-13 01:50:52 +02:00
<RiMenu5Fill size={24} color='#FFF'/>
</ActionIcon>
</Menu.Target>
<Menu.Dropdown>
{children}
</Menu.Dropdown>
</Menu>