Update Bulgarian Solitaire component
Modify the Bulgarian Solitaire component to send a double-clicked box from the container to the last used column.
This commit is contained in:
parent
23637eb547
commit
1700a6f984
1 changed files with 19 additions and 2 deletions
|
|
@ -100,9 +100,25 @@ const BulgarianSolitaire: React.FC<BulgarianSolitaireProps> = ({ showSocialShare
|
||||||
|
|
||||||
const handleDoubleClick = (boxId: number) => {
|
const handleDoubleClick = (boxId: number) => {
|
||||||
const box = boxes.find(b => b.id === boxId);
|
const box = boxes.find(b => b.id === boxId);
|
||||||
if (!box || box.columnIndex === null) return;
|
if (!box) return;
|
||||||
|
|
||||||
// Remove from current column
|
// If box is in container, move to last used column
|
||||||
|
if (box.columnIndex === null) {
|
||||||
|
if (lastUsedColumn !== null) {
|
||||||
|
// Add to last used column
|
||||||
|
setColumns(prev => prev.map((col, idx) =>
|
||||||
|
idx === lastUsedColumn ? [...col, boxId] : col
|
||||||
|
));
|
||||||
|
|
||||||
|
// Update box location
|
||||||
|
setBoxes(prev => prev.map(b =>
|
||||||
|
b.id === boxId ? { ...b, columnIndex: lastUsedColumn } : b
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If box is in a column, remove from current column
|
||||||
setColumns(prev => prev.map((col, idx) =>
|
setColumns(prev => prev.map((col, idx) =>
|
||||||
idx === box.columnIndex ? col.filter(id => id !== boxId) : col
|
idx === box.columnIndex ? col.filter(id => id !== boxId) : col
|
||||||
));
|
));
|
||||||
|
|
@ -285,6 +301,7 @@ const BulgarianSolitaire: React.FC<BulgarianSolitaireProps> = ({ showSocialShare
|
||||||
key={box.id}
|
key={box.id}
|
||||||
draggable={!isPlaying}
|
draggable={!isPlaying}
|
||||||
onDragStart={(e) => handleDragStart(e, box.id)}
|
onDragStart={(e) => handleDragStart(e, box.id)}
|
||||||
|
onDoubleClick={() => handleDoubleClick(box.id)}
|
||||||
className="w-8 h-8 bg-primary rounded cursor-move hover:bg-primary/80 transition-colors"
|
className="w-8 h-8 bg-primary rounded cursor-move hover:bg-primary/80 transition-colors"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue