-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppShellLayout.tsx
More file actions
54 lines (48 loc) · 1.37 KB
/
Copy pathAppShellLayout.tsx
File metadata and controls
54 lines (48 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use client';
import { AppShell, Group, Text, CloseButton, ScrollArea } from '@mantine/core';
import { AsideProvider, useAside } from '@/contexts/AsideContext';
import { Header } from './Header';
import { ErrorBoundary } from './ErrorBoundary';
function AppShellInner({ children }: { children: React.ReactNode }) {
const { isOpen, close, content, title } = useAside();
return (
<AppShell
header={{ height: 60 }}
aside={{
width: 400,
breakpoint: 'sm',
collapsed: { mobile: !isOpen, desktop: !isOpen },
}}
padding="md"
>
<AppShell.Header>
<Header />
</AppShell.Header>
<AppShell.Main>
<ErrorBoundary>
{children}
</ErrorBoundary>
</AppShell.Main>
{isOpen && (
<AppShell.Aside p="md">
<Group justify="space-between" mb="md">
<Text fw={600}>{title || 'Panel'}</Text>
<CloseButton onClick={close} />
</Group>
<ScrollArea style={{ height: 'calc(100vh - 140px)' }}>
<ErrorBoundary>
{content}
</ErrorBoundary>
</ScrollArea>
</AppShell.Aside>
)}
</AppShell>
);
}
export function AppShellLayout({ children }: { children: React.ReactNode }) {
return (
<AsideProvider>
<AppShellInner>{children}</AppShellInner>
</AsideProvider>
);
}