Spaces:
Sleeping
Sleeping
Commit ·
2d03bb5
1
Parent(s): 6814aac
Fixed the view
Browse files- frontend/src/components/Navbar.jsx +59 -127
- frontend/src/components/Sidebar.jsx +43 -40
frontend/src/components/Navbar.jsx
CHANGED
|
@@ -1,172 +1,104 @@
|
|
| 1 |
import React, { useState } from "react";
|
| 2 |
-
import {
|
| 3 |
import { useAuth } from "../context/AuthContext";
|
| 4 |
import { useLocation, useNavigate } from "react-router-dom";
|
| 5 |
|
| 6 |
-
export default function Navbar({ onRefresh }) {
|
| 7 |
const { user, logout } = useAuth();
|
| 8 |
const navigate = useNavigate();
|
| 9 |
-
const location = useLocation();
|
| 10 |
-
|
| 11 |
-
const [searchQuery, setSearchQuery] = useState("");
|
| 12 |
const [profileOpen, setProfileOpen] = useState(false);
|
| 13 |
-
const [
|
| 14 |
-
|
| 15 |
-
const navLinks = [
|
| 16 |
-
{ path: "/", label: "Dashboard" },
|
| 17 |
-
{ path: "/livetraffic", label: "Live Traffic" },
|
| 18 |
-
{ path: "/flow", label: "Flow Analyzer" },
|
| 19 |
-
{ path: "/alerts", label: "Alerts" },
|
| 20 |
-
{ path: "/threats", label: "Threat Intel" },
|
| 21 |
-
{ path: "/reports", label: "Reports" },
|
| 22 |
-
{ path: "/system", label: "System" },
|
| 23 |
-
{ path: "/mlmodels", label: "ML Models" },
|
| 24 |
-
];
|
| 25 |
-
|
| 26 |
-
const handleNavigate = (path) => {
|
| 27 |
-
navigate(path);
|
| 28 |
-
setMenuOpen(false); // Close mobile menu on click
|
| 29 |
-
};
|
| 30 |
|
| 31 |
return (
|
| 32 |
-
<nav className="
|
| 33 |
-
<div className="container mx-auto px-4 flex items-center justify-between
|
| 34 |
|
| 35 |
-
{/*
|
| 36 |
-
<
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
<
|
| 47 |
-
|
| 48 |
-
<div className="flex flex-col leading-tight text-left">
|
| 49 |
-
<span className="text-[12px] lg:text-sm font-semibold text-accent tracking-[0.15em] lg:tracking-[0.22em] uppercase">
|
| 50 |
-
ASTRAGUARD
|
| 51 |
-
</span>
|
| 52 |
-
<span className="text-[9px] lg:text-[11px] text-slate-400 uppercase tracking-[0.12em] lg:tracking-[0.18em]">
|
| 53 |
-
AI • NIDS
|
| 54 |
</span>
|
| 55 |
</div>
|
| 56 |
-
</button>
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
onClick={() => navigate(item.path)}
|
| 64 |
-
className={`px-3 py-1.5 rounded-full transition-all duration-200 whitespace-nowrap ${
|
| 65 |
-
location.pathname === item.path
|
| 66 |
-
? "text-accent bg-accent/10 shadow-[0_0_10px_rgba(0,229,255,0.35)]"
|
| 67 |
-
: "text-slate-300 hover:text-accent hover:bg-accent/10"
|
| 68 |
-
}`}
|
| 69 |
-
>
|
| 70 |
-
{item.label}
|
| 71 |
-
</button>
|
| 72 |
-
))}
|
| 73 |
</div>
|
| 74 |
|
| 75 |
-
{/*
|
| 76 |
-
<div className="
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
<input
|
| 81 |
type="text"
|
|
|
|
| 82 |
value={searchQuery}
|
| 83 |
onChange={(e) => setSearchQuery(e.target.value)}
|
| 84 |
-
|
| 85 |
-
className="bg-transparent text-xs text-slate-200 placeholder:text-slate-500 focus:outline-none w-24 lg:w-40"
|
| 86 |
/>
|
| 87 |
</div>
|
| 88 |
|
| 89 |
-
{/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
<div className="relative">
|
| 91 |
<button
|
| 92 |
onClick={() => setProfileOpen(!profileOpen)}
|
| 93 |
-
className="flex items-center gap-
|
| 94 |
>
|
| 95 |
-
<div className="w-
|
| 96 |
-
<User size={
|
| 97 |
</div>
|
| 98 |
-
<div className="hidden
|
| 99 |
-
<span className="text-[10px] text-slate-
|
| 100 |
-
|
| 101 |
-
</span>
|
| 102 |
-
<span className="text-xs text-accent font-medium truncate w-full text-left">
|
| 103 |
-
{user?.displayName || "Analyst"}
|
| 104 |
-
</span>
|
| 105 |
</div>
|
| 106 |
-
<ChevronDown size={14} className="text-slate-
|
| 107 |
</button>
|
| 108 |
|
| 109 |
{profileOpen && (
|
| 110 |
-
<div className="absolute right-0 mt-3 w-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
{onRefresh && (
|
| 112 |
-
<>
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
}}
|
| 118 |
-
className="w-full flex items-center gap-3 px-4 py-2.5 hover:bg-accent/10 text-slate-200 transition"
|
| 119 |
-
>
|
| 120 |
-
<RefreshCcw size={14} className="text-accent" />
|
| 121 |
-
<span>Reload data</span>
|
| 122 |
-
</button>
|
| 123 |
-
<div className="border-t border-slate-700/60 my-1" />
|
| 124 |
-
</>
|
| 125 |
)}
|
| 126 |
|
| 127 |
-
<button
|
| 128 |
-
|
| 129 |
-
className="w-full flex items-center gap-3 px-4 py-2.5 hover:bg-red-500/15 text-red-300 transition"
|
| 130 |
-
>
|
| 131 |
<LogOut size={14} />
|
| 132 |
-
<span>
|
| 133 |
</button>
|
| 134 |
</div>
|
| 135 |
)}
|
| 136 |
</div>
|
| 137 |
</div>
|
| 138 |
</div>
|
| 139 |
-
|
| 140 |
-
{/* MOBILE MENU DRAWER */}
|
| 141 |
-
{menuOpen && (
|
| 142 |
-
<div className="lg:hidden absolute top-[100%] left-0 w-full bg-[#020617]/95 border-b border-accent/20 backdrop-blur-2xl animate-in slide-in-from-top duration-300 overflow-hidden shadow-2xl">
|
| 143 |
-
<div className="flex flex-col p-4 gap-2">
|
| 144 |
-
{navLinks.map((item, i) => (
|
| 145 |
-
<button
|
| 146 |
-
key={i}
|
| 147 |
-
onClick={() => handleNavigate(item.path)}
|
| 148 |
-
className={`flex items-center px-4 py-3 rounded-xl transition-all ${
|
| 149 |
-
location.pathname === item.path
|
| 150 |
-
? "text-accent bg-accent/10 border border-accent/20 shadow-neon-sm"
|
| 151 |
-
: "text-slate-300 hover:text-accent hover:bg-accent/5"
|
| 152 |
-
}`}
|
| 153 |
-
>
|
| 154 |
-
{item.label}
|
| 155 |
-
</button>
|
| 156 |
-
))}
|
| 157 |
-
|
| 158 |
-
{/* Mobile Search - shown only in menu */}
|
| 159 |
-
<div className="flex sm:hidden items-center gap-3 px-4 py-3 mt-2 rounded-xl border border-accent/20 bg-white/5">
|
| 160 |
-
<Search size={16} className="text-accent" />
|
| 161 |
-
<input
|
| 162 |
-
type="text"
|
| 163 |
-
placeholder="Search systems..."
|
| 164 |
-
className="bg-transparent text-sm text-slate-200 focus:outline-none w-full"
|
| 165 |
-
/>
|
| 166 |
-
</div>
|
| 167 |
-
</div>
|
| 168 |
-
</div>
|
| 169 |
-
)}
|
| 170 |
</nav>
|
| 171 |
);
|
| 172 |
}
|
|
|
|
| 1 |
import React, { useState } from "react";
|
| 2 |
+
import { Search, User, ChevronDown, RefreshCcw, LogOut, Menu, Bell, ShieldCheck } from "lucide-react";
|
| 3 |
import { useAuth } from "../context/AuthContext";
|
| 4 |
import { useLocation, useNavigate } from "react-router-dom";
|
| 5 |
|
| 6 |
+
export default function Navbar({ onRefresh, setIsMobileOpen }) {
|
| 7 |
const { user, logout } = useAuth();
|
| 8 |
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
| 9 |
const [profileOpen, setProfileOpen] = useState(false);
|
| 10 |
+
const [searchQuery, setSearchQuery] = useState("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
return (
|
| 13 |
+
<nav className="fixed top-0 left-0 right-0 lg:left-0 z-[100] border-b border-cyan-500/10 backdrop-blur-md bg-[#020617]/80 py-3 shadow-[0_4px_30px_rgba(0,0,0,0.5)]">
|
| 14 |
+
<div className="container mx-auto px-4 lg:px-8 flex items-center justify-between">
|
| 15 |
|
| 16 |
+
{/* LEFT SECTION: Mobile Toggle & Brand */}
|
| 17 |
+
<div className="flex items-center gap-4">
|
| 18 |
+
{/* Mobile Menu Toggle: This triggers the Sidebar */}
|
| 19 |
+
<button
|
| 20 |
+
onClick={() => setIsMobileOpen(true)}
|
| 21 |
+
className="lg:hidden p-2 rounded-lg bg-cyan-500/5 border border-cyan-500/20 text-cyan-400 hover:bg-cyan-500/10 transition-all"
|
| 22 |
+
>
|
| 23 |
+
<Menu size={20} />
|
| 24 |
+
</button>
|
| 25 |
|
| 26 |
+
{/* Brand: Visible on Mobile, hidden on Laptop (since sidebar has it) */}
|
| 27 |
+
<div className="flex lg:hidden items-center gap-2">
|
| 28 |
+
<ShieldCheck size={20} className="text-cyan-500" />
|
| 29 |
+
<span className="text-sm font-black text-white tracking-tighter uppercase">
|
| 30 |
+
ASTRA<span className="text-cyan-500">GUARD</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</span>
|
| 32 |
</div>
|
|
|
|
| 33 |
|
| 34 |
+
{/* Desktop Status Indicator */}
|
| 35 |
+
<div className="hidden lg:flex items-center gap-3 px-4 py-1.5 rounded-full bg-emerald-500/5 border border-emerald-500/20 ml-64">
|
| 36 |
+
<span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
|
| 37 |
+
<span className="text-[10px] font-mono text-emerald-500 uppercase tracking-widest font-bold">System Online // Node_01</span>
|
| 38 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
</div>
|
| 40 |
|
| 41 |
+
{/* RIGHT SECTION: Search & Profile */}
|
| 42 |
+
<div className="flex items-center gap-3 lg:gap-6">
|
| 43 |
+
|
| 44 |
+
{/* Enhanced Search Bar */}
|
| 45 |
+
<div className="hidden md:flex items-center gap-2 px-4 py-2 rounded-lg border border-white/5 bg-white/5 focus-within:border-cyan-500/50 transition-all group">
|
| 46 |
+
<Search size={14} className="text-slate-500 group-focus-within:text-cyan-400" />
|
| 47 |
<input
|
| 48 |
type="text"
|
| 49 |
+
placeholder="QUICK SEARCH..."
|
| 50 |
value={searchQuery}
|
| 51 |
onChange={(e) => setSearchQuery(e.target.value)}
|
| 52 |
+
className="bg-transparent text-[11px] font-mono text-slate-200 placeholder:text-slate-600 focus:outline-none w-32 lg:w-64"
|
|
|
|
| 53 |
/>
|
| 54 |
</div>
|
| 55 |
|
| 56 |
+
{/* Notifications */}
|
| 57 |
+
<button className="relative p-2 text-slate-400 hover:text-cyan-400 transition-colors">
|
| 58 |
+
<Bell size={18} />
|
| 59 |
+
<span className="absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-rose-500 rounded-full border border-[#020617]"></span>
|
| 60 |
+
</button>
|
| 61 |
+
|
| 62 |
+
{/* Profile Dropdown */}
|
| 63 |
<div className="relative">
|
| 64 |
<button
|
| 65 |
onClick={() => setProfileOpen(!profileOpen)}
|
| 66 |
+
className="flex items-center gap-3 p-1 pr-3 rounded-full border border-white/10 bg-white/5 hover:bg-white/10 transition-all"
|
| 67 |
>
|
| 68 |
+
<div className="w-8 h-8 rounded-full border border-cyan-500/30 bg-cyan-500/10 flex items-center justify-center">
|
| 69 |
+
<User size={16} className="text-cyan-400" />
|
| 70 |
</div>
|
| 71 |
+
<div className="hidden sm:flex flex-col items-start">
|
| 72 |
+
<span className="text-[10px] text-slate-500 font-bold uppercase leading-none mb-1">Operator</span>
|
| 73 |
+
<span className="text-xs text-white font-medium">{user?.displayName?.split(' ')[0] || "Analyst"}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
</div>
|
| 75 |
+
<ChevronDown size={14} className="text-slate-500" />
|
| 76 |
</button>
|
| 77 |
|
| 78 |
{profileOpen && (
|
| 79 |
+
<div className="absolute right-0 mt-3 w-48 rounded-xl border border-white/10 bg-[#0b1120] shadow-[0_10px_40px_rgba(0,0,0,0.7)] py-2 text-sm z-[110] animate-in fade-in zoom-in duration-200">
|
| 80 |
+
<div className="px-4 py-2 border-b border-white/5 mb-2">
|
| 81 |
+
<p className="text-[10px] text-slate-500 font-mono">AUTH_LEVEL: ADMIN</p>
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
{onRefresh && (
|
| 85 |
+
<button onClick={() => { onRefresh(); setProfileOpen(false); }}
|
| 86 |
+
className="w-full flex items-center gap-3 px-4 py-2.5 hover:bg-cyan-500/10 text-slate-300 transition-colors group">
|
| 87 |
+
<RefreshCcw size={14} className="text-cyan-500 group-hover:rotate-180 transition-transform duration-500" />
|
| 88 |
+
<span>Sync Database</span>
|
| 89 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
)}
|
| 91 |
|
| 92 |
+
<button onClick={() => logout()}
|
| 93 |
+
className="w-full flex items-center gap-3 px-4 py-2.5 hover:bg-rose-500/10 text-rose-400 transition-colors">
|
|
|
|
|
|
|
| 94 |
<LogOut size={14} />
|
| 95 |
+
<span>Terminate Session</span>
|
| 96 |
</button>
|
| 97 |
</div>
|
| 98 |
)}
|
| 99 |
</div>
|
| 100 |
</div>
|
| 101 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</nav>
|
| 103 |
);
|
| 104 |
}
|
frontend/src/components/Sidebar.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import { NavLink } from "react-router-dom";
|
|
| 4 |
import {
|
| 5 |
Activity, AlertTriangle, FileText, Info, Settings, TrafficCone,
|
| 6 |
MonitorCog, GitBranchMinus, BrickWallShield, ChevronLeft, ChevronRight,
|
| 7 |
-
MoonStar, LayoutDashboard, X
|
| 8 |
} from "lucide-react";
|
| 9 |
|
| 10 |
export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMobileOpen }) {
|
|
@@ -12,7 +12,7 @@ export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMo
|
|
| 12 |
const canvasRef = useRef(null);
|
| 13 |
const [time, setTime] = useState("");
|
| 14 |
|
| 15 |
-
//
|
| 16 |
useEffect(() => {
|
| 17 |
const tick = () => {
|
| 18 |
const now = new Date();
|
|
@@ -23,7 +23,7 @@ export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMo
|
|
| 23 |
return () => clearInterval(id);
|
| 24 |
}, []);
|
| 25 |
|
| 26 |
-
//
|
| 27 |
useEffect(() => {
|
| 28 |
const canvas = canvasRef.current;
|
| 29 |
const sidebar = sidebarRef.current;
|
|
@@ -53,8 +53,8 @@ export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMo
|
|
| 53 |
for (let i = 0; i < COUNT; i++) {
|
| 54 |
particles.push({
|
| 55 |
x: Math.random() * width, y: Math.random() * height,
|
| 56 |
-
vx: (Math.random() - 0.5) * 0.
|
| 57 |
-
size: Math.random() *
|
| 58 |
});
|
| 59 |
}
|
| 60 |
}
|
|
@@ -67,7 +67,7 @@ export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMo
|
|
| 67 |
if (p.y < 0 || p.y > height) p.vy *= -1;
|
| 68 |
ctx.beginPath();
|
| 69 |
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
| 70 |
-
ctx.fillStyle = "rgba(0, 230, 255, 0.
|
| 71 |
ctx.fill();
|
| 72 |
}
|
| 73 |
rafId = requestAnimationFrame(step);
|
|
@@ -77,7 +77,7 @@ export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMo
|
|
| 77 |
ro.observe(sidebar);
|
| 78 |
resize(); step();
|
| 79 |
return () => { if (rafId) cancelAnimationFrame(rafId); ro.disconnect(); };
|
| 80 |
-
}, [collapsed]);
|
| 81 |
|
| 82 |
const navItems = [
|
| 83 |
{ to: "/", label: "Dashboard", icon: <LayoutDashboard size={18} /> },
|
|
@@ -95,86 +95,89 @@ export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMo
|
|
| 95 |
|
| 96 |
return (
|
| 97 |
<>
|
| 98 |
-
{/* MOBILE OVERLAY
|
| 99 |
{isMobileOpen && (
|
| 100 |
<div
|
| 101 |
-
className="fixed inset-0 bg-black/
|
| 102 |
onClick={() => setIsMobileOpen(false)}
|
| 103 |
/>
|
| 104 |
)}
|
| 105 |
|
| 106 |
<aside
|
| 107 |
ref={sidebarRef}
|
| 108 |
-
className={`fixed top-0 left-0 h-screen z-
|
| 109 |
-
border-r
|
| 110 |
${collapsed ? "w-20" : "w-64"}
|
| 111 |
-
|
| 112 |
-
${isMobileOpen ? "translate-x-0" : "-translate-x-full lg:translate-x-0"}
|
| 113 |
`}
|
| 114 |
>
|
| 115 |
-
<canvas ref={canvasRef} className="pointer-events-none absolute inset-0 -z-10" />
|
| 116 |
|
| 117 |
{/* HEADER */}
|
| 118 |
-
<div className="p-
|
| 119 |
-
<div className="flex items-center gap-
|
| 120 |
-
<
|
|
|
|
|
|
|
| 121 |
{(!collapsed || isMobileOpen) && (
|
| 122 |
-
<div>
|
| 123 |
-
<div className="text-
|
| 124 |
-
<div className="text-[
|
| 125 |
</div>
|
| 126 |
)}
|
| 127 |
</div>
|
| 128 |
|
| 129 |
-
{/* Close button -
|
| 130 |
-
<button className="lg:hidden text-slate-400" onClick={() => setIsMobileOpen(false)}>
|
| 131 |
<X size={20} />
|
| 132 |
</button>
|
| 133 |
</div>
|
| 134 |
|
| 135 |
{/* NAVIGATION */}
|
| 136 |
-
<nav className="flex-1 p-3 overflow-y-auto overflow-x-hidden custom-scroll space-y-1">
|
| 137 |
{navItems.map(({ to, label, icon }) => (
|
| 138 |
<NavLink
|
| 139 |
key={to}
|
| 140 |
to={to}
|
| 141 |
-
onClick={() => setIsMobileOpen(false)}
|
| 142 |
className={({ isActive }) => `
|
| 143 |
-
group flex items-center gap-3 px-3 py-
|
| 144 |
${isActive
|
| 145 |
-
? "bg-
|
| 146 |
-
: "text-slate-
|
| 147 |
`}
|
| 148 |
>
|
| 149 |
-
<div className="shrink-0">{icon}</div>
|
| 150 |
-
{(!collapsed || isMobileOpen) && <span className="truncate font-medium">{label}</span>}
|
|
|
|
|
|
|
|
|
|
| 151 |
</NavLink>
|
| 152 |
))}
|
| 153 |
</nav>
|
| 154 |
|
| 155 |
{/* FOOTER */}
|
| 156 |
-
<div className="p-
|
| 157 |
-
<div className="flex flex-col gap-1">
|
| 158 |
{(!collapsed || isMobileOpen) ? (
|
| 159 |
-
<>
|
| 160 |
-
<div className="text-[
|
| 161 |
-
<div className="text-[
|
| 162 |
-
</>
|
| 163 |
) : (
|
| 164 |
-
<div className="text-[
|
| 165 |
)}
|
| 166 |
</div>
|
| 167 |
</div>
|
| 168 |
|
| 169 |
-
{/* DESKTOP COLLAPSE TOGGLE
|
| 170 |
<button
|
| 171 |
onClick={() => setCollapsed(!collapsed)}
|
| 172 |
-
className="hidden lg:flex absolute right-[-
|
| 173 |
>
|
| 174 |
-
{collapsed ? <ChevronRight size={
|
| 175 |
</button>
|
| 176 |
</aside>
|
| 177 |
</>
|
| 178 |
);
|
| 179 |
}
|
| 180 |
-
|
|
|
|
| 4 |
import {
|
| 5 |
Activity, AlertTriangle, FileText, Info, Settings, TrafficCone,
|
| 6 |
MonitorCog, GitBranchMinus, BrickWallShield, ChevronLeft, ChevronRight,
|
| 7 |
+
MoonStar, LayoutDashboard, X
|
| 8 |
} from "lucide-react";
|
| 9 |
|
| 10 |
export default function Sidebar({ collapsed, setCollapsed, isMobileOpen, setIsMobileOpen }) {
|
|
|
|
| 12 |
const canvasRef = useRef(null);
|
| 13 |
const [time, setTime] = useState("");
|
| 14 |
|
| 15 |
+
// System Clock
|
| 16 |
useEffect(() => {
|
| 17 |
const tick = () => {
|
| 18 |
const now = new Date();
|
|
|
|
| 23 |
return () => clearInterval(id);
|
| 24 |
}, []);
|
| 25 |
|
| 26 |
+
// Neural Network Particle Animation
|
| 27 |
useEffect(() => {
|
| 28 |
const canvas = canvasRef.current;
|
| 29 |
const sidebar = sidebarRef.current;
|
|
|
|
| 53 |
for (let i = 0; i < COUNT; i++) {
|
| 54 |
particles.push({
|
| 55 |
x: Math.random() * width, y: Math.random() * height,
|
| 56 |
+
vx: (Math.random() - 0.5) * 0.4, vy: (Math.random() - 0.5) * 0.4,
|
| 57 |
+
size: Math.random() * 2 + 0.5,
|
| 58 |
});
|
| 59 |
}
|
| 60 |
}
|
|
|
|
| 67 |
if (p.y < 0 || p.y > height) p.vy *= -1;
|
| 68 |
ctx.beginPath();
|
| 69 |
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
| 70 |
+
ctx.fillStyle = "rgba(0, 230, 255, 0.25)"; // Softer particles
|
| 71 |
ctx.fill();
|
| 72 |
}
|
| 73 |
rafId = requestAnimationFrame(step);
|
|
|
|
| 77 |
ro.observe(sidebar);
|
| 78 |
resize(); step();
|
| 79 |
return () => { if (rafId) cancelAnimationFrame(rafId); ro.disconnect(); };
|
| 80 |
+
}, [collapsed]); // Re-run when collapsed changes to fix canvas scale
|
| 81 |
|
| 82 |
const navItems = [
|
| 83 |
{ to: "/", label: "Dashboard", icon: <LayoutDashboard size={18} /> },
|
|
|
|
| 95 |
|
| 96 |
return (
|
| 97 |
<>
|
| 98 |
+
{/* MOBILE OVERLAY */}
|
| 99 |
{isMobileOpen && (
|
| 100 |
<div
|
| 101 |
+
className="fixed inset-0 bg-black/70 backdrop-blur-md z-[150] lg:hidden"
|
| 102 |
onClick={() => setIsMobileOpen(false)}
|
| 103 |
/>
|
| 104 |
)}
|
| 105 |
|
| 106 |
<aside
|
| 107 |
ref={sidebarRef}
|
| 108 |
+
className={`fixed top-0 left-0 h-screen z-[160] transition-all duration-300 ease-in-out flex flex-col
|
| 109 |
+
border-r border-cyan-500/20 bg-[#020617]/95 backdrop-blur-2xl
|
| 110 |
${collapsed ? "w-20" : "w-64"}
|
| 111 |
+
${isMobileOpen ? "translate-x-0 shadow-[20px_0_50px_rgba(0,0,0,0.8)]" : "-translate-x-full lg:translate-x-0"}
|
|
|
|
| 112 |
`}
|
| 113 |
>
|
| 114 |
+
<canvas ref={canvasRef} className="pointer-events-none absolute inset-0 -z-10 opacity-40" />
|
| 115 |
|
| 116 |
{/* HEADER */}
|
| 117 |
+
<div className="p-6 border-b border-white/5 flex items-center justify-between">
|
| 118 |
+
<div className="flex items-center gap-3">
|
| 119 |
+
<div className="w-8 h-8 rounded-lg bg-cyan-500/10 border border-cyan-500/40 flex items-center justify-center shadow-[0_0_15px_rgba(6,182,212,0.2)]">
|
| 120 |
+
<span className="text-[14px] font-extrabold text-cyan-400">⚡</span>
|
| 121 |
+
</div>
|
| 122 |
{(!collapsed || isMobileOpen) && (
|
| 123 |
+
<div className="animate-in fade-in duration-500">
|
| 124 |
+
<div className="text-lg font-black text-white tracking-tighter uppercase">Astra<span className="text-cyan-500">Guard</span></div>
|
| 125 |
+
<div className="text-[9px] text-cyan-700 font-mono font-bold uppercase tracking-widest leading-none">AI • SHIELD v1.0</div>
|
| 126 |
</div>
|
| 127 |
)}
|
| 128 |
</div>
|
| 129 |
|
| 130 |
+
{/* Close button - Mobile */}
|
| 131 |
+
<button className="lg:hidden text-slate-400 hover:text-white transition-colors" onClick={() => setIsMobileOpen(false)}>
|
| 132 |
<X size={20} />
|
| 133 |
</button>
|
| 134 |
</div>
|
| 135 |
|
| 136 |
{/* NAVIGATION */}
|
| 137 |
+
<nav className="flex-1 p-3 overflow-y-auto overflow-x-hidden custom-scroll space-y-1 mt-4">
|
| 138 |
{navItems.map(({ to, label, icon }) => (
|
| 139 |
<NavLink
|
| 140 |
key={to}
|
| 141 |
to={to}
|
| 142 |
+
onClick={() => setIsMobileOpen(false)}
|
| 143 |
className={({ isActive }) => `
|
| 144 |
+
group relative flex items-center gap-3 px-3 py-3 rounded-xl transition-all duration-200
|
| 145 |
${isActive
|
| 146 |
+
? "bg-cyan-500/10 border border-cyan-500/20 text-cyan-400"
|
| 147 |
+
: "text-slate-400 hover:bg-white/5 hover:text-white"}
|
| 148 |
`}
|
| 149 |
>
|
| 150 |
+
<div className="shrink-0 transition-transform group-hover:scale-110">{icon}</div>
|
| 151 |
+
{(!collapsed || isMobileOpen) && <span className="truncate font-medium tracking-tight text-xs uppercase font-mono">{label}</span>}
|
| 152 |
+
|
| 153 |
+
{/* Active Indicator Dot */}
|
| 154 |
+
<NavLink to={to} className={({ isActive }) => isActive ? "absolute right-3 w-1 h-1 rounded-full bg-cyan-400 shadow-[0_0_8px_rgba(6,182,212,1)]" : "hidden"} />
|
| 155 |
</NavLink>
|
| 156 |
))}
|
| 157 |
</nav>
|
| 158 |
|
| 159 |
{/* FOOTER */}
|
| 160 |
+
<div className="p-6 border-t border-white/5 bg-black/40">
|
| 161 |
+
<div className="flex flex-col gap-1.5">
|
| 162 |
{(!collapsed || isMobileOpen) ? (
|
| 163 |
+
<div className="animate-in fade-in slide-in-from-bottom-2 duration-700">
|
| 164 |
+
<div className="text-[10px] text-cyan-500 font-mono tracking-widest font-bold">{time}</div>
|
| 165 |
+
<div className="text-[8px] text-slate-600 uppercase tracking-widest font-mono">System Localized // IN</div>
|
| 166 |
+
</div>
|
| 167 |
) : (
|
| 168 |
+
<div className="text-[8px] text-slate-700 font-mono text-center">v1.0</div>
|
| 169 |
)}
|
| 170 |
</div>
|
| 171 |
</div>
|
| 172 |
|
| 173 |
+
{/* DESKTOP COLLAPSE TOGGLE */}
|
| 174 |
<button
|
| 175 |
onClick={() => setCollapsed(!collapsed)}
|
| 176 |
+
className="hidden lg:flex absolute right-[-12px] top-24 w-6 h-6 rounded-full bg-[#020617] border border-cyan-500/30 text-cyan-500 items-center justify-center hover:bg-cyan-500 hover:text-black transition-all shadow-[0_0_10px_rgba(0,0,0,0.5)]"
|
| 177 |
>
|
| 178 |
+
{collapsed ? <ChevronRight size={12} /> : <ChevronLeft size={12} />}
|
| 179 |
</button>
|
| 180 |
</aside>
|
| 181 |
</>
|
| 182 |
);
|
| 183 |
}
|
|
|