-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic functionality but mobile layout broken
- Loading branch information
Dean Sofer
authored and
Dean Sofer
committed
May 14, 2024
1 parent
c4db5a1
commit 57e6a97
Showing
31 changed files
with
600 additions
and
99 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.piece { | ||
width: 100%; | ||
aspect-ratio: 1; | ||
cursor: pointer; | ||
border-radius: 50%; | ||
|
||
&.white { | ||
/* background: white; */ | ||
} | ||
|
||
&.black { | ||
/* background: black; */ | ||
} | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useCallback, type DragEventHandler } from "react"; | ||
import black from './images/piece-black-2.png'; | ||
import white from './images/piece-white-2.png'; | ||
import './Piece.css' | ||
|
||
const IMAGES = { black, white } | ||
|
||
type PieceProps = { | ||
color: 'black' | 'white', | ||
position?: number | ||
} | ||
|
||
export default function Piece({ color, position }: PieceProps) { | ||
const onDragStart: DragEventHandler = useCallback((event) => { | ||
switch (position) { | ||
case undefined: | ||
break; | ||
case -1: | ||
event.dataTransfer?.setData('text', color) | ||
break; | ||
default: | ||
event.dataTransfer?.setData('text', position.toString()) | ||
} | ||
}, [position, color]); | ||
|
||
return <div className={`piece ${color}`} onDragStart={onDragStart} draggable={position !== undefined}> | ||
<img src={IMAGES[color]} /> | ||
</div> | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useCallback, type DragEventHandler } from "react"; | ||
import Piece from './Piece' | ||
|
||
type PointProps = { | ||
pieces: number, | ||
move: (from: number, to: number) => void, | ||
position: number | ||
} | ||
|
||
export default function Point({ pieces, move, position }: PointProps) { | ||
const onDragOver: DragEventHandler = useCallback((event) => { event.preventDefault(); }, []) | ||
const onDrop: DragEventHandler = useCallback((event) => { | ||
event.preventDefault(); | ||
let from = event.dataTransfer?.getData("text")! | ||
return move(from, position) | ||
}, [move]) | ||
|
||
const color = pieces > 0 ? 'white' : 'black'; | ||
|
||
return <div className="point" onDragOver={onDragOver} onDrop={onDrop}> | ||
{Array.from({ length: Math.abs(pieces) }, (_, index) => <Piece key={index} color={color} position={position} />)} | ||
</div> | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export { default as black1 } from './digit-1-black.png'; | ||
export { default as black2 } from './digit-2-black.png'; | ||
export { default as black3 } from './digit-3-black.png'; | ||
export { default as black4 } from './digit-4-black.png'; | ||
export { default as black5 } from './digit-5-black.png'; | ||
export { default as black6 } from './digit-6-black.png'; | ||
export { default as white1 } from './digit-1-white.png'; | ||
export { default as white2 } from './digit-2-white.png'; | ||
export { default as white3 } from './digit-3-white.png'; | ||
export { default as white4 } from './digit-4-white.png'; | ||
export { default as white5 } from './digit-5-white.png'; | ||
export { default as white6 } from './digit-6-white.png'; |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.