Files
yaak-mountain-loop/src-web/hooks/useCommandPalette.tsx
2024-03-19 17:24:57 -07:00

25 lines
652 B
TypeScript

import { CommandPalette } from '../components/CommandPalette';
import { useDialog } from '../components/DialogContext';
import { useAppInfo } from './useAppInfo';
import { useHotKey } from './useHotKey';
export function useCommandPalette() {
const dialog = useDialog();
const appInfo = useAppInfo();
useHotKey('command_palette.toggle', () => {
// Disabled in production for now
if (!appInfo.data?.isDev) {
return;
}
dialog.toggle({
id: 'command_palette',
size: 'md',
hideX: true,
noPadding: true,
noScroll: true,
render: ({ hide }) => <CommandPalette onClose={hide} />,
});
});
}