kokopu-react 3.1.0 → 3.2.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.
Files changed (234) hide show
  1. package/.eslintrc.yml +1 -1
  2. package/CHANGELOG.md +6 -0
  3. package/dist/lib/chessboard/BoardProperties.js.map +1 -1
  4. package/dist/lib/chessboard/Chessboard.css +13 -13
  5. package/dist/lib/chessboard/Chessboard.js.map +1 -1
  6. package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
  7. package/dist/lib/chessboard/Draggable.js.map +1 -1
  8. package/dist/lib/chessboard/Motion.js.map +1 -1
  9. package/dist/lib/chessboard/colorsets.js.map +1 -1
  10. package/dist/lib/chessboard/piecesets.js.map +1 -1
  11. package/dist/lib/errorbox/ErrorBox.css +18 -18
  12. package/dist/lib/errorbox/ErrorBox.js.map +1 -1
  13. package/dist/lib/errorbox/parsing.js.map +1 -1
  14. package/dist/lib/exception.js.map +1 -1
  15. package/dist/lib/i18n.d.ts +1 -0
  16. package/dist/lib/i18n.js +1 -0
  17. package/dist/lib/i18n.js.map +1 -1
  18. package/dist/lib/icons/AnnotationSymbolShape.css +6 -6
  19. package/dist/lib/icons/AnnotationSymbolShape.js.map +1 -1
  20. package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
  21. package/dist/lib/icons/ArrowTip.js.map +1 -1
  22. package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
  23. package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
  24. package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
  25. package/dist/lib/icons/arrow.css +1 -1
  26. package/dist/lib/index.d.ts +1 -0
  27. package/dist/lib/index.js +1 -0
  28. package/dist/lib/index.js.map +1 -1
  29. package/dist/lib/movetext/Movetext.css +27 -27
  30. package/dist/lib/movetext/Movetext.js.map +1 -1
  31. package/dist/lib/movetext/MovetextImpl.js.map +1 -1
  32. package/dist/lib/movetext/fonts.css +7 -7
  33. package/dist/lib/movetext/htmlFilter.js.map +1 -1
  34. package/dist/lib/movetext/moveFormatter.js.map +1 -1
  35. package/dist/lib/navigationboard/NavigationBoard.d.ts +39 -1
  36. package/dist/lib/navigationboard/NavigationBoard.js +94 -11
  37. package/dist/lib/navigationboard/NavigationBoard.js.map +1 -1
  38. package/dist/lib/navigationboard/NavigationButton.d.ts +54 -0
  39. package/dist/lib/navigationboard/NavigationButton.js +35 -0
  40. package/dist/lib/navigationboard/NavigationButton.js.map +1 -0
  41. package/dist/lib/navigationboard/NavigationField.css +7 -7
  42. package/dist/lib/navigationboard/NavigationField.js.map +1 -1
  43. package/dist/lib/navigationboard/NavigationToolbar.css +16 -13
  44. package/dist/lib/navigationboard/NavigationToolbar.d.ts +3 -10
  45. package/dist/lib/navigationboard/NavigationToolbar.js +31 -82
  46. package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -1
  47. package/dist/lib/navigationboard/iconPaths.d.ts +29 -0
  48. package/dist/lib/navigationboard/iconPaths.js +91 -0
  49. package/dist/lib/navigationboard/iconPaths.js.map +1 -0
  50. package/dist/lib/sanitization.js.map +1 -1
  51. package/dist/lib/types.js.map +1 -1
  52. package/dist/lib/util.js.map +1 -1
  53. package/doc_src/demo/PageChessboardBase.tsx +115 -115
  54. package/doc_src/demo/PageChessboardInteraction.tsx +303 -303
  55. package/doc_src/demo/PageChessboardMove.tsx +173 -173
  56. package/doc_src/demo/PageChessboardSmallScreens.tsx +94 -94
  57. package/doc_src/demo/PageMovetextBase.tsx +180 -180
  58. package/doc_src/demo/PageMovetextInteraction.tsx +123 -123
  59. package/doc_src/demo/PageNavigationBoardBase.tsx +144 -137
  60. package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +69 -69
  61. package/doc_src/demo/decs.d.ts +4 -4
  62. package/doc_src/demo/demo.css +12 -12
  63. package/doc_src/demo/util.ts +1 -1
  64. package/doc_src/examples/NavigationBoard.md +1 -1
  65. package/doc_src/theming/LogoRenderer.js +13 -13
  66. package/doc_src/theming/theming.css +5 -5
  67. package/package.json +95 -95
  68. package/scripts/doc.styleguide.config.js +131 -131
  69. package/scripts/doc.tsconfig.json +5 -5
  70. package/scripts/docker-compose.yml +1 -1
  71. package/scripts/test-graphic.tsconfig.json +5 -5
  72. package/scripts/test-graphic.webpack.config.js +57 -57
  73. package/scripts/test-headless.webpack.config.js +29 -29
  74. package/src/chessboard/BoardProperties.ts +68 -68
  75. package/src/chessboard/Chessboard.css +13 -13
  76. package/src/chessboard/Chessboard.tsx +380 -380
  77. package/src/chessboard/ChessboardImpl.tsx +557 -557
  78. package/src/chessboard/Draggable.tsx +185 -185
  79. package/src/chessboard/Motion.tsx +67 -67
  80. package/src/chessboard/colorsets.ts +66 -66
  81. package/src/chessboard/piecesets.ts +84 -84
  82. package/src/decs.d.ts +2 -2
  83. package/src/errorbox/ErrorBox.css +18 -18
  84. package/src/errorbox/ErrorBox.tsx +75 -75
  85. package/src/errorbox/parsing.tsx +95 -95
  86. package/src/exception.ts +17 -17
  87. package/src/i18n.ts +1 -0
  88. package/src/icons/AnnotationSymbolShape.css +6 -6
  89. package/src/icons/AnnotationSymbolShape.tsx +31 -31
  90. package/src/icons/ArrowMarkerIcon.tsx +34 -34
  91. package/src/icons/ArrowTip.tsx +14 -14
  92. package/src/icons/ChessPieceIcon.tsx +45 -45
  93. package/src/icons/SquareMarkerIcon.tsx +20 -20
  94. package/src/icons/TextMarkerIcon.tsx +29 -29
  95. package/src/icons/arrow.css +1 -1
  96. package/src/index.ts +3 -2
  97. package/src/movetext/Movetext.css +27 -27
  98. package/src/movetext/Movetext.tsx +158 -158
  99. package/src/movetext/MovetextImpl.tsx +345 -345
  100. package/src/movetext/fonts.css +7 -7
  101. package/src/movetext/htmlFilter.tsx +129 -129
  102. package/src/movetext/moveFormatter.tsx +37 -37
  103. package/src/navigationboard/NavigationBoard.tsx +297 -178
  104. package/src/navigationboard/NavigationButton.ts +72 -0
  105. package/src/navigationboard/NavigationField.css +7 -7
  106. package/src/navigationboard/NavigationField.tsx +90 -90
  107. package/src/navigationboard/NavigationToolbar.css +16 -13
  108. package/src/navigationboard/NavigationToolbar.tsx +60 -117
  109. package/src/navigationboard/iconPaths.ts +98 -0
  110. package/src/sanitization.ts +17 -17
  111. package/src/types.ts +116 -116
  112. package/src/util.ts +11 -11
  113. package/test/01_types.js +167 -167
  114. package/test/02_chessboard_util.js +114 -114
  115. package/test/03_error_box_graphic.js +16 -16
  116. package/test/04_icons_graphic.js +32 -32
  117. package/test/05_chessboard_graphic.js +60 -60
  118. package/test/06_chessboard_animation.js +36 -36
  119. package/test/07_chessboard_interaction.js +101 -101
  120. package/test/08_chessboard_play_moves.js +62 -62
  121. package/test/09_chessboard_small_screens.js +32 -32
  122. package/test/10_movetext_graphic.js +32 -32
  123. package/test/11_movetext_interaction.js +100 -100
  124. package/test/12_navigation_board_base.js +151 -0
  125. package/test/13_navigation_board_graphic.js +68 -0
  126. package/test/14_navigation_board_autoplay.js +100 -0
  127. package/test/common/graphic.js +106 -97
  128. package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
  129. package/test/graphic_references/{12_navigation_board/controlled/forbidden_navigation_1.png → 12_navigation_board_base/controlled/forbidden_navigation_0.png} +0 -0
  130. package/test/graphic_references/{12_navigation_board/controlled/invalid_node_id.png → 12_navigation_board_base/controlled/forbidden_navigation_1.png} +0 -0
  131. package/test/graphic_references/{12_navigation_board/controlled/forbidden_navigation_0.png → 12_navigation_board_base/controlled/invalid_node_id.png} +0 -0
  132. package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
  133. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/controlled/no_callback_defined_1.png +0 -0
  134. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/controlled/overriding_initial_node_id.png +0 -0
  135. package/test/graphic_references/{12_navigation_board/controlled/regular_navigation_1.png → 12_navigation_board_base/controlled/regular_navigation_0.png} +0 -0
  136. package/test/graphic_references/{12_navigation_board/uncontrolled/initial_state_at_specific_id.png → 12_navigation_board_base/controlled/regular_navigation_1.png} +0 -0
  137. package/test/graphic_references/{12_navigation_board/controlled/regular_navigation_3.png → 12_navigation_board_base/controlled/regular_navigation_2.png} +0 -0
  138. package/test/graphic_references/{12_navigation_board/controlled/regular_navigation_0.png → 12_navigation_board_base/controlled/regular_navigation_3.png} +0 -0
  139. package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_2.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png} +0 -0
  140. package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_0.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png} +0 -0
  141. package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_beginning_1.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png} +0 -0
  142. package/test/graphic_references/{12_navigation_board/controlled/no_callback_defined_0.png → 12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png} +0 -0
  143. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
  144. package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
  145. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_at_end.png +0 -0
  146. package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
  147. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_default.png +0 -0
  148. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_default_with_game_index.png +0 -0
  149. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/initial_state_on_null-move.png +0 -0
  150. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_0.png +0 -0
  151. package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
  152. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_2.png +0 -0
  153. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_3.png +0 -0
  154. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/navigation_with_keys_4.png +0 -0
  155. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_flipping_0.png +0 -0
  156. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_flipping_1.png +0 -0
  157. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_0.png +0 -0
  158. package/test/graphic_references/{12_navigation_board/controlled/default.png → 12_navigation_board_base/uncontrolled/regular_navigation_1.png} +0 -0
  159. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_2.png +0 -0
  160. package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
  161. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_4.png +0 -0
  162. package/test/graphic_references/{12_navigation_board → 12_navigation_board_base}/uncontrolled/regular_navigation_5.png +0 -0
  163. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
  164. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
  165. package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
  166. package/test/graphic_references/{12_navigation_board/uncontrolled/regular_navigation_3.png → 13_navigation_board_graphic/additional_buttons/single_button.png} +0 -0
  167. package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/theme/custom_1.png +0 -0
  168. package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/theme/custom_2.png +0 -0
  169. package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/theme/large.png +0 -0
  170. package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
  171. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
  172. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
  173. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
  174. package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
  175. package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_end_1.png → 14_navigation_board_autoplay/controlled/after_reaching_the_end.png} +0 -0
  176. package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_end_2.png → 14_navigation_board_autoplay/controlled/already_at_the_end.png} +0 -0
  177. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
  178. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
  179. package/test/graphic_references/{12_navigation_board/uncontrolled/forbidden_navigation_at_end_0.png → 14_navigation_board_autoplay/controlled/initial_state_at_the_end.png} +0 -0
  180. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
  181. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
  182. package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
  183. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
  184. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
  185. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
  186. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
  187. package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
  188. package/test/graphic_references/{12_navigation_board/uncontrolled/navigation_with_keys_1.png → 14_navigation_board_autoplay/uncontrolled/initial_state_default.png} +0 -0
  189. package/test/graphic_test_app/03_error_box_graphic/base.tsx +14 -14
  190. package/test/graphic_test_app/03_error_box_graphic/localization.tsx +1 -1
  191. package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +7 -7
  192. package/test/graphic_test_app/04_icons_graphic/marker.tsx +15 -15
  193. package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -7
  194. package/test/graphic_test_app/05_chessboard_graphic/base.tsx +6 -6
  195. package/test/graphic_test_app/05_chessboard_graphic/chess_variants.tsx +7 -7
  196. package/test/graphic_test_app/05_chessboard_graphic/flipped.tsx +5 -5
  197. package/test/graphic_test_app/05_chessboard_graphic/move.tsx +12 -12
  198. package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +12 -12
  199. package/test/graphic_test_app/06_chessboard_animation/base_1.tsx +6 -6
  200. package/test/graphic_test_app/06_chessboard_animation/base_2.tsx +6 -6
  201. package/test/graphic_test_app/06_chessboard_animation/base_3.tsx +6 -6
  202. package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +16 -16
  203. package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +5 -5
  204. package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -4
  205. package/test/graphic_test_app/07_chessboard_interaction/error.tsx +2 -2
  206. package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +5 -5
  207. package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +8 -8
  208. package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +4 -4
  209. package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +9 -9
  210. package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +9 -9
  211. package/test/graphic_test_app/10_movetext_graphic/base.tsx +4 -4
  212. package/test/graphic_test_app/10_movetext_graphic/error.tsx +6 -6
  213. package/test/graphic_test_app/10_movetext_graphic/format_move.tsx +1 -1
  214. package/test/graphic_test_app/10_movetext_graphic/html.tsx +5 -5
  215. package/test/graphic_test_app/10_movetext_graphic/options.tsx +10 -10
  216. package/test/graphic_test_app/11_movetext_interaction/error.tsx +1 -1
  217. package/test/graphic_test_app/11_movetext_interaction/select_moves.tsx +11 -11
  218. package/test/graphic_test_app/{12_navigation_board → 12_navigation_board_base}/controlled.tsx +5 -5
  219. package/test/graphic_test_app/{12_navigation_board → 12_navigation_board_base}/uncontrolled.tsx +7 -7
  220. package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +49 -0
  221. package/test/graphic_test_app/{12_navigation_board → 13_navigation_board_graphic}/error.tsx +2 -2
  222. package/test/graphic_test_app/{12_navigation_board → 13_navigation_board_graphic}/theme.tsx +4 -4
  223. package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +73 -0
  224. package/test/graphic_test_app/14_navigation_board_autoplay/uncontrolled.tsx +34 -0
  225. package/test/graphic_test_app/common/decs.d.ts +2 -2
  226. package/test/graphic_test_app/common/test_app.css +15 -15
  227. package/test/graphic_test_app/common/test_app.tsx +48 -48
  228. package/tsconfig.json +13 -13
  229. package/test/12_navigation_board.js +0 -168
  230. package/test/graphic_references/12_navigation_board/controlled/regular_navigation_2.png +0 -0
  231. package/test/graphic_references/12_navigation_board/theme/small.png +0 -0
  232. package/test/graphic_references/12_navigation_board/uncontrolled/regular_navigation_1.png +0 -0
  233. /package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/error/pgn_parsing_error.png +0 -0
  234. /package/test/graphic_references/{12_navigation_board → 13_navigation_board_graphic}/error/wrong_game_type.png +0 -0
