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.
Files changed (57) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -0
  3. package/dist/lib/ArrowMarkerIcon.js +3 -5
  4. package/dist/lib/Chessboard.js +25 -32
  5. package/dist/lib/{impl/ErrorBox.js → ErrorBox.js} +1 -1
  6. package/dist/lib/TextMarkerIcon.js +11 -10
  7. package/dist/lib/css/symbol.css +25 -0
  8. package/dist/lib/i18n.js +35 -0
  9. package/dist/lib/impl/ArrowTip.js +2 -7
  10. package/dist/lib/impl/TextSymbol.js +100 -0
  11. package/dist/lib/impl/util.js +5 -5
  12. package/dist/lib/index.js +34 -18
  13. package/dist/lib/markers.js +10 -10
  14. package/doc_src/{demo/.eslintrc.yml → .eslintrc.yml} +0 -0
  15. package/doc_src/demo/PageChessboardBase.js +35 -40
  16. package/doc_src/demo/PageChessboardEdition.js +58 -70
  17. package/doc_src/demo/PageChessboardMove.js +20 -27
  18. package/doc_src/demo/PageChessboardSmallScreens.js +15 -16
  19. package/doc_src/examples/ErrorBox.md +3 -0
  20. package/doc_src/theming/LogoRenderer.js +50 -0
  21. package/doc_src/theming/kokopu-react-favicon.png +0 -0
  22. package/doc_src/theming/kokopu-react-logo.png +0 -0
  23. package/doc_src/theming/theming.css +29 -0
  24. package/graphic_test_app/01_marker_icons.js +5 -3
  25. package/graphic_test_app/04_chessboard_annotations.js +1 -1
  26. package/graphic_test_app/10_chessboard_play_moves.js +2 -0
  27. package/graphics/logo-small.svg +14 -0
  28. package/graphics/logo.svg +26 -0
  29. package/package.json +23 -21
  30. package/scripts/test_graphic/docker-compose.yml +1 -1
  31. package/scripts/test_graphic/webpack-config.js +1 -0
  32. package/scripts/test_headless.webpack-config.js +1 -0
  33. package/src/ArrowMarkerIcon.js +1 -1
  34. package/src/Chessboard.js +15 -15
  35. package/src/{impl/ErrorBox.js → ErrorBox.js} +1 -1
  36. package/src/TextMarkerIcon.js +6 -6
  37. package/src/css/symbol.css +25 -0
  38. package/src/i18n.js +30 -0
  39. package/src/impl/ArrowTip.js +2 -6
  40. package/src/impl/TextSymbol.js +77 -0
  41. package/src/impl/util.js +1 -1
  42. package/src/index.js +2 -0
  43. package/src/markers.js +7 -6
  44. package/test/1_markers.js +19 -0
  45. package/test/3_marker_icons_graphic.js +1 -1
  46. package/test/6_chessboard_play_moves.js +4 -0
  47. package/test/references/01_marker_icons/10.png +0 -0
  48. package/test/references/01_marker_icons/9.png +0 -0
  49. package/test/references/02_chessboard_simple/2.png +0 -0
  50. package/test/references/02_chessboard_simple/5.png +0 -0
  51. package/test/references/03_chessboard_flipped/2.png +0 -0
  52. package/test/references/04_chessboard_annotations/4.png +0 -0
  53. package/test/references/04_chessboard_annotations/5.png +0 -0
  54. package/test/references/10_chessboard_play_moves/chess960_ambiguous_king_move.png +0 -0
  55. package/test/references/10_chessboard_play_moves/chess960_castling_move_1.png +0 -0
  56. package/test/references/10_chessboard_play_moves/chess960_castling_move_2.png +0 -0
  57. package/test/references/10_chessboard_play_moves/chess960_non_kxr_castling.png +0 -0
@@ -25,15 +25,18 @@ import React from 'react';
25
25
  import { Chessboard } from '../../src/index';
26
26
  import { buildComponentDemoCode } from './util';
27
27
 
