@scrabble-solver/scrabble-solver 2.10.7 → 2.10.9
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 +15 -21
- 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/images-manifest.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/176.js +4603 -395
- package/.next/server/chunks/664.js +27 -2414
- package/.next/server/chunks/859.js +29 -1
- package/.next/server/font-loader-manifest.js +1 -0
- package/.next/server/font-loader-manifest.json +6 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +2 -2
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +1 -12
- package/.next/server/pages/_app.js +176 -13
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js +133 -17
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/solve.js +16 -0
- package/.next/server/pages/index.html +1 -9
- package/.next/server/pages/index.js +52 -165
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/chunks/main-74c4d6b2b5c362f3.js +1 -0
- package/.next/static/chunks/pages/{404-67383848027ec49b.js → 404-d5ff00df1c687977.js} +1 -1
- package/.next/static/chunks/pages/_app-52cb288dc680bdfe.js +28 -0
- package/.next/static/chunks/pages/index-5c2544930e46c5ce.js +1 -0
- package/.next/static/chunks/webpack-6ef43a8d4a395f49.js +1 -0
- package/.next/static/css/ec4e47a6b1866fe5.css +1 -0
- package/.next/static/css/f65b7b2a74f57c1c.css +2 -0
- package/.next/static/fZRsz4P0gQ8Wgb9jP8eap/_buildManifest.js +1 -0
- package/.next/trace +55 -55
- package/package.json +12 -10
- package/src/components/Badge/Badge.module.scss +1 -1
- package/src/components/Board/Board.module.scss +14 -0
- package/src/components/Board/Board.tsx +117 -19
- package/src/components/Board/BoardPure.tsx +7 -15
- package/src/components/Board/components/Actions/Actions.module.scss +64 -0
- package/src/components/Board/components/Actions/Actions.tsx +68 -0
- package/src/components/Board/components/Actions/index.ts +1 -0
- package/src/components/Board/components/Cell/Cell.module.scss +22 -165
- package/src/components/Board/components/Cell/Cell.tsx +0 -37
- package/src/components/Board/components/Cell/CellPure.tsx +5 -75
- package/src/components/Board/components/index.ts +1 -0
- package/src/components/Board/hooks/useGrid.ts +16 -16
- package/src/components/Button/Button.module.scss +3 -3
- package/src/components/Checkbox/Checkbox.tsx +1 -4
- package/src/components/Dictionary/Dictionary.tsx +28 -30
- package/src/components/DictionaryInput/DictionaryInput.tsx +3 -0
- package/src/components/Key/Key.module.scss +1 -1
- package/src/components/LogoSplashScreen/LogoSplashScreen.module.scss +1 -1
- package/src/components/Modal/Modal.module.scss +4 -2
- package/src/components/Rack/Rack.module.scss +5 -0
- package/src/components/Radio/Radio.tsx +1 -4
- package/src/components/Results/Results.module.scss +2 -2
- package/src/components/SeoMessage/SeoMessage.tsx +19 -0
- package/src/components/SeoMessage/index.ts +1 -0
- package/src/components/Solver/Solver.module.scss +0 -5
- package/src/components/Solver/Solver.tsx +1 -1
- package/src/components/Solver/components/EmptyState/EmptyState.module.scss +1 -1
- package/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.module.scss +9 -2
- package/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.tsx +2 -1
- package/src/components/Tile/Tile.module.scss +23 -11
- package/src/components/Tile/Tile.tsx +26 -9
- package/src/components/Tile/TilePure.tsx +9 -4
- package/src/components/Tooltip/Tooltip.module.scss +7 -7
- package/src/components/index.ts +1 -0
- package/src/hooks/useLocalStorage/useLocalStorageBoard.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageConfigId.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageLocale.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageRack.ts +6 -3
- package/src/i18n/de.json +1 -0
- package/src/i18n/en.json +1 -0
- package/src/i18n/es.json +1 -0
- package/src/i18n/fa.json +1 -0
- package/src/i18n/fr.json +1 -0
- package/src/i18n/pl.json +1 -0
- package/src/icons/Flag.svg +2 -2
- package/src/icons/FlagFill.svg +4 -0
- package/src/icons/Square.svg +4 -0
- package/src/icons/SquareFill.svg +4 -0
- package/src/icons/index.ts +3 -0
- package/src/modals/RemainingTilesModal/components/Character/Character.module.scss +1 -1
- package/src/modals/ResultsModal/ResultsModal.module.scss +1 -1
- package/src/modals/SettingsModal/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -2
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.module.scss +1 -1
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.tsx +1 -2
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.module.scss +14 -24
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.tsx +1 -2
- package/src/pages/_app.tsx +9 -5
- package/src/pages/index.module.scss +1 -2
- package/src/pages/index.tsx +10 -8
- package/src/parameters/index.ts +12 -0
- package/src/state/slices/boardSlice.ts +5 -5
- package/src/styles/animations.scss +10 -0
- package/src/styles/global.scss +2 -2
- package/src/styles/mixins.scss +60 -3
- package/src/styles/variables.scss +43 -33
- package/src/types/index.ts +1 -0
- package/.next/server/chunks/210.js +0 -122
- package/.next/server/chunks/579.js +0 -3925
- package/.next/server/chunks/676.js +0 -32
- package/.next/static/6RggBFm8kHrh-k1-CG3um/_buildManifest.js +0 -1
- package/.next/static/chunks/490-d29992f1c264d70e.js +0 -5
- package/.next/static/chunks/509-6ad4482d4351452c.js +0 -1
- package/.next/static/chunks/main-f11614d8aa7ee555.js +0 -1
- package/.next/static/chunks/pages/_app-c58cfa832b76cc87.js +0 -24
- package/.next/static/chunks/pages/index-146039f501e49c08.js +0 -1
- package/.next/static/chunks/webpack-59c5c889f52620d6.js +0 -1
- package/.next/static/css/4482c4a0064d3807.css +0 -1
- package/.next/static/css/78e42ad01f580f64.css +0 -1
- package/.next/static/css/9d1013ec684361b9.css +0 -1
- package/src/components/Board/components/Cell/Button.tsx +0 -32
- /package/.next/static/{6RggBFm8kHrh-k1-CG3um → fZRsz4P0gQ8Wgb9jP8eap}/_ssgManifest.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/scrabble-solver",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.9",
|
|
4
4
|
"description": "Scrabble Solver 2 - App",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -28,20 +28,22 @@
|
|
|
28
28
|
"start": "env-cmd next start -p 3333"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@floating-ui/react": "^0.19.2",
|
|
31
32
|
"@kamilmielnik/trie": "^2.0.1",
|
|
32
33
|
"@popperjs/core": "^2.11.6",
|
|
33
34
|
"@reduxjs/toolkit": "^1.9.3",
|
|
34
|
-
"@scrabble-solver/configs": "^2.10.
|
|
35
|
-
"@scrabble-solver/constants": "^2.10.
|
|
36
|
-
"@scrabble-solver/dictionaries": "^2.10.
|
|
37
|
-
"@scrabble-solver/logger": "^2.10.
|
|
38
|
-
"@scrabble-solver/solver": "^2.10.
|
|
39
|
-
"@scrabble-solver/types": "^2.10.
|
|
40
|
-
"@scrabble-solver/word-definitions": "^2.10.
|
|
35
|
+
"@scrabble-solver/configs": "^2.10.9",
|
|
36
|
+
"@scrabble-solver/constants": "^2.10.9",
|
|
37
|
+
"@scrabble-solver/dictionaries": "^2.10.9",
|
|
38
|
+
"@scrabble-solver/logger": "^2.10.9",
|
|
39
|
+
"@scrabble-solver/solver": "^2.10.9",
|
|
40
|
+
"@scrabble-solver/types": "^2.10.9",
|
|
41
|
+
"@scrabble-solver/word-definitions": "^2.10.9",
|
|
41
42
|
"classnames": "^2.3.2",
|
|
42
43
|
"include-media": "^2.0.0",
|
|
43
44
|
"include-media-query-builder": "^1.1.0",
|
|
44
|
-
"
|
|
45
|
+
"merge-refs": "^1.1.2",
|
|
46
|
+
"next": "^13.2.1",
|
|
45
47
|
"normalize.css": "^8.0.1",
|
|
46
48
|
"react": "^18.2.0",
|
|
47
49
|
"react-dom": "^18.2.0",
|
|
@@ -76,5 +78,5 @@
|
|
|
76
78
|
"sass": "^1.58.3",
|
|
77
79
|
"workbox-webpack-plugin": "^6.5.4"
|
|
78
80
|
},
|
|
79
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "fc5ec3ca1e4ec2c9f0ef9ae302c030659f7ef583"
|
|
80
82
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
padding: var(--spacing--xs) var(--spacing--m);
|
|
6
6
|
border: var(--border);
|
|
7
7
|
border-radius: var(--border--radius);
|
|
8
|
-
background-color: var(--color--background--
|
|
8
|
+
background-color: var(--color--background--element);
|
|
9
9
|
line-height: var(--line-height);
|
|
10
10
|
font-size: var(--font--size--m);
|
|
11
11
|
font-weight: bold;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import 'styles/animations';
|
|
2
|
+
|
|
1
3
|
.board {
|
|
2
4
|
display: table;
|
|
3
5
|
box-shadow: var(--box-shadow);
|
|
@@ -7,3 +9,15 @@
|
|
|
7
9
|
.row {
|
|
8
10
|
display: table-row;
|
|
9
11
|
}
|
|
12
|
+
|
|
13
|
+
.actions {
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: var(--z-index--actions);
|
|
16
|
+
width: max-content;
|
|
17
|
+
height: max-content;
|
|
18
|
+
animation: var(--transition--duration) var(--transition--easing) hide;
|
|
19
|
+
|
|
20
|
+
&.shown {
|
|
21
|
+
animation: var(--transition--duration) var(--transition--easing) show;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,36 +1,134 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { autoUpdate, FloatingPortal, offset, shift, useFloating, useMergeRefs } from '@floating-ui/react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { CSSProperties, FocusEventHandler, FunctionComponent, useState } from 'react';
|
|
4
|
+
import { useDispatch } from 'react-redux';
|
|
5
|
+
import { useMeasure } from 'react-use';
|
|
2
6
|
|
|
3
|
-
import {
|
|
7
|
+
import { BOARD_CELL_ACTIONS_OFFSET, TRANSITION } from 'parameters';
|
|
8
|
+
import { boardSlice, cellFilterSlice, selectBoard, selectRowsWithCandidate, useTypedSelector } from 'state';
|
|
4
9
|
|
|
10
|
+
import styles from './Board.module.scss';
|
|
5
11
|
import BoardPure from './BoardPure';
|
|
12
|
+
import { Actions } from './components';
|
|
6
13
|
import { useGrid } from './hooks';
|
|
7
14
|
|
|
8
15
|
interface Props {
|
|
9
16
|
cellSize: number;
|
|
10
17
|
className?: string;
|
|
11
|
-
innerRef?: Ref<HTMLDivElement>;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
const Board: FunctionComponent<Props> = ({ cellSize, className
|
|
20
|
+
const Board: FunctionComponent<Props> = ({ cellSize, className }) => {
|
|
21
|
+
const dispatch = useDispatch();
|
|
15
22
|
const rows = useTypedSelector(selectRowsWithCandidate);
|
|
16
23
|
const board = useTypedSelector(selectBoard);
|
|
17
|
-
const [
|
|
24
|
+
const [actionsMeasureRef, { width: actionsWidth }] = useMeasure<HTMLDivElement>();
|
|
25
|
+
const [{ activeIndex, direction, inputRefs }, { onChange, onDirectionToggle, onFocus, onKeyDown, onPaste }] =
|
|
26
|
+
useGrid(rows);
|
|
27
|
+
const inputRef = inputRefs[activeIndex.y][activeIndex.x];
|
|
28
|
+
const cell = rows[activeIndex.y][activeIndex.x];
|
|
29
|
+
const [showActions, setShowActions] = useState(false);
|
|
30
|
+
const [transition, setTransition] = useState<CSSProperties['transition']>(TRANSITION);
|
|
31
|
+
|
|
32
|
+
const { x, y, strategy, refs } = useFloating({
|
|
33
|
+
middleware: [
|
|
34
|
+
offset({
|
|
35
|
+
mainAxis: -BOARD_CELL_ACTIONS_OFFSET,
|
|
36
|
+
alignmentAxis: BOARD_CELL_ACTIONS_OFFSET - actionsWidth,
|
|
37
|
+
}),
|
|
38
|
+
shift(),
|
|
39
|
+
],
|
|
40
|
+
placement: 'top-end',
|
|
41
|
+
whileElementsMounted: autoUpdate,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const actionsRef = useMergeRefs([actionsMeasureRef, refs.setFloating]);
|
|
45
|
+
|
|
46
|
+
const handleBlur: FocusEventHandler = (event) => {
|
|
47
|
+
const eventComesFromActions = refs.floating.current?.contains(event.relatedTarget);
|
|
48
|
+
const eventComesFromBoard = event.currentTarget.contains(event.relatedTarget);
|
|
49
|
+
const isLocalEvent = eventComesFromActions || eventComesFromBoard;
|
|
50
|
+
|
|
51
|
+
if (!isLocalEvent) {
|
|
52
|
+
setShowActions(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleDirectionToggle = () => {
|
|
57
|
+
inputRef.current?.focus();
|
|
58
|
+
onDirectionToggle();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleFocus: typeof onFocus = (newX, newY) => {
|
|
62
|
+
const isFirstFocus = !showActions;
|
|
63
|
+
const originalTransition = refs.floating.current?.style.transition || '';
|
|
64
|
+
const newInputRef = inputRefs[newY][newX].current;
|
|
65
|
+
const newTileElement = newInputRef?.parentElement || null;
|
|
66
|
+
|
|
67
|
+
if (isFirstFocus) {
|
|
68
|
+
setTransition('none');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
refs.setReference(newTileElement);
|
|
72
|
+
onFocus(newX, newY);
|
|
73
|
+
setShowActions(true);
|
|
74
|
+
|
|
75
|
+
if (isFirstFocus) {
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
setTransition(originalTransition);
|
|
78
|
+
}, 0);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleToggleBlank = () => {
|
|
83
|
+
inputRef.current?.focus();
|
|
84
|
+
dispatch(boardSlice.actions.toggleCellIsBlank(cell));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleToggleFilterCell = () => {
|
|
88
|
+
inputRef.current?.focus();
|
|
89
|
+
dispatch(cellFilterSlice.actions.toggle(cell));
|
|
90
|
+
};
|
|
18
91
|
|
|
19
92
|
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
93
|
+
<>
|
|
94
|
+
<BoardPure
|
|
95
|
+
className={className}
|
|
96
|
+
cellSize={cellSize}
|
|
97
|
+
center={board.center}
|
|
98
|
+
inputRefs={inputRefs}
|
|
99
|
+
rows={rows}
|
|
100
|
+
onBlur={handleBlur}
|
|
101
|
+
onChange={onChange}
|
|
102
|
+
onFocus={handleFocus}
|
|
103
|
+
onKeyDown={onKeyDown}
|
|
104
|
+
onPaste={onPaste}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<FloatingPortal>
|
|
108
|
+
<Actions
|
|
109
|
+
cell={cell}
|
|
110
|
+
className={classNames(styles.actions, {
|
|
111
|
+
[styles.shown]: showActions,
|
|
112
|
+
})}
|
|
113
|
+
disabled={!showActions}
|
|
114
|
+
direction={direction}
|
|
115
|
+
ref={actionsRef}
|
|
116
|
+
style={{
|
|
117
|
+
position: strategy,
|
|
118
|
+
top: y ?? 0,
|
|
119
|
+
left: x ?? 0,
|
|
120
|
+
transition,
|
|
121
|
+
opacity: showActions ? 1 : 0,
|
|
122
|
+
pointerEvents: showActions ? 'auto' : 'none',
|
|
123
|
+
userSelect: showActions ? 'auto' : 'none',
|
|
124
|
+
visibility: x === null || y === null ? 'hidden' : 'visible',
|
|
125
|
+
}}
|
|
126
|
+
onDirectionToggle={handleDirectionToggle}
|
|
127
|
+
onToggleBlank={handleToggleBlank}
|
|
128
|
+
onToggleFilterCell={handleToggleFilterCell}
|
|
129
|
+
/>
|
|
130
|
+
</FloatingPortal>
|
|
131
|
+
</>
|
|
34
132
|
);
|
|
35
133
|
};
|
|
36
134
|
|
|
@@ -3,15 +3,13 @@ import classNames from 'classnames';
|
|
|
3
3
|
import {
|
|
4
4
|
ChangeEventHandler,
|
|
5
5
|
ClipboardEventHandler,
|
|
6
|
+
FocusEventHandler,
|
|
6
7
|
FunctionComponent,
|
|
7
8
|
KeyboardEventHandler,
|
|
8
9
|
memo,
|
|
9
|
-
Ref,
|
|
10
10
|
RefObject,
|
|
11
11
|
} from 'react';
|
|
12
12
|
|
|
13
|
-
import { Direction } from 'types';
|
|
14
|
-
|
|
15
13
|
import styles from './Board.module.scss';
|
|
16
14
|
import { Cell } from './components';
|
|
17
15
|
|
|
@@ -19,12 +17,10 @@ interface Props {
|
|
|
19
17
|
className?: string;
|
|
20
18
|
cellSize: number;
|
|
21
19
|
center: CellModel;
|
|
22
|
-
|
|
23
|
-
innerRef?: Ref<HTMLDivElement>;
|
|
24
|
-
refs: RefObject<HTMLInputElement>[][];
|
|
20
|
+
inputRefs: RefObject<HTMLInputElement>[][];
|
|
25
21
|
rows: CellModel[][];
|
|
22
|
+
onBlur: FocusEventHandler;
|
|
26
23
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
27
|
-
onDirectionToggle: () => void;
|
|
28
24
|
onFocus: (x: number, y: number) => void;
|
|
29
25
|
onKeyDown: KeyboardEventHandler<HTMLInputElement>;
|
|
30
26
|
onPaste: ClipboardEventHandler<HTMLInputElement>;
|
|
@@ -34,32 +30,28 @@ const BoardPure: FunctionComponent<Props> = ({
|
|
|
34
30
|
className,
|
|
35
31
|
cellSize,
|
|
36
32
|
center,
|
|
37
|
-
|
|
38
|
-
innerRef,
|
|
39
|
-
refs,
|
|
33
|
+
inputRefs,
|
|
40
34
|
rows,
|
|
35
|
+
onBlur,
|
|
41
36
|
onChange,
|
|
42
|
-
onDirectionToggle,
|
|
43
37
|
onFocus,
|
|
44
38
|
onKeyDown,
|
|
45
39
|
onPaste,
|
|
46
40
|
}) => (
|
|
47
|
-
<div className={classNames(styles.board, className)}
|
|
41
|
+
<div className={classNames(styles.board, className)} onBlur={onBlur} onKeyDown={onKeyDown} onPaste={onPaste}>
|
|
48
42
|
{rows.map((cells, y) => (
|
|
49
43
|
<div className={styles.row} key={y}>
|
|
50
44
|
{cells.map((cell, x) => (
|
|
51
45
|
<Cell
|
|
52
46
|
className={styles.cell}
|
|
53
47
|
cell={cell}
|
|
54
|
-
|
|
55
|
-
inputRef={refs[y][x]}
|
|
48
|
+
inputRef={inputRefs[y][x]}
|
|
56
49
|
isBottom={y === rows.length - 1}
|
|
57
50
|
isCenter={center.x === x && center.y === y}
|
|
58
51
|
isRight={x === cells.length - 1}
|
|
59
52
|
key={x}
|
|
60
53
|
size={cellSize}
|
|
61
54
|
onChange={onChange}
|
|
62
|
-
onDirectionToggle={onDirectionToggle}
|
|
63
55
|
onFocus={onFocus}
|
|
64
56
|
/>
|
|
65
57
|
))}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@import 'styles/mixins';
|
|
2
|
+
|
|
3
|
+
.actions {
|
|
4
|
+
display: flex;
|
|
5
|
+
box-shadow: var(--box-shadow);
|
|
6
|
+
border-radius: var(--border--radius);
|
|
7
|
+
transition: var(--transition);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.action {
|
|
11
|
+
padding: var(--spacing--m);
|
|
12
|
+
box-shadow: none !important;
|
|
13
|
+
|
|
14
|
+
& + & {
|
|
15
|
+
[dir='ltr'] & {
|
|
16
|
+
border-left: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[dir='rtl'] & {
|
|
20
|
+
border-right: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[dir='ltr'] & {
|
|
25
|
+
&:first-child {
|
|
26
|
+
border-top-right-radius: 0;
|
|
27
|
+
border-bottom-right-radius: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:last-child {
|
|
31
|
+
border-top-left-radius: 0;
|
|
32
|
+
border-bottom-left-radius: 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[dir='rtl'] & {
|
|
37
|
+
&:first-child {
|
|
38
|
+
border-top-left-radius: 0;
|
|
39
|
+
border-bottom-left-radius: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:last-child {
|
|
43
|
+
border-top-right-radius: 0;
|
|
44
|
+
border-bottom-right-radius: 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:active,
|
|
49
|
+
&:hover {
|
|
50
|
+
color: var(--color--foreground);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.toggleDirection {
|
|
55
|
+
transition: var(--transition);
|
|
56
|
+
|
|
57
|
+
&.right {
|
|
58
|
+
transform: rotate(-90deg);
|
|
59
|
+
|
|
60
|
+
[dir='rtl'] & {
|
|
61
|
+
transform: rotate(90deg);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { EMPTY_CELL } from '@scrabble-solver/constants';
|
|
2
|
+
import { Cell } from '@scrabble-solver/types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { forwardRef, HTMLProps, MouseEventHandler } from 'react';
|
|
5
|
+
|
|
6
|
+
import { ArrowDown, Flag, FlagFill, Square, SquareFill } from 'icons';
|
|
7
|
+
import { selectCellIsFiltered, useTranslate, useTypedSelector } from 'state';
|
|
8
|
+
|
|
9
|
+
import Button from '../../../Button';
|
|
10
|
+
|
|
11
|
+
import styles from './Actions.module.scss';
|
|
12
|
+
|
|
13
|
+
interface Props extends HTMLProps<HTMLDivElement> {
|
|
14
|
+
cell: Cell;
|
|
15
|
+
direction: 'horizontal' | 'vertical';
|
|
16
|
+
onDirectionToggle: MouseEventHandler<HTMLButtonElement>;
|
|
17
|
+
onToggleBlank: MouseEventHandler<HTMLButtonElement>;
|
|
18
|
+
onToggleFilterCell: MouseEventHandler<HTMLButtonElement>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Actions = forwardRef<HTMLDivElement, Props>(
|
|
22
|
+
({ cell, className, direction, disabled, onDirectionToggle, onToggleBlank, onToggleFilterCell, ...props }, ref) => {
|
|
23
|
+
const translate = useTranslate();
|
|
24
|
+
const isFiltered = useTypedSelector((state) => selectCellIsFiltered(state, cell));
|
|
25
|
+
const isBlank = cell.tile.isBlank;
|
|
26
|
+
const isEmpty = cell.tile.character === EMPTY_CELL;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className={classNames(styles.actions, className)} ref={ref} {...props}>
|
|
30
|
+
<Button
|
|
31
|
+
aria-label={translate('cell.toggle-direction')}
|
|
32
|
+
className={styles.action}
|
|
33
|
+
Icon={ArrowDown}
|
|
34
|
+
iconClassName={classNames(styles.toggleDirection, {
|
|
35
|
+
[styles.right]: direction === 'horizontal',
|
|
36
|
+
})}
|
|
37
|
+
tabIndex={disabled ? -1 : undefined}
|
|
38
|
+
tooltip={translate('cell.toggle-direction')}
|
|
39
|
+
onClick={onDirectionToggle}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
{isEmpty && (
|
|
43
|
+
<Button
|
|
44
|
+
aria-label={translate('cell.filter-cell')}
|
|
45
|
+
className={classNames(styles.action)}
|
|
46
|
+
Icon={isFiltered ? Flag : FlagFill}
|
|
47
|
+
tabIndex={disabled ? -1 : undefined}
|
|
48
|
+
tooltip={translate('cell.filter-cell')}
|
|
49
|
+
onClick={onToggleFilterCell}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{!isEmpty && (
|
|
54
|
+
<Button
|
|
55
|
+
aria-label={isBlank ? translate('cell.set-not-blank') : translate('cell.set-blank')}
|
|
56
|
+
className={styles.action}
|
|
57
|
+
Icon={isBlank ? SquareFill : Square}
|
|
58
|
+
tabIndex={disabled ? -1 : undefined}
|
|
59
|
+
tooltip={isBlank ? translate('cell.set-not-blank') : translate('cell.set-blank')}
|
|
60
|
+
onClick={onToggleBlank}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
export default Actions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Actions';
|