anky2002 commited on
Commit
b8e7113
·
2 Parent(s): f54a60758999e2

Merge branch 'main' of https://huggingface.co/spaces/gaurv007/ClauseGuard

Browse files
Files changed (1) hide show
  1. web/components/nav.tsx +79 -33
web/components/nav.tsx CHANGED
@@ -5,7 +5,7 @@ import { usePathname } from "next/navigation";
5
  import type { LucideIcon } from "lucide-react";
6
  import {
7
  ShieldCheck, Menu, X, Crown, GitCompare, LayoutDashboard,
8
- ScanText, Settings, LogIn, Zap
9
  } from "lucide-react";
10
  import { useState, useEffect } from "react";
11
  import { createClient } from "@/lib/supabase/client";
@@ -42,18 +42,18 @@ export function Nav() {
42
  });
43
  }, []);
44
 
45
- const publicLinks: NavLink[] = [
46
- { href: "/#features", label: "Features" },
47
- { href: "/#pricing", label: "Pricing" },
48
- ];
49
-
50
- const appLinks: NavLink[] = [
51
- { href: "/dashboard-pages/dashboard", label: "Dashboard", icon: LayoutDashboard },
52
  { href: "/dashboard-pages/analyze", label: "Scanner", icon: ScanText },
53
  { href: "/dashboard-pages/compare", label: "Compare", icon: GitCompare },
54
  ];
55
 
56
- const links: NavLink[] = isLoggedIn ? appLinks : publicLinks;
 
 
 
57
 
