Overview
Spreadsheet applications are fundamental tools for data organization and analysis. Building the core interactive grid component is a common task in frontend development, requiring careful management of UI state and user interactions. This problem focuses on creating a simplified, interactive spreadsheet-like grid where users can view and edit cell values.
What you need to do / Task
Your task is to implement a React component that displays a grid of cells and allows basic user interaction.
- Render a grid: Display a 5x5 grid of cells. Each cell should initially display a simple value (e.g., "A1", "B2", etc., or some mock numbers/text).
- Cell Selection: When a user clicks on any cell, it should become the "selected" cell. Only one cell can be selected at a time.
- Highlight Selected Cell: The currently selected cell must be visually highlighted to distinguish it from other cells.
- Display Selected Value: An input field should be rendered above the grid. This input field must display the value of the currently selected cell.
- Edit Cell Value: When the user types into the input field, the value of the currently selected cell in the grid should update in real-time to reflect the input field's content. If no cell is selected, the input field should be disabled.
UI/UX expectations
- The grid should be clearly structured with distinct rows and columns.
- The input field for editing should be placed prominently above the grid.
- The visual highlight for the selected cell should be clear and distinct (e.g., an outline or background color change).
- The overall layout should be clean and functional.
Acceptance criteria
- A 5x5 grid of cells is rendered, each displaying its initial value.
- Clicking a cell selects it and applies a visual highlight.
- Clicking a different cell deselects the previous one and selects the new one, updating the highlight.
- The input field above the grid displays the value of the currently selected cell.
- When no cell is selected, the input field is disabled.
- Typing into the input field updates the value of the selected cell within the grid in real-time.