Overview
A command palette is a powerful UI element that allows users to quickly find and execute actions within an application using a search-like interface. It significantly enhances productivity by providing a fast way to access features without navigating menus. In this problem, you will build a basic version of a command palette that displays a list of commands and allows users to filter them by typing.
What you need to do / Task
Your goal is to implement a CommandPalette component that satisfies the following requirements:
- Render an input field: Display a text input where users can type their search queries.
- Display commands: Initially, show a predefined list of commands. Each command should display its name.
- Filter commands: As the user types into the input field, dynamically filter the displayed commands. The filtering should be case-insensitive and match if the input string is a substring of the command's name.
- Handle no results: If no commands match the current search query, display a "No matching commands." message.
UI/UX expectations
- The command palette should be a self-contained component.
- The input field should be clearly visible at the top.
- Below the input, a list of matching commands should be displayed.
- Each command in the list should be presented clearly (e.g., as a list item or a simple div).
- Basic styling is expected for readability, but complex visual design is not required. Focus on functionality.
Acceptance criteria
- An input field is rendered and allows user input.
- The initial list of
MOCK_COMMANDS is displayed when the input is empty.
- Typing "open" into the input field correctly filters the list to show only commands containing "open" (e.g., "Open File", "Open Project").
- Typing "file" (or "FILE") correctly filters the list to show "Open File", "Save File As".
- Typing a query with no matches (e.g., "xyz") displays "No matching commands."
- Clearing the input field (empty string) restores the full list of commands.