Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.3 KB
Raw Blame
import { Icon } from '@chakra-ui/react';
import { IconButton } from '@platform/ui/Button';
import { Tooltip } from '@platform/ui/Tooltip';
import { OPEN_COMMAND_PALETTE_HOTKEY } from '@workbench/hotkeys/catalog';
import { formatHotkeyLabel } from '@workbench/hotkeys/keys';
import { applyCustomHotkeys } from '@workbench/hotkeys/resolve';
import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';
import { SearchIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';

import { openCommandPalette } from './paletteStore';

/** Pointer affordance for the palette; the tooltip advertises its effective binding. */
export const PaletteButton = () => {
  const { t } = useTranslation();
  const customHotkeys = useWorkbenchPreferenceSelector((preferences) => preferences.customHotkeys);
  const firstHotkey = applyCustomHotkeys(OPEN_COMMAND_PALETTE_HOTKEY, customHotkeys).keys[0];
  const hotkeyLabel = firstHotkey ? formatHotkeyLabel(firstHotkey) : null;
  const tooltip = hotkeyLabel
    ? t('commandPalette.buttonTooltip', { hotkey: hotkeyLabel })
    : t('commandPalette.buttonLabel');

  return (
    <Tooltip content={tooltip}>
      <IconButton aria-label={t('commandPalette.buttonLabel')} size="lg" variant="ghost" onClick={openCommandPalette}>
        <Icon as={SearchIcon} />
      </IconButton>
    </Tooltip>
  );
};