Frontend School

Basic Spreadsheet Cell Grid

Machine Coding
easy

Basic Spreadsheet Cell Grid

Easy
React
TypeScript
Frontend
UI
Spreadsheet

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.

  1. 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).
  2. Cell Selection: When a user clicks on any cell, it should become the "selected" cell. Only one cell can be selected at a time.
  3. Highlight Selected Cell: The currently selected cell must be visually highlighted to distinguish it from other cells.
  4. Display Selected Value: An input field should be rendered above the grid. This input field must display the value of the currently selected cell.
  5. 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.

Constraints

Constraints & assumptions

  • The grid size is fixed at 5 rows by 5 columns.
  • Cell values are simple strings or numbers, not complex formulas.
  • You should use React and TypeScript for your solution.
  • The focus is on functionality and basic UI, not advanced styling or responsiveness.
  • You can use CSS for basic styling, but extensive design is not required.

Out of scope

  • Implementing complex spreadsheet formulas (e.g., SUM, AVG).
  • Keyboard navigation (arrow keys, Tab).
  • Dynamic adding/removing of rows or columns.
  • Copy-paste functionality.
  • Persistence of data.

What interviewers evaluate

  • Component Structure: How well the React components are organized and modularized.
  • State Management: Effective use of React's state hooks (useState) to manage grid data and selected cell.
  • Event Handling: Correct implementation of click and change handlers.
  • UI Rendering: Accurate display of grid cells, selected state, and input field synchronization.
  • Code Quality: Readability, maintainability, and adherence to TypeScript best practices.

Loading editor...