import { CONTROL_H, ICON_BTN, INPUT, Segmented } from "./ui"; export type ViewMode = "list" | "grid"; interface Props { search: string; onSearch: (v: string) => void; downloadedOnly: boolean; onDownloadedOnly: (v: boolean) => void; online: boolean; reachable: boolean; forcedOffline: boolean; onToggleForcedOffline: () => void; onRefresh: () => void; refreshing: boolean; refreshProgress: { done: number; total: number } | null; resultCount: number; view: ViewMode; onView: (v: ViewMode) => void; sidebarHidden: boolean; onShowSidebar: () => void; /** Present only when there is something to delete. */ onDeleteAll?: () => void; /** Matches the sidebar's inset so the two headers share a baseline. */ titleBarInset: boolean; } /** Neutral outline until active; active is the one filled state. */ function Toggle({ active, onClick, children, title, disabled, }: { active: boolean; onClick: () => void; children: React.ReactNode; title?: string; disabled?: boolean; }) { return ( ); } export default function TopBar({ search, onSearch, downloadedOnly, onDownloadedOnly, online, reachable, forcedOffline, onToggleForcedOffline, onRefresh, refreshing, refreshProgress, resultCount, view, onView, sidebarHidden, onShowSidebar, onDeleteAll, titleBarInset, }: Props) { const pct = refreshProgress && refreshProgress.total > 0 ? (refreshProgress.done / refreshProgress.total) * 100 : null; return (
{titleBarInset &&
}
{sidebarHidden && ( )} onSearch(e.target.value)} placeholder="Search videos and channels" className={`${INPUT} min-w-[17rem] max-w-sm flex-1`} /> {resultCount}
onDownloadedOnly(!downloadedOnly)} disabled={!online} title={online ? "Show only what is on this Mac" : "Offline: showing local videos only"}> Local {downloadedOnly && onDeleteAll && ( )} ), }, { value: "grid", title: "Tiles", label: ( ), }, ]} />
{refreshing && (
)}
); }