Queen Moves
Build a React app that renders a chessboard. When the user hovers over a square, it should highlight all legal Queen moves from that position.
Requirements
-
Render a standard 8Ć8 chessboard (total 64 cells).
-
When the user hovers over any square:
-
Highlight all valid Queen moves:
- Horizontally (same row)
- Vertically (same column)
- Diagonally (all 4 directions)
-
The hovered square must be visually distinct (e.g.
hoveredstyle).
-
-
When the mouse leaves the square:
- All highlights should be cleared.
-
On initial load:
- No square should be highlighted.
-
Each square must:
- Be accessible with
data-testid="cell-{row}-{col}"(for testing). - Have
role="gridcell"and the board must haverole="grid".
- Be accessible with
Edge Cases & Constraints
- Hovering over corner squares like A1
(0,0)or H8(7,7)should still show valid moves. - Hovering over a square, then quickly hovering over another square, should update highlights smoothly.
- Hovering away from the board must remove all highlights.
- The total number of highlighted squares for the Queen should be 27, excluding the hovered square.
Reference UI

Companies:
Solve Similar questions š„
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
