Create a Command Palette that opens up with Keyboard events like Command + K. In this problem, The command palette will have navigation links to which a user can navigate. Also, the user can search on the page on the command palette for a link to which they want to navigate.
Command + K
(on Mac) and Control + K
(on windows), A modal should pop up that will be an overlay on the screen./constants/navlinks.ts
file. Navlinks will have name
, link
and icon
fields associated. Icons are provided in the same file./home
, /about
and /playground
pages. Use react-router-dom
package for routing. Version 5 or 6 both are fine.autofocused
. That means, the user should not have to manually click in the input box./icons
folder contains all the necessary SVG icons.Click to reveal
useRef()
can help you autofocus on the input box every time the component mounts
Click to reveal
use the history
object from react-router-dom
to push
to a specific page. Callbacks are your friends here to change modal state as well for closing it.
Click to reveal
For Control + K
key, you can use event listerens for keyup
and keydown
events. When a key is pressed, keydown
event can be called.
Click to reveal
Try using the App.tsx
component to manage your opening and closing of modal state logic. Even better is to use context for this and supply it to your application wherever you need it.