28
- import Box from '@material-ui/core/Box';
29
- import Button from '@material-ui/core/Button';
30
- import ButtonGroup from '@material-ui/core/ButtonGroup';
31
- import FormControlLabel from '@material-ui/core/FormControlLabel';
32
- import MenuItem from '@material-ui/core/MenuItem';
33
- import Select from '@material-ui/core/Select';
34
- import Slider from '@material-ui/core/Slider';
35
- import Switch from '@material-ui/core/Switch';
36
- import Typography from '@material-ui/core/Typography';
28
+ import Box from '@mui/material/Box';
29
+ import Button from '@mui/material/Button';
30
+ import ButtonGroup from '@mui/material/ButtonGroup';
31
+ import FormControl from '@mui/material/FormControl';
32
+ import FormControlLabel from '@mui/material/FormControlLabel';
33
+ import InputLabel from '@mui/material/InputLabel';
34
+ import MenuItem from '@mui/material/MenuItem';
35
+ import Select from '@mui/material/Select';
36
+ import Slider from '@mui/material/Slider';
37
+ import Stack from '@mui/material/Stack';
38
+ import Switch from '@mui/material/Switch';
39
+ import Typography from '@mui/material/Typography';
37
40
 
38
41
  import './demo.css';
39
42
 
@@ -59,17 +62,17 @@ export default class Page extends React.Component {
59
62
 
60
63
  render() {
61
64
  return (
62
- <div>
65
+ <Stack spacing={2} mt={2}>
63
66
  {this.renderControls()}
64
67
  {this.renderChessboard()}
65
68
  {this.renderCode()}
66
- </div>
69
+ </Stack>
67
70
  );
68
71
  }
69
72
 
70
73
  renderControls() {
71
74
  return (<>
72
- <Box my={2}>
75
+ <Stack direction="row" spacing={2} alignItems="center">
73
76
  <FormControlLabel label="Flip"
74
77
  control={<Switch checked={this.state.flipped} onChange={() => this.set('flipped', !this.state.flipped)} color="primary" />}
75
78
  />
@@ -79,42 +82,40 @@ export default class Page extends React.Component {
79
82
  <FormControlLabel label="Show annotations"
80
83
  control={<Switch checked={this.state.annotationVisible} onChange={() => this.set('annotationVisible', !this.state.annotationVisible)} color="primary" />}
81
84
  />
82
- </Box>
83
- <Box my={2}>
85
+ </Stack>
86
+ <Box>
84
87
  <Typography gutterBottom>Square size</Typography>
85
88
  <Slider
86
89
  value={this.state.squareSize} onChange={(_, newValue) => this.set('squareSize', newValue)}
87
90
  min={Chessboard.minSquareSize()} max={Chessboard.maxSquareSize()} step={1} valueLabelDisplay="on" color="primary"
88
91
  />
89
92
  </Box>
90
- <Box my={2} display="flex" flexDirection="row" alignItems="center">
91
- <Box mr={2}>
92
- <Typography>Colorset</Typography>
93
- <Select value={this.state.colorset} onChange={evt => this.set('colorset', evt.target.value)}>
93
+ <Stack direction="row" spacing={2} alignItems="center">
94
+ <FormControl variant="standard">
95
+ <InputLabel id="colorset-label">Colorset</InputLabel>
96
+ <Select labelId="colorset-label" sx={{ width: '8em' }} value={this.state.colorset} onChange={evt => this.set('colorset', evt.target.value)}>
94
97
  {Object.keys(Chessboard.colorsets()).sort().map(colorset => <MenuItem key={colorset} value={colorset}>{colorset}</MenuItem>)}
95
98
  </Select>
96
- </Box>
97
- <Box mx={2}>
98
- <Typography>Pieceset</Typography>
99
- <Select value={this.state.pieceset} onChange={evt => this.set('pieceset', evt.target.value)}>
99
+ </FormControl>
100
+ <FormControl variant="standard">
101
+ <InputLabel id="pieceset-label">Pieceset</InputLabel>
102
+ <Select labelId="pieceset-label" sx={{ width: '8em' }} value={this.state.pieceset} onChange={evt => this.set('pieceset', evt.target.value)}>
100
103
  {Object.keys(Chessboard.piecesets()).sort().map(pieceset => <MenuItem key={pieceset} value={pieceset}>{pieceset}</MenuItem>)}
101
104
  </Select>
102
- </Box>
103
- <Box ml={2}>
104
- <ButtonGroup color="primary" size="small">
105
- <Button onClick={() => this.set('position', 'empty')}>Clear</Button>
106
- <Button onClick={() => this.set('position', 'start')}>Reset</Button>
107
- <Button onClick={() => this.set('position', '8/8/8/8/8/4k3/q7/4K3 b - - 0 1')}>Set FEN</Button>
108
- <Button onClick={() => this.set('position', 'I\'m an invalid FEN string')}>Set ill-formed FEN</Button>
109
- </ButtonGroup>
110
- </Box>
111
- </Box>
105
+ </FormControl>
106
+ <ButtonGroup color="primary" size="small">
107
+ <Button onClick={() => this.set('position', 'empty')}>Clear</Button>
108
+ <Button onClick={() => this.set('position', 'start')}>Reset</Button>
109
+ <Button onClick={() => this.set('position', '8/8/8/8/8/4k3/q7/4K3 b - - 0 1')}>Set FEN</Button>
110
+ <Button onClick={() => this.set('position', 'I\'m an invalid FEN string')}>Set ill-formed FEN</Button>
111
+ </ButtonGroup>
112
+ </Stack>
112
113
  </>);
113
114
  }
114
115
 
115
116
  renderChessboard() {
116
117
  return (
117
- <Box my={2}>
118
+ <Box>
118
119
  <Chessboard
119
120
  position={this.state.position}
120
121
  flipped={this.state.flipped}
@@ -145,13 +146,7 @@ export default class Page extends React.Component {
145
146
  attributes.push(`coordinateVisible={${this.state.coordinateVisible}}`);
146
147
  attributes.push(`colorset="${this.state.colorset}"`);
147
148
  attributes.push(`pieceset="${this.state.pieceset}"`);
148
- return (
149
- <Box my={2}>
150
- <pre className="kokopu-demoCode">
151
- {buildComponentDemoCode('Chessboard', attributes)}
152
- </pre>
153
- </Box>
154
- );
149
+ return <pre className="kokopu-demoCode">{buildComponentDemoCode('Chessboard', attributes)}</pre>;
155
150
  }
156
151
 
157
152
  set(attributeName, newValue) {
@@ -26,18 +26,19 @@ import kokopu from 'kokopu';
26
26
  import { Chessboard, SquareMarkerIcon, TextMarkerIcon, ArrowMarkerIcon, flattenSquareMarkers, flattenTextMarkers, flattenArrowMarkers } from '../../src/index';
27
27
  import { buildComponentDemoCode } from './util';
28
28
 
29
- import Box from '@material-ui/core/Box';
30
- import Button from '@material-ui/core/Button';
31
- import ButtonGroup from '@material-ui/core/ButtonGroup';
32
- import FormControlLabel from '@material-ui/core/FormControlLabel';
33
- import MenuItem from '@material-ui/core/MenuItem';
34
- import Radio from '@material-ui/core/Radio';
35
- import RadioGroup from '@material-ui/core/RadioGroup';
36
- import Select from '@material-ui/core/Select';
37
- import Switch from '@material-ui/core/Switch';
38
- import ToggleButton from '@material-ui/lab/ToggleButton';
39
- import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
40
- import Typography from '@material-ui/core/Typography';
29
+ import Box from '@mui/material/Box';
30
+ import Button from '@mui/material/Button';
31
+ import ButtonGroup from '@mui/material/ButtonGroup';
32
+ import FormControlLabel from '@mui/material/FormControlLabel';
33
+ import MenuItem from '@mui/material/MenuItem';
34
+ import Radio from '@mui/material/Radio';
35
+ import RadioGroup from '@mui/material/RadioGroup';
36
+ import Select from '@mui/material/Select';
37
+ import Stack from '@mui/material/Stack';
38
+ import Switch from '@mui/material/Switch';
39
+ import ToggleButton from '@mui/material/ToggleButton';
40
+ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
41
+ import Typography from '@mui/material/Typography';
41
42
 
42
43
  import './demo.css';
43
44
 
@@ -68,55 +69,53 @@ export default class Page extends React.Component {
68
69
 
69
70
  render() {
70
71
  return (
71
- <div>
72
+ <Stack spacing={2} mt={2}>
72
73
  {this.renderControls()}
73
74
  {this.renderChessboard()}
74
75
  {this.renderCode()}
75
- </div>
76
+ </Stack>
76
77
  );
77
78
  }
78
79
 
79
80
  renderControls() {
80
81
  return (<>
81
- <Box my={2} display="flex" flexDirection="row" alignItems="center">
82
+ <Stack direction="row" spacing={2} alignItems="center">
82
83
  <FormControlLabel label="Flip"
83
84
  control={<Switch checked={this.state.flipped} onChange={() => this.set('flipped', !this.state.flipped)} color="primary" />}
84
85
  />
85
86
  <Button color="primary" size="small" variant="contained" onClick={() => this.handleTurnClicked(kokopu.oppositeColor(this.state.position.turn()))}>
86
87
  Change turn
87
88
  </Button>
88
- <Box mx={2}>
89
- <ButtonGroup color="primary" size="small">
90
- <Button onClick={() => this.set('position', new kokopu.Position('empty'))}>Clear</Button>
91
- <Button onClick={() => this.set('position', new kokopu.Position())}>Reset</Button>
92
- </ButtonGroup>
93
- </Box>
94
- </Box>
95
- <Box my={2}>
89
+ <ButtonGroup color="primary" size="small">
90
+ <Button onClick={() => this.set('position', new kokopu.Position('empty'))}>Clear</Button>
91
+ <Button onClick={() => this.set('position', new kokopu.Position())}>Reset</Button>
92
+ </ButtonGroup>
93
+ </Stack>
94
+ <Box>
96
95
  <Typography gutterBottom>
97
96
  Edition mode
98
97
  </Typography>
99
98
  <RadioGroup value={this.state.interactionMode} onChange={evt => this.set('interactionMode', evt.target.value)}>
100
99
  <FormControlLabel value="" control={<Radio color="primary" />} label="None" />
101
- <Box display="flex" flexDirection="row">
100
+ <Stack direction="row" spacing={2} alignItems="center">
102
101
  <FormControlLabel value="addRemovePieces" control={<Radio color="primary" />} label="Add/remove pieces" />
103
102
  {this.renderPieceSelector()}
104
- </Box>
103
+ </Stack>
105
104
  <FormControlLabel value="movePieces" control={<Radio color="primary" />} label="Move pieces" />
106
105
  <FormControlLabel value="playMoves" control={<Radio color="primary" />} label="Move pieces (obeying chess rules)" />
107
- <Box display="flex" flexDirection="row">
106
+ <Stack direction="row" spacing={2} alignItems="center">
108
107
  <FormControlLabel value="editSquareMarkers" control={<Radio color="primary" />} label="Edit square annotations" />
109
108
  {this.renderMarkerColorSelector('squareMarkerColor', 'editSquareMarkers')}
110
- </Box>
111
- <Box display="flex" flexDirection="row">
109
+ </Stack>
110
+ <Stack direction="row" spacing={2} alignItems="center">
112
111
  <FormControlLabel value="editTextMarkers" control={<Radio color="primary" />} label="Edit text annotations" />
113
112
  {this.renderMarkerColorSelector('textMarkerColor', 'editTextMarkers')}
114
113
  {this.renderTextMarkerSymbolSelector()}
115
- </Box>
116
- <Box display="flex" flexDirection="row">
114
+ </Stack>
115
+ <Stack direction="row" spacing={2} alignItems="center">
117
116
  <FormControlLabel value="editArrowMarkers" control={<Radio color="primary" />} label="Edit arrow annotations" />
118
117
  {this.renderMarkerColorSelector('arrowMarkerColor', 'editArrowMarkers')}
119
- </Box>
118
+ </Stack>
120
119
  </RadioGroup>
121
120
  </Box>
122
121
  </>);
@@ -128,28 +127,24 @@ export default class Page extends React.Component {
128
127
  }
129
128
  let pieceset = Chessboard.piecesets()['cburnett'];
130
129
  return (
131
- <Box mx={2}>
132
- <Box my={0.5}>
133
- <ToggleButtonGroup value={this.state.pieceEditMode} exclusive size="small" onChange={(_, newMode) => this.setIfNonNull('pieceEditMode', newMode)}>
134
- <ToggleButton value="wk"><img src={pieceset.wk} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
135
- <ToggleButton value="wq"><img src={pieceset.wq} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
136
- <ToggleButton value="wr"><img src={pieceset.wr} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
137
- <ToggleButton value="wb"><img src={pieceset.wb} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
138
- <ToggleButton value="wn"><img src={pieceset.wn} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
139
- <ToggleButton value="wp"><img src={pieceset.wp} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
140
- </ToggleButtonGroup>
141
- </Box>
142
- <Box my={0.5}>
143
- <ToggleButtonGroup value={this.state.pieceEditMode} exclusive size="small" onChange={(_, newMode) => this.setIfNonNull('pieceEditMode', newMode)}>
144
- <ToggleButton value="bk"><img src={pieceset.bk} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
145
- <ToggleButton value="bq"><img src={pieceset.bq} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
146
- <ToggleButton value="br"><img src={pieceset.br} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
147
- <ToggleButton value="bb"><img src={pieceset.bb} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
148
- <ToggleButton value="bn"><img src={pieceset.bn} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
149
- <ToggleButton value="bp"><img src={pieceset.bp} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
150
- </ToggleButtonGroup>
151
- </Box>
152
- </Box>
130
+ <Stack spacing={0.5}>
131
+ <ToggleButtonGroup value={this.state.pieceEditMode} exclusive size="small" onChange={(_, newMode) => this.setIfNonNull('pieceEditMode', newMode)}>
132
+ <ToggleButton value="wk"><img src={pieceset.wk} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
133
+ <ToggleButton value="wq"><img src={pieceset.wq} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
134
+ <ToggleButton value="wr"><img src={pieceset.wr} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
135
+ <ToggleButton value="wb"><img src={pieceset.wb} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
136
+ <ToggleButton value="wn"><img src={pieceset.wn} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
137
+ <ToggleButton value="wp"><img src={pieceset.wp} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
138
+ </ToggleButtonGroup>
139
+ <ToggleButtonGroup value={this.state.pieceEditMode} exclusive size="small" onChange={(_, newMode) => this.setIfNonNull('pieceEditMode', newMode)}>
140
+ <ToggleButton value="bk"><img src={pieceset.bk} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
141
+ <ToggleButton value="bq"><img src={pieceset.bq} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
142
+ <ToggleButton value="br"><img src={pieceset.br} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
143
+ <ToggleButton value="bb"><img src={pieceset.bb} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
144
+ <ToggleButton value="bn"><img src={pieceset.bn} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
145
+ <ToggleButton value="bp"><img src={pieceset.bp} width={PIECE_ICON_SIZE} height={PIECE_ICON_SIZE} /></ToggleButton>
146
+ </ToggleButtonGroup>
147
+ </Stack>
153
148
  );
154
149
  }
155
150
 
@@ -157,9 +152,10 @@ export default class Page extends React.Component {
157
152
  if (this.state.interactionMode !== 'editTextMarkers') {
158
153
  return undefined;
159
154
  }
155
+ let availableSymbols = [ 'plus', 'times', 'dot', 'circle' ].concat([...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789']);
160
156
  return (
161
- <Select value={this.state.textMarkerSymbol} onChange={evt => this.set('textMarkerSymbol', evt.target.value)}>
162
- {[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'].map(mode => <MenuItem key={mode} value={mode}>{mode}</MenuItem>)}
157
+ <Select variant="standard" value={this.state.textMarkerSymbol} onChange={evt => this.set('textMarkerSymbol', evt.target.value)}>
158
+ {availableSymbols.map(mode => <MenuItem key={mode} value={mode}>{mode}</MenuItem>)}
163
159
  </Select>
164
160
  );
165
161
  }
@@ -170,13 +166,11 @@ export default class Page extends React.Component {
170
166
  }
171
167
  let colorset = Chessboard.colorsets()['original'];
172
168
  return (
173
- <Box mx={2} my={0.5}>
174
- <ToggleButtonGroup value={this.state[attributeName]} exclusive size="small" onChange={(_, newColor) => this.setIfNonNull(attributeName, newColor)}>
175
- <ToggleButton className="kokopu-fixTextTransform" value="g">{this.renderColorButtonLabel(colorset.g)}</ToggleButton>
176
- <ToggleButton className="kokopu-fixTextTransform" value="r">{this.renderColorButtonLabel(colorset.r)}</ToggleButton>
177
- <ToggleButton className="kokopu-fixTextTransform" value="y">{this.renderColorButtonLabel(colorset.y)}</ToggleButton>
178
- </ToggleButtonGroup>
179
- </Box>
169
+ <ToggleButtonGroup value={this.state[attributeName]} exclusive size="small" onChange={(_, newColor) => this.setIfNonNull(attributeName, newColor)}>
170
+ <ToggleButton className="kokopu-fixTextTransform" value="g">{this.renderColorButtonLabel(colorset.g)}</ToggleButton>
171
+ <ToggleButton className="kokopu-fixTextTransform" value="r">{this.renderColorButtonLabel(colorset.r)}</ToggleButton>
172
+ <ToggleButton className="kokopu-fixTextTransform" value="y">{this.renderColorButtonLabel(colorset.y)}</ToggleButton>
173
+ </ToggleButtonGroup>
180
174
  );
181
175
  }
182
176
 
@@ -195,7 +189,7 @@ export default class Page extends React.Component {
195
189
 
196
190
  renderChessboard() {
197
191
  return (
198
- <Box my={2}>
192
+ <Box>
199
193
  <Chessboard
200
194
  position={this.state.position}
201
195
  flipped={this.state.flipped}
@@ -257,13 +251,7 @@ export default class Page extends React.Component {
257
251
  default:
258
252
  break;
259
253
  }
260
- return (
261
- <Box my={2}>
262
- <pre className="kokopu-demoCode">
263
- {buildComponentDemoCode('Chessboard', attributes)}
264
- </pre>
265
- </Box>
266
- );
254
+ return <pre className="kokopu-demoCode">{buildComponentDemoCode('Chessboard', attributes)}</pre>;
267
255
  }
268
256
 
269
257
  set(attributeName, newValue) {
@@ -26,12 +26,13 @@ import kokopu from 'kokopu';
26
26
  import { Chessboard } from '../../src/index';
27
27
  import { buildComponentDemoCode } from './util';
28
28
 
29
- import Box from '@material-ui/core/Box';
30
- import Button from '@material-ui/core/Button';
31
- import ButtonGroup from '@material-ui/core/ButtonGroup';
32
- import FormControlLabel from '@material-ui/core/FormControlLabel';
33
- import Switch from '@material-ui/core/Switch';
34
- import TextField from '@material-ui/core/TextField';
29
+ import Box from '@mui/material/Box';
30
+ import Button from '@mui/material/Button';
31
+ import ButtonGroup from '@mui/material/ButtonGroup';
32
+ import FormControlLabel from '@mui/material/FormControlLabel';
33
+ import Stack from '@mui/material/Stack';
34
+ import Switch from '@mui/material/Switch';
35
+ import TextField from '@mui/material/TextField';
35
36
 
36
37
  import './demo.css';
37
38
 
@@ -56,17 +57,17 @@ export default class Page extends React.Component {
56
57
 
57
58
  render() {
58
59
  return (
59
- <div>
60
+ <Stack spacing={2} mt={2}>
60
61
  {this.renderControls()}
61
62
  {this.renderChessboard()}
62
63
  {this.renderCode()}
63
- </div>
64
+ </Stack>
64
65
  );
65
66
  }
66
67
 
67
68
  renderControls() {
68
69
  return (<>
69
- <Box my={2}>
70
+ <Stack direction="row" spacing={2} alignItems="center">
70
71
  <FormControlLabel label="Flip"
71
72
  control={<Switch checked={this.state.flipped} onChange={() => this.set('flipped', !this.state.flipped)} color="primary" />}
72
73
  />
@@ -76,23 +77,21 @@ export default class Page extends React.Component {
76
77
  <FormControlLabel label="Animation" disabled={!this.state.positionAfter}
77
78
  control={<Switch checked={this.state.animated} onChange={() => this.set('animated', !this.state.animated)} color="primary" />}
78
79
  />
79
- </Box>
80
- <Box my={2} display="flex" flexDirection="row" alignItems="center">
81
- <TextField label="Move" value={this.state.editedMove} onChange={evt => this.set('editedMove', evt.target.value)} />
80
+ </Stack>
81
+ <Stack direction="row" spacing={2} alignItems="center">
82
+ <TextField label="Move" variant="standard" value={this.state.editedMove} onChange={evt => this.set('editedMove', evt.target.value)} />
82
83
  <Button color="primary" size="small" variant="contained" onClick={() => this.handlePlayClicked()}>Play</Button>
83
- <Box mx={2}>
84
- <ButtonGroup color="primary" size="small">
85
- <Button onClick={() => this.setPosition(new kokopu.Position('empty'))}>Clear</Button>
86
- <Button onClick={() => this.setPosition(new kokopu.Position())}>Reset</Button>
87
- </ButtonGroup>
88
- </Box>
89
- </Box>
84
+ <ButtonGroup color="primary" size="small">
85
+ <Button onClick={() => this.setPosition(new kokopu.Position('empty'))}>Clear</Button>
86
+ <Button onClick={() => this.setPosition(new kokopu.Position())}>Reset</Button>
87
+ </ButtonGroup>
88
+ </Stack>
90
89
  </>);
91
90
  }
92
91
 
93
92
  renderChessboard() {
94
93
  return (
95
- <Box my={2}>
94
+ <Box>
96
95
  <Chessboard
97
96
  position={this.state.position}
98
97
  move={this.state.playedMove}
@@ -115,13 +114,7 @@ export default class Page extends React.Component {
115
114
  }
116
115
  attributes.push(`moveArrowVisible={${this.state.moveArrowVisible}}`);
117
116
  attributes.push(`animated={${this.state.animated}}`);
118
- return (
119
- <Box my={2}>
120
- <pre className="kokopu-demoCode">
121
- {buildComponentDemoCode('Chessboard', attributes)}
122
- </pre>
123
- </Box>
124
- );
117
+ return <pre className="kokopu-demoCode">{buildComponentDemoCode('Chessboard', attributes)}</pre>;
125
118
  }
126
119
 
127
120
  set(attributeName, newValue) {
@@ -25,8 +25,9 @@ import React from 'react';
25
25
  import { Chessboard } from '../../src/index';
26
26
  import { buildComponentDemoCode } from './util';
27
27
 
28
- import Box from '@material-ui/core/Box';
29
- import Typography from '@material-ui/core/Typography';
28
+ import Box from '@mui/material/Box';
29
+ import Stack from '@mui/material/Stack';
30
+ import Typography from '@mui/material/Typography';
30
31
 
31
32
  import './demo.css';
32
33
 
@@ -63,17 +64,17 @@ export default class Page extends React.Component {
63
64
 
64
65
  render() {
65
66
  return (
66
- <div>
67
+ <Stack spacing={2} mt={2}>
67
68
  {this.renderControls()}
68
69
  {this.renderChessboard()}
69
70
  {this.renderCode()}
70
- </div>
71
+ </Stack>
71
72
  );
72
73
  }
73
74
 
74
75
  renderControls() {
75
76
  return (
76
- <Box my={2}>
77
+ <Box>
77
78
  <Typography>Resize the browser to see the chessboard adapt its size...</Typography>
78
79
  <Typography>{`Current browser width: ${this.state.windowWidth} px`}</Typography>
79
80
  </Box>
@@ -82,7 +83,7 @@ export default class Page extends React.Component {
82
83
 
83
84
  renderChessboard() {
84
85
  return (
85
- <Box my={2}>
86
+ <Box>
86
87
  <Chessboard squareSize={this.state.squareSize} smallScreenLimits={this.state.limits} />
87
88
  </Box>
88
89
  );
@@ -102,16 +103,14 @@ export default class Page extends React.Component {
102
103
  attributes.push(`squareSize={${this.state.squareSize}}`);
103
104
  attributes.push('smallScreenLimits={limits}');
104
105
  return (
105
- <Box my={2}>
106
- <pre className="kokopu-demoCode">
107
- {
108
- 'let limits = [\n' +
109
- limits.join('') +
110
- '];\n' +
111
- buildComponentDemoCode('Chessboard', attributes)
112
- }
113
- </pre>
114
- </Box>
106
+ <pre className="kokopu-demoCode">
107
+ {
108
+ 'let limits = [\n' +
109
+ limits.join('') +
110
+ '];\n' +
111
+ buildComponentDemoCode('Chessboard', attributes)
112
+ }
113
+ </pre>
115
114
  );
116
115
  }
117
116
 
@@ -0,0 +1,3 @@
1
+ ```js
2
+ <ErrorBox title="Something went wrong" message="This message describes what went wrong." />
3
+ ```
@@ -0,0 +1,50 @@
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 React from 'react';
24
+ import Styled from 'react-styleguidist/lib/client/rsg-components/Styled';
25
+
26
+ import logo from './kokopu-react-logo.png';
27
+
28
+ import './theming.css';
29
+
30
+
31
+ const styles = ({ color, fontFamily, fontSize }) => ({
32
+ logo: {
33
+ color: color.base,
34
+ margin: 0,
35
+ fontFamily: fontFamily.base,
36
+ fontSize: fontSize.h4,
37
+ fontWeight: 'normal',
38
+ },
39
+ });
40
+
41
+ function LogoRenderer({ classes, children }) {
42
+ return (<>
43
+ <div className="kokopu-logo">
44
+ <img src={logo} />
45
+ </div>
46
+ <h1 className={classes.logo}>{children}</h1>
47
+ </>);
48
+ }
49
+
50
+ export default Styled(styles)(LogoRenderer);
@@ -0,0 +1,29 @@
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-logo {
24
+ text-align: center;
25
+ }
26
+
27
+ footer {
28
+ display: none !important;
29
+ }
@@ -27,11 +27,13 @@ import { SquareMarkerIcon, TextMarkerIcon, ArrowMarkerIcon } from '../src/index'
27
27
  testApp([ /* eslint-disable react/jsx-key */
28
28
  <SquareMarkerIcon size={40} />,
29
29
  <SquareMarkerIcon size={45} color="green" />,
30
- <div style={{ color: 'purple' }} ><SquareMarkerIcon size={31} /></div>,
30
+ <div style={{ color: 'purple' }}><SquareMarkerIcon size={31} /></div>,
31
31
  <TextMarkerIcon size={41} symbol="A" />,
32
32
  <TextMarkerIcon size={29} symbol="b" color="#0ff" />,
33
- <div style={{ color: 'red' }} ><TextMarkerIcon size={53} symbol="5" /></div>,
33
+ <div style={{ color: 'red' }}><TextMarkerIcon size={53} symbol="5" /></div>,
34
34
  <ArrowMarkerIcon size={40} />,
35
35
  <ArrowMarkerIcon size={24} color="#888" />,
36
- <div style={{ color: '#f70' }} ><ArrowMarkerIcon size={48} /></div>,
36
+ <div style={{ color: '#f70' }}><ArrowMarkerIcon size={48} /></div>,
37
+ <TextMarkerIcon size={47} symbol="dot" color="#00f" />,
38
+ <div style={{ color: 'pink' }}><TextMarkerIcon size={48} symbol="circle" /></div>,
37
39
  ]); /* eslint-enable react/jsx-key */
@@ -34,7 +34,7 @@ let textMarkers2 = { g3: { symbol: 'H', color: 'r' }, g5: { symbol: 'M', color:
34
34
 
35
35
  let squareMarkers3 = { b5: 'r', e4: 'g', h5: 'y' };
36
36
  let arrowMarkers3 = { d1h5: 'g', a5f4: 'r', c7c3: 'y', g7g7: 'g' };
37
- let textMarkers3 = 'G5c6';
37
+ let textMarkers3 = 'G5c6,R(plus)a1,G(times)b1,R(dot)a2,Y(circle)b2';
38
38
 
39
39
  testApp([ /* eslint-disable react/jsx-key */
40
40
  <Chessboard squareMarkers={squareMarkers1} arrowMarkers={arrowMarkers1} textMarkers={textMarkers1} flipped={false} coordinateVisible={true} />,
@@ -34,4 +34,6 @@ testApp([ /* eslint-disable react/jsx-key */
34
34
  flipped position="rnbqk2r/ppp2ppp/3p1n2/2b1p3/4P3/2NP1N2/PPP2PPP/R1BQKB1R w KQkq - 0 1" move="Bg5" animated={false} />,
35
35
  <Chessboard squareSize={50} coordinateVisible={false} interactionMode="playMoves" onMovePlayed={onMovePlayed}
36
36
  position="rnbq1bnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1" />,
37
+ <Chessboard squareSize={50} coordinateVisible={false} interactionMode="playMoves" onMovePlayed={onMovePlayed}
38
+ position="chess960:1r3k1r/pppppppp/8/8/8/8/PPPPPPPP/1R3K1R w BHbh - 0 1" />,
37
39
  ]); /* eslint-enable react/jsx-key */