|
1 | | -import { ReactNode } from 'react'; |
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { ReactNode, useState } from 'react'; |
2 | 4 | import { Providers } from '@/providers/session'; |
| 5 | +import { AppShell, Container, rem, useMantineTheme } from '@mantine/core'; |
| 6 | +import HeaderNav from '@/components/HeaderNav'; |
| 7 | +import Navigation from '@/components/Navigation'; |
| 8 | +import AppMain from '@/components/AppMain'; |
| 9 | +import FooterNav from '@/components/FooterNav'; |
| 10 | +import { useDisclosure, useMediaQuery } from '@mantine/hooks'; |
3 | 11 |
|
4 | 12 | type Auth0LayoutProps = { |
5 | 13 | children: ReactNode; |
6 | 14 | }; |
7 | 15 |
|
8 | 16 | export default function Auth0Layout({ children }: Auth0LayoutProps) { |
9 | | - return <Providers>{children}</Providers>; |
| 17 | + const theme = useMantineTheme(); |
| 18 | + const [opened, setOpened] = useState(false); |
| 19 | + const [themeOpened, { open: themeOpen, close: themeClose }] = |
| 20 | + useDisclosure(false); |
| 21 | + const tablet_match = useMediaQuery('(max-width: 768px)'); |
| 22 | + const [mobileOpened, { toggle: toggleMobile }] = useDisclosure(); |
| 23 | + const [desktopOpened, { toggle: toggleDesktop }] = useDisclosure(true); |
| 24 | + |
| 25 | + return ( |
| 26 | + <AppShell |
| 27 | + layout="alt" |
| 28 | + header={{ height: 60 }} |
| 29 | + footer={{ height: 60 }} |
| 30 | + navbar={{ |
| 31 | + width: 300, |
| 32 | + breakpoint: 'md', |
| 33 | + collapsed: { mobile: !mobileOpened, desktop: !desktopOpened }, |
| 34 | + }} |
| 35 | + padding={0} |
| 36 | + > |
| 37 | + <AppShell.Header |
| 38 | + style={{ |
| 39 | + height: rem(60), |
| 40 | + border: 'none', |
| 41 | + boxShadow: tablet_match ? theme.shadows.md : theme.shadows.sm, |
| 42 | + }} |
| 43 | + > |
| 44 | + <Container fluid py="sm" px="lg"> |
| 45 | + <HeaderNav |
| 46 | + opened={opened} |
| 47 | + handleOpen={() => setOpened((o) => !o)} |
| 48 | + desktopOpened={desktopOpened} |
| 49 | + mobileOpened={mobileOpened} |
| 50 | + toggleDesktop={toggleDesktop} |
| 51 | + toggleMobile={toggleMobile} |
| 52 | + /> |
| 53 | + </Container> |
| 54 | + </AppShell.Header> |
| 55 | + <AppShell.Navbar> |
| 56 | + <Navigation onClose={() => setOpened(false)} /> |
| 57 | + </AppShell.Navbar> |
| 58 | + <AppShell.Main> |
| 59 | + <AppMain> |
| 60 | + <Providers>{children}</Providers> |
| 61 | + </AppMain> |
| 62 | + </AppShell.Main> |
| 63 | + <AppShell.Footer p="md"> |
| 64 | + <Container fluid px="lg"> |
| 65 | + <FooterNav /> |
| 66 | + </Container> |
| 67 | + </AppShell.Footer> |
| 68 | + </AppShell> |
| 69 | + ); |
10 | 70 | } |
0 commit comments