项目作者: ginger-gm

项目描述 :
A React PGN viewer for chess games.
高级语言: JavaScript
项目地址: git://github.com/ginger-gm/react-pgn-viewer.git
创建时间: 2020-08-09T13:43:56Z
项目社区:https://github.com/ginger-gm/react-pgn-viewer

开源协议:MIT License

下载


@gingergm/react-pgn-viewer

WIP. Use at own risk.

Usage

yarn add @gingergm/react-pgn-viewer

Requires chessboard.js and jQuery to be available on the window object.

  1. import PGNViewer from '@gingergm/react-pgn-viewer'
  2. const pgnData = `
  3. [Event "?"]
  4. [Site "?"]
  5. [Date "????.??.??"]
  6. [Round "?"]
  7. [White "Mating : Blind Swine 1"]
  8. [Black "?"]
  9. [Result "*"]
  10. [Annotator "Lawrence Trent / Mark Lyell"]
  11. [SetUp "1"]
  12. [FEN "r4rk1/2R2pp1/1n2N2p/2Rp4/p2P4/P3PQ1P/qP3PPK/8 w - - 0 1"]
  13. [PlyCount "7"]
  14. [SourceTitle "Ultimate Attacking Guide"]
  15. [Source "Ginger GM Ltd"]
  16. [SourceDate "2020.02.17"]
  17. [SourceVersion "4"]
  18. [SourceVersionDate "2020.02.17"]
  19. [SourceQuality "1"]
  20. 1. Qg3 g6 (1... fxe6 2. Qxg7#) 2. Qxg6+ fxg6 3. Rg7+ Kh8 4. Rcc7 {Any move
  21. allows the Blind Swine mate Swiderski,R-Nimzowitsch,A Barmen 1905} *
  22. `
  23. <PGNViewer
  24. enginePath="/js/stockfish.js" // If not provided, engine button will not be shown
  25. pgnData={pgnData}
  26. pieceTheme="/chessboardjs-0.3.0/img/chesspieces/alpha/{piece}.svg" // see https://chessboardjs.com/docs
  27. opts={{
  28. // defaults shown below
  29. blackSquareColour: '#b85649',
  30. border: 'none', // or '4px solid green' etc.
  31. mobileBreakpoint: 600, // px. >= this number, game text will be shown alongside the board. < this number, game text is shown below the board. *Note that this applies to to the container width, not the viewport.*
  32. showNotation: false,
  33. showGameHeader: true,
  34. whiteSquareColour: '#efd8c0',
  35. }}
  36. />

TODO:

By no means a definitive list!

  • Allow custom styling, custom <GameSelect ></GameSelect> component
  • Don’t show game text if there are no moves
  • Examples
  • Tests