forked from BETAIL-BOYS/TradeFlow-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavbar.tsx
More file actions
115 lines (104 loc) · 3.48 KB
/
Navbar.tsx
File metadata and controls
115 lines (104 loc) · 3.48 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
"use client";
import React, { useState } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { Wallet, Copy, Check, CreditCard } from "lucide-react";
import NetworkSelector, { Network } from "./src/components/NetworkSelector";
import FiatOnRampModal from "./src/components/FiatOnRampModal";
interface NavbarProps {
address?: string;
onConnect?: () => void;
}
export default function Navbar({ address, onConnect }: NavbarProps) {
const pathname = usePathname();
const [copied, setCopied] = useState(false);
const [isFiatModalOpen, setIsFiatModalOpen] = useState(false);
const copyToClipboard = async () => {
if (address) {
try {
await navigator.clipboard.writeText(address);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch (err) {
console.error('Failed to copy address:', err);
}
}
};
const navLinks = [
{ name: "Dashboard", href: "/" },
{ name: "Swap", href: "/swap" },
{ name: "Pools", href: "/pools" },
{ name: "Portfolio", href: "/portfolio" },
{ name: "FAQ", href: "/faq" },
];
return (
<div className="flex justify-between items-center mb-12 p-8">
<div className="flex items-center gap-12">
<h1 className="text-3xl font-bold tracking-tight">
TradeFlow <span className="text-blue-400">RWA</span>
</h1>
<nav className="hidden md:flex gap-8">
{navLinks.map((link) => {
const isActive = pathname === link.href;
return (
<Link
key={link.href}
href={link.href}
className={`text-sm font-medium transition-colors ${
isActive
? "text-cyan-400"
: "text-slate-400 hover:text-white"
}`}
>
{link.name}
</Link>
);
})}
</nav>
</div>
<div className="flex items-center gap-4">
<NetworkSelector />
{/* Buy Crypto Button */}
<button
onClick={() => setIsFiatModalOpen(true)}
className="flex items-center gap-2 bg-green-600 hover:bg-green-700 px-6 py-2 rounded-full transition"
>
<CreditCard size={18} />
Buy Crypto
</button>
{address ? (
<div className="flex items-center gap-2 bg-blue-600 hover:bg-blue-700 px-6 py-2 rounded-full transition">
<Wallet size={18} />
<span className="text-sm">
{`${address.slice(0, 6)}...${address.slice(-4)}`}
</span>
<button
onClick={copyToClipboard}
className="ml-2 p-1 hover:bg-blue-500 rounded-full transition-colors"
title="Copy address"
>
{copied ? (
<Check size={16} className="text-green-300" />
) : (
<Copy size={16} className="text-white" />
)}
</button>
</div>
) : (
<button
onClick={onConnect}
className="flex items-center gap-2 bg-blue-600 hover:bg-blue-700 px-6 py-2 rounded-full transition"
>
<Wallet size={18} />
Connect Wallet
</button>
)}
</div>
{/* Fiat On-Ramp Modal */}
<FiatOnRampModal
isOpen={isFiatModalOpen}
onClose={() => setIsFiatModalOpen(false)}
/>
</div>
);
}