import { type ReactNode } from "react"; import { useTranslation } from "react-i18next"; import { Search, X } from "lucide-react"; // The floating search pill in the top header. One component for every module that searches // (feed, Plex, channels, playlists): a glass rounded box with a search icon, the input, a // clear button, and a "Go" trigger (Enter also fires it). The feed passes its live-YouTube // escalation as the Go action; the other modules filter as you type and Go just commits/blurs. export default function SearchBar({ value, onChange, placeholder, onGo, goLabel, goIcon, goDisabled, goTitle, }: { value: string; onChange: (q: string) => void; placeholder: string; // Enter / the Go button call this. Omit to hide the Go button entirely. onGo?: () => void; goLabel?: string; goIcon?: ReactNode; goDisabled?: boolean; goTitle?: string; }) { const { t } = useTranslation(); const fire = () => { if (onGo && !goDisabled) onGo(); }; return (
onChange(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") fire(); }} placeholder={placeholder} className="flex-1 min-w-0 bg-transparent outline-none text-sm placeholder:text-muted" /> {value && ( )} {onGo && ( )}
); }