2026-10-23 11:43:49 -05:00
|
|
|
'use client';
|
|
|
|
|
|
2026-10-23 19:56:38 -07:00
|
|
|
import { Button } from '@/components/ui/Button';
|
2026-10-23 11:43:49 -05:00
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { usePathname } from 'next/navigation';
|
2026-10-23 19:56:38 -07:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2026-10-23 11:43:49 -05:00
|
|
|
|
|
|
|
|
interface NavbarProps {
|
|
|
|
|
onToggleSidebar?: () => void;
|
|
|
|
|
showSidebarToggle?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const Navbar: React.FC<NavbarProps> = ({
|
|
|
|
|
onToggleSidebar,
|
|
|
|
|
showSidebarToggle = false,
|
|
|
|
|
}) => {
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const saved = localStorage.getItem('datastack-theme') as 'dark' | 'light' | null;
|
2026-11-16 21:58:18 +06:00
|
|
|
const initial = saved === 'light' ? 'light' : 'dark';
|
2026-10-23 11:43:49 -05:00
|
|
|
setTheme(initial);
|
2026-11-16 21:58:18 +06:00
|
|
|
document.documentElement.classList.toggle('light', initial === 'light');
|
|
|
|
|
document.documentElement.classList.toggle('dark', initial === 'dark');
|
2026-10-23 11:43:49 -05:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const toggleTheme = () => {
|
|
|
|
|
const nextTheme = theme === 'dark' ? 'light' : 'dark';
|
|
|
|
|
setTheme(nextTheme);
|
|
|
|
|
localStorage.setItem('datastack-theme', nextTheme);
|
2026-11-16 21:58:18 +06:00
|
|
|
document.documentElement.classList.toggle('light', nextTheme === 'light');
|
|
|
|
|
document.documentElement.classList.toggle('dark', nextTheme === 'dark');
|
2026-10-23 11:43:49 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const isVcon = pathname?.startsWith('/vcon');
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-16 21:58:18 +06:00
|
|
|
<header className="h-11 shrink-0 bg-[var(--bg-activity)] border-b border-[var(--border)] px-3.5 sm:px-5 flex items-center justify-between gap-4 z-40 select-none">
|
2026-10-23 11:43:49 -05:00
|
|
|
{/* Left: Mobile hamburger + Brand */}
|
2026-11-16 21:58:18 +06:00
|
|
|
<div className="flex items-center gap-2.5 min-w-0">
|
2026-10-23 11:43:49 -05:00
|
|
|
{showSidebarToggle && (
|
2026-11-16 21:58:18 +06:00
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="icon"
|
|
|
|
|
size="icon"
|
|
|
|
|
icon="Menu"
|
2026-10-23 11:43:49 -05:00
|
|
|
onClick={onToggleSidebar}
|
2026-11-16 21:58:18 +06:00
|
|
|
className="lg:hidden h-7 w-7 shrink-0 border border-[var(--border)] bg-[var(--bg-elevated)]"
|
2026-10-23 11:43:49 -05:00
|
|
|
aria-label="Toggle Navigation"
|
2026-11-16 21:58:18 +06:00
|
|
|
title="Toggle Navigation"
|
|
|
|
|
/>
|
2026-10-23 11:43:49 -05:00
|
|
|
)}
|
|
|
|
|
|
2026-11-16 21:58:18 +06:00
|
|
|
<Link href="/" className="flex items-center gap-1.5 min-w-0 text-[13px] font-medium whitespace-nowrap shrink-0">
|
|
|
|
|
<span className="grid h-3.5 w-3.5 shrink-0 place-items-center bg-[var(--accent)]">
|
2026-10-23 19:56:38 -07:00
|
|
|
<span className="h-1.5 w-1.5 bg-[var(--bg)]" />
|
|
|
|
|
</span>
|
|
|
|
|
<span className="truncate text-[var(--text)]">
|
2026-10-23 11:43:49 -05:00
|
|
|
DataStack
|
|
|
|
|
</span>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Middle: Links */}
|
2026-11-16 21:58:18 +06:00
|
|
|
<nav className="hidden sm:flex items-center gap-5 text-[12px]">
|
2026-10-23 19:56:38 -07:00
|
|
|
{isVcon ? (
|
|
|
|
|
<>
|
2026-11-16 21:58:18 +06:00
|
|
|
<Link href="/" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">
|
2026-10-23 19:56:38 -07:00
|
|
|
Overview
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href="/vcon/dashboard"
|
2026-11-16 21:58:18 +06:00
|
|
|
className={`px-2 py-1.5 transition-colors border-b-2 whitespace-nowrap shrink-0 ${
|
|
|
|
|
pathname !== '/vcon/export'
|
|
|
|
|
? 'border-[var(--accent)] text-[var(--text)] font-medium'
|
|
|
|
|
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
|
|
|
|
|
}`}
|
2026-10-23 19:56:38 -07:00
|
|
|
>
|
2026-11-16 21:58:18 +06:00
|
|
|
Console
|
2026-10-23 19:56:38 -07:00
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href="/vcon/export"
|
2026-11-16 21:58:18 +06:00
|
|
|
className={`px-2 py-1.5 transition-colors border-b-2 whitespace-nowrap shrink-0 ${
|
2026-10-23 19:56:38 -07:00
|
|
|
pathname === '/vcon/export'
|
|
|
|
|
? 'border-[var(--accent)] text-[var(--text)] font-medium'
|
|
|
|
|
: 'border-transparent text-[var(--text-muted)] hover:text-[var(--text)]'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
2026-11-16 21:58:18 +06:00
|
|
|
Export
|
2026-10-23 19:56:38 -07:00
|
|
|
</Link>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
2026-11-16 21:58:18 +06:00
|
|
|
<Link href="#features" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">Features</Link>
|
|
|
|
|
<Link href="#sdk" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">SDK</Link>
|
|
|
|
|
<Link href="#about" className="text-[var(--text-muted)] hover:text-[var(--text)] whitespace-nowrap shrink-0">About</Link>
|
2026-10-23 19:56:38 -07:00
|
|
|
</>
|
|
|
|
|
)}
|
2026-10-23 11:43:49 -05:00
|
|
|
</nav>
|
|
|
|
|
|
2026-11-16 21:58:18 +06:00
|
|
|
{/* Right: Theme switcher or public CTA */}
|
2026-10-23 19:56:38 -07:00
|
|
|
<div className="flex items-center gap-2 shrink-0">
|
2026-11-16 21:58:18 +06:00
|
|
|
<Button
|
|
|
|
|
type="button"
|
|
|
|
|
variant="icon"
|
|
|
|
|
size="icon"
|
|
|
|
|
icon={theme === 'dark' ? 'Sun' : 'Moon'}
|
2026-10-23 11:43:49 -05:00
|
|
|
onClick={toggleTheme}
|
|
|
|
|
aria-label="Toggle Theme"
|
2026-11-16 21:58:18 +06:00
|
|
|
title="Toggle Theme"
|
|
|
|
|
className="h-7 w-7 border border-[var(--border)] bg-[var(--bg-elevated)]"
|
|
|
|
|
/>
|
2026-10-23 11:43:49 -05:00
|
|
|
|
|
|
|
|
{!isVcon && (
|
2026-10-23 19:56:38 -07:00
|
|
|
<Link href="#sdk">
|
2026-11-16 21:58:18 +06:00
|
|
|
<Button size="xs" variant="primary">
|
|
|
|
|
SDK Guide
|
2026-10-23 11:43:49 -05:00
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Navbar;
|