• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    JavaScript
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React wrapper of Chessground

React Chessground

react-chessground is a react wrapper of the awesome Chessground

Installation

npm install --save react-chessground

Example

  • An example of playing with random opponent is provided in example

Usage

import Chessground from 'react-chessground'
import 'react-chessground/dist/styles/chessground.css'

class Demo extends React.Component {
  render () {
    return <Chessground />
  }
}

Properties

  • onMove - function Function is called when user moves a piece to a new position. Receives two parameters:
    • from - string Previous square position
    • to - string New square position
  • randomMove - function Function is called when computer moves a piece to a new position. Contains two objects:
    • moves - object Stores all valid moves
    • move - object Generates a move chosen from moves randomly
  • promotion - function Provides choices for pawn's promotion. Receive one parameter:
    • e - string Stores pieces user might want to choose upon promotion
  • reset - function Function is called when reset button clicked
  • undo - function Function is called when undo button clicked. Disabled when game is over

Reset: Reset the board to the initial starting position.

reset = () => {
    this.chess.reset()
    this.setState({ fen: this.chess.fen() })
  }

Undo: Take back the last half-move.

undo = () => {
    this.chess.undo()
    this.setState({ fen: this.chess.fen() })
  }

Promotion: Provides choices for pawn's promotion.

promotion(e) {
   const { chess } = this
   const from = this.pendingMove[0]
   const to = this.pendingMove[1]
   chess.move({ from, to, promotion: e })
   this.setState({
     fen: chess.fen(),
     lastMove: [from, to],
     selectVisible: false
   })
   setTimeout(this.randomMove, 500)
 }

Features

  • Display last move and check

  • Display move destinations, and premove destinations (hover effects possible)

It's available to see more features in Chessground

Documentation

Options of Chessground are mapped to properties of react-chessground

You can refer to documentation of Chessground for detailed configuration

An example of playing with random opponent is provided in example

More Repositories

1

fortune-sheet

A drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets
TypeScript
2,384
star
2

css-checker

Reduce Similar & Duplicated CSS Classes with Diff in Seconds!
Go
577
star
3

rails-pangu

Rails starter kit that every startup needs
Ruby
192
star
4

go-pangu

rest api web server based on go(High availability, high security, high performance)
Go
45
star
5

react-media-previewer

A media previewer component for React
TypeScript
20
star
6

NSHoverableButton

NSButton with two images for hovering and not hovering separately
Swift
19
star
7

react-keycode-input

A cool component for inputing many kinds of code
JavaScript
17
star
8

macbit

Macbit aims to solve mac development issues in a bit level.
C
11
star
9

chart-pangu

Pangu-chart is a helm chart template which inherits from the default template, but brings many conveniences originated from our daily devops.
HTML
10
star
10

rails-influxdb-logger

Logger for Influxdb in Rails
Ruby
10
star
11

NSGradientView

NSView with Gradient Background Colour Settings for Mac OS
Swift
9
star
12

feishu-api

FeishuApi is an integration of commonly used feishu open platform's APIs, easy to call.
Ruby
7
star
13

dockery

JavaScript
7
star
14

CountryCodeNSTextField

CountryCodeNSTextField subclasses NSTextfield for International Phone Calling Code Input With Flags
Swift
6
star
15

weibo-crawler

Weibo-crawler is a crawler project based on golang colly framework to crawl weibo sites and get information. It crawls web content by regular expressions and Xpath selector, spatially transforms keywords using word vector model, and clusters text content by HDBSCAN clustering algorithm.
Go
6
star
16

pangu.js

JavaScript
5
star
17

golang-crawler-example

HTML
5
star
18

learn-webpack

JavaScript
5
star
19

goetc

Go
5
star
20

Rocket.Chat.Go.SDK

Go SDK for REST API and Realtime api(almost all api)
Go
5
star
21

NSScrollSideBar

Swift
4
star
22

react-pangu

JavaScript
4
star
23

nextjs-docker-base

docker image base for nextjs
Dockerfile
4
star
24

css-cookbook

https://ruilisi.github.io/css-cookbook/
4
star
25

govet

Go
4
star
26

actioncable-jwt

Actioncable with authentication by jwt token
Ruby
3
star
27

golang-examples

Go
3
star
28

IMChatSDK-Mac

Swift
2
star
29

fortune-sheet-demo

HTML
2
star
30

UICustomView

Swift
2
star
31

IMChatSDK

Swift
2
star
32

xcode-cookbook

2
star
33

actioncable-rails

JavaScript
1
star
34

esheep

1
star
35

react-chessground-demo

JavaScript
1
star
36

rails-6-api-template

Ruby
1
star
37

rollup-react-library

Another react library creator which follows latest js libraries
JavaScript
1
star
38

chatsdk

Sample DatoCMS website built with GatsbyJS
Sass
1
star
39

lingtihuyu

1
star
40

fortune-sheet-docs

HTML
1
star