| 1 | "use client"; |
| 2 | |
| 3 | import { Search, Bell } from "lucide-react"; |
| 4 | import { ConnectionStatus } from "@/components/shared/ConnectionStatus"; |
| 5 | import { useUiStore } from "@/stores/ui"; |
| 6 | import { useWatchlist } from "@/hooks/useWatchlist"; |
| 7 | |
| 8 | export function Topbar({ title }: { title: string }) { |
| 9 | const setCommandOpen = useUiStore((s) => s.setCommandOpen); |
| 10 | const { data: watchlist } = useWatchlist(); |
| 11 | const activeWatches = watchlist?.filter((w) => w.active).length ?? 0; |
| 12 | |
| 13 | return ( |
| 14 | <header className="glass sticky top-0 z-[var(--z-sticky)] flex h-16 items-center gap-4 border-b border-[var(--color-border-subtle)] px-4 md:px-6"> |
| 15 | <h1 className="text-sm font-semibold tracking-[var(--tracking-tight)] text-[var(--color-fg-primary)] md:text-base"> |
| 16 | {title} |
| 17 | </h1> |
| 18 | |
| 19 | <button |
| 20 | type="button" |
| 21 | onClick={() => setCommandOpen(true)} |
| 22 | className="ml-auto flex h-9 items-center gap-2 rounded-[var(--radius)] border border-[var(--color-border-default)] bg-[var(--color-bg-inset)] px-3 text-sm text-[var(--color-fg-tertiary)] transition-colors hover:border-[var(--color-border-strong)] hover:text-[var(--color-fg-secondary)]" |
| 23 | aria-label="Open command palette" |
| 24 | > |
| 25 | <Search className="h-4 w-4" aria-hidden /> |
| 26 | <span className="hidden sm:inline">Search…</span> |
| 27 | <kbd className="hidden rounded border border-[var(--color-border-default)] bg-[var(--color-bg-overlay)] px-1.5 font-mono text-[10px] sm:inline"> |
| 28 | ⌘K |
| 29 | </kbd> |
| 30 | </button> |
| 31 | |
| 32 | {activeWatches > 0 ? ( |
| 33 | <span className="hidden items-center gap-1.5 rounded-full border border-[color-mix(in_oklch,var(--color-accent-teal)_30%,transparent)] bg-[var(--color-accent-teal-soft)] px-2.5 py-1 text-xs font-medium text-[var(--color-accent-teal)] sm:inline-flex"> |
| 34 | <Bell className="h-3 w-3" aria-hidden /> |
| 35 | {activeWatches} watching |
| 36 | </span> |
| 37 | ) : null} |
| 38 | |
| 39 | <ConnectionStatus /> |
| 40 | </header> |
| 41 | ); |
| 42 | } |