@@ -48,147 +48,154 @@ const COLOR_ICON_SIZE = 16;
48
48
 
49
49
 
50
50
  interface PageState {
51
- squareSize: number;
52
- coordinateVisible: boolean;
53
- turnVisible: boolean;
54
- colorset: string;
55
- pieceset: string;
56
- moveArrowVisible: boolean;
57
- moveArrowColor: AnnotationColor;
58
- animated: boolean;
59
- flipButtonVisible: boolean;
51
+ squareSize: number;
52
+ coordinateVisible: boolean;
53
+ turnVisible: boolean;
54
+ colorset: string;
55
+ pieceset: string;
56
+ moveArrowVisible: boolean;
57
+ moveArrowColor: AnnotationColor;
58
+ animated: boolean;
59
+ playButtonVisible: boolean;
60
+ flipButtonVisible: boolean;
60
61
  }
61
62
 
62
63
 
63
64
  export default class Page extends React.Component<object, PageState> {
64
65
 
65
- constructor(props: object) {
66
- super(props);
67
- this.state = {
68
- squareSize: 40,
69
- coordinateVisible: true,
70
- turnVisible: true,
71
- colorset: 'original',
72
- pieceset: 'cburnett',
73
- moveArrowVisible: true,
74
- moveArrowColor: 'b',
75
- animated: true,
76
- flipButtonVisible: true,
77
- };
78
- }
79
-
80
- render() {
81
- return (
82
- <Stack spacing={2} mt={2}>
83
- {this.renderControls()}
84
- {this.renderNavigationBoard()}
85
- {this.renderCode()}
86
- </Stack>
87
- );
88
- }
89
-
90
- private renderControls() {
91
- return (<>
92
- <Stack direction="row" spacing={2} alignItems="center">
93
- <FormControlLabel label="Show flip button"
94
- control={<Switch checked={this.state.flipButtonVisible} onChange={() => this.setState({ flipButtonVisible: !this.state.flipButtonVisible })} color="primary" />}
95
- />
96
- <FormControlLabel label="Show coordinates"
97
- control={<Switch checked={this.state.coordinateVisible} onChange={() => this.setState({ coordinateVisible: !this.state.coordinateVisible })} color="primary" />}
98
- />
99
- <FormControlLabel label="Show turn"
100
- control={<Switch checked={this.state.turnVisible} onChange={() => this.setState({ turnVisible: !this.state.turnVisible })} color="primary" />}
101
- />
102
- <FormControlLabel label="Animated"
103
- control={<Switch checked={this.state.animated} onChange={() => this.setState({ animated: !this.state.animated })} color="primary" />}
104
- />
105
- </Stack>
106
- <Box>
107
- <Typography gutterBottom>Square size</Typography>
108
- <Slider
109
- value={this.state.squareSize} onChange={(_, newValue) => this.setState({ squareSize: newValue as number })}
110
- min={Chessboard.minSquareSize()} max={Chessboard.maxSquareSize()} step={1} valueLabelDisplay="on" color="primary"
111
- />
112
- </Box>
113
- <Stack direction="row" spacing={2} alignItems="center">
114
- <FormControl variant="standard">
115
- <InputLabel id="colorset-label">Colorset</InputLabel>
116
- <Select labelId="colorset-label" sx={{ width: '8em' }} value={this.state.colorset} onChange={evt => this.setState({ colorset: evt.target.value })}>
117
- {Object.keys(Chessboard.colorsets()).sort().map(colorset => <MenuItem key={colorset} value={colorset}>{colorset}</MenuItem>)}
118
- </Select>
119
- </FormControl>
120
- <FormControl variant="standard">
121
- <InputLabel id="pieceset-label">Pieceset</InputLabel>
122
- <Select labelId="pieceset-label" sx={{ width: '8em' }} value={this.state.pieceset} onChange={evt => this.setState({ pieceset: evt.target.value })}>
123
- {Object.keys(Chessboard.piecesets()).sort().map(pieceset => <MenuItem key={pieceset} value={pieceset}>{pieceset}</MenuItem>)}
124
- </Select>
125
- </FormControl>
126
- <FormControlLabel label="Show move arrow"
127
- control={<Switch checked={this.state.moveArrowVisible} onChange={() => this.setState({ moveArrowVisible: !this.state.moveArrowVisible })} color="primary" />}
128
- />
129
- {this.renderMoveArrowColorSelector()}
130
- </Stack>
131
- </>);
132
- }
133
-
134
- private renderMoveArrowColorSelector() {
135
- if (!this.state.moveArrowVisible) {
136
- return undefined;
137
- }
138
- const colorset = Chessboard.colorsets()['original'];
139
- return (
140
- <ToggleButtonGroup value={this.state.moveArrowColor} exclusive size="small" onChange={(_, newColor) => this.handleMoveArrowColorChanged(newColor)}>
141
- <ToggleButton value="b"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cb} /></ToggleButton>
142
- <ToggleButton value="g"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cg} /></ToggleButton>
143
- <ToggleButton value="r"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cr} /></ToggleButton>
144
- <ToggleButton value="y"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cy} /></ToggleButton>
145
- </ToggleButtonGroup>
146
- );
147
- }
148
-
149
- private renderNavigationBoard() {
150
- return (
151
- <Box>
152
- <NavigationBoard
153
- game={pgn}
154
- initialNodeId="end"
155
- squareSize={this.state.squareSize}
156
- coordinateVisible={this.state.coordinateVisible}
157
- turnVisible={this.state.turnVisible}
158
- colorset={this.state.colorset}
159
- pieceset={this.state.pieceset}
160
- moveArrowVisible={this.state.moveArrowVisible}
161
- moveArrowColor={this.state.moveArrowColor}
162
- animated={this.state.animated}
163
- flipButtonVisible={this.state.flipButtonVisible}
164
- />
165
- </Box>
166
- );
167
- }
168
-
169
- private renderCode() {
170
- const attributes: string[] = [];
171
- attributes.push('game={pgn}');
172
- attributes.push('initialNodeId="end"');
173
- attributes.push(`squareSize={${this.state.squareSize}}`);
174
- attributes.push(`coordinateVisible={${this.state.coordinateVisible}}`);
175
- attributes.push(`turnVisible={${this.state.turnVisible}}`);
176
- attributes.push(`colorset="${this.state.colorset}"`);
177
- attributes.push(`pieceset="${this.state.pieceset}"`);
178
- attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
179
- if (this.state.moveArrowVisible) {
180
- attributes.push(`moveArrowColor="${this.state.moveArrowColor}"`);
181
- }
182
- attributes.push(`animated={${this.state.animated}}`);
183
- attributes.push(`flipButtonVisible={${this.state.flipButtonVisible}}`);
184
- const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
185
- return <pre className="kokopu-demoCode">{pgnDeclaration + buildComponentDemoCode('NavigationBoard', attributes)}</pre>;
186
- }
187
-
188
- private handleMoveArrowColorChanged(newColor: AnnotationColor | null) {
189
- if (newColor !== null) {
190
- this.setState({ moveArrowColor: newColor });
191
- }
192
- }
66
+ constructor(props: object) {
67
+ super(props);
68
+ this.state = {
69
+ squareSize: 40,
70
+ coordinateVisible: true,
71
+ turnVisible: true,
72
+ colorset: 'original',
73
+ pieceset: 'cburnett',
74
+ moveArrowVisible: true,
75
+ moveArrowColor: 'b',
76
+ animated: true,
77
+ playButtonVisible: true,
78
+ flipButtonVisible: true,
79
+ };
80
+ }
81
+
82
+ render() {
83
+ return (
84
+ <Stack spacing={2} mt={2}>
85
+ {this.renderControls()}
86
+ {this.renderNavigationBoard()}
87
+ {this.renderCode()}
88
+ </Stack>
89
+ );
90
+ }
91
+
92
+ private renderControls() {
93
+ return (<>
94
+ <Stack direction="row" spacing={2} alignItems="center">
95
+ <FormControlLabel label="Show play/stop button"
96
+ control={<Switch checked={this.state.playButtonVisible} onChange={() => this.setState({ playButtonVisible: !this.state.playButtonVisible })} color="primary" />}
97
+ />
98
+ <FormControlLabel label="Show flip button"
99
+ control={<Switch checked={this.state.flipButtonVisible} onChange={() => this.setState({ flipButtonVisible: !this.state.flipButtonVisible })} color="primary" />}
100
+ />
101
+ <FormControlLabel label="Show coordinates"
102
+ control={<Switch checked={this.state.coordinateVisible} onChange={() => this.setState({ coordinateVisible: !this.state.coordinateVisible })} color="primary" />}
103
+ />
104
+ <FormControlLabel label="Show turn"
105
+ control={<Switch checked={this.state.turnVisible} onChange={() => this.setState({ turnVisible: !this.state.turnVisible })} color="primary" />}
106
+ />
107
+ <FormControlLabel label="Animated"
108
+ control={<Switch checked={this.state.animated} onChange={() => this.setState({ animated: !this.state.animated })} color="primary" />}
109
+ />
110
+ </Stack>
111
+ <Box>
112
+ <Typography gutterBottom>Square size</Typography>
113
+ <Slider
114
+ value={this.state.squareSize} onChange={(_, newValue) => this.setState({ squareSize: newValue as number })}
115
+ min={Chessboard.minSquareSize()} max={Chessboard.maxSquareSize()} step={1} valueLabelDisplay="on" color="primary"
116
+ />
117
+ </Box>
118
+ <Stack direction="row" spacing={2} alignItems="center">
119
+ <FormControl variant="standard">
120
+ <InputLabel id="colorset-label">Colorset</InputLabel>
121
+ <Select labelId="colorset-label" sx={{ width: '8em' }} value={this.state.colorset} onChange={evt => this.setState({ colorset: evt.target.value })}>
122
+ {Object.keys(Chessboard.colorsets()).sort().map(colorset => <MenuItem key={colorset} value={colorset}>{colorset}</MenuItem>)}
123
+ </Select>
124
+ </FormControl>
125
+ <FormControl variant="standard">
126
+ <InputLabel id="pieceset-label">Pieceset</InputLabel>
127
+ <Select labelId="pieceset-label" sx={{ width: '8em' }} value={this.state.pieceset} onChange={evt => this.setState({ pieceset: evt.target.value })}>
128
+ {Object.keys(Chessboard.piecesets()).sort().map(pieceset => <MenuItem key={pieceset} value={pieceset}>{pieceset}</MenuItem>)}
129
+ </Select>
130
+ </FormControl>
131
+ <FormControlLabel label="Show move arrow"
132
+ control={<Switch checked={this.state.moveArrowVisible} onChange={() => this.setState({ moveArrowVisible: !this.state.moveArrowVisible })} color="primary" />}
133
+ />
134
+ {this.renderMoveArrowColorSelector()}
135
+ </Stack>
136
+ </>);
137
+ }
138
+
139
+ private renderMoveArrowColorSelector() {
140
+ if (!this.state.moveArrowVisible) {
141
+ return undefined;
142
+ }
143
+ const colorset = Chessboard.colorsets()['original'];
144
+ return (
145
+ <ToggleButtonGroup value={this.state.moveArrowColor} exclusive size="small" onChange={(_, newColor) => this.handleMoveArrowColorChanged(newColor)}>
146
+ <ToggleButton value="b"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cb} /></ToggleButton>
147
+ <ToggleButton value="g"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cg} /></ToggleButton>
148
+ <ToggleButton value="r"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cr} /></ToggleButton>
149
+ <ToggleButton value="y"><ArrowMarkerIcon size={COLOR_ICON_SIZE} color={colorset.cy} /></ToggleButton>
150
+ </ToggleButtonGroup>
151
+ );
152
+ }
153
+
154
+ private renderNavigationBoard() {
155
+ return (
156
+ <Box>
157
+ <NavigationBoard
158
+ game={pgn}
159
+ initialNodeId="end"
160
+ squareSize={this.state.squareSize}
161
+ coordinateVisible={this.state.coordinateVisible}
162
+ turnVisible={this.state.turnVisible}
163
+ colorset={this.state.colorset}
164
+ pieceset={this.state.pieceset}
165
+ moveArrowVisible={this.state.moveArrowVisible}
166
+ moveArrowColor={this.state.moveArrowColor}
167
+ animated={this.state.animated}
168
+ playButtonVisible={this.state.playButtonVisible}
169
+ flipButtonVisible={this.state.flipButtonVisible}
170
+ />
171
+ </Box>
172
+ );
173
+ }
174
+
175
+ private renderCode() {
176
+ const attributes: string[] = [];
177
+ attributes.push('game={pgn}');
178
+ attributes.push('initialNodeId="end"');
179
+ attributes.push(`squareSize={${this.state.squareSize}}`);
180
+ attributes.push(`coordinateVisible={${this.state.coordinateVisible}}`);
181
+ attributes.push(`turnVisible={${this.state.turnVisible}}`);
182
+ attributes.push(`colorset="${this.state.colorset}"`);
183
+ attributes.push(`pieceset="${this.state.pieceset}"`);
184
+ attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
185
+ if (this.state.moveArrowVisible) {
186
+ attributes.push(`moveArrowColor="${this.state.moveArrowColor}"`);
187
+ }
188
+ attributes.push(`animated={${this.state.animated}}`);
189
+ attributes.push(`playButtonVisible={${this.state.playButtonVisible}}`);
190
+ attributes.push(`flipButtonVisible={${this.state.flipButtonVisible}}`);
191
+ const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
192
+ return <pre className="kokopu-demoCode">{pgnDeclaration + buildComponentDemoCode('NavigationBoard', attributes)}</pre>;
193
+ }
194
+
195
+ private handleMoveArrowColorChanged(newColor: AnnotationColor | null) {
196
+ if (newColor !== null) {
197
+ this.setState({ moveArrowColor: newColor });
198
+ }
199
+ }
193
200
 
