-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathSidebarNav.tsx
More file actions
69 lines (64 loc) · 2 KB
/
SidebarNav.tsx
File metadata and controls
69 lines (64 loc) · 2 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import {Suspense} from 'react';
import * as React from 'react';
import cn from 'classnames';
import {SidebarRouteTree} from '../Sidebar/SidebarRouteTree';
import type {RouteItem} from '../getRouteMeta';
declare global {
interface Window {
__theme: string;
__setPreferredTheme: (theme: string) => void;
}
}
export default function SidebarNav({
routeTree,
breadcrumbs,
}: {
routeTree: RouteItem;
breadcrumbs: RouteItem[];
}) {
// HACK. Fix up the data structures instead.
if ((routeTree as any).routes.length === 1) {
routeTree = (routeTree as any).routes[0];
}
return (
<div
className={cn(
'sticky top-0 lg:bottom-0 lg:h-[calc(100vh-4rem)] flex flex-col'
)}>
<div
className="overflow-y-scroll no-bg-scrollbar lg:w-[342px] grow bg-wash dark:bg-wash-dark"
style={{
overscrollBehavior: 'contain',
}}>
<aside
className={cn(
`lg:grow flex-col w-full pb-8 lg:pb-0 lg:max-w-custom-xs z-10 hidden lg:block`
)}>
<nav
role="navigation"
style={{'--bg-opacity': '.2'} as React.CSSProperties} // Need to cast here because CSS vars aren't considered valid in TS types (cuz they could be anything)
className="w-full pt-6 scrolling-touch lg:h-auto grow pe-0 lg:pe-5 lg:pb-16 md:pt-4 lg:pt-4 scrolling-gpu">
{/* No fallback UI so need to be careful not to suspend directly inside. */}
<Suspense fallback={null}>
<SidebarRouteTree
routeTree={routeTree}
breadcrumbs={breadcrumbs}
isForceExpanded={false}
/>
</Suspense>
<div className="h-20" />
</nav>
</aside>
</div>
</div>
);
}