8
8
} from 'react' ;
9
9
10
10
import clsx from 'clsx' ;
11
+ import Image from 'next/image' ;
11
12
12
13
function useGridSize ( ) {
13
14
const [ gridSize , setGridSize ] = useState ( 3 ) ;
@@ -424,13 +425,13 @@ export default function PuzzleClient() {
424
425
// Render puzzle
425
426
// ------------------------------------------------------
426
427
return (
427
- < div style = { { width : 400 , margin : "20px auto" } } >
428
+ < div className = "min-h-screen w-screen flex items-center justify-center" >
428
429
< div
430
+ className = "border"
429
431
style = { {
430
432
position : "relative" ,
431
433
width : gridSize * tileSize ,
432
434
height : gridSize * tileSize ,
433
- border : "1px solid #999" ,
434
435
} }
435
436
>
436
437
{ /* Bottom layer: NxN facts */ }
@@ -453,14 +454,12 @@ export default function PuzzleClient() {
453
454
style = { {
454
455
width : tileSize ,
455
456
height : tileSize ,
456
- backgroundColor : "#fff" ,
457
- border : "1px solid #444" ,
458
457
boxSizing : "border-box" ,
459
458
transform : `translate(${ baseX } px, ${ baseY } px)` ,
460
459
} }
461
460
>
462
461
< div
463
- className = "text-sm text-center [&_a]:cursor-pointer [&_a]:text-primary [&_a]:underline [&_a]:pointer-events-auto hover:[&_a]:opacity-70 px-1"
462
+ className = "text-sm text-center select-none [&_a]:cursor-pointer [&_a]:text-primary [&_a]:underline [&_a]:pointer-events-auto hover:[&_a]:opacity-70 px-1"
464
463
style = { {
465
464
display : "-webkit-box" ,
466
465
WebkitLineClamp : 4 ,
@@ -494,7 +493,7 @@ export default function PuzzleClient() {
494
493
// If isDraggingTile[i] => no transition
495
494
// else transition 200ms => for click or final snap
496
495
const tileClasses = clsx (
497
- "absolute pointer-events-auto draggable" ,
496
+ "absolute pointer-events-auto draggable border " ,
498
497
! isDraggingTile [ i ] &&
499
498
"transition-transform duration-200 ease-in-out"
500
499
) ;
@@ -505,24 +504,28 @@ export default function PuzzleClient() {
505
504
className = { clsx (
506
505
tileClasses ,
507
506
isDraggingTile [ i ]
508
- ? "cursor-grabbing opacity-70 "
507
+ ? "cursor-grabbing"
509
508
: canMove
510
- ? "cursor-grab hover:opacity-70 "
509
+ ? "cursor-grab"
511
510
: "cursor-default"
512
511
) }
513
512
style = { {
514
513
width : tileSize ,
515
514
height : tileSize ,
516
515
backgroundColor : "#fff" ,
517
- border : "1px solid #444" ,
518
516
boxSizing : "border-box" ,
519
517
transform : `translate(${ baseX + off . x } px, ${ baseY + off . y } px)` ,
520
518
} }
521
519
onPointerDown = { ( e ) => handlePointerDown ( e , i ) }
522
520
onPointerMove = { ( e ) => handlePointerMove ( e , i ) }
523
521
onPointerUp = { ( e ) => handlePointerUp ( e , i ) }
524
522
>
525
- { tile }
523
+ < Image
524
+ src = { puzzleImages [ tile ] }
525
+ alt = { `Tile ${ tile } ` }
526
+ fill
527
+ className = "object-cover pointer-events-none"
528
+ />
526
529
</ div >
527
530
) ;
528
531
} ) }
0 commit comments