0.9.0 • Published 5 years ago
chessy-board v0.9.0
Chessy Board
A light react chess board. Live example on codesandbox.
Installation and Usage
The simplest way to use chessy-board is to install it from npm.
npm install --save chessy-board
Then use it in your app:
import React from 'react';
import Board from 'chessy-board';
class App extends React.Component {
state = {
matrix: {
'1': {
a: { color: 'white', role: 'queen'},
b: { color: 'white', role: 'king'},
c: { color: 'white', role: 'bishop'},
d: { color: 'white', role: 'king'},
e: null,
f: null,
g: null,
h: null,
},
'5': {
c: { color: 'white', role: 'pawn'}
}
}
}
onSquareClick ({ row, col, elements }) {
/* Do something with target square.. */
}
render() {
const { selectedOption } = this.state;
return (
<Board
isLoading={false}
matrix={this.state.matrix}
onClick={this.onSquareClick}
orientation={0}
highLightSelections={['c7']}
highLightOptions={['c6', 'c5']}
/>
);
}
}
Props
Props you may require/may need to specify:
className
- apply a class name to boardisLoading
- allows to show spinner over boardmatrix
- position pieces on boardonClick
- callback with clicked square detailsorientation
- white/black point of viewhighLightSelections
- highlight selected pieceshighLightOptions
- highlight possible move options for selected piececolors
- defines board's main elements color (black/white/selections color)
License
Chessy Board is MIT Licensed.
0.9.0
5 years ago
0.8.1
5 years ago
0.7.16
5 years ago
0.7.15
5 years ago
0.7.14
5 years ago
0.7.13
5 years ago
0.7.12
5 years ago
0.7.11
5 years ago
0.7.10
5 years ago
0.7.9
5 years ago
0.7.8
5 years ago
0.7.7
5 years ago
0.7.6
5 years ago
0.7.4
5 years ago
0.7.3
5 years ago
0.7.2
5 years ago
0.7.1
5 years ago
0.7.0
5 years ago
0.6.14
5 years ago
0.6.13
5 years ago
0.6.12
5 years ago
0.6.11
5 years ago
0.6.10
5 years ago
0.6.9
5 years ago
0.6.8
5 years ago
0.6.7
5 years ago
0.6.6
5 years ago
0.6.5
5 years ago
0.6.4
5 years ago
0.6.3
5 years ago
0.6.2
5 years ago
0.6.1
5 years ago
0.6.0
5 years ago
0.5.0
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.0
5 years ago
0.1.0
5 years ago