import * as React from "react"; import { Dialog, DialogTrigger, Input, ListBox, ListBoxItem, Modal, ModalOverlay, } from "react-aria-components"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router"; import { SearchIcon } from "~/components/icons/Search"; import styles from "./CommandPalette.module.css"; // xxx: placeholder const MOCK_RESULTS = [ { id: "builds", label: "Builds", href: "/builds" }, { id: "calendar", label: "Calendar", href: "/calendar" }, { id: "sendouq", label: "SendouQ", href: "/q" }, { id: "vods", label: "VODs", href: "/vods" }, { id: "maps", label: "Maps", href: "/maps" }, ]; export function CommandPalette() { const { t } = useTranslation(["common"]); const [isOpen, setIsOpen] = React.useState(false); return ( setIsOpen(false)} /> ); } function CommandPaletteContent({ onClose }: { onClose: () => void }) { const { t } = useTranslation(["common"]); const navigate = useNavigate(); const [query, setQuery] = React.useState(""); const filteredResults = query ? MOCK_RESULTS.filter((r) => r.label.toLowerCase().includes(query.toLowerCase()), ) : MOCK_RESULTS; const handleSelect = (key: React.Key) => { const result = MOCK_RESULTS.find((r) => r.id === key); if (result) { navigate(result.href); onClose(); } }; return ( <>
setQuery(e.target.value)} autoFocus />
{filteredResults.map((result) => ( {result.label} ))} ); }