194
201
  }
@@ -36,79 +36,79 @@ import pgn from './game-3.pgn';
36
36
 
37
37
 
38
38
  interface PageState {
39
- nodeId: string;
39
+ nodeId: string;
40
40
  }
41
41
 
42
42
 
43
43
  export default class Page extends React.Component<object, PageState> {
44
44
 
45
- constructor(props: object) {
46
- super(props);
47
- this.state = {
48
- nodeId: '9b',
49
- };
50
- }
51
-
52
- render() {
53
- return (
54
- <Stack spacing={2} mt={2}>
55
- {this.renderControls()}
56
- {this.renderNavigationBoards()}
57
- {this.renderCode()}
58
- </Stack>
59
- );
60
- }
61
-
62
- private renderControls() {
63
- return (<>
64
- <Typography>
65
- In uncontrolled mode, the current node ID (aka. the current move) of the <code>NavigationBoard</code> component is managed internally.
66
- No additional code is needed to make the navigation buttons work.
67
- </Typography>
68
- <Typography>
69
- In controlled mode, the current node ID is defined by the <code>nodeId</code> attribute, and a callback must be set
70
- on the <code>onNodeIdChanged</code> attribute to respond to clicks on the navigation buttons.
71
- This mode requires more code, as a state variable holding the current node ID must be explicitely managed out of the component,
72
- but it allows to define more complex behaviors (e.g. synchronizing the node ID on the <code>NavigationBoard</code> with another component).
73
- </Typography>
74
- <Typography>
75
- Whether the component is in uncontrolled mode or controlled mode depends on the presence of the <code>nodeId</code> attribute.
76
- </Typography>
77
- </>);
78
- }
79
-
80
- private renderNavigationBoards() {
81
- return (
82
- <Box display="flex" alignItems="top" justifyContent="space-around">
83
- <Box>
84
- <NavigationBoard game={pgn} animated initialNodeId="9b" />
85
- <Typography mt={2} textAlign="center">Uncontrolled</Typography>
86
- </Box>
87
- <Box>
88
- <NavigationBoard game={pgn} animated nodeId={this.state.nodeId} onNodeIdChanged={nodeId => this.setState({ nodeId: nodeId })} />
89
- <Typography mt={2} textAlign="center">Controlled</Typography>
90
- <Typography textAlign="center">{`Current node ID: ${this.state.nodeId}`}</Typography>
91
- </Box>
92
- </Box>
93
- );
94
- }
95
-
96
- private renderCode() {
97
-
98
- const uncontrolledAttributes: string[] = [];
99
- uncontrolledAttributes.push('game={pgn}');
100
- uncontrolledAttributes.push('animated');
101
- uncontrolledAttributes.push('initialNodeId="9b"');
102
-
103
- const controlledAttributes: string[] = [];
104
- controlledAttributes.push('game={pgn}');
105
- controlledAttributes.push('animated');
106
- controlledAttributes.push(`nodeId="${this.state.nodeId}"`);
107
- controlledAttributes.push('onNodeIdChanged={nodeId => handleNodeIdChanged(nodeId)}');
108
-
109
- const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
110
- return <pre className="kokopu-demoCode">{pgnDeclaration + '// Uncontrolled\n' + buildComponentDemoCode('NavigationBoard', uncontrolledAttributes)
111
- + '\n\n// Controlled\n' + buildComponentDemoCode('NavigationBoard', controlledAttributes)}</pre>;
112
- }
45
+ constructor(props: object) {
46
+ super(props);
47
+ this.state = {
48
+ nodeId: '9b',
49
+ };
50
+ }
51
+
52
+ render() {
53
+ return (
54
+ <Stack spacing={2} mt={2}>
55
+ {this.renderControls()}
56
+ {this.renderNavigationBoards()}
57
+ {this.renderCode()}
58
+ </Stack>
59
+ );
60
+ }
61
+
62
+ private renderControls() {
63
+ return (<>
64
+ <Typography>
65
+ In uncontrolled mode, the current node ID (aka. the current move) of the <code>NavigationBoard</code> component is managed internally.
66
+ No additional code is needed to make the navigation buttons work.
67
+ </Typography>
68
+ <Typography>
69
+ In controlled mode, the current node ID is defined by the <code>nodeId</code> attribute, and a callback must be set
70
+ on the <code>onNodeIdChanged</code> attribute to respond to clicks on the navigation buttons.
71
+ This mode requires more code, as a state variable holding the current node ID must be explicitely managed out of the component,
72
+ but it allows to define more complex behaviors (e.g. synchronizing the node ID on the <code>NavigationBoard</code> with another component).
73
+ </Typography>
74
+ <Typography>
75
+ Whether the component is in uncontrolled mode or controlled mode depends on the presence of the <code>nodeId</code> attribute.
76
+ </Typography>
77
+ </>);
78
+ }
79
+
80
+ private renderNavigationBoards() {
81
+ return (
82
+ <Box display="flex" alignItems="top" justifyContent="space-around">
83
+ <Box>
84
+ <NavigationBoard game={pgn} animated initialNodeId="9b" />
85
+ <Typography mt={2} textAlign="center">Uncontrolled</Typography>
86
+ </Box>
87
+ <Box>
88
+ <NavigationBoard game={pgn} animated nodeId={this.state.nodeId} onNodeIdChanged={nodeId => this.setState({ nodeId: nodeId })} />
89
+ <Typography mt={2} textAlign="center">Controlled</Typography>
90
+ <Typography textAlign="center">{`Current node ID: ${this.state.nodeId}`}</Typography>
91
+ </Box>
92
+ </Box>
93
+ );
94
+ }
95
+
96
+ private renderCode() {
97
+
98
+ const uncontrolledAttributes: string[] = [];
99
+ uncontrolledAttributes.push('game={pgn}');
100
+ uncontrolledAttributes.push('animated');
101
+ uncontrolledAttributes.push('initialNodeId="9b"');
102
+
103
+ const controlledAttributes: string[] = [];
104
+ controlledAttributes.push('game={pgn}');
105
+ controlledAttributes.push('animated');
106
+ controlledAttributes.push(`nodeId="${this.state.nodeId}"`);
107
+ controlledAttributes.push('onNodeIdChanged={nodeId => handleNodeIdChanged(nodeId)}');
108
+
109
+ const pgnDeclaration = 'const pgn = `\n' + pgn.trim() + '`;\n\n';
110
+ return <pre className="kokopu-demoCode">{pgnDeclaration + '// Uncontrolled\n' + buildComponentDemoCode('NavigationBoard', uncontrolledAttributes)
111
+ + '\n\n// Controlled\n' + buildComponentDemoCode('NavigationBoard', controlledAttributes)}</pre>;
112
+ }
113
113
 
114
114
  }
