From c1c5e5ca60c6e91af94320aa01e9e378688207d7 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 09:15:54 +0000 Subject: [PATCH] Refactor Knights Puzzle layout Restructure the Knights Puzzle layout based on the provided image, including title, description, move counter, status, interactive area, initial/target positions, and game rules. --- src/components/KnightsPuzzle.tsx | 248 +++++++++++++++++-------------- 1 file changed, 133 insertions(+), 115 deletions(-) diff --git a/src/components/KnightsPuzzle.tsx b/src/components/KnightsPuzzle.tsx index 6edcd67..02b7387 100644 --- a/src/components/KnightsPuzzle.tsx +++ b/src/components/KnightsPuzzle.tsx @@ -171,129 +171,147 @@ const KnightsPuzzle = ({ showSocialShare = false }: KnightsPuzzleProps) => { }; return ( -
- - - - Knights Exchange Puzzle - Classic - - - Can the black and white knights swap places using legal chess moves? Move knights by clicking on them, then clicking on a valid destination. - - - -
- {/* Game Board */} -
-
- {board.map((row, rowIndex) => - row.map((piece, colIndex) => ( -
handleSquareClick(rowIndex, colIndex)} - > - {renderPiece(piece)} -
- )) - )} -
- - {/* Controls */} -
- - -
-
+
+ {/* Green: Title and Description */} +
+
+

Knights Exchange Puzzle

+ Classic +
+

+ Can the black and white knights swap places using legal chess moves? Move knights by clicking on them, then clicking on a valid destination. +

+
- {/* Info Panel */} -
-
-

Game Status

-
-

Moves: {moveCount}

-

Status: {isComplete ? "🎉 Solved!" : "🎯 In Progress"}

-
-
+ {/* Blue: Number of moves */} +
+ Moves: + {moveCount} +
-
-

How to Play

-
    -
  • • Click on a knight to select it
  • -
  • • Valid moves will be highlighted
  • -
  • • Click on a highlighted square to move
  • -
  • • Goal: Swap white and black knights
  • -
  • • Knights move in an L-shape (like in chess)
  • -
-
+ {/* Orange: Status (without heading) */} +
+ + {isComplete ? "🎉 Puzzle Solved!" : "🎯 In Progress"} + +
-
-

Initial Position

-
- {initialBoard.map((row, rowIndex) => - row.map((piece, colIndex) => ( -
- {piece === 'white' ? '♘' : piece === 'black' ? '♞' : ''} -
- )) - )} -
-
- -
-

Target Position

-
- {targetBoard.map((row, rowIndex) => - row.map((piece, colIndex) => ( -
- {piece === 'white' ? '♘' : piece === 'black' ? '♞' : ''} -
- )) - )} -
-
- - {/* Attribution */} -
-

- Puzzle source:{" "} - + +

+ + {/* Controls */} +
+ +
+ + {/* Purple: Initial and Target positions side by side */} +
+ + + Initial Position + + +
+ {initialBoard.map((row, rowIndex) => + row.map((piece, colIndex) => ( +
+ {piece === 'white' ? '♘' : piece === 'black' ? '♞' : ''} +
+ )) + )} +
+
+
+ + + + Target Position + + +
+ {targetBoard.map((row, rowIndex) => + row.map((piece, colIndex) => ( +
+ {piece === 'white' ? '♘' : piece === 'black' ? '♞' : ''} +
+ )) + )} +
+
+
+
+ + {/* Red: Game rules */} + + + How to Play + + +
    +
  • • Click on a knight to select it
  • +
  • • Valid moves will be highlighted
  • +
  • • Click on a highlighted square to move
  • +
  • • Goal: Swap white and black knights
  • +
  • • Knights move in an L-shape (like in chess)
  • +
+
+
+ + {/* Attribution */} +
+

+ Puzzle source:{" "} + + @neuwirthe.bsky.social + + +

+
); };