kokopu-react 1.1.0 → 1.4.0
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.
- package/CHANGELOG.md +17 -0
- package/README.md +2 -0
- package/dist/lib/ArrowMarkerIcon.js +3 -5
- package/dist/lib/Chessboard.js +25 -32
- package/dist/lib/{impl/ErrorBox.js → ErrorBox.js} +1 -1
- package/dist/lib/TextMarkerIcon.js +11 -10
- package/dist/lib/css/symbol.css +25 -0
- package/dist/lib/i18n.js +35 -0
- package/dist/lib/impl/ArrowTip.js +2 -7
- package/dist/lib/impl/TextSymbol.js +100 -0
- package/dist/lib/impl/util.js +5 -5
- package/dist/lib/index.js +34 -18
- package/dist/lib/markers.js +10 -10
- package/doc_src/{demo/.eslintrc.yml → .eslintrc.yml} +0 -0
- package/doc_src/demo/PageChessboardBase.js +35 -40
- package/doc_src/demo/PageChessboardEdition.js +58 -70
- package/doc_src/demo/PageChessboardMove.js +20 -27
- package/doc_src/demo/PageChessboardSmallScreens.js +15 -16
- package/doc_src/examples/ErrorBox.md +3 -0
- package/doc_src/theming/LogoRenderer.js +50 -0
- package/doc_src/theming/kokopu-react-favicon.png +0 -0
- package/doc_src/theming/kokopu-react-logo.png +0 -0
- package/doc_src/theming/theming.css +29 -0
- package/graphic_test_app/01_marker_icons.js +5 -3
- package/graphic_test_app/04_chessboard_annotations.js +1 -1
- package/graphic_test_app/10_chessboard_play_moves.js +2 -0
- package/graphics/logo-small.svg +14 -0
- package/graphics/logo.svg +26 -0
- package/package.json +23 -21
- package/scripts/test_graphic/docker-compose.yml +1 -1
- package/scripts/test_graphic/webpack-config.js +1 -0
- package/scripts/test_headless.webpack-config.js +1 -0
- package/src/ArrowMarkerIcon.js +1 -1
- package/src/Chessboard.js +15 -15
- package/src/{impl/ErrorBox.js → ErrorBox.js} +1 -1
- package/src/TextMarkerIcon.js +6 -6
- package/src/css/symbol.css +25 -0
- package/src/i18n.js +30 -0
- package/src/impl/ArrowTip.js +2 -6
- package/src/impl/TextSymbol.js +77 -0
- package/src/impl/util.js +1 -1
- package/src/index.js +2 -0
- package/src/markers.js +7 -6
- package/test/1_markers.js +19 -0
- package/test/3_marker_icons_graphic.js +1 -1
- package/test/6_chessboard_play_moves.js +4 -0
- package/test/references/01_marker_icons/10.png +0 -0
- package/test/references/01_marker_icons/9.png +0 -0
- package/test/references/02_chessboard_simple/2.png +0 -0
- package/test/references/02_chessboard_simple/5.png +0 -0
- package/test/references/03_chessboard_flipped/2.png +0 -0
- package/test/references/04_chessboard_annotations/4.png +0 -0
- package/test/references/04_chessboard_annotations/5.png +0 -0
- package/test/references/10_chessboard_play_moves/chess960_ambiguous_king_move.png +0 -0
- package/test/references/10_chessboard_play_moves/chess960_castling_move_1.png +0 -0
- package/test/references/10_chessboard_play_moves/chess960_castling_move_2.png +0 -0
- package/test/references/10_chessboard_play_moves/chess960_non_kxr_castling.png +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
3
|
+
<rect x="0" y="0" width="24" height="24" fill="#282c34" />
|
|
4
|
+
<g transform="matrix(0.04515812,0,0,0.04515812,-7.0115685,-1.3871247)">
|
|
5
|
+
<path fill="#61DAFB" d="M666.3,296.5c0-32.5-40.7-63.3-103.1-82.4c14.4-63.6,8-114.2-20.2-130.4c-6.5-3.8-14.1-5.6-22.4-5.6v22.3 c4.6,0,8.3,0.9,11.4,2.6c13.6,7.8,19.5,37.5,14.9,75.7c-1.1,9.4-2.9,19.3-5.1,29.4c-19.6-4.8-41-8.5-63.5-10.9 c-13.5-18.5-27.5-35.3-41.6-50c32.6-30.3,63.2-46.9,84-46.9l0-22.3c0,0,0,0,0,0c-27.5,0-63.5,19.6-99.9,53.6 c-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7,0,51.4,16.5,84,46.6c-14,14.7-28,31.4-41.3,49.9c-22.6,2.4-44,6.1-63.6,11 c-2.3-10-4-19.7-5.2-29c-4.7-38.2,1.1-67.9,14.6-75.8c3-1.8,6.9-2.6,11.5-2.6l0-22.3c0,0,0,0,0,0c-8.4,0-16,1.8-22.6,5.6 c-28.1,16.2-34.4,66.7-19.9,130.1c-62.2,19.2-102.7,49.9-102.7,82.3c0,32.5,40.7,63.3,103.1,82.4c-14.4,63.6-8,114.2,20.2,130.4 c6.5,3.8,14.1,5.6,22.5,5.6c27.5,0,63.5-19.6,99.9-53.6c36.4,33.8,72.4,53.2,99.9,53.2c8.4,0,16-1.8,22.6-5.6 c28.1-16.2,34.4-66.7,19.9-130.1C625.8,359.7,666.3,328.9,666.3,296.5z M536.1,229.8c-3.7,12.9-8.3,26.2-13.5,39.5 c-4.1-8-8.4-16-13.1-24c-4.6-8-9.5-15.8-14.4-23.4C509.3,224,523,226.6,536.1,229.8z M490.3,336.3c-7.8,13.5-15.8,26.3-24.1,38.2 c-14.9,1.3-30,2-45.2,2c-15.1,0-30.2-0.7-45-1.9c-8.3-11.9-16.4-24.6-24.2-38c-7.6-13.1-14.5-26.4-20.8-39.8 c6.2-13.4,13.2-26.8,20.7-39.9c7.8-13.5,15.8-26.3,24.1-38.2c14.9-1.3,30-2,45.2-2c15.1,0,30.2,0.7,45,1.9 c8.3,11.9,16.4,24.6,24.2,38c7.6,13.1,14.5,26.4,20.8,39.8C504.7,309.8,497.8,323.2,490.3,336.3z M522.6,323.3 c5.4,13.4,10,26.8,13.8,39.8c-13.1,3.2-26.9,5.9-41.2,8c4.9-7.7,9.8-15.6,14.4-23.7C514.2,339.4,518.5,331.3,522.6,323.3z M421.2,430c-9.3-9.6-18.6-20.3-27.8-32c9,0.4,18.2,0.7,27.5,0.7c9.4,0,18.7-0.2,27.8-0.7C439.7,409.7,430.4,420.4,421.2,430z M346.8,371.1c-14.2-2.1-27.9-4.7-41-7.9c3.7-12.9,8.3-26.2,13.5-39.5c4.1,8,8.4,16,13.1,24C337.1,355.7,341.9,363.5,346.8,371.1z M420.7,163c9.3,9.6,18.6,20.3,27.8,32c-9-0.4-18.2-0.7-27.5-0.7c-9.4,0-18.7,0.2-27.8,0.7C402.2,183.3,411.5,172.6,420.7,163z M346.7,221.9c-4.9,7.7-9.8,15.6-14.4,23.7c-4.6,8-8.9,16-13,24c-5.4-13.4-10-26.8-13.8-39.8C318.6,226.7,332.4,224,346.7,221.9z M256.2,347.1c-35.4-15.1-58.3-34.9-58.3-50.6c0-15.7,22.9-35.6,58.3-50.6c8.6-3.7,18-7,27.7-10.1c5.7,19.6,13.2,40,22.5,60.9 c-9.2,20.8-16.6,41.1-22.2,60.6C274.3,354.2,264.9,350.8,256.2,347.1z M310,490c-13.6-7.8-19.5-37.5-14.9-75.7 c1.1-9.4,2.9-19.3,5.1-29.4c19.6,4.8,41,8.5,63.5,10.9c13.5,18.5,27.5,35.3,41.6,50c-32.6,30.3-63.2,46.9-84,46.9 C316.8,492.6,313,491.7,310,490z M547.2,413.8c4.7,38.2-1.1,67.9-14.6,75.8c-3,1.8-6.9,2.6-11.5,2.6c-20.7,0-51.4-16.5-84-46.6 c14-14.7,28-31.4,41.3-49.9c22.6-2.4,44-6.1,63.6-11C544.3,394.8,546.1,404.5,547.2,413.8z M585.7,347.1c-8.6,3.7-18,7-27.7,10.1 c-5.7-19.6-13.2-40-22.5-60.9c9.2-20.8,16.6-41.1,22.2-60.6c9.9,3.1,19.3,6.5,28.1,10.2c35.4,15.1,58.3,34.9,58.3,50.6 C644,312.2,621.1,332.1,585.7,347.1z"/>
|
|
6
|
+
<polygon fill="#61DAFB" points="320.8,78.4 320.8,78.4 320.8,78.4 "/>
|
|
7
|
+
<circle fill="#61DAFB" cx="420.9" cy="296.5" r="45.7"/>
|
|
8
|
+
<polygon fill="#61DAFB" points="520.5,78.1 520.5,78.1 520.5,78.1 "/>
|
|
9
|
+
</g>
|
|
10
|
+
<rect x="12" y="12" width="5" height="5" fill="#fff" />
|
|
11
|
+
<rect x="17" y="12" width="5" height="5" fill="#000" />
|
|
12
|
+
<rect x="12" y="17" width="5" height="5" fill="#000" />
|
|
13
|
+
<rect x="17" y="17" width="5" height="5" fill="#fff" />
|
|
14
|
+
</svg>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
|
|
3
|
+
<rect x="4" y="4" width="56" height="56" fill="#282c34" rx="2" ry="2" />
|
|
4
|
+
<g transform="matrix(0.10805931,0,0,0.10805931,-13.49297,-0.03418245)">
|
|
5
|
+
<path fill="#61DAFB" d="M666.3,296.5c0-32.5-40.7-63.3-103.1-82.4c14.4-63.6,8-114.2-20.2-130.4c-6.5-3.8-14.1-5.6-22.4-5.6v22.3 c4.6,0,8.3,0.9,11.4,2.6c13.6,7.8,19.5,37.5,14.9,75.7c-1.1,9.4-2.9,19.3-5.1,29.4c-19.6-4.8-41-8.5-63.5-10.9 c-13.5-18.5-27.5-35.3-41.6-50c32.6-30.3,63.2-46.9,84-46.9l0-22.3c0,0,0,0,0,0c-27.5,0-63.5,19.6-99.9,53.6 c-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7,0,51.4,16.5,84,46.6c-14,14.7-28,31.4-41.3,49.9c-22.6,2.4-44,6.1-63.6,11 c-2.3-10-4-19.7-5.2-29c-4.7-38.2,1.1-67.9,14.6-75.8c3-1.8,6.9-2.6,11.5-2.6l0-22.3c0,0,0,0,0,0c-8.4,0-16,1.8-22.6,5.6 c-28.1,16.2-34.4,66.7-19.9,130.1c-62.2,19.2-102.7,49.9-102.7,82.3c0,32.5,40.7,63.3,103.1,82.4c-14.4,63.6-8,114.2,20.2,130.4 c6.5,3.8,14.1,5.6,22.5,5.6c27.5,0,63.5-19.6,99.9-53.6c36.4,33.8,72.4,53.2,99.9,53.2c8.4,0,16-1.8,22.6-5.6 c28.1-16.2,34.4-66.7,19.9-130.1C625.8,359.7,666.3,328.9,666.3,296.5z M536.1,229.8c-3.7,12.9-8.3,26.2-13.5,39.5 c-4.1-8-8.4-16-13.1-24c-4.6-8-9.5-15.8-14.4-23.4C509.3,224,523,226.6,536.1,229.8z M490.3,336.3c-7.8,13.5-15.8,26.3-24.1,38.2 c-14.9,1.3-30,2-45.2,2c-15.1,0-30.2-0.7-45-1.9c-8.3-11.9-16.4-24.6-24.2-38c-7.6-13.1-14.5-26.4-20.8-39.8 c6.2-13.4,13.2-26.8,20.7-39.9c7.8-13.5,15.8-26.3,24.1-38.2c14.9-1.3,30-2,45.2-2c15.1,0,30.2,0.7,45,1.9 c8.3,11.9,16.4,24.6,24.2,38c7.6,13.1,14.5,26.4,20.8,39.8C504.7,309.8,497.8,323.2,490.3,336.3z M522.6,323.3 c5.4,13.4,10,26.8,13.8,39.8c-13.1,3.2-26.9,5.9-41.2,8c4.9-7.7,9.8-15.6,14.4-23.7C514.2,339.4,518.5,331.3,522.6,323.3z M421.2,430c-9.3-9.6-18.6-20.3-27.8-32c9,0.4,18.2,0.7,27.5,0.7c9.4,0,18.7-0.2,27.8-0.7C439.7,409.7,430.4,420.4,421.2,430z M346.8,371.1c-14.2-2.1-27.9-4.7-41-7.9c3.7-12.9,8.3-26.2,13.5-39.5c4.1,8,8.4,16,13.1,24C337.1,355.7,341.9,363.5,346.8,371.1z M420.7,163c9.3,9.6,18.6,20.3,27.8,32c-9-0.4-18.2-0.7-27.5-0.7c-9.4,0-18.7,0.2-27.8,0.7C402.2,183.3,411.5,172.6,420.7,163z M346.7,221.9c-4.9,7.7-9.8,15.6-14.4,23.7c-4.6,8-8.9,16-13,24c-5.4-13.4-10-26.8-13.8-39.8C318.6,226.7,332.4,224,346.7,221.9z M256.2,347.1c-35.4-15.1-58.3-34.9-58.3-50.6c0-15.7,22.9-35.6,58.3-50.6c8.6-3.7,18-7,27.7-10.1c5.7,19.6,13.2,40,22.5,60.9 c-9.2,20.8-16.6,41.1-22.2,60.6C274.3,354.2,264.9,350.8,256.2,347.1z M310,490c-13.6-7.8-19.5-37.5-14.9-75.7 c1.1-9.4,2.9-19.3,5.1-29.4c19.6,4.8,41,8.5,63.5,10.9c13.5,18.5,27.5,35.3,41.6,50c-32.6,30.3-63.2,46.9-84,46.9 C316.8,492.6,313,491.7,310,490z M547.2,413.8c4.7,38.2-1.1,67.9-14.6,75.8c-3,1.8-6.9,2.6-11.5,2.6c-20.7,0-51.4-16.5-84-46.6 c14-14.7,28-31.4,41.3-49.9c22.6-2.4,44-6.1,63.6-11C544.3,394.8,546.1,404.5,547.2,413.8z M585.7,347.1c-8.6,3.7-18,7-27.7,10.1 c-5.7-19.6-13.2-40-22.5-60.9c9.2-20.8,16.6-41.1,22.2-60.6c9.9,3.1,19.3,6.5,28.1,10.2c35.4,15.1,58.3,34.9,58.3,50.6 C644,312.2,621.1,332.1,585.7,347.1z"/>
|
|
6
|
+
<polygon fill="#61DAFB" points="320.8,78.4 320.8,78.4 320.8,78.4 "/>
|
|
7
|
+
<circle fill="#61DAFB" cx="420.9" cy="296.5" r="45.7"/>
|
|
8
|
+
<polygon fill="#61DAFB" points="520.5,78.1 520.5,78.1 520.5,78.1 "/>
|
|
9
|
+
</g>
|
|
10
|
+
<rect x="32" y="32" width="6" height="6" fill="#fff" />
|
|
11
|
+
<rect x="38" y="32" width="6" height="6" fill="#000" />
|
|
12
|
+
<rect x="44" y="32" width="6" height="6" fill="#fff" />
|
|
13
|
+
<rect x="50" y="32" width="6" height="6" fill="#000" />
|
|
14
|
+
<rect x="32" y="38" width="6" height="6" fill="#000" />
|
|
15
|
+
<rect x="38" y="38" width="6" height="6" fill="#fff" />
|
|
16
|
+
<rect x="44" y="38" width="6" height="6" fill="#000" />
|
|
17
|
+
<rect x="50" y="38" width="6" height="6" fill="#fff" />
|
|
18
|
+
<rect x="32" y="44" width="6" height="6" fill="#fff" />
|
|
19
|
+
<rect x="38" y="44" width="6" height="6" fill="#000" />
|
|
20
|
+
<rect x="44" y="44" width="6" height="6" fill="#fff" />
|
|
21
|
+
<rect x="50" y="44" width="6" height="6" fill="#000" />
|
|
22
|
+
<rect x="32" y="50" width="6" height="6" fill="#000" />
|
|
23
|
+
<rect x="38" y="50" width="6" height="6" fill="#fff" />
|
|
24
|
+
<rect x="44" y="50" width="6" height="6" fill="#000" />
|
|
25
|
+
<rect x="50" y="50" width="6" height="6" fill="#fff" />
|
|
26
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokopu-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A React-based library to create and display chessboard components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chess",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dist/lib",
|
|
20
20
|
"doc_src",
|
|
21
21
|
"graphic_test_app",
|
|
22
|
+
"graphics",
|
|
22
23
|
"scripts/test_graphic",
|
|
23
24
|
"scripts/test_headless.webpack-config.js",
|
|
24
25
|
"src",
|
|
@@ -28,40 +29,41 @@
|
|
|
28
29
|
".nycrc.yml"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"kokopu": "^
|
|
32
|
+
"kokopu": "^2.2.0",
|
|
32
33
|
"prop-types": "^15.7.2",
|
|
33
34
|
"react": "^17.0.2",
|
|
34
|
-
"react-draggable": "^4.4.
|
|
35
|
+
"react-draggable": "^4.4.4",
|
|
35
36
|
"react-motion": "^0.5.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@babel/cli": "^7.
|
|
39
|
-
"@babel/core": "^7.15.
|
|
40
|
-
"@babel/preset-env": "^7.15.
|
|
39
|
+
"@babel/cli": "^7.15.7",
|
|
40
|
+
"@babel/core": "^7.15.8",
|
|
41
|
+
"@babel/preset-env": "^7.15.8",
|
|
41
42
|
"@babel/preset-react": "^7.14.5",
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"babel-
|
|
43
|
+
"@emotion/react": "^11.5.0",
|
|
44
|
+
"@emotion/styled": "^11.3.0",
|
|
45
|
+
"@mui/material": "^5.0.4",
|
|
46
|
+
"babel-loader": "^8.2.3",
|
|
47
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
46
48
|
"copy-webpack-plugin": "^9.0.1",
|
|
47
49
|
"coveralls": "^3.1.1",
|
|
48
|
-
"css-loader": "^6.
|
|
49
|
-
"eslint": "^
|
|
50
|
-
"eslint-plugin-react": "^7.
|
|
51
|
-
"html-webpack-plugin": "^5.
|
|
50
|
+
"css-loader": "^6.4.0",
|
|
51
|
+
"eslint": "^8.0.1",
|
|
52
|
+
"eslint-plugin-react": "^7.26.1",
|
|
53
|
+
"html-webpack-plugin": "^5.4.0",
|
|
52
54
|
"img-diff-js": "^0.5.2",
|
|
53
|
-
"mocha": "^9.
|
|
55
|
+
"mocha": "^9.1.3",
|
|
54
56
|
"null-loader": "^4.0.1",
|
|
55
57
|
"nyc": "^15.1.0",
|
|
56
|
-
"prompt": "^1.
|
|
58
|
+
"prompt": "^1.2.0",
|
|
57
59
|
"react-dom": "^17.0.2",
|
|
58
60
|
"react-styleguidist": "^11.1.7",
|
|
59
|
-
"selenium-webdriver": "^4.0.0
|
|
60
|
-
"ssh2-sftp-client": "^7.0
|
|
61
|
-
"style-loader": "^3.
|
|
61
|
+
"selenium-webdriver": "^4.0.0",
|
|
62
|
+
"ssh2-sftp-client": "^7.1.0",
|
|
63
|
+
"style-loader": "^3.3.0",
|
|
62
64
|
"unit.js": "^2.1.1",
|
|
63
|
-
"webpack": "^5.
|
|
64
|
-
"webpack-cli": "^4.
|
|
65
|
+
"webpack": "^5.59.0",
|
|
66
|
+
"webpack-cli": "^4.9.1"
|
|
65
67
|
},
|
|
66
68
|
"scripts": {
|
|
67
69
|
"lint": "eslint doc_src graphic_test_app src test",
|
|
@@ -47,6 +47,7 @@ module.exports = {
|
|
|
47
47
|
entry: entries,
|
|
48
48
|
output: {
|
|
49
49
|
path: path.resolve(__dirname, '../../build/test_graphic'),
|
|
50
|
+
hashFunction: "xxhash64", // FIXME The default hash function used by Webpack has been removed from OpenSSL.
|
|
50
51
|
},
|
|
51
52
|
plugins: plugins,
|
|
52
53
|
module: {
|
package/src/ArrowMarkerIcon.js
CHANGED
|
@@ -54,7 +54,7 @@ export default class ArrowMarkerIcon extends React.Component {
|
|
|
54
54
|
<ArrowTip id={this.arrowTipId} color={this.props.color} />
|
|
55
55
|
</defs>
|
|
56
56
|
<line className="kokopu-arrow" x1={halfThickness} y1={size / 2} x2={size - halfThickness * 3} y2={size / 2} stroke={this.props.color}
|
|
57
|
-
|
|
57
|
+
strokeWidth={halfThickness * 2} markerEnd={`url(#${this.arrowTipId})`} />
|
|
58
58
|
</svg>
|
|
59
59
|
);
|
|
60
60
|
}
|
package/src/Chessboard.js
CHANGED
|
@@ -29,7 +29,9 @@ import kokopu from 'kokopu';
|
|
|
29
29
|
import colorsets from './impl/colorsets';
|
|
30
30
|
import piecesets from './impl/piecesets';
|
|
31
31
|
import ArrowTip from './impl/ArrowTip';
|
|
32
|
-
import
|
|
32
|
+
import TextSymbol from './impl/TextSymbol';
|
|
33
|
+
import ErrorBox from './ErrorBox';
|
|
34
|
+
import i18n from './i18n';
|
|
33
35
|
import { parseSquareMarkers, parseTextMarkers, parseArrowMarkers } from './markers';
|
|
34
36
|
import { MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, sanitizeInteger, generateRandomId, isValidSquare, isValidVector, isValidColor, isValidSymbol } from './impl/util';
|
|
35
37
|
|
|
@@ -82,10 +84,10 @@ export default class Chessboard extends React.Component {
|
|
|
82
84
|
// Compute the current position.
|
|
83
85
|
let info = this.getPositionAndMoveInfo();
|
|
84
86
|
if (info.positionError) {
|
|
85
|
-
return <ErrorBox title=
|
|
87
|
+
return <ErrorBox title={i18n.INVALID_FEN_ERROR_TITLE} message={info.message}></ErrorBox>;
|
|
86
88
|
}
|
|
87
89
|
else if (info.moveError) {
|
|
88
|
-
return <ErrorBox title=
|
|
90
|
+
return <ErrorBox title={i18n.INVALID_NOTATION_ERROR_TITLE} message={info.message}></ErrorBox>;
|
|
89
91
|
}
|
|
90
92
|
let { position, move, positionBefore } = info;
|
|
91
93
|
|
|
@@ -271,7 +273,7 @@ export default class Chessboard extends React.Component {
|
|
|
271
273
|
return (
|
|
272
274
|
<line
|
|
273
275
|
className="kokopu-annotation kokopu-arrow kokopu-arrowDraggable kokopu-dragging" x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
|
|
274
|
-
stroke={colorset[this.props.editedArrowColor]}
|
|
276
|
+
stroke={colorset[this.props.editedArrowColor]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
|
|
275
277
|
/>
|
|
276
278
|
);
|
|
277
279
|
}
|
|
@@ -346,9 +348,9 @@ export default class Chessboard extends React.Component {
|
|
|
346
348
|
x += squareSize / 2;
|
|
347
349
|
y += squareSize / 2;
|
|
348
350
|
result.push(
|
|
349
|
-
<
|
|
350
|
-
{value.symbol}
|
|
351
|
-
</
|
|
351
|
+
<g key={'txtm-' + sq} className="kokopu-annotation">
|
|
352
|
+
<TextSymbol x={x} y={y} size={squareSize} symbol={value.symbol} color={colorset[value.color]} />
|
|
353
|
+
</g>
|
|
352
354
|
);
|
|
353
355
|
});
|
|
354
356
|
return result;
|
|
@@ -375,7 +377,7 @@ export default class Chessboard extends React.Component {
|
|
|
375
377
|
result.push(
|
|
376
378
|
<line
|
|
377
379
|
key={'arm-' + vect} className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
|
|
378
|
-
stroke={colorset[color]}
|
|
380
|
+
stroke={colorset[color]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
|
|
379
381
|
/>
|
|
380
382
|
);
|
|
381
383
|
});
|
|
@@ -399,7 +401,7 @@ export default class Chessboard extends React.Component {
|
|
|
399
401
|
return (
|
|
400
402
|
<line
|
|
401
403
|
className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={x} y2={y} stroke={colorset['highlight']}
|
|
402
|
-
|
|
404
|
+
strokeWidth={squareSize * STROKE_THICKNESS_FACTOR} markerEnd={`url(#${this.getArrowTipId('highlight')})`}
|
|
403
405
|
/>
|
|
404
406
|
);
|
|
405
407
|
}
|
|
@@ -418,14 +420,14 @@ export default class Chessboard extends React.Component {
|
|
|
418
420
|
let x = Math.round(-RANK_COORDINATE_WIDTH_FACTOR * fontSize) / 2;
|
|
419
421
|
let y = (this.props.flipped ? rank + 0.5 : 7.5 - rank) * squareSize;
|
|
420
422
|
let label = RANK_LABELS[rank];
|
|
421
|
-
return <text key={'rank-' + label} className="kokopu-coordinate kokopu-label" x={x} y={y}
|
|
423
|
+
return <text key={'rank-' + label} className="kokopu-coordinate kokopu-label" x={x} y={y} fontSize={fontSize}>{label}</text>;
|
|
422
424
|
}
|
|
423
425
|
|
|
424
426
|
renderFileCoordinate(squareSize, fontSize, file) {
|
|
425
427
|
let x = (this.props.flipped ? 7.5 - file : 0.5 + file) * squareSize;
|
|
426
428
|
let y = 8 * squareSize + Math.round(FILE_COORDINATE_HEIGHT_FACTOR * fontSize) / 2;
|
|
427
429
|
let label = FILE_LABELS[file];
|
|
428
|
-
return <text key={'file-' + label} className="kokopu-coordinate kokopu-label" x={x} y={y}
|
|
430
|
+
return <text key={'file-' + label} className="kokopu-coordinate kokopu-label" x={x} y={y} fontSize={fontSize}>{label}</text>;
|
|
429
431
|
}
|
|
430
432
|
|
|
431
433
|
handleWindowResize() {
|
|
@@ -498,8 +500,6 @@ export default class Chessboard extends React.Component {
|
|
|
498
500
|
});
|
|
499
501
|
break;
|
|
500
502
|
|
|
501
|
-
// TODO fix chess960 castling
|
|
502
|
-
|
|
503
503
|
// Other cases are not supposed to happen.
|
|
504
504
|
// istanbul ignore next
|
|
505
505
|
default:
|
|
@@ -940,7 +940,7 @@ function parsePosition(position) {
|
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
942
|
else {
|
|
943
|
-
return { error: true, message:
|
|
943
|
+
return { error: true, message: i18n.INVALID_POSITION_ATTRIBUTE_ERROR_MESSAGE };
|
|
944
944
|
}
|
|
945
945
|
}
|
|
946
946
|
|
|
@@ -967,7 +967,7 @@ function parseMove(position, move) {
|
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
969
|
else {
|
|
970
|
-
return { error: true, message:
|
|
970
|
+
return { error: true, message: i18n.INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE };
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
|
package/src/TextMarkerIcon.js
CHANGED
|
@@ -23,9 +23,8 @@
|
|
|
23
23
|
import PropTypes from 'prop-types';
|
|
24
24
|
import React from 'react';
|
|
25
25
|
|
|
26
|
-
import './css/label.css';
|
|
27
|
-
|
|
28
26
|
import { MIN_SQUARE_SIZE, MAX_SQUARE_SIZE, sanitizeInteger, isValidSymbol } from './impl/util';
|
|
27
|
+
import TextSymbol from './impl/TextSymbol';
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
/**
|
|
@@ -39,9 +38,7 @@ export default function TextMarkerIcon(props) {
|
|
|
39
38
|
let viewBox = `0 0 ${size} ${size}`;
|
|
40
39
|
return (
|
|
41
40
|
<svg className="kokopu-textMarkerIcon" viewBox={viewBox} width={size} height={size}>
|
|
42
|
-
<
|
|
43
|
-
{props.symbol}
|
|
44
|
-
</text>
|
|
41
|
+
<TextSymbol x={size / 2} y={size / 2} size={size} symbol={props.symbol} color={props.color} />
|
|
45
42
|
</svg>
|
|
46
43
|
);
|
|
47
44
|
}
|
|
@@ -54,7 +51,10 @@ TextMarkerIcon.propTypes = {
|
|
|
54
51
|
size: PropTypes.number.isRequired,
|
|
55
52
|
|
|
56
53
|
/**
|
|
57
|
-
* Symbol to represent on the icon. Must be
|
|
54
|
+
* Symbol to represent on the icon. Must be one of:
|
|
55
|
+
* - any letter from A to Z (either upper-case or lower-case),
|
|
56
|
+
* - any digit from 0 to 9,
|
|
57
|
+
* - any symbol code among `'plus'`, `'times'`, `'dot'`, or `'circle'`.
|
|
58
58
|
*/
|
|
59
59
|
symbol: PropTypes.string.isRequired,
|
|
60
60
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
.kokopu-symbolCircle {
|
|
24
|
+
fill: transparent;
|
|
25
|
+
}
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const i18n = {
|
|
24
|
+
INVALID_FEN_ERROR_TITLE: 'Invalid FEN string.',
|
|
25
|
+
INVALID_NOTATION_ERROR_TITLE: 'Invalid move notation.',
|
|
26
|
+
INVALID_POSITION_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "position" attribute.',
|
|
27
|
+
INVALID_MOVE_ATTRIBUTE_ERROR_MESSAGE: 'Invalid "move" attribute.',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default i18n;
|
package/src/impl/ArrowTip.js
CHANGED
|
@@ -29,7 +29,7 @@ import React from 'react';
|
|
|
29
29
|
*/
|
|
30
30
|
export default function ArrowTip(props) {
|
|
31
31
|
return (
|
|
32
|
-
<marker id={props.id} markerWidth={4} markerHeight={4} refX={2.5} refY={2} orient="auto"
|
|
32
|
+
<marker id={props.id} markerWidth={4} markerHeight={4} refX={2.5} refY={2} orient="auto" fill={props.color}>
|
|
33
33
|
<path d="M 4,2 L 0,4 L 1,2 L 0,0 Z" />
|
|
34
34
|
</marker>
|
|
35
35
|
);
|
|
@@ -45,9 +45,5 @@ ArrowTip.propTypes = {
|
|
|
45
45
|
/**
|
|
46
46
|
* Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
47
47
|
*/
|
|
48
|
-
color: PropTypes.string,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
ArrowTip.defaultProps = {
|
|
52
|
-
color: 'currentcolor',
|
|
48
|
+
color: PropTypes.string.isRequired,
|
|
53
49
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
import PropTypes from 'prop-types';
|
|
24
|
+
import React from 'react';
|
|
25
|
+
|
|
26
|
+
import '../css/label.css';
|
|
27
|
+
import '../css/symbol.css';
|
|
28
|
+
|
|
29
|
+
const SHAPE_THICKNESS_FACTOR = 0.1;
|
|
30
|
+
const DOT_RADIUS_FACTOR = 0.15;
|
|
31
|
+
const CIRCLE_RADIUS_FACTOR = 0.425;
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Symbol of a text marker.
|
|
36
|
+
*/
|
|
37
|
+
export default function TextSymbol(props) {
|
|
38
|
+
if (props.symbol === 'dot') {
|
|
39
|
+
return <circle cx={props.x} cy={props.y} r={props.size * DOT_RADIUS_FACTOR} fill={props.color} />;
|
|
40
|
+
}
|
|
41
|
+
else if (props.symbol === 'circle') {
|
|
42
|
+
let thickness = props.size * SHAPE_THICKNESS_FACTOR;
|
|
43
|
+
return <circle className="kokopu-symbolCircle" cx={props.x} cy={props.y} r={props.size * CIRCLE_RADIUS_FACTOR} stroke={props.color} strokeWidth={thickness} />;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
let symbol = props.symbol === 'plus' ? '+' : props.symbol === 'times' ? '\u00d7' : props.symbol;
|
|
47
|
+
return <text className="kokopu-label" x={props.x} y={props.y} fill={props.color} fontSize={props.size}>{symbol}</text>;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
TextSymbol.propTypes = {
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* X-coordinate of the center of the symbol.
|
|
55
|
+
*/
|
|
56
|
+
x: PropTypes.number.isRequired,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Y-coordinate of the center of the symbol.
|
|
60
|
+
*/
|
|
61
|
+
y: PropTypes.number.isRequired,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Size of the symbol (i.e. size of square in which the symbol is rendered).
|
|
65
|
+
*/
|
|
66
|
+
size: PropTypes.number.isRequired,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Symbol code.
|
|
70
|
+
*/
|
|
71
|
+
symbol: PropTypes.string.isRequired,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Color to use to colorize the shape (for example: `'green'`, `'#ff0000'`...).
|
|
75
|
+
*/
|
|
76
|
+
color: PropTypes.string.isRequired,
|
|
77
|
+
};
|
package/src/impl/util.js
CHANGED
package/src/index.js
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
export { flattenSquareMarkers, parseSquareMarkers, flattenTextMarkers, parseTextMarkers, flattenArrowMarkers, parseArrowMarkers } from './markers';
|
|
24
|
+
export { default as i18n } from './i18n';
|
|
24
25
|
export { default as Chessboard } from './Chessboard';
|
|
26
|
+
export { default as ErrorBox } from './ErrorBox';
|
|
25
27
|
export { default as SquareMarkerIcon } from './SquareMarkerIcon';
|
|
26
28
|
export { default as TextMarkerIcon } from './TextMarkerIcon';
|
|
27
29
|
export { default as ArrowMarkerIcon } from './ArrowMarkerIcon';
|
package/src/markers.js
CHANGED
|
@@ -41,14 +41,14 @@ export function flattenSquareMarkers(markers) {
|
|
|
41
41
|
/**
|
|
42
42
|
* Transform a set of text markers defined as a "square -> (symbol, color)" struct into a comma-separated string.
|
|
43
43
|
*
|
|
44
|
-
* @param {object} markers For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }}`
|
|
45
|
-
* @returns {string} For example: `'Rzd5,GAe4'`
|
|
44
|
+
* @param {object} markers For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }, h3: { symbol: 'plus', color: 'y' } }`
|
|
45
|
+
* @returns {string} For example: `'Rzd5,GAe4,Y(plus)h3'`
|
|
46
46
|
*/
|
|
47
47
|
export function flattenTextMarkers(markers) {
|
|
48
48
|
return Object.entries(markers)
|
|
49
49
|
.filter(([ sq, desc ]) => isValidSquare(sq) && desc && isValidColor(desc.color) && isValidSymbol(desc.symbol))
|
|
50
50
|
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
51
|
-
.map(([ sq, desc ]) => desc.color.toUpperCase() + desc.symbol + sq)
|
|
51
|
+
.map(([ sq, desc ]) => desc.color.toUpperCase() + (desc.symbol.length === 1 ? desc.symbol : '(' + desc.symbol + ')') + sq)
|
|
52
52
|
.join(',');
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -91,12 +91,13 @@ export function parseSquareMarkers(markers) {
|
|
|
91
91
|
/**
|
|
92
92
|
* Parse a set of text markers defined as a comma-separated string into a "square -> (symbol, color)" struct.
|
|
93
93
|
*
|
|
94
|
-
* @param {string} markers For example: `'Rzd5,GAe4'`
|
|
95
|
-
* @returns {object} For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }}`
|
|
94
|
+
* @param {string} markers For example: `'Rzd5,GAe4,Y(plus)h3'`
|
|
95
|
+
* @returns {object} For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }, h3: { symbol: 'plus', color: 'y' } }`
|
|
96
96
|
*/
|
|
97
97
|
export function parseTextMarkers(markers) {
|
|
98
98
|
return parseMarkers(markers, token => {
|
|
99
|
-
return /^([GRY])([A-Za-z0-9])([a-h][1-8])$/.test(token) ?
|
|
99
|
+
return /^([GRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ?
|
|
100
|
+
{ key: RegExp.$4, value: { symbol: RegExp.$2 || RegExp.$3, color: RegExp.$1.toLowerCase() } } : undefined;
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
|
package/test/1_markers.js
CHANGED
|
@@ -65,6 +65,13 @@ describe('Flatten text markers', () => {
|
|
|
65
65
|
h7: { symbol: 'x', color: 'r' },
|
|
66
66
|
d2: { symbol: 'L', color: 'r' },
|
|
67
67
|
})).is('G2a1,YMc5,RLd2,Rxh7,Ywh8'); });
|
|
68
|
+
it('Multi-character symbols', () => { test.value(flattenTextMarkers({
|
|
69
|
+
a1: { symbol: 'A', color: 'y' },
|
|
70
|
+
a7: { symbol: 'plus', color: 'g' },
|
|
71
|
+
b3: { symbol: 'times', color: 'r' },
|
|
72
|
+
g5: { symbol: 'dot', color: 'y' },
|
|
73
|
+
h3: { symbol: 'circle', color: 'g' },
|
|
74
|
+
})).is('YAa1,G(plus)a7,R(times)b3,Y(dot)g5,G(circle)h3'); });
|
|
68
75
|
it('<empty>', () => { test.value(flattenTextMarkers({})).is(''); });
|
|
69
76
|
|
|
70
77
|
it('Wrong square', () => { test.value(flattenTextMarkers({
|
|
@@ -83,6 +90,10 @@ describe('Flatten text markers', () => {
|
|
|
83
90
|
d8: { symbol: '-', color: 'r' },
|
|
84
91
|
c1: { symbol: 'abcd', color: 'r' },
|
|
85
92
|
})).is('G0a2'); });
|
|
93
|
+
it('Wrong multi-character symbol', () => { test.value(flattenTextMarkers({
|
|
94
|
+
a2: { symbol: '0', color: 'g' },
|
|
95
|
+
b5: { symbol: 'whatever', color: 'r' },
|
|
96
|
+
})).is('G0a2'); });
|
|
86
97
|
});
|
|
87
98
|
|
|
88
99
|
|
|
@@ -100,6 +111,13 @@ describe('Parse text markers', () => {
|
|
|
100
111
|
h7: { symbol: 'x', color: 'r' },
|
|
101
112
|
d2: { symbol: 'L', color: 'r' },
|
|
102
113
|
}); });
|
|
114
|
+
it('Multi-character symbols', () => { test.value(parseTextMarkers('YAa1,G(plus)a7, R(times)b3 ,Y(dot)g5,G(circle)h3')).is({
|
|
115
|
+
a1: { symbol: 'A', color: 'y' },
|
|
116
|
+
a7: { symbol: 'plus', color: 'g' },
|
|
117
|
+
b3: { symbol: 'times', color: 'r' },
|
|
118
|
+
g5: { symbol: 'dot', color: 'y' },
|
|
119
|
+
h3: { symbol: 'circle', color: 'g' },
|
|
120
|
+
}); });
|
|
103
121
|
it('<empty>', () => { test.value(parseTextMarkers('')).is({}); });
|
|
104
122
|
it('<blank>', () => { test.value(parseTextMarkers(' ')).is({}); });
|
|
105
123
|
|
|
@@ -107,6 +125,7 @@ describe('Parse text markers', () => {
|
|
|
107
125
|
it('Duplicated square', () => { test.value(parseTextMarkers('Rka3,Gba3')).is({ a3: { symbol: 'b', color: 'g' } }); });
|
|
108
126
|
it('Wrong color', () => { test.value(parseTextMarkers('G3a6,BAg5')).is({ a6: { symbol: '3', color: 'g' } }); });
|
|
109
127
|
it('Wrong symbol', () => { test.value(parseTextMarkers('Rb2,RAg5,G.d3,Yabcde7')).is({ g5: { symbol: 'A', color: 'r' } }); });
|
|
128
|
+
it('Wrong multi-character symbol', () => { test.value(parseTextMarkers('RZb2,Y(whatever)e4')).is({ b2: { symbol: 'Z', color: 'r' } }); });
|
|
110
129
|
it('Wrong format', () => { test.value(parseTextMarkers('Something RHa2 invalid, Yqe4, G g3')).is({ e4: { symbol: 'q', color: 'y' } }); });
|
|
111
130
|
});
|
|
112
131
|
|
|
@@ -36,5 +36,5 @@ describe('Marker icons graphic', function() {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
itChecksScreenshots(browserContext, '01_marker_icons', [ 'default square', 'colorized square', 'wrapped square', 'default text', 'colorized text', 'wrapped text',
|
|
39
|
-
'default arrow', 'colorized arrow', 'wrapped arrow' ]);
|
|
39
|
+
'default arrow', 'colorized arrow', 'wrapped arrow', 'colorized symbol', 'wrapped symbol' ]);
|
|
40
40
|
});
|
|
@@ -50,6 +50,9 @@ describe('Chessboard play moves', function() {
|
|
|
50
50
|
itCheckPlayMove(0, 'regular move 1', 225, 335, 220, 225, 'regular_move_1', 'move played: e4');
|
|
51
51
|
itCheckPlayMove(1, 'regular move 2', 275, 225, 135, 85, 'regular_move_2', 'move played: Bxf2+');
|
|
52
52
|
itCheckPlayMove(1, 'castling move', 175, 375, 75, 375, 'castling_move', 'move played: O-O');
|
|
53
|
+
itCheckPlayMove(3, 'chess960 castling move 1', 275, 375, 75, 375, 'chess960_castling_move_1', 'move played: O-O-O');
|
|
54
|
+
itCheckPlayMove(3, 'chess960 castling move 2', 275, 375, 375, 375, 'chess960_castling_move_2', 'move played: O-O');
|
|
55
|
+
itCheckPlayMove(3, 'chess960 ambiguous king move', 275, 375, 320, 375, 'chess960_ambiguous_king_move', 'move played: Kg1');
|
|
53
56
|
|
|
54
57
|
function itCheckNonPlayMove(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName) {
|
|
55
58
|
itCustom(browserContext, '10_chessboard_play_moves', itemIndex, label, async function(element) {
|
|
@@ -69,6 +72,7 @@ describe('Chessboard play moves', function() {
|
|
|
69
72
|
itCheckNonPlayMove(0, 'illegal move', 75, 375, 125, 225, 'illegal_move');
|
|
70
73
|
itCheckNonPlayMove(0, 'from == to', 75, 375, 85, 365, 'null_vector');
|
|
71
74
|
itCheckNonPlayMove(0, 'out of board', 325, 375, 450, 285, 'out_of_board');
|
|
75
|
+
itCheckNonPlayMove(3, 'chess960 non-KxR castling', 275, 375, 130, 375, 'chess960_non_kxr_castling');
|
|
72
76
|
|
|
73
77
|
function itCheckPlayPromotion(itemIndex, label, xFrom, yFrom, xTo, yTo, xPromo, yPromo, imageBaseName, expectedText) {
|
|
74
78
|
itCustom(browserContext, '11_chessboard_play_promotions', itemIndex, label, async function(element) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|