-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGlobalHeader.tsx
More file actions
59 lines (54 loc) · 2.39 KB
/
GlobalHeader.tsx
File metadata and controls
59 lines (54 loc) · 2.39 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
import { Msgs } from "@happy.tech/wallet-common"
import { ArrowLeft, ArrowsInSimple } from "@phosphor-icons/react"
import { GearSix } from "@phosphor-icons/react/dist/ssr"
import { Link, useLocation } from "@tanstack/react-router"
import { useAtom } from "jotai"
import { appMessageBus } from "#src/services/eventBus"
import { secondaryMenuVisibilityAtom } from "#src/state/interfaceState"
import { UserGasBudgetIndicator } from "./home/UserGasBudgetIndicator"
function signalClosed() {
void appMessageBus.emit(Msgs.WalletVisibility, { isOpen: false })
}
const GlobalHeader = () => {
const location = useLocation()
const [isVisible, setVisibility] = useAtom(secondaryMenuVisibilityAtom)
const optionsLabel = isVisible ? "Close options menu" : "Open options menu"
return (
<div className="relative max-w-prose mx-auto items-center w-full py-1.5 hidden lg:flex">
{location.pathname !== "/embed" && (
<Link to={"/embed"}>
<ArrowLeft weight="bold" className="text-base-content absolute start-2 top-1/2 -translate-y-1/2" />
</Link>
)}
<span className="text-base-content text-[0.825rem] font-bold mx-auto hidden lg:flex justify-center">
🤠 HappyChain
</span>
<div className="flex flex-row gap-1 items-center absolute end-2">
<UserGasBudgetIndicator />
<button
title={optionsLabel}
type="button"
aria-label={optionsLabel}
className="dark:opacity-60 text-lg"
onClick={() => {
// Don't toggle visibility: the menu will close if clicking the gear while the menu is open
// via the menu's own `onInteractOutsideHandler`.
if (!isVisible) setVisibility(true)
}}
>
<GearSix weight="bold" />
</button>
<button
title="Hide wallet"
type="button"
aria-label="Click to hide wallet"
className="dark:opacity-60 text-lg"
onClick={signalClosed}
>
<ArrowsInSimple weight="bold" />
</button>
</div>
</div>
)
}
export default GlobalHeader