kokopu-react 1.6.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.nycrc.yml +1 -1
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +2 -2
  4. package/dist/lib/Chessboard.js +27 -19
  5. package/dist/lib/Movetext.js +5 -5
  6. package/dist/lib/impl/colorsets.js +44 -44
  7. package/dist/lib/impl/util.js +1 -1
  8. package/dist/lib/markers.js +7 -7
  9. package/doc_src/demo/PageChessboardInteraction.js +4 -3
  10. package/doc_src/demo/PageChessboardMove.js +36 -5
  11. package/doc_src/demo/demo.css +4 -0
  12. package/{graphic_test_app → graphic_test_src}/01_marker_icons.js +0 -0
  13. package/{graphic_test_app → graphic_test_src}/02_chessboard_simple.js +0 -0
  14. package/{graphic_test_app → graphic_test_src}/03_chessboard_flipped.js +0 -0
  15. package/{graphic_test_app → graphic_test_src}/04_chessboard_annotations.js +8 -8
  16. package/{graphic_test_app → graphic_test_src}/05_chessboard_move.js +4 -4
  17. package/{graphic_test_app → graphic_test_src}/06_chessboard_theme.js +2 -2
  18. package/{graphic_test_app → graphic_test_src}/07_chessboard_click_squares.js +0 -0
  19. package/{graphic_test_app → graphic_test_src}/08_chessboard_move_pieces.js +1 -1
  20. package/{graphic_test_app → graphic_test_src}/09_chessboard_edit_arrows.js +0 -0
  21. package/{graphic_test_app → graphic_test_src}/10_chessboard_play_moves.js +1 -1
  22. package/{graphic_test_app → graphic_test_src}/11_chessboard_play_promotions.js +0 -0
  23. package/{graphic_test_app → graphic_test_src}/12_movetext_simple.js +0 -0
  24. package/{graphic_test_app → graphic_test_src}/13_movetext_error.js +0 -0
  25. package/{graphic_test_app → graphic_test_src}/14_movetext_html.js +0 -0
  26. package/{graphic_test_app → graphic_test_src}/15_movetext_options.js +0 -4
  27. package/{graphic_test_app → graphic_test_src}/16_movetext_interaction.js +0 -0
  28. package/{graphic_test_app → graphic_test_src}/common/dummy.pgn +0 -0
  29. package/{graphic_test_app → graphic_test_src}/common/games.pgn +0 -0
  30. package/{graphic_test_app → graphic_test_src}/common/heartbeat.txt +0 -0
  31. package/{graphic_test_app → graphic_test_src}/common/smiley.png +0 -0
  32. package/{graphic_test_app → graphic_test_src}/common/test_app.css +0 -0
  33. package/{graphic_test_app → graphic_test_src}/common/test_app.js +3 -2
  34. package/graphics/chess_sprites/cburnett/bb.svg +45 -0
  35. package/graphics/chess_sprites/cburnett/bk.svg +47 -0
  36. package/graphics/chess_sprites/cburnett/bn.svg +37 -0
  37. package/graphics/chess_sprites/cburnett/bp.svg +19 -0
  38. package/graphics/chess_sprites/cburnett/bq.svg +58 -0
  39. package/graphics/chess_sprites/cburnett/br.svg +60 -0
  40. package/graphics/chess_sprites/cburnett/bx.svg +56 -0
  41. package/graphics/chess_sprites/cburnett/wb.svg +48 -0
  42. package/graphics/chess_sprites/cburnett/wk.svg +26 -0
  43. package/graphics/chess_sprites/cburnett/wn.svg +37 -0
  44. package/graphics/chess_sprites/cburnett/wp.svg +19 -0
  45. package/graphics/chess_sprites/cburnett/wq.svg +60 -0
  46. package/graphics/chess_sprites/cburnett/wr.svg +44 -0
  47. package/graphics/chess_sprites/cburnett/wx.svg +56 -0
  48. package/graphics/chess_sprites/generate_sprites.sh +135 -0
  49. package/graphics/chess_sprites/mmonge/celtic-bx.svg +112 -0
  50. package/graphics/chess_sprites/mmonge/celtic-wx.svg +111 -0
  51. package/graphics/chess_sprites/mmonge/celtic.svg +1576 -0
  52. package/graphics/chess_sprites/mmonge/eyes-spatial-bx.svg +101 -0
  53. package/graphics/chess_sprites/mmonge/eyes-spatial-wx.svg +100 -0
  54. package/graphics/chess_sprites/mmonge/eyes.svg +2538 -0
  55. package/graphics/chess_sprites/mmonge/fantasy-bx.svg +112 -0
  56. package/graphics/chess_sprites/mmonge/fantasy-wx.svg +111 -0
  57. package/graphics/chess_sprites/mmonge/fantasy.svg +5497 -0
  58. package/graphics/chess_sprites/mmonge/fantasy_alt.svg +3742 -0
  59. package/graphics/chess_sprites/mmonge/freak.svg +3479 -0
  60. package/graphics/chess_sprites/mmonge/prmi.svg +6776 -0
  61. package/graphics/chess_sprites/mmonge/skulls-bx.svg +124 -0
  62. package/graphics/chess_sprites/mmonge/skulls-wx.svg +111 -0
  63. package/graphics/chess_sprites/mmonge/skulls.svg +12978 -0
  64. package/graphics/chess_sprites/mmonge/spatial.svg +1223 -0
  65. package/package.json +30 -24
  66. package/scripts/{test_graphic/clean-graphic-output.js → clean-graphic-output.js} +1 -1
  67. package/scripts/docker-compose.yml +14 -0
  68. package/scripts/{test_graphic/webpack-config.js → test-graphic.webpack.config.js} +7 -6
  69. package/scripts/{test_headless.webpack-config.js → test-headless.webpack.config.js} +2 -1
  70. package/src/Chessboard.js +27 -19
  71. package/src/Movetext.js +5 -5
  72. package/src/impl/colorsets.js +44 -44
  73. package/src/impl/util.js +1 -1
  74. package/src/markers.js +7 -7
  75. package/test/1_markers.js +14 -14
  76. package/test/common/graphic.js +2 -2
  77. package/test/references/04_chessboard_annotations/0.png +0 -0
  78. package/test/references/04_chessboard_annotations/1.png +0 -0
  79. package/test/references/04_chessboard_annotations/2.png +0 -0
  80. package/test/references/04_chessboard_annotations/3.png +0 -0
  81. package/test/references/04_chessboard_annotations/4.png +0 -0
  82. package/test/references/04_chessboard_annotations/5.png +0 -0
  83. package/test/references/05_chessboard_move/3.png +0 -0
  84. package/test/references/05_chessboard_move/4.png +0 -0
  85. package/test/references/05_chessboard_move/5.png +0 -0
  86. package/test/references/05_chessboard_move/6.png +0 -0
  87. package/test/references/06_chessboard_theme/0.png +0 -0
  88. package/test/references/06_chessboard_theme/1.png +0 -0
  89. package/test/references/06_chessboard_theme/2.png +0 -0
  90. package/test/references/06_chessboard_theme/3.png +0 -0
  91. package/test/references/06_chessboard_theme/4.png +0 -0
  92. package/test/references/06_chessboard_theme/5.png +0 -0
  93. package/test/references/06_chessboard_theme/6.png +0 -0
  94. package/test/references/06_chessboard_theme/7.png +0 -0
  95. package/test/references/06_chessboard_theme/8.png +0 -0
  96. package/test/references/08_chessboard_move_pieces/over_arrow_marker.png +0 -0
  97. package/test/references/08_chessboard_move_pieces/over_square_marker.png +0 -0
  98. package/test/references/08_chessboard_move_pieces/over_text_marker.png +0 -0
  99. package/test/references/09_chessboard_edit_arrows/base_1.png +0 -0
  100. package/test/references/09_chessboard_edit_arrows/base_2.png +0 -0
  101. package/test/references/09_chessboard_edit_arrows/null_vector.png +0 -0
  102. package/test/references/09_chessboard_edit_arrows/over_arrow_marker.png +0 -0
  103. package/test/references/09_chessboard_edit_arrows/over_square_marker.png +0 -0
  104. package/test/references/10_chessboard_play_moves/castling_move.png +0 -0
  105. package/test/references/10_chessboard_play_moves/regular_move_2.png +0 -0
  106. package/scripts/test_graphic/docker-compose.yml +0 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kokopu-react",
