@scrabble-solver/scrabble-solver 2.11.5 → 2.11.7
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +11 -11
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/.next/cache/next-server.js.nft.json +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/277.js +778 -746
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -5
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/_app.js +9 -2
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/api/solve.js +29 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js +10 -4
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/static/chunks/framework-2c5cac93e8c637b5.js +49 -0
- package/.next/static/chunks/pages/{404-d30fe85d005ce32b.js → 404-ca203fa27afc37d8.js} +1 -1
- package/.next/static/chunks/pages/_app-e89a3c225b87516a.js +28 -0
- package/.next/static/chunks/pages/index-58744f49bf6b891f.js +1 -0
- package/.next/static/css/34adfcf12a7d9bb6.css +1 -0
- package/.next/static/css/edaeaa48321b4cf2.css +2 -0
- package/.next/static/uhB6d-q63uRC6RubwepLq/_buildManifest.js +1 -0
- package/.next/trace +50 -50
- package/package.json +9 -9
- package/src/components/Board/Board.module.scss +2 -59
- package/src/components/Board/Board.tsx +22 -10
- package/src/components/Board/BoardPure.tsx +13 -8
- package/src/components/Board/components/Cell/Cell.module.scss +8 -144
- package/src/components/Board/components/Cell/Cell.tsx +18 -37
- package/src/components/Board/hooks/index.ts +1 -0
- package/src/components/Board/hooks/useBackgroundImage.tsx +170 -0
- package/src/components/Board/lib/getBonusColor.ts +18 -0
- package/src/components/Board/lib/index.ts +1 -0
- package/src/components/Dictionary/Dictionary.module.scss +0 -1
- package/src/components/DictionaryInput/DictionaryInput.tsx +5 -3
- package/src/components/EmptyState/EmptyState.module.scss +0 -1
- package/src/components/Key/Key.module.scss +1 -1
- package/src/components/PlainTiles/PlainTiles.tsx +0 -10
- package/src/components/PlainTiles/Tile.tsx +1 -4
- package/src/components/Results/Cell.tsx +2 -2
- package/src/components/Results/Result.tsx +4 -8
- package/src/components/Results/Results.module.scss +5 -4
- package/src/components/Solver/Solver.tsx +2 -2
- package/src/components/Tooltip/Tooltip.module.scss +2 -0
- package/src/components/index.ts +0 -2
- package/src/hooks/useAppLayout.ts +1 -0
- package/src/hooks/useDirection.ts +2 -2
- package/src/hooks/useLanguage.ts +2 -2
- package/src/i18n/constants.ts +25 -16
- package/src/i18n/de.json +2 -2
- package/src/i18n/en.json +2 -2
- package/src/i18n/es.json +2 -2
- package/src/i18n/fa.json +2 -2
- package/src/i18n/fr.json +2 -2
- package/src/i18n/pl.json +2 -2
- package/src/lib/dataUrlToBlob.ts +20 -0
- package/src/lib/index.ts +1 -0
- package/src/modals/KeyMapModal/components/Mapping/Mapping.module.scss +0 -1
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.module.scss +0 -1
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.module.scss +0 -5
- package/src/pages/_app.tsx +1 -3
- package/src/pages/index.tsx +1 -3
- package/src/parameters/index.ts +33 -2
- package/src/state/index.ts +1 -1
- package/src/state/sagas.ts +3 -4
- package/src/state/store.ts +34 -0
- package/src/styles/global.scss +4 -8
- package/src/styles/mixins.scss +0 -1
- package/src/styles/variables.scss +5 -5
- package/.next/static/UzQCOB6CHhyOupkEq8oZM/_buildManifest.js +0 -1
- package/.next/static/chunks/framework-2c79e2a64abdb08b.js +0 -33
- package/.next/static/chunks/pages/_app-e27464a187a58684.js +0 -28
- package/.next/static/chunks/pages/index-3fd280f406cc00fd.js +0 -1
- package/.next/static/css/4bd04cebe207859c.css +0 -1
- package/.next/static/css/5b3b78170f4c5875.css +0 -2
- package/src/components/Board/components/Cell/CellPure.tsx +0 -93
- package/src/components/Board/components/Cell/lib.ts +0 -59
- package/src/components/SvgFontCss/SvgFontCss.tsx +0 -14
- package/src/components/SvgFontCss/createCss.ts +0 -11
- package/src/components/SvgFontCss/createStyle.ts +0 -9
- package/src/components/SvgFontCss/createSvg.ts +0 -10
- package/src/components/SvgFontCss/index.ts +0 -1
- package/src/components/SvgFontFix/SvgFontFix.module.scss +0 -5
- package/src/components/SvgFontFix/SvgFontFix.tsx +0 -21
- package/src/components/SvgFontFix/index.ts +0 -1
- package/src/state/createAppStore.ts +0 -38
- /package/.next/static/{UzQCOB6CHhyOupkEq8oZM → uhB6d-q63uRC6RubwepLq}/_ssgManifest.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/scrabble-solver",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.7",
|
|
4
4
|
"description": "Scrabble Solver 2 - App",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@floating-ui/react": "^0.21.1",
|
|
32
32
|
"@kamilmielnik/trie": "^2.0.1",
|
|
33
33
|
"@reduxjs/toolkit": "^1.9.3",
|
|
34
|
-
"@scrabble-solver/configs": "^2.11.
|
|
35
|
-
"@scrabble-solver/constants": "^2.11.
|
|
36
|
-
"@scrabble-solver/dictionaries": "^2.11.
|
|
37
|
-
"@scrabble-solver/logger": "^2.11.
|
|
38
|
-
"@scrabble-solver/solver": "^2.11.
|
|
39
|
-
"@scrabble-solver/types": "^2.11.
|
|
40
|
-
"@scrabble-solver/word-definitions": "^2.11.
|
|
34
|
+
"@scrabble-solver/configs": "^2.11.7",
|
|
35
|
+
"@scrabble-solver/constants": "^2.11.7",
|
|
36
|
+
"@scrabble-solver/dictionaries": "^2.11.7",
|
|
37
|
+
"@scrabble-solver/logger": "^2.11.7",
|
|
38
|
+
"@scrabble-solver/solver": "^2.11.7",
|
|
39
|
+
"@scrabble-solver/types": "^2.11.7",
|
|
40
|
+
"@scrabble-solver/word-definitions": "^2.11.7",
|
|
41
41
|
"classnames": "^2.3.2",
|
|
42
42
|
"include-media": "^2.0.0",
|
|
43
43
|
"include-media-query-builder": "^1.1.0",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"sass": "^1.59.3",
|
|
72
72
|
"workbox-webpack-plugin": "^6.5.4"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "2d485c8578e634628fa627d0c140ff9656a7375b"
|
|
75
75
|
}
|
|
@@ -1,70 +1,13 @@
|
|
|
1
1
|
@import 'styles/animations';
|
|
2
2
|
|
|
3
3
|
.board {
|
|
4
|
-
display:
|
|
4
|
+
display: grid;
|
|
5
|
+
gap: var(--border--width);
|
|
5
6
|
box-shadow: var(--box-shadow);
|
|
6
7
|
border: var(--border);
|
|
7
8
|
border-radius: var(--border--radius);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
.row {
|
|
11
|
-
display: table-row;
|
|
12
|
-
|
|
13
|
-
&:first-child {
|
|
14
|
-
border-top-left-radius: var(--border--radius);
|
|
15
|
-
border-top-right-radius: var(--border--radius);
|
|
16
|
-
|
|
17
|
-
.cell {
|
|
18
|
-
&:first-child {
|
|
19
|
-
[dir='ltr'] & {
|
|
20
|
-
border-top-left-radius: var(--border--radius);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
[dir='rtl'] & {
|
|
24
|
-
border-top-right-radius: var(--border--radius);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&:last-child {
|
|
29
|
-
[dir='ltr'] & {
|
|
30
|
-
border-top-right-radius: var(--border--radius);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
[dir='rtl'] & {
|
|
34
|
-
border-top-left-radius: var(--border--radius);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:last-child {
|
|
41
|
-
border-bottom-left-radius: var(--border--radius);
|
|
42
|
-
border-bottom-right-radius: var(--border--radius);
|
|
43
|
-
|
|
44
|
-
.cell {
|
|
45
|
-
&:first-child {
|
|
46
|
-
[dir='ltr'] & {
|
|
47
|
-
border-bottom-left-radius: var(--border--radius);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[dir='rtl'] & {
|
|
51
|
-
border-bottom-right-radius: var(--border--radius);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&:last-child {
|
|
56
|
-
[dir='ltr'] & {
|
|
57
|
-
border-bottom-right-radius: var(--border--radius);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[dir='rtl'] & {
|
|
61
|
-
border-bottom-left-radius: var(--border--radius);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
11
|
.actions {
|
|
69
12
|
position: absolute;
|
|
70
13
|
z-index: var(--z-index--actions);
|
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
import { autoUpdate, FloatingPortal, offset, shift, useFloating } from '@floating-ui/react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { CSSProperties, FocusEventHandler, FunctionComponent, useCallback, useState } from 'react';
|
|
3
|
+
import { CSSProperties, FocusEventHandler, FunctionComponent, useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import { useDispatch } from 'react-redux';
|
|
5
5
|
|
|
6
6
|
import { useAppLayout } from 'hooks';
|
|
7
|
+
import { getTileSizes } from 'lib';
|
|
7
8
|
import { BOARD_CELL_ACTIONS_OFFSET, TRANSITION } from 'parameters';
|
|
8
|
-
import { boardSlice, cellFilterSlice,
|
|
9
|
+
import { boardSlice, cellFilterSlice, selectConfig, selectRowsWithCandidate, useTypedSelector } from 'state';
|
|
9
10
|
|
|
10
11
|
import styles from './Board.module.scss';
|
|
11
12
|
import BoardPure from './BoardPure';
|
|
12
13
|
import { Actions } from './components';
|
|
13
|
-
import { useGrid } from './hooks';
|
|
14
|
+
import { useBackgroundImage, useGrid } from './hooks';
|
|
14
15
|
|
|
15
16
|
interface Props {
|
|
16
|
-
cellSize: number;
|
|
17
17
|
className?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const Board: FunctionComponent<Props> = ({
|
|
20
|
+
const Board: FunctionComponent<Props> = ({ className }) => {
|
|
21
21
|
const dispatch = useDispatch();
|
|
22
22
|
const rows = useTypedSelector(selectRowsWithCandidate);
|
|
23
|
-
const
|
|
24
|
-
const { actionsWidth } = useAppLayout();
|
|
23
|
+
const config = useTypedSelector(selectConfig);
|
|
24
|
+
const { actionsWidth, cellSize } = useAppLayout();
|
|
25
|
+
const { tileFontSize } = getTileSizes(cellSize);
|
|
26
|
+
|
|
25
27
|
const [{ activeIndex, direction, inputRefs }, { onChange, onDirectionToggle, onFocus, onKeyDown, onPaste }] =
|
|
26
28
|
useGrid(rows);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
+
const backgroundImage = useBackgroundImage();
|
|
30
|
+
const boardStyle = useMemo<CSSProperties>(
|
|
31
|
+
() => ({
|
|
32
|
+
backgroundImage,
|
|
33
|
+
fontSize: tileFontSize,
|
|
34
|
+
gridTemplateColumns: `repeat(${config.boardWidth}, 1fr)`,
|
|
35
|
+
gridTemplateRows: `repeat(${config.boardHeight}, 1fr)`,
|
|
36
|
+
}),
|
|
37
|
+
[backgroundImage, config.boardHeight, config.boardWidth, tileFontSize],
|
|
38
|
+
);
|
|
29
39
|
const [showActions, setShowActions] = useState(false);
|
|
30
40
|
const [transition, setTransition] = useState<CSSProperties['transition']>(TRANSITION);
|
|
41
|
+
const inputRef = inputRefs[activeIndex.y][activeIndex.x];
|
|
42
|
+
const cell = rows[activeIndex.y][activeIndex.x];
|
|
31
43
|
|
|
32
44
|
const { x, y, strategy, refs } = useFloating({
|
|
33
45
|
middleware: [
|
|
@@ -98,9 +110,9 @@ const Board: FunctionComponent<Props> = ({ cellSize, className }) => {
|
|
|
98
110
|
<BoardPure
|
|
99
111
|
className={className}
|
|
100
112
|
cellSize={cellSize}
|
|
101
|
-
center={board.center}
|
|
102
113
|
inputRefs={inputRefs}
|
|
103
114
|
rows={rows}
|
|
115
|
+
style={boardStyle}
|
|
104
116
|
onBlur={handleBlur}
|
|
105
117
|
onChange={onChange}
|
|
106
118
|
onFocus={handleFocus}
|
|
@@ -3,7 +3,9 @@ import classNames from 'classnames';
|
|
|
3
3
|
import {
|
|
4
4
|
ChangeEventHandler,
|
|
5
5
|
ClipboardEventHandler,
|
|
6
|
+
CSSProperties,
|
|
6
7
|
FocusEventHandler,
|
|
8
|
+
Fragment,
|
|
7
9
|
FunctionComponent,
|
|
8
10
|
KeyboardEventHandler,
|
|
9
11
|
memo,
|
|
@@ -16,9 +18,9 @@ import { Cell } from './components';
|
|
|
16
18
|
interface Props {
|
|
17
19
|
className?: string;
|
|
18
20
|
cellSize: number;
|
|
19
|
-
center: CellModel;
|
|
20
21
|
inputRefs: RefObject<HTMLInputElement>[][];
|
|
21
22
|
rows: CellModel[][];
|
|
23
|
+
style?: CSSProperties;
|
|
22
24
|
onBlur: FocusEventHandler;
|
|
23
25
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
24
26
|
onFocus: (x: number, y: number) => void;
|
|
@@ -29,18 +31,24 @@ interface Props {
|
|
|
29
31
|
const BoardPure: FunctionComponent<Props> = ({
|
|
30
32
|
className,
|
|
31
33
|
cellSize,
|
|
32
|
-
center,
|
|
33
34
|
inputRefs,
|
|
34
35
|
rows,
|
|
36
|
+
style,
|
|
35
37
|
onBlur,
|
|
36
38
|
onChange,
|
|
37
39
|
onFocus,
|
|
38
40
|
onKeyDown,
|
|
39
41
|
onPaste,
|
|
40
42
|
}) => (
|
|
41
|
-
<div
|
|
43
|
+
<div
|
|
44
|
+
className={classNames(styles.board, className)}
|
|
45
|
+
style={style}
|
|
46
|
+
onBlur={onBlur}
|
|
47
|
+
onKeyDown={onKeyDown}
|
|
48
|
+
onPaste={onPaste}
|
|
49
|
+
>
|
|
42
50
|
{rows.map((cells, y) => (
|
|
43
|
-
<
|
|
51
|
+
<Fragment key={y}>
|
|
44
52
|
{cells.map((cell, x) => (
|
|
45
53
|
<Cell
|
|
46
54
|
className={styles.cell}
|
|
@@ -50,16 +58,13 @@ const BoardPure: FunctionComponent<Props> = ({
|
|
|
50
58
|
cellRight={x < rows.length - 1 ? rows[y][x + 1] : undefined}
|
|
51
59
|
cellTop={y > 0 ? rows[y - 1][x] : undefined}
|
|
52
60
|
inputRef={inputRefs[y][x]}
|
|
53
|
-
isBottom={y === rows.length - 1}
|
|
54
|
-
isCenter={center.x === x && center.y === y}
|
|
55
|
-
isRight={x === cells.length - 1}
|
|
56
61
|
key={x}
|
|
57
62
|
size={cellSize}
|
|
58
63
|
onChange={onChange}
|
|
59
64
|
onFocus={onFocus}
|
|
60
65
|
/>
|
|
61
66
|
))}
|
|
62
|
-
</
|
|
67
|
+
</Fragment>
|
|
63
68
|
))}
|
|
64
69
|
</div>
|
|
65
70
|
);
|
|
@@ -59,139 +59,11 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
.
|
|
62
|
+
.tile {
|
|
63
63
|
@include focus-effect;
|
|
64
64
|
@include lighthouse-input-size-hack;
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
display: table-cell;
|
|
68
|
-
vertical-align: middle;
|
|
69
|
-
background-color: var(--color--white);
|
|
70
|
-
border-bottom: var(--border--width) dotted var(--border--color--light);
|
|
71
|
-
background-clip: padding-box;
|
|
72
|
-
|
|
73
|
-
[dir='ltr'] & {
|
|
74
|
-
border-right: var(--border--width) dotted var(--border--color--light);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
[dir='rtl'] & {
|
|
78
|
-
border-left: var(--border--width) dotted var(--border--color--light);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&.bottom {
|
|
82
|
-
border-bottom: none;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&.right {
|
|
86
|
-
[dir='ltr'] & {
|
|
87
|
-
border-right: none;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
[dir='rtl'] & {
|
|
91
|
-
border-left: none;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
&.bonusStart {
|
|
96
|
-
&::before {
|
|
97
|
-
content: '';
|
|
98
|
-
background-color: var(--color--bonus--start);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&.bonusCharacter1 {
|
|
103
|
-
&::before {
|
|
104
|
-
content: '';
|
|
105
|
-
background-color: var(--color--bonus--character--1);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&.bonusCharacter2 {
|
|
110
|
-
&::before {
|
|
111
|
-
content: '';
|
|
112
|
-
background-color: var(--color--bonus--character--2);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
&.bonusCharacter3 {
|
|
117
|
-
&::before {
|
|
118
|
-
content: '';
|
|
119
|
-
background-color: var(--color--bonus--character--3);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
&.bonusCharacter5 {
|
|
124
|
-
&::before {
|
|
125
|
-
content: '';
|
|
126
|
-
background-color: var(--color--bonus--character--5);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
&.bonusCharacterMultiplier2 {
|
|
131
|
-
&::before {
|
|
132
|
-
content: '';
|
|
133
|
-
background-color: var(--color--bonus--character-multiplier--2);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
&.bonusCharacterMultiplier3 {
|
|
138
|
-
&::before {
|
|
139
|
-
content: '';
|
|
140
|
-
background-color: var(--color--bonus--character-multiplier--3);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
&.bonusWord2 {
|
|
145
|
-
&::before {
|
|
146
|
-
content: 'x2';
|
|
147
|
-
background-color: var(--color--bonus--word-multiplier--2);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
&.bonusWord3 {
|
|
152
|
-
&::before {
|
|
153
|
-
content: 'x3';
|
|
154
|
-
background-color: var(--color--bonus--word-multiplier--3);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&.filtered {
|
|
159
|
-
&::before {
|
|
160
|
-
content: '';
|
|
161
|
-
background-color: var(--color--foreground--secondary);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
&::before {
|
|
166
|
-
$size: 80%;
|
|
167
|
-
|
|
168
|
-
display: flex;
|
|
169
|
-
justify-content: center;
|
|
170
|
-
align-items: center;
|
|
171
|
-
position: absolute;
|
|
172
|
-
top: (100% - $size) / 2;
|
|
173
|
-
left: (100% - $size) / 2;
|
|
174
|
-
width: $size;
|
|
175
|
-
height: $size;
|
|
176
|
-
border-radius: var(--border--radius);
|
|
177
|
-
pointer-events: none;
|
|
178
|
-
font-size: 60%;
|
|
179
|
-
font-weight: bold;
|
|
180
|
-
color: var(--color--white);
|
|
181
|
-
transition: var(--transition);
|
|
182
|
-
|
|
183
|
-
[lang='fa-IR'] & {
|
|
184
|
-
font-family: var(--font--family--latin);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
&:focus-within {
|
|
189
|
-
z-index: 2;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.tile {
|
|
194
|
-
.sharpTopLeft & {
|
|
66
|
+
&.sharpTopLeft {
|
|
195
67
|
[dir='ltr'] & {
|
|
196
68
|
border-top-left-radius: 0;
|
|
197
69
|
}
|
|
@@ -201,7 +73,7 @@
|
|
|
201
73
|
}
|
|
202
74
|
}
|
|
203
75
|
|
|
204
|
-
|
|
76
|
+
&.sharpTopRight {
|
|
205
77
|
[dir='ltr'] & {
|
|
206
78
|
border-top-right-radius: 0;
|
|
207
79
|
}
|
|
@@ -211,7 +83,7 @@
|
|
|
211
83
|
}
|
|
212
84
|
}
|
|
213
85
|
|
|
214
|
-
|
|
86
|
+
&.sharpBottomLeft {
|
|
215
87
|
[dir='ltr'] & {
|
|
216
88
|
border-bottom-left-radius: 0;
|
|
217
89
|
}
|
|
@@ -221,7 +93,7 @@
|
|
|
221
93
|
}
|
|
222
94
|
}
|
|
223
95
|
|
|
224
|
-
|
|
96
|
+
&.sharpBottomRight {
|
|
225
97
|
[dir='ltr'] & {
|
|
226
98
|
border-bottom-right-radius: 0;
|
|
227
99
|
}
|
|
@@ -230,16 +102,8 @@
|
|
|
230
102
|
border-bottom-left-radius: 0;
|
|
231
103
|
}
|
|
232
104
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.icon {
|
|
236
|
-
$size: 40%;
|
|
237
105
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
width: $size;
|
|
242
|
-
height: $size;
|
|
243
|
-
transform: translate(-50%, -50%);
|
|
244
|
-
color: var(--color--white);
|
|
106
|
+
&:focus-within {
|
|
107
|
+
z-index: 2;
|
|
108
|
+
}
|
|
245
109
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { EMPTY_CELL } from '@scrabble-solver/constants';
|
|
2
2
|
import { Cell as CellModel } from '@scrabble-solver/types';
|
|
3
|
-
import
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { ChangeEventHandler, FunctionComponent, RefObject, useCallback } from 'react';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
selectCellBonus,
|
|
8
|
-
selectCellIsFiltered,
|
|
9
|
-
selectCellIsValid,
|
|
10
|
-
selectLocale,
|
|
11
|
-
selectTilePoints,
|
|
12
|
-
useTranslate,
|
|
13
|
-
useTypedSelector,
|
|
14
|
-
} from 'state';
|
|
6
|
+
import { selectCellIsValid, selectLocale, selectTilePoints, useTranslate, useTypedSelector } from 'state';
|
|
15
7
|
|
|
16
|
-
import
|
|
8
|
+
import Tile from '../../../Tile';
|
|
9
|
+
|
|
10
|
+
import styles from './Cell.module.scss';
|
|
17
11
|
|
|
18
12
|
interface Props {
|
|
19
13
|
cell: CellModel;
|
|
@@ -23,9 +17,6 @@ interface Props {
|
|
|
23
17
|
cellTop?: CellModel;
|
|
24
18
|
className?: string;
|
|
25
19
|
inputRef: RefObject<HTMLInputElement>;
|
|
26
|
-
isBottom: boolean;
|
|
27
|
-
isCenter: boolean;
|
|
28
|
-
isRight: boolean;
|
|
29
20
|
size: number;
|
|
30
21
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
31
22
|
onFocus: (x: number, y: number) => void;
|
|
@@ -39,9 +30,6 @@ const Cell: FunctionComponent<Props> = ({
|
|
|
39
30
|
cellTop,
|
|
40
31
|
className,
|
|
41
32
|
inputRef,
|
|
42
|
-
isBottom,
|
|
43
|
-
isCenter,
|
|
44
|
-
isRight,
|
|
45
33
|
size,
|
|
46
34
|
onChange,
|
|
47
35
|
onFocus,
|
|
@@ -49,40 +37,33 @@ const Cell: FunctionComponent<Props> = ({
|
|
|
49
37
|
const { tile, x, y } = cell;
|
|
50
38
|
const translate = useTranslate();
|
|
51
39
|
const locale = useTypedSelector(selectLocale);
|
|
52
|
-
const bonus = useTypedSelector((state) => selectCellBonus(state, cell));
|
|
53
40
|
const points = useTypedSelector((state) => selectTilePoints(state, cell.tile));
|
|
54
|
-
const isFiltered = useTypedSelector((state) => selectCellIsFiltered(state, cell));
|
|
55
41
|
const isValid = useTypedSelector((state) => selectCellIsValid(state, cell));
|
|
56
|
-
const { tileFontSize } = getTileSizes(size);
|
|
57
42
|
const isEmpty = tile.character === EMPTY_CELL;
|
|
58
|
-
const style = useMemo(() => ({ fontSize: tileFontSize }), [tileFontSize]);
|
|
59
43
|
|
|
60
44
|
const handleFocus = useCallback(() => onFocus(x, y), [x, y, onFocus]);
|
|
61
45
|
|
|
62
46
|
return (
|
|
63
|
-
<
|
|
47
|
+
<Tile
|
|
64
48
|
aria-label={translate('cell.tile.location', {
|
|
65
49
|
x: (x + 1).toLocaleString(locale),
|
|
66
50
|
y: (y + 1).toLocaleString(locale),
|
|
67
51
|
})}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
className={classNames(styles.tile, className, {
|
|
53
|
+
[styles.sharpTopLeft]: cellTop?.hasTile() || cellLeft?.hasTile(),
|
|
54
|
+
[styles.sharpTopRight]: cellTop?.hasTile() || cellRight?.hasTile(),
|
|
55
|
+
[styles.sharpBottomLeft]: cellBottom?.hasTile() || cellLeft?.hasTile(),
|
|
56
|
+
[styles.sharpBottomRight]: cellBottom?.hasTile() || cellRight?.hasTile(),
|
|
57
|
+
})}
|
|
58
|
+
character={isEmpty ? undefined : tile.character}
|
|
59
|
+
highlighted={cell.isCandidate()}
|
|
75
60
|
inputRef={inputRef}
|
|
76
|
-
|
|
77
|
-
isCenter={isCenter}
|
|
78
|
-
isRight={isRight}
|
|
79
|
-
isEmpty={isEmpty}
|
|
80
|
-
isFiltered={isFiltered}
|
|
61
|
+
isBlank={tile.isBlank}
|
|
81
62
|
isValid={isValid}
|
|
82
63
|
points={points}
|
|
64
|
+
raised={!isEmpty}
|
|
83
65
|
size={size}
|
|
84
|
-
|
|
85
|
-
tile={tile}
|
|
66
|
+
tabIndex={cell.x === 0 && cell.y === 0 ? undefined : -1}
|
|
86
67
|
onChange={onChange}
|
|
87
68
|
onFocus={handleFocus}
|
|
88
69
|
/>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* eslint-disable max-statements */
|
|
2
|
+
|
|
3
|
+
import { BONUS_CHARACTER, BONUS_WORD } from '@scrabble-solver/constants';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { renderToString } from 'react-dom/server';
|
|
6
|
+
import { Provider } from 'react-redux';
|
|
7
|
+
|
|
8
|
+
import { useAppLayout } from 'hooks';
|
|
9
|
+
import { FlagFill, Star } from 'icons';
|
|
10
|
+
import { dataUrlToBlob, getTileSizes } from 'lib';
|
|
11
|
+
import { BORDER_COLOR_LIGHT, BORDER_RADIUS, BORDER_WIDTH, COLOR_BONUS_START, COLOR_FILTERED } from 'parameters';
|
|
12
|
+
import { selectCellFilter, selectConfig, store, useTypedSelector } from 'state';
|
|
13
|
+
import { Point } from 'types';
|
|
14
|
+
|
|
15
|
+
import { getBonusColor } from '../lib';
|
|
16
|
+
|
|
17
|
+
const HORIZONTAL_LINE = 'h';
|
|
18
|
+
const VERTICAL_LINE = 'v';
|
|
19
|
+
const BONUS = 'b';
|
|
20
|
+
const BONUS_WORD_2 = 'b2';
|
|
21
|
+
const BONUS_WORD_3 = 'b3';
|
|
22
|
+
const CELL_FILTER = 'c';
|
|
23
|
+
|
|
24
|
+
const useBackgroundImage = () => {
|
|
25
|
+
const { boardSize, cellSize } = useAppLayout();
|
|
26
|
+
const config = useTypedSelector(selectConfig);
|
|
27
|
+
const center = { x: Math.floor(config.boardWidth / 2), y: Math.floor(config.boardHeight / 2) };
|
|
28
|
+
const cellFilter = useTypedSelector(selectCellFilter);
|
|
29
|
+
const viewBoxHeight = boardSize;
|
|
30
|
+
const viewBoxWidth = boardSize;
|
|
31
|
+
const bonusSize = cellSize * 0.8;
|
|
32
|
+
const bonusOffset = cellSize * 0.1;
|
|
33
|
+
const iconSize = cellSize * 0.4;
|
|
34
|
+
const iconOffset = (cellSize - iconSize) / 2;
|
|
35
|
+
const { tileFontSize } = getTileSizes(cellSize);
|
|
36
|
+
const fontSize = tileFontSize * 0.6;
|
|
37
|
+
const fontOffset = cellSize / 2;
|
|
38
|
+
const characterBonuses = config.bonuses.filter((bonus) => bonus.type === BONUS_CHARACTER);
|
|
39
|
+
const word2Bonuses = config.bonuses.filter((bonus) => bonus.type === BONUS_WORD && bonus.multiplier === 2);
|
|
40
|
+
const word3Bonuses = config.bonuses.filter((bonus) => bonus.type === BONUS_WORD && bonus.multiplier === 3);
|
|
41
|
+
|
|
42
|
+
const getX = (point: Point): number => point.x * (cellSize + BORDER_WIDTH);
|
|
43
|
+
|
|
44
|
+
const getY = (point: Point): number => point.y * (cellSize + BORDER_WIDTH);
|
|
45
|
+
|
|
46
|
+
const backgroundSvg = renderToString(
|
|
47
|
+
<Provider store={store}>
|
|
48
|
+
<svg
|
|
49
|
+
height={viewBoxHeight}
|
|
50
|
+
viewBox={`0 0 ${viewBoxWidth} ${viewBoxHeight}`}
|
|
51
|
+
width={viewBoxWidth}
|
|
52
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
+
>
|
|
54
|
+
<defs>
|
|
55
|
+
<symbol id={HORIZONTAL_LINE}>
|
|
56
|
+
<rect fill={BORDER_COLOR_LIGHT} height={1} width={viewBoxWidth} />
|
|
57
|
+
</symbol>
|
|
58
|
+
|
|
59
|
+
<symbol id={VERTICAL_LINE}>
|
|
60
|
+
<rect fill={BORDER_COLOR_LIGHT} height={viewBoxHeight} width={1} />
|
|
61
|
+
</symbol>
|
|
62
|
+
|
|
63
|
+
<symbol id={BONUS}>
|
|
64
|
+
<rect height={bonusSize} rx={BORDER_RADIUS} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
65
|
+
</symbol>
|
|
66
|
+
|
|
67
|
+
<symbol id={BONUS_WORD_2}>
|
|
68
|
+
<rect height={bonusSize} rx={BORDER_RADIUS} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
69
|
+
|
|
70
|
+
<text
|
|
71
|
+
dominantBaseline="central"
|
|
72
|
+
fill="white"
|
|
73
|
+
fontFamily="system-ui, sans-serif"
|
|
74
|
+
fontSize={fontSize}
|
|
75
|
+
fontWeight="bold"
|
|
76
|
+
textAnchor="middle"
|
|
77
|
+
x={fontOffset}
|
|
78
|
+
y={fontOffset}
|
|
79
|
+
>
|
|
80
|
+
x2
|
|
81
|
+
</text>
|
|
82
|
+
</symbol>
|
|
83
|
+
|
|
84
|
+
<symbol id={BONUS_WORD_3}>
|
|
85
|
+
<rect height={bonusSize} rx={BORDER_RADIUS} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
86
|
+
|
|
87
|
+
<text
|
|
88
|
+
dominantBaseline="central"
|
|
89
|
+
fill="white"
|
|
90
|
+
fontFamily="system-ui, sans-serif"
|
|
91
|
+
fontSize={fontSize}
|
|
92
|
+
fontWeight="bold"
|
|
93
|
+
textAnchor="middle"
|
|
94
|
+
x={fontOffset}
|
|
95
|
+
y={fontOffset}
|
|
96
|
+
>
|
|
97
|
+
x3
|
|
98
|
+
</text>
|
|
99
|
+
</symbol>
|
|
100
|
+
|
|
101
|
+
<symbol id={CELL_FILTER}>
|
|
102
|
+
<rect
|
|
103
|
+
fill={COLOR_FILTERED}
|
|
104
|
+
height={bonusSize}
|
|
105
|
+
rx={BORDER_RADIUS}
|
|
106
|
+
width={bonusSize}
|
|
107
|
+
x={bonusOffset}
|
|
108
|
+
y={bonusOffset}
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
<FlagFill color="white" height={iconSize} width={iconSize} x={iconOffset} y={iconOffset} />
|
|
112
|
+
</symbol>
|
|
113
|
+
</defs>
|
|
114
|
+
|
|
115
|
+
<rect fill="white" height={viewBoxHeight} rx={BORDER_RADIUS} width={viewBoxWidth} x="0" y="0" />
|
|
116
|
+
|
|
117
|
+
{Array.from({ length: config.boardHeight - 1 }).map((_value, index) => (
|
|
118
|
+
<use key={index} href={`#${HORIZONTAL_LINE}`} y={(index + 1) * (cellSize + BORDER_WIDTH) - BORDER_WIDTH} />
|
|
119
|
+
))}
|
|
120
|
+
|
|
121
|
+
{Array.from({ length: config.boardWidth - 1 }).map((_value, index) => (
|
|
122
|
+
<use key={index} href={`#${VERTICAL_LINE}`} x={(index + 1) * (cellSize + BORDER_WIDTH) - BORDER_WIDTH} />
|
|
123
|
+
))}
|
|
124
|
+
|
|
125
|
+
{characterBonuses.map((bonus, index) => (
|
|
126
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS}`} x={getX(bonus)} y={getY(bonus)} />
|
|
127
|
+
))}
|
|
128
|
+
|
|
129
|
+
{word2Bonuses.map((bonus, index) => (
|
|
130
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_2}`} x={getX(bonus)} y={getY(bonus)} />
|
|
131
|
+
))}
|
|
132
|
+
|
|
133
|
+
{word3Bonuses.map((bonus, index) => (
|
|
134
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_3}`} x={getX(bonus)} y={getY(bonus)} />
|
|
135
|
+
))}
|
|
136
|
+
|
|
137
|
+
<rect
|
|
138
|
+
fill={COLOR_BONUS_START}
|
|
139
|
+
height={bonusSize}
|
|
140
|
+
rx={BORDER_RADIUS}
|
|
141
|
+
width={bonusSize}
|
|
142
|
+
x={getX(center) + bonusOffset}
|
|
143
|
+
y={getY(center) + bonusOffset}
|
|
144
|
+
/>
|
|
145
|
+
|
|
146
|
+
<Star
|
|
147
|
+
color="white"
|
|
148
|
+
height={iconSize}
|
|
149
|
+
width={iconSize}
|
|
150
|
+
x={getX(center) + iconOffset}
|
|
151
|
+
y={getY(center) + iconOffset}
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
{cellFilter.map((cell, index) => (
|
|
155
|
+
<use key={index} href={`#${CELL_FILTER}`} x={getX(cell)} y={getY(cell)} />
|
|
156
|
+
))}
|
|
157
|
+
</svg>
|
|
158
|
+
</Provider>,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const encodedSvg = globalThis.btoa(backgroundSvg);
|
|
162
|
+
const dataUrl = `data:image/svg+xml;base64,${encodedSvg}`;
|
|
163
|
+
const blob = useMemo(() => dataUrlToBlob(dataUrl), [dataUrl]);
|
|
164
|
+
const blobUrl = useMemo(() => URL.createObjectURL(blob), [blob]);
|
|
165
|
+
const url = `url(${blobUrl})`;
|
|
166
|
+
|
|
167
|
+
return url;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export default useBackgroundImage;
|