File size: 8,873 Bytes
527d436 bbcfe72 527d436 bbcfe72 527d436 bbcfe72 11b240f bbcfe72 527d436 bbcfe72 11b240f bbcfe72 11b240f bbcfe72 11b240f 527d436 bbcfe72 11b240f bbcfe72 11b240f bbcfe72 11b240f bbcfe72 11b240f 527d436 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 'use client'
import { useState, useRef, useEffect } from 'react'
import { Menu, Zap, Settings, Bell, Activity, Sun, Moon, Globe, ChevronDown, Cpu, MonitorPlay } from 'lucide-react'
import { useAppStore, type Theme, type Locale } from '@/store/useAppStore'
const THEMES: { id: Theme; label: string; en: string; my: string; icon: string }[] = [
{ id: 'dark', label: 'Dark', en: 'Dark', my: 'မှောင်', icon: '🌑' },
{ id: 'amoled', label: 'AMOLED', en: 'AMOLED', my: 'AMOLED', icon: '⬛' },
{ id: 'neon', label: 'Neon', en: 'Neon', my: 'Neon', icon: '💜' },
{ id: 'glass', label: 'Glass', en: 'Glass', my: 'ဖန်ထည်', icon: '🔮' },
]
const LOCALES: { id: Locale; flag: string; label: string }[] = [
{ id: 'en', flag: '🇬🇧', label: 'English' },
{ id: 'my', flag: '🇲🇲', label: 'မြန်မာ' },
]
export default function TopBar() {
const {
sidebarOpen, setSidebarOpen,
theme, setTheme,
locale, setLocale,
setCurrentPage, currentPage,
isComputerUseOpen, setComputerUseOpen,
} = useAppStore()
const [themeOpen, setThemeOpen] = useState(false)
const [langOpen, setLangOpen] = useState(false)
const themeRef = useRef<HTMLDivElement>(null)
const langRef = useRef<HTMLDivElement>(null)
// Close dropdowns on outside click
useEffect(() => {
function handler(e: MouseEvent) {
if (themeRef.current && !themeRef.current.contains(e.target as Node)) setThemeOpen(false)
if (langRef.current && !langRef.current.contains(e.target as Node)) setLangOpen(false)
}
document.addEventListener('mousedown', handler)
return () => document.removeEventListener('mousedown', handler)
}, [])
const currentTheme = THEMES.find(t => t.id === theme) || THEMES[0]
const currentLocale = LOCALES.find(l => l.id === locale) || LOCALES[0]
return (
<header
className="h-12 flex items-center justify-between px-3 shrink-0 z-50"
style={{ background: 'var(--surface-1)', borderBottom: '1px solid var(--border)' }}
>
{/* Left */}
<div className="flex items-center gap-3">
<button
onClick={() => setSidebarOpen(!sidebarOpen)}
className="p-1.5 rounded-lg hover:bg-white/5 transition-colors"
title="Toggle Sidebar"
>
<Menu size={16} style={{ color: 'var(--text-secondary)' }} />
</button>
<div className="flex items-center gap-2">
<div className="w-7 h-7 rounded-lg flex items-center justify-center shadow-lg"
style={{ background: 'linear-gradient(135deg, var(--accent), #4f46e5)' }}>
<Zap size={14} className="text-white" />
</div>
<div className="hidden sm:block">
<span className="text-sm font-bold" style={{ color: 'var(--text-primary)' }}>
{locale === 'my' ? 'GOD AGENT OS' : 'GOD AGENT OS'}
</span>
<span
className="text-[10px] ml-1.5 px-1.5 py-0.5 rounded-full font-semibold"
style={{ background: 'rgba(124,58,237,0.15)', border: '1px solid rgba(124,58,237,0.3)', color: '#c4b5fd' }}
>
v11 · God Mode
</span>
</div>
</div>
</div>
{/* Center - Status */}
<div className="hidden md:flex items-center gap-3">
<div
className="flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium"
style={{ background: 'rgba(34,197,94,0.1)', border: '1px solid rgba(34,197,94,0.2)', color: '#4ade80' }}
>
<div className="w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse" />
<Activity size={10} />
<span>{locale === 'my' ? 'Backend Online' : 'Backend Online'}</span>
</div>
<div className="flex items-center gap-1.5 px-3 py-1 rounded-full text-xs"
style={{ background: 'rgba(124,58,237,0.1)', border: '1px solid rgba(124,58,237,0.2)', color: '#a78bfa' }}>
<Cpu size={10} />
<span>16 Agents · 22 Spaces</span>
</div>
</div>
{/* Right - Controls */}
<div className="flex items-center gap-1">
{/* Computer Use Toggle (Manus-style) */}
<button
onClick={() => setComputerUseOpen(!isComputerUseOpen)}
className="flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all"
style={{
background: isComputerUseOpen ? 'rgba(124,58,237,0.15)' : 'transparent',
color: isComputerUseOpen ? '#a78bfa' : 'var(--text-muted)',
border: isComputerUseOpen ? '1px solid rgba(124,58,237,0.25)' : '1px solid transparent',
}}
title={locale === 'my' ? 'Computer ကြည့်ရန်' : 'Computer Use View'}
>
<MonitorPlay size={14} />
<span className="hidden sm:inline">
{locale === 'my' ? 'Computer' : 'Computer Use'}
</span>
</button>
{/* Language Toggle */}
<div className="relative" ref={langRef}>
<button
onClick={() => { setLangOpen(!langOpen); setThemeOpen(false) }}
className="flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-white/5 transition-colors text-xs"
style={{ color: 'var(--text-secondary)' }}
title="Language"
>
<Globe size={13} />
<span className="hidden sm:inline">{currentLocale.flag}</span>
<ChevronDown size={10} />
</button>
{langOpen && (
<div
className="absolute right-0 top-full mt-1 py-1 rounded-xl shadow-xl z-50 min-w-[130px] animate-fade-in"
style={{ background: 'var(--surface-3)', border: '1px solid var(--border)' }}
>
{LOCALES.map(l => (
<button
key={l.id}
onClick={() => { setLocale(l.id); setLangOpen(false) }}
className="w-full flex items-center gap-2.5 px-3 py-2 text-xs hover:bg-white/5 transition-colors"
style={{ color: locale === l.id ? 'var(--accent-bright)' : 'var(--text-secondary)' }}
>
<span>{l.flag}</span>
<span>{l.label}</span>
{locale === l.id && <span className="ml-auto text-[10px]">✓</span>}
</button>
))}
</div>
)}
</div>
{/* Theme Toggle */}
<div className="relative" ref={themeRef}>
<button
onClick={() => { setThemeOpen(!themeOpen); setLangOpen(false) }}
className="flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-white/5 transition-colors text-xs"
style={{ color: 'var(--text-secondary)' }}
title="Theme"
>
<span>{currentTheme.icon}</span>
<ChevronDown size={10} />
</button>
{themeOpen && (
<div
className="absolute right-0 top-full mt-1 py-1 rounded-xl shadow-xl z-50 min-w-[140px] animate-fade-in"
style={{ background: 'var(--surface-3)', border: '1px solid var(--border)' }}
>
<div className="px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider" style={{ color: 'var(--text-muted)' }}>
{locale === 'my' ? 'အပြင်အဆင်' : 'Theme'}
</div>
{THEMES.map(t => (
<button
key={t.id}
onClick={() => { setTheme(t.id); setThemeOpen(false) }}
className="w-full flex items-center gap-2.5 px-3 py-2 text-xs hover:bg-white/5 transition-colors"
style={{ color: theme === t.id ? 'var(--accent-bright)' : 'var(--text-secondary)' }}
>
<span>{t.icon}</span>
<span>{locale === 'my' ? t.my : t.en}</span>
{theme === t.id && <span className="ml-auto text-[10px]">✓</span>}
</button>
))}
</div>
)}
</div>
{/* Notifications */}
<button
className="p-1.5 rounded-lg hover:bg-white/5 transition-colors"
style={{ color: 'var(--text-muted)' }}
title="Notifications"
>
<Bell size={15} />
</button>
{/* Settings */}
<button
onClick={() => setCurrentPage('settings')}
className="p-1.5 rounded-lg hover:bg-white/5 transition-colors"
style={{
color: currentPage === 'settings' ? 'var(--accent-bright)' : 'var(--text-muted)',
background: currentPage === 'settings' ? 'rgba(124,58,237,0.1)' : 'transparent',
}}
title="Settings"
>
<Settings size={15} />
</button>
</div>
</header>
)
}
|