Create src/components/Sidebar.tsx
Browse files- src/components/Sidebar.tsx +116 -0
src/components/Sidebar.tsx
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState, createContext, useContext } from 'react';
|
| 2 |
+
import {
|
| 3 |
+
ChevronFirst,
|
| 4 |
+
ChevronLast,
|
| 5 |
+
Activity,
|
| 6 |
+
Beaker,
|
| 7 |
+
BookOpen,
|
| 8 |
+
ShieldCheck,
|
| 9 |
+
Settings,
|
| 10 |
+
LogOut,
|
| 11 |
+
UserCircle
|
| 12 |
+
} from 'lucide-react';
|
| 13 |
+
import { useOncologyStore } from '../store/useOncologyStore';
|
| 14 |
+
|
| 15 |
+
const SidebarContext = createContext({ expanded: true });
|
| 16 |
+
|
| 17 |
+
const Sidebar = () => {
|
| 18 |
+
const [expanded, setExpanded] = useState(true);
|
| 19 |
+
const { mutation } = useOncologyStore();
|
| 20 |
+
|
| 21 |
+
return (
|
| 22 |
+
<aside className="h-screen sticky top-0">
|
| 23 |
+
<nav className={`h-full flex flex-col bg-white border-r border-gray-200 shadow-sm transition-all ${expanded ? 'w-64' : 'w-20'}`}>
|
| 24 |
+
|
| 25 |
+
{/* Header: Branding & Toggle */}
|
| 26 |
+
<div className="p-4 pb-2 flex justify-between items-center">
|
| 27 |
+
<div className={`flex items-center gap-2 overflow-hidden transition-all ${expanded ? 'w-40' : 'w-0'}`}>
|
| 28 |
+
<div className="flex-shrink-0 w-9 h-9 bg-blue-600 rounded-xl flex items-center justify-center shadow-lg shadow-blue-200">
|
| 29 |
+
<ShieldCheck className="text-white" size={20} />
|
| 30 |
+
</div>
|
| 31 |
+
<div className="flex flex-col leading-tight">
|
| 32 |
+
<span className="font-bold text-gray-800 text-sm tracking-tight">ABYSSINIA</span>
|
| 33 |
+
<span className="text-[10px] font-medium text-blue-600 uppercase tracking-widest">OncoOS V13</span>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
<button
|
| 37 |
+
onClick={() => setExpanded(curr => !curr)}
|
| 38 |
+
className="p-2 rounded-lg bg-gray-50 hover:bg-gray-100 text-gray-500 transition-colors"
|
| 39 |
+
>
|
| 40 |
+
{expanded ? <ChevronFirst size={20}/> : <ChevronLast size={20}/>}
|
| 41 |
+
</button>
|
| 42 |
+
</div>
|
| 43 |
+
|
| 44 |
+
<SidebarContext.Provider value={{ expanded }}>
|
| 45 |
+
<ul className="flex-1 px-3 mt-6 space-y-2">
|
| 46 |
+
<SidebarItem icon={<Activity size={20}/>} text="Clinical Hub" active />
|
| 47 |
+
<SidebarItem icon={<Beaker size={20}/>} text="Trial Matching" alert />
|
| 48 |
+
<SidebarItem icon={<BookOpen size={20}/>} text="Evidence Library" />
|
| 49 |
+
|
| 50 |
+
<hr className="my-4 border-gray-100" />
|
| 51 |
+
|
| 52 |
+
<p className={`text-[10px] font-bold text-gray-400 uppercase px-3 mb-2 transition-all ${!expanded && 'opacity-0'}`}>
|
| 53 |
+
System
|
| 54 |
+
</p>
|
| 55 |
+
<SidebarItem icon={<Settings size={20}/>} text="Protocols" />
|
| 56 |
+
</ul>
|
| 57 |
+
</SidebarContext.Provider>
|
| 58 |
+
|
| 59 |
+
{/* Footer: User Profile */}
|
| 60 |
+
<div className="border-t border-gray-100 p-3 bg-gray-50/50">
|
| 61 |
+
<div className="flex items-center group cursor-pointer p-2 rounded-xl hover:bg-gray-100 transition-colors">
|
| 62 |
+
<div className="w-10 h-10 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center font-bold">
|
| 63 |
+
DR
|
| 64 |
+
</div>
|
| 65 |
+
<div className={`flex justify-between items-center overflow-hidden transition-all ${expanded ? "w-40 ml-3" : "w-0"}`}>
|
| 66 |
+
<div className="leading-4">
|
| 67 |
+
<h4 className="text-xs font-semibold text-gray-800">Dr. Researcher</h4>
|
| 68 |
+
<p className="text-[10px] text-gray-500">Oncology Lead</p>
|
| 69 |
+
</div>
|
| 70 |
+
<LogOut size={16} className="text-gray-400 hover:text-red-500" />
|
| 71 |
+
</div>
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
</nav>
|
| 75 |
+
</aside>
|
| 76 |
+
);
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
// Sub-component for individual items
|
| 80 |
+
const SidebarItem = ({ icon, text, active = false, alert = false }: any) => {
|
| 81 |
+
const { expanded } = useContext(SidebarContext);
|
| 82 |
+
|
| 83 |
+
return (
|
| 84 |
+
<li className={`
|
| 85 |
+
relative flex items-center py-2.5 px-3 my-1
|
| 86 |
+
font-medium rounded-xl cursor-pointer
|
| 87 |
+
transition-all group
|
| 88 |
+
${active
|
| 89 |
+
? "bg-blue-50 text-blue-600"
|
| 90 |
+
: "text-gray-500 hover:bg-gray-50 hover:text-gray-700"
|
| 91 |
+
}
|
| 92 |
+
`}>
|
| 93 |
+
{icon}
|
| 94 |
+
<span className={`overflow-hidden transition-all ${expanded ? "w-40 ml-3" : "w-0 opacity-0"}`}>
|
| 95 |
+
{text}
|
| 96 |
+
</span>
|
| 97 |
+
{alert && (
|
| 98 |
+
<div className={`absolute right-2 w-2 h-2 rounded-full bg-blue-500 ${!expanded && "top-2"}`} />
|
| 99 |
+
)}
|
| 100 |
+
|
| 101 |
+
{!expanded && (
|
| 102 |
+
<div className={`
|
| 103 |
+
absolute left-full rounded-md px-2 py-1 ml-6
|
| 104 |
+
bg-gray-900 text-white text-xs
|
| 105 |
+
invisible opacity-0 -translate-x-3 transition-all
|
| 106 |
+
group-hover:visible group-hover:opacity-100 group-hover:translate-x-0
|
| 107 |
+
z-50 whitespace-nowrap
|
| 108 |
+
`}>
|
| 109 |
+
{text}
|
| 110 |
+
</div>
|
| 111 |
+
)}
|
| 112 |
+
</li>
|
| 113 |
+
);
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
export default Sidebar;
|