Spotlight
EVA Spotlight is a power user feature where you can initiate EVA suite intents from a convenient popup dialog. Modeled after Mac OS Spotlight feature. An action inside the Spotlight autocomplete are called shortcuts.
#
ShortcutsSpotlight shortcuts are automatically discovered by looking for the eva-spotlight.json file inside a EVA Suite module. This file is generated at build time for each module. A Spotlight shortcut is a simple JSX element the module. For example:
<SpotlightShortcut type="search" nameI18nKey="spotlight.shortcut.search.discount.title" descriptionI18nKey="spotlight.shortcut.search.discount.description" intent={EIntentAction.searchDiscount}/>
Props
#
Shortcut PromptThis is the components that renders the actual popup dialog prompt that can find all the shortcuts added in our modules. Add this to your App component.
const App = () => { ...
// This hook contains the hot key business logic for Spotlight // const [isOpen, toggleIsOpen] = useSpotlightHotKey();
return ( <> <Header moduleName={EVA_MODULE_NAME} onLogoClick={toggleIsOpen} /> <Box display="flex" p={0}> {currentUserType.isEmployee ? <SideNav /> : null} <Routes /> </Box> <ShortcutProvider> <SpotlightShortcutPrompt isOpen={isOpen} toggleIsOpen={toggleIsOpen} noOptionsText={intl.formatMessage({ id: 'spotlight.shortcut.search.no.options' })} placeHolders={{ general: intl.formatMessage({ id: 'spotlight.shortcut.search.placeholder.general' }), search: intl.formatMessage({ id: 'spotlight.shortcut.search.placeholder.search' }), id: intl.formatMessage({ id: 'spotlight.shortcut.search.placeholder.id' }), }} /> </ShortcutProvider> </> );};
Props
As with all great functionalities that just seem to work, there's a context provider that abstracts all the magic away. Make sure to wrap your SpotlightShortcutPrompt
into a ShortcutProvider
. There's also a useSpotlightHotKey
hook that handles the hotkey logic for opening the spotlight prompt, so make sure to pass the isOpen
state and toggle from the hook into your prompt component.