@@ -23,11 +23,11 @@
23
23
 
24
24
 
25
25
  declare module '*.pgn' {
26
- const pgnText: string;
27
- export default pgnText;
26
+ const pgnText: string;
27
+ export default pgnText;
28
28
  }
29
29
 
30
30
  declare module '*.png' {
31
- const path: string;
32
- export default path;
31
+ const path: string;
32
+ export default path;
33
33
  }
@@ -23,25 +23,25 @@
23
23
 
24
24
 
25
25
  .kokopu-demoCode {
26
- border: 1px solid rgb(232, 232, 232);
27
- border-radius: 3px;
28
- background-color: rgb(245, 245, 245);
29
- font-size: 13px;
30
- padding: 16px;
31
- white-space: pre-wrap;
26
+ border: 1px solid rgb(232, 232, 232);
27
+ border-radius: 3px;
28
+ background-color: rgb(245, 245, 245);
29
+ font-size: 13px;
30
+ padding: 16px;
31
+ white-space: pre-wrap;
32
32
  }
33
33
 
34
34
  .MuiToggleButton-root.kokopu-fixTextTransform {
35
- text-transform: none;
35
+ text-transform: none;
36
36
  }
37
37
 
38
38
  .MuiToggleButton-root.Mui-disabled.kokopu-fixOpacity .kokopu-arrowMarkerIcon {
39
- opacity: 0.3;
39
+ opacity: 0.3;
40
40
  }
