forked from FlowwStar/FlowStar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavbar.tsx
More file actions
158 lines (147 loc) · 5.66 KB
/
Copy pathnavbar.tsx
File metadata and controls
158 lines (147 loc) · 5.66 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
150
151
152
153
154
155
156
157
158
'use client'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { Plus, Moon, Sun, Monitor, Network, AlertTriangle } from 'lucide-react'
import { useTheme } from 'next-themes'
import { Brand } from '@/components/brand'
import { useNetwork } from '@/components/providers/network-provider'
import { useWalletContext } from '@/components/providers/wallet-provider'
import { Button } from '@/components/ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { ConnectWalletButton } from '@/components/layout/connect-wallet-button'
import { NotificationBell } from '@/components/layout/notification-bell'
import { cn } from '@/lib/utils'
const NAV_LINKS = [
{ href: '/app', label: 'Dashboard' },
{ href: '/app/streams', label: 'Streams' },
{ href: '/app/analytics', label: 'Analytics' },
{ href: '/app/settings', label: 'Settings' },
]
export function Navbar() {
const pathname = usePathname()
const { setTheme } = useTheme()
const { network, setNetwork } = useNetwork()
const { networkMismatch, walletNetwork, isConnected } = useWalletContext()
return (
<header className="sticky top-0 z-40 border-b border-border bg-background/80 backdrop-blur-xl">
<div className="mx-auto flex h-16 max-w-6xl items-center gap-6 px-4 sm:px-6">
<Brand href="/app" />
<nav className="hidden items-center gap-1 md:flex">
{NAV_LINKS.map((link) => {
const active =
link.href === '/app'
? pathname === '/app'
: pathname.startsWith(link.href)
return (
<Link
key={link.href}
href={link.href}
className={cn(
'rounded-md px-3 py-1.5 text-sm font-medium transition-colors',
active
? 'bg-secondary text-foreground'
: 'text-muted-foreground hover:text-foreground',
)}
>
{link.label}
</Link>
)
})}
</nav>
<div className="ml-auto flex items-center gap-2">
<Button
asChild
variant="ghost"
size="sm"
className="gap-1.5"
disabled={networkMismatch}
>
<Link href="/app/create">
<Plus className="size-4" />
<span className="hidden sm:inline">New stream</span>
</Link>
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="gap-1.5">
<Network className="size-4" />
<span className="hidden sm:inline">{network === 'mainnet' ? 'Mainnet' : 'Testnet'}</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setNetwork('testnet')}>
Testnet
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setNetwork('mainnet')}>
Mainnet
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon">
<Sun className="size-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute size-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setTheme('light')}>
<Sun className="mr-2 size-4" />
Light
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme('dark')}>
<Moon className="mr-2 size-4" />
Dark
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme('system')}>
<Monitor className="mr-2 size-4" />
System
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<NotificationBell />
<ConnectWalletButton />
</div>
</div>
{/* Network mismatch banner */}
{isConnected && networkMismatch && (
<div className="flex items-center gap-2 border-t border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-sm text-yellow-600 dark:text-yellow-400">
<AlertTriangle className="size-4 shrink-0" />
<span>
Your wallet is on <strong>{walletNetwork}</strong> — please switch to{' '}
<strong>{network}</strong> in Freighter settings. Transactions are disabled until you switch.
</span>
</div>
)}
{/* Mobile nav */}
<nav className="flex items-center gap-1 border-t border-border px-4 py-2 md:hidden">
{NAV_LINKS.map((link) => {
const active =
link.href === '/app'
? pathname === '/app'
: pathname.startsWith(link.href)
return (
<Link
key={link.href}
href={link.href}
className={cn(
'rounded-md px-3 py-1.5 text-sm font-medium transition-colors',
active
? 'bg-secondary text-foreground'
: 'text-muted-foreground hover:text-foreground',
)}
>
{link.label}
</Link>
)
})}
</nav>
</header>
)
}