Interactive Command Palette
A command palette is a powerful UI pattern, popularized by tools like VS Code and Figma, that allows users to quickly access features and navigate an application using keyboard commands and fuzzy search. In complex developer tools like Browserstack, providing an efficient way for users to trigger actions or find specific settings can significantly enhance productivity. This problem challenges you to build a functional command palette component.
Your goal is to implement a reusable CommandPalette component that offers a streamlined user experience for executing predefined actions.
Cmd + K (on Mac) or Ctrl + K (on Windows/Linux) anywhere on the page.ArrowUp and ArrowDown keys.ArrowUp from the first item goes to the last, and ArrowDown from the last item goes to the first).Enter key while a command is selected should "execute" that command. For this exercise, execution means logging the command's name to the console and then closing the palette.Escape key.Cmd/Ctrl + K.Escape or after command execution.ArrowUp and ArrowDown keys correctly navigate and highlight commands in the filtered list, with wrapping behavior.Enter on a highlighted command logs its name to the console and closes the palette.Constraints
App.tsx (mock data). Assume this list is relatively small (e.g., < 50 commands).CommandPalette component is structured, and how effectively React state and props are managed.Loading editor...