react-native-chess-kit 0.5.2 → 0.5.3
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/LICENSE +21 -21
- package/README.md +187 -168
- package/lib/commonjs/board-annotations.js +8 -8
- package/lib/commonjs/board-annotations.js.map +1 -1
- package/lib/commonjs/board-arrows.js.map +1 -1
- package/lib/commonjs/board-background.js +5 -5
- package/lib/commonjs/board-background.js.map +1 -1
- package/lib/commonjs/board-coordinates.js +8 -8
- package/lib/commonjs/board-coordinates.js.map +1 -1
- package/lib/commonjs/board-drag-ghost.js +10 -10
- package/lib/commonjs/board-drag-ghost.js.map +1 -1
- package/lib/commonjs/board-highlights.js +15 -15
- package/lib/commonjs/board-highlights.js.map +1 -1
- package/lib/commonjs/board-legal-dots.js +5 -5
- package/lib/commonjs/board-legal-dots.js.map +1 -1
- package/lib/commonjs/board-piece.js +25 -25
- package/lib/commonjs/board-piece.js.map +1 -1
- package/lib/commonjs/board-pieces.js +6 -6
- package/lib/commonjs/board-pieces.js.map +1 -1
- package/lib/commonjs/board.js +68 -63
- package/lib/commonjs/board.js.map +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pieces/default-pieces.js.map +1 -1
- package/lib/commonjs/pieces/index.js.map +1 -1
- package/lib/commonjs/promotion-picker.js +9 -9
- package/lib/commonjs/promotion-picker.js.map +1 -1
- package/lib/commonjs/static-board.js +7 -7
- package/lib/commonjs/static-board.js.map +1 -1
- package/lib/commonjs/themes.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/use-board-gesture.js +26 -26
- package/lib/commonjs/use-board-gesture.js.map +1 -1
- package/lib/commonjs/use-board-pieces.js +15 -15
- package/lib/commonjs/use-board-pieces.js.map +1 -1
- package/lib/commonjs/use-board-state.js +21 -12
- package/lib/commonjs/use-board-state.js.map +1 -1
- package/lib/commonjs/use-premove.js +12 -12
- package/lib/commonjs/use-premove.js.map +1 -1
- package/lib/module/board-annotations.js +8 -8
- package/lib/module/board-annotations.js.map +1 -1
- package/lib/module/board-arrows.js.map +1 -1
- package/lib/module/board-background.js +5 -5
- package/lib/module/board-background.js.map +1 -1
- package/lib/module/board-coordinates.js +8 -8
- package/lib/module/board-coordinates.js.map +1 -1
- package/lib/module/board-drag-ghost.js +10 -10
- package/lib/module/board-drag-ghost.js.map +1 -1
- package/lib/module/board-highlights.js +15 -15
- package/lib/module/board-highlights.js.map +1 -1
- package/lib/module/board-legal-dots.js +5 -5
- package/lib/module/board-legal-dots.js.map +1 -1
- package/lib/module/board-piece.js +25 -25
- package/lib/module/board-piece.js.map +1 -1
- package/lib/module/board-pieces.js +6 -6
- package/lib/module/board-pieces.js.map +1 -1
- package/lib/module/board.js +68 -63
- package/lib/module/board.js.map +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pieces/default-pieces.js.map +1 -1
- package/lib/module/pieces/index.js.map +1 -1
- package/lib/module/promotion-picker.js +9 -9
- package/lib/module/promotion-picker.js.map +1 -1
- package/lib/module/static-board.js +7 -7
- package/lib/module/static-board.js.map +1 -1
- package/lib/module/themes.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/use-board-gesture.js +26 -26
- package/lib/module/use-board-gesture.js.map +1 -1
- package/lib/module/use-board-pieces.js +15 -15
- package/lib/module/use-board-pieces.js.map +1 -1
- package/lib/module/use-board-state.js +21 -12
- package/lib/module/use-board-state.js.map +1 -1
- package/lib/module/use-premove.js +12 -12
- package/lib/module/use-premove.js.map +1 -1
- package/lib/typescript/board-coordinates.d.ts.map +1 -1
- package/lib/typescript/board.d.ts.map +1 -1
- package/lib/typescript/promotion-picker.d.ts.map +1 -1
- package/lib/typescript/static-board.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +12 -2
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/use-board-gesture.d.ts.map +1 -1
- package/lib/typescript/use-board-state.d.ts.map +1 -1
- package/package.json +23 -3
- package/src/board-annotations.tsx +147 -147
- package/src/board-background.tsx +46 -46
- package/src/board-coordinates.tsx +192 -192
- package/src/board-drag-ghost.tsx +132 -132
- package/src/board-highlights.tsx +226 -226
- package/src/board-legal-dots.tsx +73 -73
- package/src/board-piece.tsx +160 -160
- package/src/board-pieces.tsx +63 -63
- package/src/board.tsx +688 -685
- package/src/constants.ts +103 -103
- package/src/index.ts +101 -101
- package/src/pieces/default-pieces.tsx +383 -383
- package/src/pieces/index.ts +1 -1
- package/src/promotion-picker.tsx +147 -147
- package/src/static-board.tsx +186 -187
- package/src/themes.ts +129 -129
- package/src/types.ts +394 -373
- package/src/use-board-gesture.ts +459 -429
- package/src/use-board-pieces.ts +158 -158
- package/src/use-board-state.ts +120 -111
- package/src/use-premove.ts +59 -59
package/src/static-board.tsx
CHANGED
|
@@ -1,187 +1,186 @@
|
|
|
1
|
-
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
-
import { View, type LayoutChangeEvent } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import type { StaticBoardProps,
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
// ---
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
});
|
|
1
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import { View, type LayoutChangeEvent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { StaticBoardProps, PieceCode } from './types';
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_BOARD_COLORS,
|
|
7
|
+
DEFAULT_LAST_MOVE_COLOR,
|
|
8
|
+
COORDINATE_GUTTER_SCALE,
|
|
9
|
+
} from './constants';
|
|
10
|
+
import { DefaultPieceSet } from './pieces';
|
|
11
|
+
import { useBoardPieces, squareToXY } from './use-board-pieces';
|
|
12
|
+
import { BoardBackground } from './board-background';
|
|
13
|
+
import { BoardCoordinates } from './board-coordinates';
|
|
14
|
+
import { BoardHighlights } from './board-highlights';
|
|
15
|
+
import { BoardArrows } from './board-arrows';
|
|
16
|
+
import { BoardAnnotations } from './board-annotations';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Non-interactive chess board — optimized for lists, thumbnails, and analysis previews.
|
|
20
|
+
*
|
|
21
|
+
* No gesture handler, no drag ghost, no legal move dots.
|
|
22
|
+
* Just: background + coordinates + highlights + pieces + arrows + annotations.
|
|
23
|
+
*
|
|
24
|
+
* Significantly lighter than the full Board component.
|
|
25
|
+
*/
|
|
26
|
+
export const StaticBoard = React.memo(function StaticBoard({
|
|
27
|
+
fen,
|
|
28
|
+
orientation = 'white',
|
|
29
|
+
boardSize: boardSizeProp,
|
|
30
|
+
colors,
|
|
31
|
+
coordinatePosition: coordinatePositionProp,
|
|
32
|
+
withCoordinates,
|
|
33
|
+
renderPiece,
|
|
34
|
+
pieceSet,
|
|
35
|
+
lastMove,
|
|
36
|
+
highlights,
|
|
37
|
+
arrows,
|
|
38
|
+
annotations,
|
|
39
|
+
}: StaticBoardProps) {
|
|
40
|
+
// --- Auto-sizing via onLayout when boardSize not provided ---
|
|
41
|
+
const [measuredSize, setMeasuredSize] = useState(0);
|
|
42
|
+
const handleLayout = useCallback((e: LayoutChangeEvent) => {
|
|
43
|
+
const { width, height } = e.nativeEvent.layout;
|
|
44
|
+
setMeasuredSize(Math.min(width, height));
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
const outerSize = boardSizeProp ?? measuredSize;
|
|
48
|
+
const boardColors = colors ?? DEFAULT_BOARD_COLORS;
|
|
49
|
+
|
|
50
|
+
// Resolve coordinate position: new prop > legacy boolean > 'none'
|
|
51
|
+
const coordinatePosition = coordinatePositionProp ?? (withCoordinates ? 'inside' : 'none');
|
|
52
|
+
const isOutside = coordinatePosition === 'outside';
|
|
53
|
+
const isCoordVisible = coordinatePosition !== 'none';
|
|
54
|
+
|
|
55
|
+
const gutterWidth = isOutside ? Math.round((outerSize / 8) * COORDINATE_GUTTER_SCALE) : 0;
|
|
56
|
+
const boardSize = isOutside ? outerSize - gutterWidth : outerSize;
|
|
57
|
+
const squareSize = boardSize / 8;
|
|
58
|
+
|
|
59
|
+
// --- Piece data from FEN ---
|
|
60
|
+
const pieces = useBoardPieces(fen);
|
|
61
|
+
|
|
62
|
+
// --- Resolve piece renderer: renderPiece > pieceSet > DefaultPieceSet ---
|
|
63
|
+
const resolvedRenderer = useMemo(() => {
|
|
64
|
+
if (renderPiece) return renderPiece;
|
|
65
|
+
const set = pieceSet ?? DefaultPieceSet;
|
|
66
|
+
return (code: string, size: number) => {
|
|
67
|
+
const renderer = set[code as PieceCode];
|
|
68
|
+
if (renderer) return renderer(size);
|
|
69
|
+
// Fallback for unknown piece codes
|
|
70
|
+
return <View style={{ width: size, height: size }} />;
|
|
71
|
+
};
|
|
72
|
+
}, [renderPiece, pieceSet]);
|
|
73
|
+
|
|
74
|
+
// If no size yet (auto-sizing), render invisible container for measurement
|
|
75
|
+
if (outerSize === 0) {
|
|
76
|
+
return <View style={{ flex: 1, aspectRatio: 1 }} onLayout={handleLayout} />;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const boardContent = (
|
|
80
|
+
<View
|
|
81
|
+
style={
|
|
82
|
+
isOutside
|
|
83
|
+
? { width: boardSize, height: boardSize, position: 'absolute', top: 0, right: 0 }
|
|
84
|
+
: { width: boardSize, height: boardSize }
|
|
85
|
+
}
|
|
86
|
+
onLayout={!isOutside && !boardSizeProp ? handleLayout : undefined}
|
|
87
|
+
accessibilityLabel="Chess board"
|
|
88
|
+
accessibilityRole="image"
|
|
89
|
+
>
|
|
90
|
+
{/* Layer 1: Board background */}
|
|
91
|
+
<BoardBackground
|
|
92
|
+
boardSize={boardSize}
|
|
93
|
+
lightColor={boardColors.light}
|
|
94
|
+
darkColor={boardColors.dark}
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
{/* Layer 2: Inside coordinates */}
|
|
98
|
+
{isCoordVisible && !isOutside && (
|
|
99
|
+
<BoardCoordinates
|
|
100
|
+
boardSize={boardSize}
|
|
101
|
+
orientation={orientation}
|
|
102
|
+
lightColor={boardColors.light}
|
|
103
|
+
darkColor={boardColors.dark}
|
|
104
|
+
withLetters
|
|
105
|
+
withNumbers
|
|
106
|
+
position="inside"
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
|
|
110
|
+
{/* Layer 3: Highlights */}
|
|
111
|
+
<BoardHighlights
|
|
112
|
+
boardSize={boardSize}
|
|
113
|
+
orientation={orientation}
|
|
114
|
+
squareSize={squareSize}
|
|
115
|
+
lastMove={lastMove}
|
|
116
|
+
lastMoveColor={DEFAULT_LAST_MOVE_COLOR}
|
|
117
|
+
checkColor="transparent"
|
|
118
|
+
selectedColor="transparent"
|
|
119
|
+
premoveColor="transparent"
|
|
120
|
+
highlights={highlights}
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
{/* Layer 4: Pieces (static — no animation needed) */}
|
|
124
|
+
<View
|
|
125
|
+
style={{ position: 'absolute', width: boardSize, height: boardSize }}
|
|
126
|
+
pointerEvents="none"
|
|
127
|
+
>
|
|
128
|
+
{pieces.map((piece) => {
|
|
129
|
+
const { x, y } = squareToXY(piece.square, squareSize, orientation);
|
|
130
|
+
return (
|
|
131
|
+
<View
|
|
132
|
+
key={piece.id}
|
|
133
|
+
style={{
|
|
134
|
+
position: 'absolute',
|
|
135
|
+
width: squareSize,
|
|
136
|
+
height: squareSize,
|
|
137
|
+
transform: [{ translateX: x }, { translateY: y }],
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{resolvedRenderer(piece.code, squareSize)}
|
|
141
|
+
</View>
|
|
142
|
+
);
|
|
143
|
+
})}
|
|
144
|
+
</View>
|
|
145
|
+
|
|
146
|
+
{/* Layer 5: Arrows */}
|
|
147
|
+
{arrows && arrows.length > 0 && (
|
|
148
|
+
<BoardArrows boardSize={boardSize} orientation={orientation} arrows={arrows} />
|
|
149
|
+
)}
|
|
150
|
+
|
|
151
|
+
{/* Layer 6: Annotations */}
|
|
152
|
+
{annotations && annotations.length > 0 && (
|
|
153
|
+
<BoardAnnotations
|
|
154
|
+
boardSize={boardSize}
|
|
155
|
+
orientation={orientation}
|
|
156
|
+
squareSize={squareSize}
|
|
157
|
+
annotations={annotations}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (isOutside) {
|
|
164
|
+
return (
|
|
165
|
+
<View
|
|
166
|
+
style={{ width: outerSize, height: boardSize + gutterWidth }}
|
|
167
|
+
onLayout={boardSizeProp ? undefined : handleLayout}
|
|
168
|
+
>
|
|
169
|
+
{boardContent}
|
|
170
|
+
|
|
171
|
+
<BoardCoordinates
|
|
172
|
+
boardSize={boardSize}
|
|
173
|
+
orientation={orientation}
|
|
174
|
+
lightColor={boardColors.light}
|
|
175
|
+
darkColor={boardColors.dark}
|
|
176
|
+
withLetters
|
|
177
|
+
withNumbers
|
|
178
|
+
position="outside"
|
|
179
|
+
gutterWidth={gutterWidth}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return boardContent;
|
|
186
|
+
});
|
package/src/themes.ts
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import type { BoardTheme, BoardColors } from './types';
|
|
2
|
-
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Board color presets (matching popular chess platforms)
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
const greenTheme: BoardTheme = {
|
|
8
|
-
name: 'Green',
|
|
9
|
-
board: { light: '#eeeed2', dark: '#769656' },
|
|
10
|
-
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
11
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
12
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
13
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
14
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
15
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
16
|
-
coordinates: { light: '#769656', dark: '#eeeed2' },
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const brownTheme: BoardTheme = {
|
|
20
|
-
name: 'Brown',
|
|
21
|
-
board: { light: '#f0d9b5', dark: '#b58863' },
|
|
22
|
-
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
23
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
24
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
25
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
26
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
27
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
28
|
-
coordinates: { light: '#b58863', dark: '#f0d9b5' },
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const blueTheme: BoardTheme = {
|
|
32
|
-
name: 'Blue',
|
|
33
|
-
board: { light: '#dee3e6', dark: '#8ca2ad' },
|
|
34
|
-
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
35
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
36
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
37
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
38
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
39
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
40
|
-
coordinates: { light: '#8ca2ad', dark: '#dee3e6' },
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const purpleTheme: BoardTheme = {
|
|
44
|
-
name: 'Purple',
|
|
45
|
-
board: { light: '#e8daf0', dark: '#9b72b0' },
|
|
46
|
-
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
47
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
48
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
49
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
50
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
51
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
52
|
-
coordinates: { light: '#9b72b0', dark: '#e8daf0' },
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const grayTheme: BoardTheme = {
|
|
56
|
-
name: 'Gray',
|
|
57
|
-
board: { light: '#e0e0e0', dark: '#888888' },
|
|
58
|
-
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
59
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
60
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
61
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
62
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
63
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
64
|
-
coordinates: { light: '#888888', dark: '#e0e0e0' },
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const woodTheme: BoardTheme = {
|
|
68
|
-
name: 'Wood',
|
|
69
|
-
board: { light: '#e6c88c', dark: '#a67c52' },
|
|
70
|
-
lastMove: 'rgba(255, 255, 0, 0.35)',
|
|
71
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
72
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
73
|
-
legalDot: 'rgba(0, 0, 0, 0.2)',
|
|
74
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
75
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
76
|
-
coordinates: { light: '#a67c52', dark: '#e6c88c' },
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const iceTheme: BoardTheme = {
|
|
80
|
-
name: 'Ice',
|
|
81
|
-
board: { light: '#e8f0f8', dark: '#7ba0c4' },
|
|
82
|
-
lastMove: 'rgba(255, 255, 0, 0.35)',
|
|
83
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
84
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
85
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
86
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
87
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
88
|
-
coordinates: { light: '#7ba0c4', dark: '#e8f0f8' },
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const tournamentTheme: BoardTheme = {
|
|
92
|
-
name: 'Tournament',
|
|
93
|
-
board: { light: '#fffff0', dark: '#3d945e' },
|
|
94
|
-
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
95
|
-
check: 'rgba(235, 97, 80, 0.8)',
|
|
96
|
-
selected: 'rgba(20, 85, 200, 0.5)',
|
|
97
|
-
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
98
|
-
premove: 'rgba(20, 85, 200, 0.3)',
|
|
99
|
-
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
100
|
-
coordinates: { light: '#3d945e', dark: '#fffff0' },
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// ---------------------------------------------------------------------------
|
|
104
|
-
// Exports
|
|
105
|
-
// ---------------------------------------------------------------------------
|
|
106
|
-
|
|
107
|
-
/** All built-in board themes */
|
|
108
|
-
export const BOARD_THEMES = {
|
|
109
|
-
green: greenTheme,
|
|
110
|
-
brown: brownTheme,
|
|
111
|
-
blue: blueTheme,
|
|
112
|
-
purple: purpleTheme,
|
|
113
|
-
gray: grayTheme,
|
|
114
|
-
wood: woodTheme,
|
|
115
|
-
ice: iceTheme,
|
|
116
|
-
tournament: tournamentTheme,
|
|
117
|
-
} as const;
|
|
118
|
-
|
|
119
|
-
/** Shorthand board color presets (just light/dark, no overlay colors) */
|
|
120
|
-
export const BOARD_COLORS: Record<keyof typeof BOARD_THEMES, BoardColors> = {
|
|
121
|
-
green: greenTheme.board,
|
|
122
|
-
brown: brownTheme.board,
|
|
123
|
-
blue: blueTheme.board,
|
|
124
|
-
purple: purpleTheme.board,
|
|
125
|
-
gray: grayTheme.board,
|
|
126
|
-
wood: woodTheme.board,
|
|
127
|
-
ice: iceTheme.board,
|
|
128
|
-
tournament: tournamentTheme.board,
|
|
129
|
-
};
|
|
1
|
+
import type { BoardTheme, BoardColors } from './types';
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Board color presets (matching popular chess platforms)
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
const greenTheme: BoardTheme = {
|
|
8
|
+
name: 'Green',
|
|
9
|
+
board: { light: '#eeeed2', dark: '#769656' },
|
|
10
|
+
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
11
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
12
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
13
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
14
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
15
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
16
|
+
coordinates: { light: '#769656', dark: '#eeeed2' },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const brownTheme: BoardTheme = {
|
|
20
|
+
name: 'Brown',
|
|
21
|
+
board: { light: '#f0d9b5', dark: '#b58863' },
|
|
22
|
+
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
23
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
24
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
25
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
26
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
27
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
28
|
+
coordinates: { light: '#b58863', dark: '#f0d9b5' },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const blueTheme: BoardTheme = {
|
|
32
|
+
name: 'Blue',
|
|
33
|
+
board: { light: '#dee3e6', dark: '#8ca2ad' },
|
|
34
|
+
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
35
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
36
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
37
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
38
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
39
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
40
|
+
coordinates: { light: '#8ca2ad', dark: '#dee3e6' },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const purpleTheme: BoardTheme = {
|
|
44
|
+
name: 'Purple',
|
|
45
|
+
board: { light: '#e8daf0', dark: '#9b72b0' },
|
|
46
|
+
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
47
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
48
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
49
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
50
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
51
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
52
|
+
coordinates: { light: '#9b72b0', dark: '#e8daf0' },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const grayTheme: BoardTheme = {
|
|
56
|
+
name: 'Gray',
|
|
57
|
+
board: { light: '#e0e0e0', dark: '#888888' },
|
|
58
|
+
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
59
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
60
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
61
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
62
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
63
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
64
|
+
coordinates: { light: '#888888', dark: '#e0e0e0' },
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const woodTheme: BoardTheme = {
|
|
68
|
+
name: 'Wood',
|
|
69
|
+
board: { light: '#e6c88c', dark: '#a67c52' },
|
|
70
|
+
lastMove: 'rgba(255, 255, 0, 0.35)',
|
|
71
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
72
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
73
|
+
legalDot: 'rgba(0, 0, 0, 0.2)',
|
|
74
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
75
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
76
|
+
coordinates: { light: '#a67c52', dark: '#e6c88c' },
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const iceTheme: BoardTheme = {
|
|
80
|
+
name: 'Ice',
|
|
81
|
+
board: { light: '#e8f0f8', dark: '#7ba0c4' },
|
|
82
|
+
lastMove: 'rgba(255, 255, 0, 0.35)',
|
|
83
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
84
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
85
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
86
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
87
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
88
|
+
coordinates: { light: '#7ba0c4', dark: '#e8f0f8' },
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const tournamentTheme: BoardTheme = {
|
|
92
|
+
name: 'Tournament',
|
|
93
|
+
board: { light: '#fffff0', dark: '#3d945e' },
|
|
94
|
+
lastMove: 'rgba(255, 255, 0, 0.4)',
|
|
95
|
+
check: 'rgba(235, 97, 80, 0.8)',
|
|
96
|
+
selected: 'rgba(20, 85, 200, 0.5)',
|
|
97
|
+
legalDot: 'rgba(0, 0, 0, 0.25)',
|
|
98
|
+
premove: 'rgba(20, 85, 200, 0.3)',
|
|
99
|
+
arrow: 'rgba(243, 166, 50, 0.85)',
|
|
100
|
+
coordinates: { light: '#3d945e', dark: '#fffff0' },
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Exports
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
/** All built-in board themes */
|
|
108
|
+
export const BOARD_THEMES = {
|
|
109
|
+
green: greenTheme,
|
|
110
|
+
brown: brownTheme,
|
|
111
|
+
blue: blueTheme,
|
|
112
|
+
purple: purpleTheme,
|
|
113
|
+
gray: grayTheme,
|
|
114
|
+
wood: woodTheme,
|
|
115
|
+
ice: iceTheme,
|
|
116
|
+
tournament: tournamentTheme,
|
|
117
|
+
} as const;
|
|
118
|
+
|
|
119
|
+
/** Shorthand board color presets (just light/dark, no overlay colors) */
|
|
120
|
+
export const BOARD_COLORS: Record<keyof typeof BOARD_THEMES, BoardColors> = {
|
|
121
|
+
green: greenTheme.board,
|
|
122
|
+
brown: brownTheme.board,
|
|
123
|
+
blue: blueTheme.board,
|
|
124
|
+
purple: purpleTheme.board,
|
|
125
|
+
gray: grayTheme.board,
|
|
126
|
+
wood: woodTheme.board,
|
|
127
|
+
ice: iceTheme.board,
|
|
128
|
+
tournament: tournamentTheme.board,
|
|
129
|
+
};
|