forked from Disciplr-Org/Disciplr-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayout.tsx
More file actions
149 lines (140 loc) · 4.46 KB
/
Copy pathLayout.tsx
File metadata and controls
149 lines (140 loc) · 4.46 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import React, { useState, type HTMLAttributes } from "react";
import { Link, useLocation } from "react-router-dom";
import { Menu } from "lucide-react";
import { WalletConnectButton } from "./Wallet/WalletConnectButton";
import { WalletBalanceChip } from "./Wallet/WalletBalanceChip";
import MobileDrawer from "./MobileDrawer";
import NavLink from "./NavLink";
import { NetworkMismatchBanner } from "./NetworkMismatchBanner";
import { Text } from "./Text";
import { TrustlineBanner } from "./TrustlineBanner";
import NotificationBell from "./Notification/NotificationBell";
import { ShortcutsHelp } from "./ShortcutsHelp";
import ErrorBoundary from "./ErrorBoundary";
import "./Layout.css";
interface LayoutProps {
children: React.ReactNode;
}
export default function Layout({ children }: LayoutProps) {
const [isDrawerOpen, setDrawerOpen] = useState(false);
const toggleDrawer = () => setDrawerOpen((prev) => !prev);
const location = useLocation();
const backgroundA11yProps = isDrawerOpen
? ({ "aria-hidden": true, inert: "" } as HTMLAttributes<HTMLElement> & {
inert: "";
})
: {};
return (
<div
style={{ minHeight: "100vh", display: "flex", flexDirection: "column" }}
>
<header className="site-header">
<div className="header-brand" {...backgroundA11yProps}>
<Link to="/" className="header-link" aria-label="Disciplr home">
<Text role="title" as="span">
Disciplr
</Text>
</Link>
<NavLink
to="/transactions"
className="header-link"
ariaLabel="Transactions"
>
<span className="header-transactions-label">Transactions</span>
<span
aria-hidden="true"
className="header-transactions-icon"
style={{ display: "none" }}
>
↗
</span>
</NavLink>
</div>
<nav
className="desktop-nav"
aria-label="Main navigation"
{...backgroundA11yProps}
>
<div style={{ display: "flex", alignItems: "center", gap: "1rem" }}>
<NavLink
to="/"
className="header-link"
aria-current={location.pathname === "/" ? "page" : undefined}
>
<Text role="caption" as="span">
Home
</Text>
</NavLink>
<NavLink to="/verifier" className="header-link">
<Text role="caption" as="span">
Verifier
</Text>
</NavLink>
<NavLink
to="/analytics"
className="header-link"
aria-current={
location.pathname === "/analytics" ? "page" : undefined
}
>
<Text role="caption" as="span">
Analytics
</Text>
</NavLink>
<NavLink
to="/help"
className="header-link"
aria-current={location.pathname.startsWith('/help') ? 'page' : undefined}
>
<Text role="caption" as="span">
Help
</Text>
</NavLink>
<Link
to="/vaults/create"
className="header-link header-cta"
aria-current={
location.pathname === "/vaults/create" ? "page" : undefined
}
>
Create Vault
</Link>
<NotificationBell />
<WalletConnectButton />
</div>
</nav>
<div className="mobile-bell-wrapper" {...backgroundA11yProps}>
<NotificationBell />
</div>
<button
type="button"
className="mobile-hamburger"
aria-label="Open navigation menu"
aria-controls="mobile-drawer"
aria-expanded={isDrawerOpen}
onClick={toggleDrawer}
>
<Menu size={24} aria-hidden="true" />
</button>
<MobileDrawer
isOpen={isDrawerOpen}
onClose={() => setDrawerOpen(false)}
/>
</header>
<TrustlineBanner />
<main
{...backgroundA11yProps}
style={{
flex: 1,
padding: "var(--spacing-8)",
maxWidth: "var(--container-standard)",
margin: "0 auto",
width: "100%",
}}
>
<ErrorBoundary>{children}</ErrorBoundary>
</main>
<ShortcutsHelp />
</div>
);
}