41
41
 
42
42
  .kokopu-fixedPopup {
43
- position: fixed;
44
- bottom: 20px;
45
- right: 20px;
46
- padding: 10px;
43
+ position: fixed;
44
+ bottom: 20px;
45
+ right: 20px;
46
+ padding: 10px;
47
47
  }
@@ -23,5 +23,5 @@
23
23
 
24
24
 
25
25
  export function buildComponentDemoCode(componentName: string, attributes: string[]) {
26
- return attributes.length === 0 ? `<${componentName} />` : `<${componentName} ${attributes.join(' ')} />`;
26
+ return attributes.length === 0 ? `<${componentName} />` : `<${componentName} ${attributes.join(' ')} />`;
27
27
  }
@@ -11,5 +11,5 @@ const pgn = `
11
11
  1.e4 Nc6 2.Nf3 d5 3.Bd3 Nf6 4.exd5 Qxd5 5.Nc3 Qh5 6.O-O Bg4
12
12
  7.h3 Ne5 8.hxg4 Nfxg4 9.Nxe5 Qh2# 0-1`;
13
13
 
14
- <NavigationBoard game={pgn} initialNodeId="end" />
14
+ <NavigationBoard game={pgn} initialNodeId="end" playButtonVisible />
15
15
  ```
@@ -31,22 +31,22 @@ import './theming.css';
31
31
  /* eslint-disable react/prop-types */
32
32
 
33
33
  const styles = ({ color, fontFamily, fontSize }) => ({
34
- logo: {
35
- color: color.base,
36
- margin: 0,
37
- fontFamily: fontFamily.base,
38
- fontSize: fontSize.h4,
39
- fontWeight: 'normal',
40
- },
34
+ logo: {
35
+ color: color.base,
36
+ margin: 0,
37
+ fontFamily: fontFamily.base,
38
+ fontSize: fontSize.h4,
39
+ fontWeight: 'normal',
40
+ },
41
41
  });
42
42
 
43
43
  function LogoRenderer({ classes, children }) {
44
- return (<>
45
- <div className="kokopu-logo">
46
- <img src="kokopu-react-logo.png" />
47
- </div>
48
- <h1 className={classes.logo}>{children}</h1>
49
- </>);
44
+ return (<>
45
+ <div className="kokopu-logo">
46
+ <img src="kokopu-react-logo.png" />
47
+ </div>
48
+ <h1 className={classes.logo}>{children}</h1>
49
+ </>);
50
50
  }
51
51
 
52
52
  export default Styled(styles)(LogoRenderer);
@@ -23,15 +23,15 @@
23
23
 
24
24
 
25
25
  .kokopu-logo {
26
- text-align: center;
26
+ text-align: center;
27
27
  }
28
28
 
29
29
  footer {
30
- display: none !important;
30
+ display: none !important;
31
31
  }
32
32
 
33
33
  #changelog h2 {
34
- font-size: inherit;
35
- font-weight: bold;
36
- margin-top: 24px;
34
+ font-size: inherit;
35
+ font-weight: bold;
36
+ margin-top: 24px;
37
37
  }