diff --git a/src/components/BulgarianSolitaire.tsx b/src/components/BulgarianSolitaire.tsx index 5d3343a..881ed45 100644 --- a/src/components/BulgarianSolitaire.tsx +++ b/src/components/BulgarianSolitaire.tsx @@ -75,6 +75,26 @@ const BulgarianSolitaire: React.FC = ({ showSocialShare setDraggedBox(null); }; + const handleDropToContainer = (e: React.DragEvent) => { + e.preventDefault(); + if (draggedBox === null) return; + + const box = boxes.find(b => b.id === draggedBox); + if (!box || box.columnIndex === null) return; + + // Remove from column + setColumns(prev => prev.map((col, idx) => + idx === box.columnIndex ? col.filter(id => id !== draggedBox) : col + )); + + // Return to container + setBoxes(prev => prev.map(b => + b.id === draggedBox ? { ...b, columnIndex: null } : b + )); + + setDraggedBox(null); + }; + const handleDoubleClick = (boxId: number) => { const box = boxes.find(b => b.id === boxId); if (!box || box.columnIndex === null) return; @@ -237,7 +257,11 @@ const BulgarianSolitaire: React.FC = ({ showSocialShare {/* Container */}
-
+
Container
{containerBoxes.map((box) => ( @@ -277,13 +301,15 @@ const BulgarianSolitaire: React.FC = ({ showSocialShare {column.map((boxId, boxIndex) => (
handleDragStart(e, boxId)} onDoubleClick={() => handleDoubleClick(boxId)} - className={`w-8 h-8 rounded cursor-pointer transition-all duration-300 flex items-center justify-center text-xs font-medium mx-auto ${ + className={`w-8 h-8 rounded cursor-move transition-all duration-300 flex items-center justify-center text-xs font-medium mx-auto ${ highlightedBoxes.has(boxId) ? 'bg-red-500 text-white shadow-lg scale-110' : 'bg-primary text-primary-foreground hover:bg-primary/80' } ${isAnimating && highlightedBoxes.has(boxId) ? 'animate-pulse' : ''}`} - title="Double-click to return to container" + title="Drag to move or double-click to return to container" > {boxId + 1}
@@ -321,7 +347,8 @@ const BulgarianSolitaire: React.FC = ({ showSocialShare
  • Choose a value for n (2-6) using the slider
  • Drag the {totalBoxes} numbered boxes from the container into any of the columns
  • -
  • Double-click any box in a column to return it to the container
  • +
  • Drag boxes between columns to rearrange them as needed
  • +
  • Drag boxes back to the container or double-click any box in a column to return it
  • Once all boxes are placed in columns, click "Play" to start the simulation
  • Watch as the algorithm takes one box from each non-empty column to form a new column
  • The process continues until reaching the triangular configuration: columns of sizes 1, 2, 3, ..., n