Upload src/components/TopBar.tsx with huggingface_hub
Browse files- src/components/TopBar.tsx +64 -0
src/components/TopBar.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { KeyRound, CheckCircle2, XCircle, Menu } from "lucide-react";
|
| 2 |
+
import { useApiKey } from "../context/ApiKeyContext";
|
| 3 |
+
import { Link } from "react-router-dom";
|
| 4 |
+
|
| 5 |
+
export default function TopBar({ onMenuClick }: { onMenuClick?: () => void }) {
|
| 6 |
+
const { apiKeys, activeKeyId, setActiveKeyId, activeKey } = useApiKey();
|
| 7 |
+
|
| 8 |
+
return (
|
| 9 |
+
<header className="h-16 border-b border-white/5 bg-zinc-950/40 backdrop-blur-xl flex items-center justify-between px-4 md:px-6 shrink-0 relative z-20 shadow-[0_4px_24px_-4px_rgba(6,10,12,0.65)]">
|
| 10 |
+
<div className="flex items-center gap-4">
|
| 11 |
+
{onMenuClick && (
|
| 12 |
+
<button
|
| 13 |
+
onClick={onMenuClick}
|
| 14 |
+
className="p-2 -ml-2 text-zinc-400 hover:text-zinc-200 md:hidden"
|
| 15 |
+
aria-label="Open menu"
|
| 16 |
+
>
|
| 17 |
+
<Menu className="w-5 h-5" />
|
| 18 |
+
</button>
|
| 19 |
+
)}
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
<div className="flex items-center gap-2 md:gap-4">
|
| 23 |
+
<div className="flex items-center gap-2 hidden sm:flex">
|
| 24 |
+
{activeKey ? (
|
| 25 |
+
<div className="flex items-center gap-1.5 text-[11px] font-medium text-emerald-300 bg-emerald-500/10 border border-emerald-500/20 px-2.5 py-1 rounded-full shadow-[inset_0_1px_1px_rgba(246,248,242,0.05)]">
|
| 26 |
+
<CheckCircle2 className="w-3.5 h-3.5" />
|
| 27 |
+
API Connected
|
| 28 |
+
</div>
|
| 29 |
+
) : (
|
| 30 |
+
<div className="flex items-center gap-1.5 text-[11px] font-medium text-rose-300 bg-rose-500/10 border border-rose-500/20 px-2.5 py-1 rounded-full shadow-[inset_0_1px_1px_rgba(246,248,242,0.05)]">
|
| 31 |
+
<XCircle className="w-3.5 h-3.5" />
|
| 32 |
+
API Key Missing
|
| 33 |
+
</div>
|
| 34 |
+
)}
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
<div className="h-5 w-px bg-white/10" />
|
| 38 |
+
|
| 39 |
+
<div className="flex items-center gap-3">
|
| 40 |
+
<div className="w-6 h-6 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shadow-[inset_0_1px_1px_rgba(246,248,242,0.05)]">
|
| 41 |
+
<KeyRound className="w-3.5 h-3.5 text-zinc-400" />
|
| 42 |
+
</div>
|
| 43 |
+
<select
|
| 44 |
+
value={activeKeyId || ""}
|
| 45 |
+
onChange={(e) => setActiveKeyId(e.target.value)}
|
| 46 |
+
className="bg-white/5 border border-white/10 rounded-md py-1.5 pl-3 pr-8 text-xs text-zinc-200 focus:outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 w-32 md:w-48 shadow-[inset_0_1px_1px_rgba(246,248,242,0.05)] transition-all hover:bg-white/10"
|
| 47 |
+
>
|
| 48 |
+
<option value="" disabled className="bg-zinc-900">Select API Key...</option>
|
| 49 |
+
{apiKeys.map((key) => (
|
| 50 |
+
<option key={key.id} value={key.id} className="bg-zinc-900">
|
| 51 |
+
{key.name}
|
| 52 |
+
</option>
|
| 53 |
+
))}
|
| 54 |
+
</select>
|
| 55 |
+
{apiKeys.length === 0 && (
|
| 56 |
+
<Link to="/settings" className="text-xs text-indigo-400 hover:text-indigo-300 font-medium">
|
| 57 |
+
Add Key
|
| 58 |
+
</Link>
|
| 59 |
+
)}
|
| 60 |
+
</div>
|
| 61 |
+
</div>
|
| 62 |
+
</header>
|
| 63 |
+
);
|
| 64 |
+
}
|