58
  return (
59
  <nav className="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-zinc-100">
@@ -66,13 +66,28 @@ export function Nav() {
66
  </Link>
67
 
68
  {/* Desktop Nav */}
69
- <div className="hidden md:flex items-center gap-1">
70
- {links.map((l) => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  const Icon = l.icon ?? null;
72
  const isActive = pathname === l.href;
73
  return (
74
  <Link key={l.href} href={l.href}
75
- className={`flex items-center gap-1.5 px-3 py-1.5 text-[13px] rounded-md transition-colors ${
76
  isActive ? "text-zinc-900 bg-zinc-100 font-medium" : "text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"
77
  }`}>
78
  {Icon && <Icon className="w-3.5 h-3.5" />}
@@ -81,9 +96,10 @@ export function Nav() {
81
  );
82
  })}
83
 
 
84
  {isAdmin && (
85
  <Link href="/admin"
86
- className={`flex items-center gap-1.5 px-3 py-1.5 text-[13px] rounded-md transition-colors ${
87
  pathname === "/admin"
88
  ? "text-amber-700 bg-amber-50 font-medium"
89
  : "text-amber-600 hover:text-amber-700 hover:bg-amber-50"
@@ -92,18 +108,19 @@ export function Nav() {
92
  </Link>
93
  )}
94
 
95
- <div className="w-px h-4 bg-zinc-200 mx-2" />
96
 
 
97
  {isLoggedIn ? (
98
  <>
99
  <Link href="/dashboard-pages/settings"
100
- className={`flex items-center gap-1.5 px-3 py-1.5 text-[13px] rounded-md transition-colors ${
101
  pathname?.includes("settings") ? "text-zinc-900 bg-zinc-100" : "text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"
102
  }`}>
103
  <Settings className="w-3.5 h-3.5" /> Settings
104
  </Link>
105
  <Link href="/dashboard-pages/analyze"
106
- className="ml-1 px-3.5 py-1.5 text-[13px] font-medium text-white bg-zinc-900 rounded-md hover:bg-zinc-800 transition-colors flex items-center gap-1.5">
107
  <Zap className="w-3.5 h-3.5" /> New scan
108
  </Link>
109
  </>
@@ -111,12 +128,12 @@ export function Nav() {
111
  <>
112
  {loaded && (
113
  <Link href="/auth/login"
114
- className="flex items-center gap-1.5 px-3 py-1.5 text-[13px] text-zinc-500 hover:text-zinc-900 rounded-md hover:bg-zinc-50 transition-colors">
115
  <LogIn className="w-3.5 h-3.5" /> Log in
116
  </Link>
117
  )}
118
  <Link href="/auth/signup"
119
- className="ml-1 px-3.5 py-1.5 text-[13px] font-medium text-white bg-zinc-900 rounded-md hover:bg-zinc-800 transition-colors">
120
  Get started
121
  </Link>
122
  </>
@@ -131,31 +148,60 @@ export function Nav() {
131
 
132
  {/* Mobile Menu */}
133
  {open && (
134
- <div className="md:hidden border-t border-zinc-100 bg-white px-5 py-3 space-y-1">
135
- {links.map((l) => (
136
- <Link key={l.href} href={l.href} onClick={() => setOpen(false)}
137
- className="block px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">{l.label}</Link>
138
- ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  {isAdmin && (
140
  <Link href="/admin" onClick={() => setOpen(false)}
141
- className="px-3 py-2.5 text-sm text-amber-600 rounded-md hover:bg-amber-50 flex items-center gap-2">
142
  <Crown className="w-4 h-4" /> Admin Panel
143
  </Link>
144
  )}
145
- <div className="h-px bg-zinc-100 my-2" />
 
 
 
146
  {isLoggedIn ? (
147
- <>
148
- <Link href="/dashboard-pages/settings" onClick={() => setOpen(false)}
149
- className="block px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">Settings</Link>
150
- <Link href="/dashboard-pages/analyze" onClick={() => setOpen(false)}
151
- className="block px-3 py-2.5 text-sm font-medium text-white bg-zinc-900 rounded-lg text-center hover:bg-zinc-800">New Scan</Link>
152
- </>
153
  ) : (
154
  <>
155
  <Link href="/auth/login" onClick={() => setOpen(false)}
156
- className="block px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">Log in</Link>
 
 
157
  <Link href="/auth/signup" onClick={() => setOpen(false)}
158
- className="block px-3 py-2.5 text-sm font-medium text-white bg-zinc-900 rounded-lg text-center hover:bg-zinc-800">Get started</Link>
 
 
159
  </>
160
  )}
161
  </div>
 
5
  import type { LucideIcon } from "lucide-react";
6
  import {
7
  ShieldCheck, Menu, X, Crown, GitCompare, LayoutDashboard,
8
+ ScanText, Settings, LogIn, Zap, Sparkles, CreditCard
9
  } from "lucide-react";
10
  import { useState, useEffect } from "react";
11
  import { createClient } from "@/lib/supabase/client";
 
42
  });
43
  }, []);
44
 
45
+ // All links always visible
46
+ const mainLinks: NavLink[] = [
47
+ { href: "/#features", label: "Features", icon: Sparkles },
48
+ { href: "/#pricing", label: "Pricing", icon: CreditCard },
 
 
 
49
  { href: "/dashboard-pages/analyze", label: "Scanner", icon: ScanText },
50
  { href: "/dashboard-pages/compare", label: "Compare", icon: GitCompare },
51
  ];
52
 
53
+ // Extra links only for logged-in users
54
+ const authLinks: NavLink[] = [
55
+ { href: "/dashboard-pages/dashboard", label: "Dashboard", icon: LayoutDashboard },
56
+ ];
57
 
58
  return (
59
  <nav className="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-zinc-100">
 
66
  </Link>
67
 
68
  {/* Desktop Nav */}
69
+ <div className="hidden md:flex items-center gap-0.5">
70
+ {/* Main links always visible */}
71
+ {mainLinks.map((l) => {
72
+ const Icon = l.icon ?? null;
73
+ const isActive = pathname === l.href;
74
+ return (
75
+ <Link key={l.href} href={l.href}
76
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] rounded-md transition-colors ${
77
+ isActive ? "text-zinc-900 bg-zinc-100 font-medium" : "text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"
78
+ }`}>
79
+ {l.label}
80
+ </Link>
81
+ );
82
+ })}
83
+
84
+ {/* Dashboard — only when logged in */}
85
+ {isLoggedIn && authLinks.map((l) => {
86
  const Icon = l.icon ?? null;
87
  const isActive = pathname === l.href;
88
  return (
89
  <Link key={l.href} href={l.href}
90
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] rounded-md transition-colors ${
91
  isActive ? "text-zinc-900 bg-zinc-100 font-medium" : "text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"
92
  }`}>
93
  {Icon && <Icon className="w-3.5 h-3.5" />}
 
96
  );
97
  })}
98
 
99
+ {/* Admin — always visible for admins */}
100
  {isAdmin && (
101
  <Link href="/admin"
102
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] rounded-md transition-colors ${
103
  pathname === "/admin"
104
  ? "text-amber-700 bg-amber-50 font-medium"
105
  : "text-amber-600 hover:text-amber-700 hover:bg-amber-50"
 
108
  </Link>
109
  )}
110
 
111
+ <div className="w-px h-4 bg-zinc-200 mx-1.5" />
112
 
113
+ {/* Right side — auth actions */}
114
  {isLoggedIn ? (
115
  <>
116
  <Link href="/dashboard-pages/settings"
117
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] rounded-md transition-colors ${
118
  pathname?.includes("settings") ? "text-zinc-900 bg-zinc-100" : "text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"
119
  }`}>
120
  <Settings className="w-3.5 h-3.5" /> Settings
121
  </Link>
122
  <Link href="/dashboard-pages/analyze"
123
+ className="ml-1 px-3 py-1.5 text-[13px] font-medium text-white bg-zinc-900 rounded-md hover:bg-zinc-800 transition-colors flex items-center gap-1.5">
124
  <Zap className="w-3.5 h-3.5" /> New scan
125
  </Link>
126
  </>
 
128
  <>
129
  {loaded && (
130
  <Link href="/auth/login"
131
+ className="flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] text-zinc-500 hover:text-zinc-900 rounded-md hover:bg-zinc-50 transition-colors">
132
  <LogIn className="w-3.5 h-3.5" /> Log in
133
  </Link>
134
  )}
135
  <Link href="/auth/signup"
136
+ className="ml-1 px-3 py-1.5 text-[13px] font-medium text-white bg-zinc-900 rounded-md hover:bg-zinc-800 transition-colors">
137
  Get started
138
  </Link>
139
  </>
 
148
 
149
  {/* Mobile Menu */}
150
  {open && (
151
+ <div className="md:hidden border-t border-zinc-100 bg-white px-5 py-3 space-y-0.5">
152
+ {/* Main links */}
153
+ {mainLinks.map((l) => {
154
+ const Icon = l.icon ?? null;
155
+ return (
156
+ <Link key={l.href} href={l.href} onClick={() => setOpen(false)}
157
+ className="flex items-center gap-2.5 px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">
158
+ {Icon && <Icon className="w-4 h-4 text-zinc-400" />}
159
+ {l.label}
160
+ </Link>
161
+ );
162
+ })}
163
+
164
+ {/* Auth links */}
165
+ {isLoggedIn && (
166
+ <>
167
+ <div className="h-px bg-zinc-100 my-1.5" />
168
+ <Link href="/dashboard-pages/dashboard" onClick={() => setOpen(false)}
169
+ className="flex items-center gap-2.5 px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">
170
+ <LayoutDashboard className="w-4 h-4 text-zinc-400" /> Dashboard
171
+ </Link>
172
+ <Link href="/dashboard-pages/settings" onClick={() => setOpen(false)}
173
+ className="flex items-center gap-2.5 px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">
174
+ <Settings className="w-4 h-4 text-zinc-400" /> Settings
175
+ </Link>
176
+ </>
177
+ )}
178
+
179
+ {/* Admin */}
180
  {isAdmin && (
181
  <Link href="/admin" onClick={() => setOpen(false)}
182
+ className="flex items-center gap-2.5 px-3 py-2.5 text-sm text-amber-600 rounded-md hover:bg-amber-50">
183
  <Crown className="w-4 h-4" /> Admin Panel
184
  </Link>
185
  )}
186
+
187
+ <div className="h-px bg-zinc-100 my-1.5" />
188
+
189
+ {/* Auth actions */}
190
  {isLoggedIn ? (
191
+ <Link href="/dashboard-pages/analyze" onClick={() => setOpen(false)}
192
+ className="block px-3 py-2.5 text-sm font-medium text-white bg-zinc-900 rounded-lg text-center hover:bg-zinc-800">
193
+ New Scan
194
+ </Link>
 
 
195
  ) : (
196
  <>
197
  <Link href="/auth/login" onClick={() => setOpen(false)}
198
+ className="flex items-center gap-2.5 px-3 py-2.5 text-sm text-zinc-600 rounded-md hover:bg-zinc-50">
199
+ <LogIn className="w-4 h-4 text-zinc-400" /> Log in
200
+ </Link>
201
  <Link href="/auth/signup" onClick={() => setOpen(false)}
202
+ className="block px-3 py-2.5 text-sm font-medium text-white bg-zinc-900 rounded-lg text-center hover:bg-zinc-800">
203
+ Get started
204
+ </Link>
205
  </>
206
  )}
207
  </div>