3
- "version": "1.6.0",
3
+ "version": "1.7.2",
4
4
  "description": "A React-based library to create and display chessboard and chess-related components.",
5
5
  "keywords": [
6
6
  "chess",
@@ -18,61 +18,67 @@
18
18
  "files": [
19
19
  "dist/lib",
20
20
  "doc_src",
21
- "graphic_test_app",
21
+ "graphic_test_src",
22
22
  "graphics",
23
- "scripts/test_graphic",
24
- "scripts/test_headless.webpack-config.js",
23
+ "scripts/clean-graphic-output.js",
24
+ "scripts/docker-compose.yml",
25
+ "scripts/test-graphic.webpack.config.js",
26
+ "scripts/test-headless.webpack.config.js",
25
27
  "src",
26
28
  "test",
27
29
  ".babelrc",
28
30
  ".eslint.yml",
29
31
  ".nycrc.yml"
30
32
  ],
33
+ "peerDependencies": {
34
+ "kokopu": "^2.6.0",
35
+ "react": "17.x.x || 18.x.x"
36
+ },
31
37
  "dependencies": {
32
38
  "htmlparser2": "^8.0.1",
33
- "kokopu": "^2.8.0",
34
39
  "prop-types": "^15.8.1",
35
- "react": "^17.0.2",
36
40
  "react-draggable": "^4.4.5",
37
41
  "react-motion": "^0.5.2"
38
42
  },
39
43
  "devDependencies": {
40
- "@babel/cli": "^7.17.10",
41
- "@babel/core": "^7.18.2",
42
- "@babel/preset-env": "^7.18.2",
43
- "@babel/preset-react": "^7.17.12",
44
- "@emotion/react": "^11.9.0",
45
- "@emotion/styled": "^11.8.1",
46
- "@mui/material": "^5.8.2",
44
+ "@babel/cli": "^7.18.10",
45
+ "@babel/core": "^7.18.10",
46
+ "@babel/preset-env": "^7.18.10",
47
+ "@babel/preset-react": "^7.18.6",
48
+ "@emotion/react": "^11.10.0",
49
+ "@emotion/styled": "^11.10.0",
50
+ "@mui/material": "^5.9.3",
47
51
  "babel-loader": "^8.2.5",
48
52
  "babel-plugin-istanbul": "^6.1.1",
49
53
  "copy-webpack-plugin": "^11.0.0",
50
54
  "coveralls": "^3.1.1",
51
55
  "css-loader": "^6.7.1",
52
- "eslint": "^8.16.0",
53
- "eslint-plugin-react": "^7.30.0",
56
+ "eslint": "^8.21.0",
57
+ "eslint-plugin-react": "^7.30.1",
54
58
  "html-webpack-plugin": "^5.5.0",
55
59
  "img-diff-js": "^0.5.2",
60
+ "kokopu": "^2.9.2",
56
61
  "mocha": "^10.0.0",
57
62
  "null-loader": "^4.0.1",
58
63
  "nyc": "^15.1.0",
59
- "react-dom": "^17.0.2",
64
+ "react": "^18.2.0",
65
+ "react-dom": "^18.2.0",
60
66
  "react-styleguidist": "^11.2.0",
61
- "selenium-webdriver": "^4.1.2",
62
- "ssh2-sftp-client": "^8.1.0",
67
+ "selenium-webdriver": "^4.3.1",
68
+ "ssh2-sftp-client": "^9.0.2",
63
69
  "style-loader": "^3.3.1",
64
70
  "unit.js": "^2.1.1",
65
- "webpack": "^5.72.1",
66
- "webpack-cli": "^4.9.2"
71
+ "webpack": "^5.74.0",
72
+ "webpack-cli": "^4.10.0"
67
73
  },
68
74
  "scripts": {
69
- "lint": "eslint doc_src graphic_test_app src test",
70
- "preunit": "webpack --config scripts/test_headless.webpack-config.js && webpack --config scripts/test_graphic/webpack-config.js && node scripts/test_graphic/clean-graphic-output.js",
75
+ "lint": "eslint doc_src graphic_test_src src test",
76
+ "preunit": "webpack --config scripts/test-headless.webpack.config.js && webpack --config scripts/test-graphic.webpack.config.js && node scripts/clean-graphic-output.js",
71
77
  "unit": "nyc mocha --bail --sort",
72
78
  "test": "npm run lint && npm run unit",
73
79
  "publish_coverage": "nyc report --reporter=text-lcov | coveralls",
74
- "start_test_env": "docker-compose -f scripts/test_graphic/docker-compose.yml up -d",
75
- "stop_test_env": "docker-compose -f scripts/test_graphic/docker-compose.yml down",
80
+ "test_env:start": "docker-compose -p kokopu-react-test-env -f scripts/docker-compose.yml up -d",
81
+ "test_env:stop": "docker-compose -p kokopu-react-test-env -f scripts/docker-compose.yml down",
76
82
  "build": "make -f scripts/build.mk",
77
83
  "clean": "make -f scripts/build.mk clean",
78
84
  "start": "styleguidist server --open --config scripts/styleguide.config.js",
@@ -22,7 +22,7 @@
22
22
 
23
23
  const fs = require('fs');
24
24
 
25
- const rootDir = __dirname + '/../..';
25
+ const rootDir = __dirname + '/..';
26
26
  const outputDir = rootDir + '/build/graphic_output';
27
27
 
28
28
  // Erase the directory in which the screenshots are generated.
@@ -0,0 +1,14 @@
1
+ version: "3.7"
2
+
3
+ services:
4
+ web-client:
5
+ image: selenium/standalone-firefox:4.3.0-20220726
6
+ shm_size: '2gb'
7
+ ports:
8
+ - 4444:4444 # http://localhost:4444 (driver)
9
+ - 7900:7900 # http://localhost:7900 (VNC, pass: secret)
10
+ volumes:
11
+ - type: bind
12
+ source: ..
13
+ target: /app
14
+ read_only: true
@@ -25,11 +25,11 @@ const path = require('path');
25
25
  const CopyWebpackPlugin = require('copy-webpack-plugin');
26
26
  const HtmlWebpackPlugin = require('html-webpack-plugin');
27
27
 
28
- // List all the JS files in /test/graphic, each of them corresponding to a entry.
29
- var items = fs.readdirSync('./graphic_test_app').filter(filename => path.extname(filename) === '.js').map(filename => path.basename(filename, '.js')).sort();
28
+ // List all the JS files in /graphic_test_src, each of them corresponding to a entry.
29
+ var items = fs.readdirSync('./graphic_test_src').filter(filename => path.extname(filename) === '.js').map(filename => path.basename(filename, '.js')).sort();
30
30
  var entries = {};
31
31
  items.forEach(item => {
32
- entries[item] = `./graphic_test_app/${item}.js`;
32
+ entries[item] = `./graphic_test_src/${item}`;
33
33
  });
34
34
 
35
35
  // Define the outputs.
@@ -40,16 +40,17 @@ var plugins = items.map(item => new HtmlWebpackPlugin({
40
40
  }));
41
41
  plugins.push(new CopyWebpackPlugin({
42
42
  patterns: [
43
- { from: './graphic_test_app/common/heartbeat.txt', to: 'heartbeat.txt' },
44
- { from: './graphic_test_app/common/smiley.png', to: 'smiley.png' },
43
+ { from: './graphic_test_src/common/heartbeat.txt', to: 'heartbeat.txt' },
44
+ { from: './graphic_test_src/common/smiley.png', to: 'smiley.png' },
45
45
  ],
46
46
  }));
47
47
 
48
48
  module.exports = {
49
49
  mode: 'development',
50
+ devtool: 'inline-source-map',
50
51
  entry: entries,
51
52
  output: {
52
- path: path.resolve(__dirname, '../../build/test_graphic'),
53
+ path: path.resolve(__dirname, '../build/test_graphic'),
53
54
  hashFunction: "xxhash64", // FIXME The default hash function used by Webpack has been removed from OpenSSL.
54
55
  },
55
56
  plugins: plugins,
@@ -24,8 +24,9 @@ const path = require('path');
24
24
 
25
25
  module.exports = {
26
26
  mode: 'development',
27
+ devtool: 'inline-source-map',
27
28
  entry: {
28
- index: './src/index.js',
29
+ index: './src/index',
29
30
  },
30
31
  output: {
31
32
  path: path.resolve(__dirname, '../build/test_headless'),
package/src/Chessboard.js CHANGED
@@ -123,10 +123,10 @@ export default class Chessboard extends React.Component {
123
123
  return (
124
124
  <svg className="kokopu-chessboard" viewBox={viewBox} width={xmax - xmin} height={ymax - ymin}>
125
125
  <defs>
126
+ {this.renderArrowTip(colorset, 'b')}
126
127
  {this.renderArrowTip(colorset, 'g')}
127
128
  {this.renderArrowTip(colorset, 'r')}
128
129
  {this.renderArrowTip(colorset, 'y')}
129
- {this.renderArrowTip(colorset, 'highlight')}
130
130
  </defs>
131
131
  {squares}
132
132
  {rankCoordinates}
@@ -213,7 +213,8 @@ export default class Chessboard extends React.Component {
213
213
  let { x, y } = this.getSquareCoordinates(squareSize, this.state.hoveredSquare);
214
214
  let thickness = Math.max(2, Math.round(HOVER_MARKER_THICKNESS_FACTOR * squareSize));
215
215
  let size = squareSize - thickness;
216
- return <rect className="kokopu-hoveredSquare" x={x + thickness/2} y={y + thickness/2} width={size} height={size} stroke={colorset.highlight} strokeWidth={thickness} />;
216
+ let color = this.isEditArrowModeEnabled() ? this.props.editedArrowColor : this.props.moveArrowColor;
217
+ return <rect className="kokopu-hoveredSquare" x={x + thickness/2} y={y + thickness/2} width={size} height={size} stroke={colorset['c' + color]} strokeWidth={thickness} />;
217
218
  }
218
219
 
219
220
  renderPiece(position, squareSize, pieceset, sq) {
@@ -272,7 +273,7 @@ export default class Chessboard extends React.Component {
272
273
  return (
273
274
  <line
274
275
  className="kokopu-annotation kokopu-arrow kokopu-arrowDraggable kokopu-dragging" x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
275
- stroke={colorset[this.props.editedArrowColor]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
276
+ stroke={colorset['c' + this.props.editedArrowColor]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
276
277
  />
277
278
  );
278
279
  }
@@ -335,7 +336,7 @@ export default class Chessboard extends React.Component {
335
336
  let result = [];
336
337
  Object.entries(sqm).forEach(([ sq, color ]) => {
337
338
  let { x, y } = this.getSquareCoordinates(squareSize, sq);
338
- result.push(<rect key={'sqm-' + sq} className="kokopu-annotation" x={x} y={y} width={squareSize} height={squareSize} fill={colorset[color]} />);
339
+ result.push(<rect key={'sqm-' + sq} className="kokopu-annotation" x={x} y={y} width={squareSize} height={squareSize} fill={colorset['c' + color]} />);
339
340
  });
340
341
  return result;
341
342
  }
@@ -348,7 +349,7 @@ export default class Chessboard extends React.Component {
348
349
  y += squareSize / 2;
349
350
  result.push(
350
351
  <g key={'txtm-' + sq} className="kokopu-annotation">
351
- <TextSymbol x={x} y={y} size={squareSize} symbol={value.symbol} color={colorset[value.color]} />
352
+ <TextSymbol x={x} y={y} size={squareSize} symbol={value.symbol} color={colorset['c' + value.color]} />
352
353
  </g>
353
354
  );
354
355
  });
@@ -376,7 +377,7 @@ export default class Chessboard extends React.Component {
376
377
  result.push(
377
378
  <line
378
379
  key={'arm-' + vect} className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
379
- stroke={colorset[color]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
380
+ stroke={colorset['c' + color]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
380
381
  />
381
382
  );
382
383
  });
@@ -397,16 +398,17 @@ export default class Chessboard extends React.Component {
397
398
  yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
398
399
  let x = xTo * alpha + xFrom * (1 - alpha);
399
400
  let y = yTo * alpha + yFrom * (1 - alpha);
401
+ let color = this.props.moveArrowColor;
400
402
  return (
401
403
  <line
402
- className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={x} y2={y} stroke={colorset['highlight']}
403
- strokeWidth={squareSize * STROKE_THICKNESS_FACTOR} markerEnd={`url(#${this.getArrowTipId('highlight')})`}
404
+ className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={x} y2={y} stroke={colorset['c' + color]}
405
+ strokeWidth={squareSize * STROKE_THICKNESS_FACTOR} markerEnd={`url(#${this.getArrowTipId(color)})`}
404
406
  />
405
407
  );
406
408
  }
407
409
 
408
410
  renderArrowTip(colorset, color) {
409
- return <ArrowTip id={this.getArrowTipId(color)} color={colorset[color]} />;
411
+ return <ArrowTip id={this.getArrowTipId(color)} color={colorset['c' + color]} />;
410
412
  }
411
413
 
412
414
  renderTurnFlag(turn, squareSize, pieceset) {
@@ -735,7 +737,7 @@ export default class Chessboard extends React.Component {
735
737
  /**
736
738
  * Available colorsets for theming.
737
739
  *
738
- * @returns {Object.<string, {w: string, b: string, g: string, r: string, y: string, highlight: string}>}
740
+ * @returns {Object.<string, { w: string, b: string, cb: string, cg: string, cr: string, cy: string }>}
739
741
  * @public
740
742
  */
741
743
  static colorsets() {
@@ -745,8 +747,8 @@ export default class Chessboard extends React.Component {
745
747
  /**
746
748
  * Available piecesets for theming.
747
749
  *
748
- * @returns {Object.<string, {bb: string, bk: string, bn: string, bp: string, bq: string, br: string, bx: string,
749
- * wb: string, wk: string, wn: string, wp: string, wq: string, wr: string, wx: string}>}
750
+ * @returns {Object.<string, { bb: string, bk: string, bn: string, bp: string, bq: string, br: string, bx: string,
751
+ * wb: string, wk: string, wn: string, wp: string, wq: string, wr: string, wx: string }>}
750
752
  * @public
751
753
  */
752
754
  static piecesets() {
@@ -758,12 +760,12 @@ export default class Chessboard extends React.Component {
758
760
  Chessboard.propTypes = {
759
761
 
760
762
  /**
761
- * Displayed position. Can be a [kokopu.Position](https://kokopu.yo35.org/docs/Position.html) object,
763
+ * Displayed position. Can be a [kokopu.Position](https://kokopu.yo35.org/docs/current/Position.html) object,
762
764
  * a [FEN string](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation),
763
765
  * `'start'` (usual starting position), or `'empty'` (empty board).
764
766
  *
765
767
  * Optionally, the FEN string can be prefixed with `'variant:'`, `variant` corresponding to one of the
766
- * [game variant](https://kokopu.yo35.org/docs/global.html#GameVariant) supported by Kokopu. For instance:
768
+ * [game variant](https://kokopu.yo35.org/docs/current/global.html#GameVariant) supported by Kokopu. For instance:
767
769
  * `'chess960:nrkbqrbn/pppppppp/8/8/8/8/PPPPPPPP/NRKBQRBN w KQkq - 0 1'`.
768
770
  */
769
771
  position: PropTypes.oneOfType([
@@ -772,7 +774,7 @@ Chessboard.propTypes = {
772
774
  ]),
773
775
 
774
776
  /**
775
- * Displayed move (optional), defined either as a [kokopu.MoveDescriptor](https://kokopu.yo35.org/docs/MoveDescriptor.html) object
777
+ * Displayed move (optional), defined either as a [kokopu.MoveDescriptor](https://kokopu.yo35.org/docs/current/MoveDescriptor.html) object
776
778
  * or as a [SAN string](https://en.wikipedia.org/wiki/Algebraic_notation_(chess)) (e.g. `'Nf3'`). In both cases, it must represent
777
779
  * a legal move in position defined in attribute `position`.
778
780
  */
@@ -789,7 +791,7 @@ Chessboard.propTypes = {
789
791
  * Square markers, defined as a "square -> color" struct (e.g. `{ e4: 'g', d5: 'r' }`) or as a comma-separated CSL string (e.g. `'Rd5,Ge4'`).
790
792
  */
791
793
  squareMarkers: PropTypes.oneOfType([
792
- PropTypes.objectOf(PropTypes.oneOf([ 'g', 'r', 'y' ])),
794
+ PropTypes.objectOf(PropTypes.oneOf([ 'b', 'g', 'r', 'y' ])),
793
795
  PropTypes.string
794
796
  ]),
795
797
 
@@ -800,7 +802,7 @@ Chessboard.propTypes = {
800
802
  textMarkers: PropTypes.oneOfType([
801
803
  PropTypes.objectOf(PropTypes.shape({
802
804
  symbol: PropTypes.string.isRequired,
803
- color: PropTypes.oneOf([ 'g', 'r', 'y' ]).isRequired
805
+ color: PropTypes.oneOf([ 'b', 'g', 'r', 'y' ]).isRequired
804
806
  })),
805
807
  PropTypes.string
806
808
  ]),
@@ -810,7 +812,7 @@ Chessboard.propTypes = {
810
812
  * or as a comma-separated CAL string (e.g. `'Ge2e4,Rg8f6,Yg8h6'`).
811
813
  */
812
814
  arrowMarkers: PropTypes.oneOfType([
813
- PropTypes.objectOf(PropTypes.oneOf([ 'g', 'r', 'y' ])),
815
+ PropTypes.objectOf(PropTypes.oneOf([ 'b', 'g', 'r', 'y' ])),
814
816
  PropTypes.string
815
817
  ]),
816
818
 
@@ -834,6 +836,11 @@ Chessboard.propTypes = {
834
836
  */
835
837
  moveArrowVisible: PropTypes.bool,
836
838
 
839
+ /**
840
+ * Color of the move arrow.
841
+ */
842
+ moveArrowColor: PropTypes.oneOf([ 'b', 'g', 'r', 'y' ]),
843
+
837
844
  /**
838
845
  * Whether moves are animated or not.
839
846
  */
@@ -881,7 +888,7 @@ Chessboard.propTypes = {
881
888
  /**
882
889
  * Color of the edited arrow (only used if `interactionMode` is set to `'editArrows'`).
883
890
  */
884
- editedArrowColor: PropTypes.oneOf([ 'g', 'r', 'y' ]),
891
+ editedArrowColor: PropTypes.oneOf([ 'b', 'g', 'r', 'y' ]),
885
892
 
886
893
  /**
887
894
  * Callback invoked when a piece is moved through drag&drop (only if `interactionMode` is set to `'movePieces'`).
@@ -921,6 +928,7 @@ Chessboard.defaultProps = {
921
928
  squareSize: 40,
922
929
  coordinateVisible: true,
923
930
  moveArrowVisible: true,
931
+ moveArrowColor: 'b',
924
932
  animated: false,
925
933
  colorset: 'original',
926
934
  pieceset: 'cburnett',
package/src/Movetext.js CHANGED
@@ -482,8 +482,8 @@ export default class Movetext extends React.Component {
482
482
  Movetext.propTypes = {
483
483
 
484
484
  /**
485
- * Displayed position. Can be a [kokopu.Game](https://kokopu.yo35.org/docs/Game.html) object,
486
- * a [kokopu.Database](https://kokopu.yo35.org/docs/Database.html) object,
485
+ * Displayed position. Can be a [kokopu.Game](https://kokopu.yo35.org/docs/current/Game.html) object,
486
+ * a [kokopu.Database](https://kokopu.yo35.org/docs/current/Database.html) object,
487
487
  * or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation).
488
488
  */
489
489
  game: PropTypes.oneOfType([
@@ -493,7 +493,7 @@ Movetext.propTypes = {
493
493
  ]),
494
494
 
495
495
  /**
496
- * Index of the game to display (only if attribute `game` is a [kokopu.Database](https://kokopu.yo35.org/docs/Database.html)
496
+ * Index of the game to display (only if attribute `game` is a [kokopu.Database](https://kokopu.yo35.org/docs/current/Database.html)
497
497
  * or a [PGN string](https://en.wikipedia.org/wiki/Portable_Game_Notation)): `0` for the first game of the database/PGN, `1` for the second one, etc.
498
498
  * If omitted, the first game of the database/PGN is displayed.
499
499
  */
@@ -542,7 +542,7 @@ Movetext.propTypes = {
542
542
 
543
543
  /**
544
544
  * ID of the selected move (or `'start'` for the beginning of the main variation).
545
- * Use [kokopu.Node#id](https://kokopu.yo35.org/docs/Node.html#id) to get the ID of a game move.
545
+ * Use [kokopu.Node#id](https://kokopu.yo35.org/docs/current/Node.html#id) to get the ID of a game move.
546
546
  */
547
547
  selection: PropTypes.string,
548
548
 
@@ -556,7 +556,7 @@ Movetext.propTypes = {
556
556
  /**
557
557
  * Callback invoked when the user selects a move (only if `interactionMode` is set to `'selectMove'`).
558
558
  *
559
- * @param {string?} nodeId ID of the selected move (as returned by [kokopu.Node#id](https://kokopu.yo35.org/docs/Node.html#id)),
559
+ * @param {string?} nodeId ID of the selected move (as returned by [kokopu.Node#id](https://kokopu.yo35.org/docs/current/Node.html#id)),
560
560
  * `'start'` for the beginning of the main variation, or `undefined` if the user unselects the previously selected move.
561
561
  * @param {string} evtOrigin Origin of the event. Can be:
562
562
  * - `'key-first'`: the event has been triggered by the "go-to-first-move" key (aka. the home key),
@@ -25,42 +25,42 @@ export default {
25
25
  original: {
26
26
  b: '#b5876b',
27
27
  w: '#f0dec7',
28
- g: '#0e0',
29
- r: '#d00',
30
- y: '#db0',
31
- highlight: '#04f',
28
+ cb: '#04f',
29
+ cg: '#0e0',
30
+ cr: '#d00',
31
+ cy: '#db0',
32
32
  },
33
33
  gray: {
34
34
  b: '#bbbbbb',
35
35
  w: '#f8f8f8',
36
- g: '#0a0',
37
- r: '#d00',
38
- y: '#a90',
39
- highlight: '#04f',
36
+ cb: '#04f',
37
+ cg: '#0a0',
38
+ cr: '#d00',
39
+ cy: '#a90',
40
40
  },
41
41
  scid: {
42
42
  b: '#7389b6',
43
43
  w: '#f3f3f3',
44
- g: '#0e0',
45
- r: '#d00',
46
- y: '#db0',
47
- highlight: '#04f',
44
+ cb: '#04f',
45
+ cg: '#0e0',
46
+ cr: '#d00',
47
+ cy: '#db0',
48
48
  },
49
49
  wikipedia: {
50
50
  b: '#d18b47',
51
51
  w: '#ffce9e',
52
- g: '#0e0',
53
- r: '#d00',
54
- y: '#db0',
55
- highlight: '#04f',
52
+ cb: '#04f',
53
+ cg: '#0e0',
54
+ cr: '#d00',
55
+ cy: '#db0',
56
56
  },
57
57
  xboard: {
58
58
  b: '#77a26d',
59
59
  w: '#c8c365',
60
- g: '#0f0',
61
- r: '#d00',
62
- y: '#ff0',
63
- highlight: '#04f',
60
+ cb: '#04f',
61
+ cg: '#0f0',
62
+ cr: '#d00',
63
+ cy: '#ff0',
64
64
  },
65
65
 
66
66
  /*
@@ -70,50 +70,50 @@ export default {
70
70
  coral: {
71
71
  b: 'rgb(112,162,163)',
72
72
  w: 'rgb(177,228,185)',
73
- g: '#080',
74
- r: '#d00',
75
- y: '#ff0',
76
- highlight: '#04f',
73
+ cb: '#04f',
74
+ cg: '#080',
75
+ cr: '#d00',
76
+ cy: '#ff0',
77
77
  },
78
78
  dusk: {
79
79
  b: 'rgb(112,102,119)',
80
80
  w: 'rgb(204,183,174)',
81
- g: '#3f3',
82
- r: '#f20',
83
- y: '#ff0',
84
- highlight: '#04f',
81
+ cb: '#04f',
82
+ cg: '#3f3',
83
+ cr: '#f20',
84
+ cy: '#ff0',
85
85
  },
86
86
  emerald: {
87
87
  b: 'rgb(111,143,114)',
88
88
  w: 'rgb(173,189,143)',
89
- g: '#6f6',
90
- r: '#d00',
91
- y: '#ff0',
92
- highlight: '#04f',
89
+ cb: '#04f',
90
+ cg: '#6f6',
91
+ cr: '#d00',
92
+ cy: '#ff0',
93
93
  },
94
94
  marine: {
95
95
  b: 'rgb(111,115,210)',
96
96
  w: 'rgb(157,172,255)',
97
- g: '#6f6',
98
- r: '#f50',
99
- y: '#ff0',
100
- highlight: '#04f',
97
+ cb: '#04f',
98
+ cg: '#6f6',
99
+ cr: '#f50',
100
+ cy: '#ff0',
101
101
  },
102
102
  sandcastle: {
103
103
  b: 'rgb(184,139,74)',
104
104
  w: 'rgb(227,193,111)',
105
- g: '#0c3',
106
- r: '#d02',
107
- y: '#ff0',
108
- highlight: '#04f',
105
+ cb: '#04f',
106
+ cg: '#0c3',
107
+ cr: '#d02',
108
+ cy: '#ff0',
109
109
  },
110
110
  wheat: {
111
111
  b: 'rgb(187,190,100)',
112
112
  w: 'rgb(234,240,206)',
113
- g: '#0c3',
114
- r: '#d00',
115
- y: '#ff3',
116
- highlight: '#04f',
113
+ cb: '#04f',
114
+ cg: '#0c3',
115
+ cr: '#d00',
116
+ cy: '#ff3',
117
117
  },
118
118
 
119
119
  };
package/src/impl/util.js CHANGED
@@ -51,7 +51,7 @@ export function isValidVector(vect) {
51
51
 
52
52
 
53
53
  export function isValidColor(color) {
54
- return color === 'g' || color === 'r' || color === 'y';
54
+ return color === 'b' || color === 'g' || color === 'r' || color === 'y';
55
55
  }
56
56
 
57
57
 
package/src/markers.js CHANGED
@@ -56,8 +56,8 @@ export function flattenTextMarkers(markers) {
56
56
  /**
57
57
  * Transform a set of arrow markers defined as a "squareFromSquareTo -> color" struct into a comma-separated string.
58
58
  *
59
- * @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'y' }`
60
- * @returns {string} For example: `'Ge2e4,Rg8f6,Yg8h6'`
59
+ * @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
60
+ * @returns {string} For example: `'Ge2e4,Rg8f6,Bg8h6'`
61
61
  */
62
62
  export function flattenArrowMarkers(markers) {
63
63
  return Object.entries(markers)
@@ -83,7 +83,7 @@ function parseMarkers(markers, tokenParser) {
83
83
  */
84
84
  export function parseSquareMarkers(markers) {
85
85
  return parseMarkers(markers, token => {
86
- return /^([GRY])([a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
86
+ return /^([BGRY])([a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
87
87
  });
88
88
  }
89
89
 
@@ -96,7 +96,7 @@ export function parseSquareMarkers(markers) {
96
96
  */
97
97
  export function parseTextMarkers(markers) {
98
98
  return parseMarkers(markers, token => {
99
- return /^([GRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ?
99
+ return /^([BGRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ?
100
100
  { key: RegExp.$4, value: { symbol: RegExp.$2 || RegExp.$3, color: RegExp.$1.toLowerCase() } } : undefined;
101
101
  });
102
102
  }
@@ -105,11 +105,11 @@ export function parseTextMarkers(markers) {
105
105
  /**
106
106
  * Parse a set of arrow markers defined as a comma-separated string into a "squareFromSquareTo -> color" struct.
107
107
  *
108
- * @param {string} markers For example: `'Ge2e4,Rg8f6,Yg8h6'`
109
- * @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'y' }`
108
+ * @param {string} markers For example: `'Ge2e4,Rg8f6,Bg8h6'`
109
+ * @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
110
110
  */
111
111
  export function parseArrowMarkers(markers) {
112
112
  return parseMarkers(markers, token => {
113
- return /^([GRY])([a-h][1-8][a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
113
+ return /^([BGRY])([a-h][1-8][a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
114
114
  });
115
115
  }