Skip to content

Commit

Permalink
fix(chessboard): update types
Browse files Browse the repository at this point in the history
  • Loading branch information
myarete committed Aug 19, 2019
1 parent 1248679 commit d911ac6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 32 deletions.
30 changes: 10 additions & 20 deletions chessboard.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { Component, CSSProperties } from 'react';

type Square =
'a8' | 'b8' | 'c8' | 'd8' | 'e8' | 'f8' | 'g8' | 'h8' |
'a7' | 'b7' | 'c7' | 'd7' | 'e7' | 'f7' | 'g7' | 'h7' |
'a6' | 'b6' | 'c6' | 'd6' | 'e6' | 'f6' | 'g6' | 'h6' |
'a5' | 'b5' | 'c5' | 'd5' | 'e5' | 'f5' | 'g5' | 'h5' |
'a4' | 'b4' | 'c4' | 'd4' | 'e4' | 'f4' | 'g4' | 'h4' |
'a3' | 'b3' | 'c3' | 'd3' | 'e3' | 'f3' | 'g3' | 'h3' |
'a2' | 'b2' | 'c2' | 'd2' | 'e2' | 'f2' | 'g2' | 'h2' |
'a1' | 'b1' | 'c1' | 'd1' | 'e1' | 'f1' | 'g1' | 'h1'
;
import { Square } from "chess.js"

type Piece =
'wP' | 'wN' | 'wB' | 'wR' | 'wQ' | 'wK' |
Expand All @@ -21,11 +11,11 @@ type Position = {
}

type CustomPieces = {
[piece in Piece]?: (obj: {isDragging: boolean, squareWidth: number, droppedPiece: string, targetSquare: string, sourceSquare: string}) => JSX.Element
[piece in Piece]?: (obj: {isDragging: boolean, squareWidth: number, droppedPiece: Piece, targetSquare: Square, sourceSquare: Square}) => JSX.Element
}

interface Props {
allowDrag?: (obj: {piece: string, sourceSquare: string}) => boolean,
allowDrag?: (obj: {piece: Piece, sourceSquare: Square}) => boolean,
boardStyle?: CSSProperties,
calcWidth?: (obj: {screenWidth: number, screenHeight: number}) => number,
darkSquareStyle?: CSSProperties,
Expand All @@ -35,13 +25,13 @@ interface Props {
getPosition?: (currentPosition: Position) => void,
id?: string | number,
lightSquareStyle?: CSSProperties,
onDragOverSquare?: (square: string) => void,
onDrop?: (obj: {sourceSquare: string, targetSquare: string, piece: string}) => void,
onMouseOutSquare?: (square: string) => void,
onMouseOverSquare?: (square: string) => void,
onPieceClick?: (piece: string) => void,
onSquareClick?: (square: string) => void,
onSquareRightClick?: (square: string) => void,
onDragOverSquare?: (square: Square) => void,
onDrop?: (obj: {sourceSquare: Square, targetSquare: Square, piece: Piece}) => void,
onMouseOutSquare?: (square: Square) => void,
onMouseOverSquare?: (square: Square) => void,
onPieceClick?: (piece: Piece) => void,
onSquareClick?: (square: Square) => void,
onSquareRightClick?: (square: Square) => void,
orientation?: 'white' | 'black',
pieces?: CustomPieces,
position?: string | Position,
Expand Down
52 changes: 40 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@babel/register": "7.0.0-beta.51",
"@commitlint/cli": "6.2.0",
"@commitlint/config-conventional": "6.1.3",
"@types/chess.js": "^0.10.0",
"all-contributors-cli": "5.2.0",
"babel-cli": "6.26.0",
"babel-core": "7.0.0-bridge.0",
Expand Down

0 comments on commit d911ac6

Please sign in to comment.