@scrabble-solver/scrabble-solver 2.10.8 → 2.10.10

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 (87) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +15 -15
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_8dgz12 +1 -1
  5. package/.next/cache/next-server.js.nft.json +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  9. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  10. package/.next/cache/webpack/server-production/0.pack +0 -0
  11. package/.next/cache/webpack/server-production/index.pack +0 -0
  12. package/.next/images-manifest.json +1 -1
  13. package/.next/next-server.js.nft.json +1 -1
  14. package/.next/prerender-manifest.json +1 -1
  15. package/.next/required-server-files.json +1 -1
  16. package/.next/routes-manifest.json +1 -1
  17. package/.next/server/chunks/131.js +24 -17
  18. package/.next/server/chunks/176.js +443 -288
  19. package/.next/server/chunks/50.js +712 -1025
  20. package/.next/server/chunks/664.js +27 -2414
  21. package/.next/server/chunks/859.js +29 -1
  22. package/.next/server/font-loader-manifest.js +1 -0
  23. package/.next/server/font-loader-manifest.json +6 -0
  24. package/.next/server/middleware-build-manifest.js +1 -1
  25. package/.next/server/pages/404.html +2 -2
  26. package/.next/server/pages/404.js.nft.json +1 -1
  27. package/.next/server/pages/500.html +1 -12
  28. package/.next/server/pages/_app.js +13 -133
  29. package/.next/server/pages/_app.js.nft.json +1 -1
  30. package/.next/server/pages/_document.js +1 -1
  31. package/.next/server/pages/_document.js.nft.json +1 -1
  32. package/.next/server/pages/_error.js +133 -17
  33. package/.next/server/pages/_error.js.nft.json +1 -1
  34. package/.next/server/pages/api/solve.js +5 -6
  35. package/.next/server/pages/index.html +1 -1
  36. package/.next/server/pages/index.js +34 -154
  37. package/.next/server/pages/index.js.nft.json +1 -1
  38. package/.next/server/pages/index.json +1 -1
  39. package/.next/server/pages-manifest.json +1 -1
  40. package/.next/static/chunks/main-74c4d6b2b5c362f3.js +1 -0
  41. package/.next/static/chunks/pages/{404-8cab6d62fe4ead73.js → 404-d5ff00df1c687977.js} +1 -1
  42. package/.next/static/chunks/pages/_app-3272e798504c40d8.js +28 -0
  43. package/.next/static/chunks/pages/index-5c2544930e46c5ce.js +1 -0
  44. package/.next/static/chunks/webpack-6ef43a8d4a395f49.js +1 -0
  45. package/.next/static/css/336e75db2b74b157.css +2 -0
  46. package/.next/static/css/{d1cc6b79b211b7b8.css → ec4e47a6b1866fe5.css} +1 -1
  47. package/.next/static/warzWo25tDxo_Eiv9T6f2/_buildManifest.js +1 -0
  48. package/.next/trace +55 -55
  49. package/package.json +12 -11
  50. package/src/components/Board/Board.module.scss +14 -0
  51. package/src/components/Board/Board.tsx +117 -19
  52. package/src/components/Board/BoardPure.tsx +7 -15
  53. package/src/components/Board/components/Actions/Actions.module.scss +64 -0
  54. package/src/components/Board/components/Actions/Actions.tsx +74 -0
  55. package/src/components/Board/components/Actions/index.ts +1 -0
  56. package/src/components/Board/components/Cell/Cell.module.scss +10 -121
  57. package/src/components/Board/components/Cell/Cell.tsx +0 -37
  58. package/src/components/Board/components/Cell/CellPure.tsx +5 -68
  59. package/src/components/Board/components/index.ts +1 -0
  60. package/src/components/Board/hooks/useGrid.ts +16 -16
  61. package/src/components/Modal/Modal.module.scss +3 -1
  62. package/src/components/Rack/Rack.module.scss +2 -1
  63. package/src/components/Solver/Solver.module.scss +0 -5
  64. package/src/components/Solver/Solver.tsx +1 -1
  65. package/src/components/Tile/Tile.module.scss +0 -26
  66. package/src/components/Tile/Tile.tsx +5 -3
  67. package/src/components/Tile/TilePure.tsx +16 -18
  68. package/src/hooks/useLocalStorage/useLocalStorageBoard.ts +6 -3
  69. package/src/hooks/useLocalStorage/useLocalStorageConfigId.ts +6 -3
  70. package/src/hooks/useLocalStorage/useLocalStorageLocale.ts +6 -3
  71. package/src/hooks/useLocalStorage/useLocalStorageRack.ts +6 -3
  72. package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.module.scss +1 -1
  73. package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.module.scss +2 -2
  74. package/src/parameters/index.ts +5 -3
  75. package/src/styles/animations.scss +10 -0
  76. package/src/styles/global.scss +2 -2
  77. package/src/styles/mixins.scss +56 -1
  78. package/src/styles/variables.scss +5 -2
  79. package/.next/server/chunks/210.js +0 -122
  80. package/.next/server/chunks/676.js +0 -32
  81. package/.next/static/Cs23uxWG6AxS72F2yrjHu/_buildManifest.js +0 -1
  82. package/.next/static/chunks/main-f11614d8aa7ee555.js +0 -1
  83. package/.next/static/chunks/pages/_app-dcbbb823dc93a031.js +0 -28
  84. package/.next/static/chunks/pages/index-df1ff01aa82d2d4d.js +0 -1
  85. package/.next/static/chunks/webpack-59c5c889f52620d6.js +0 -1
  86. package/.next/static/css/bf2e969b88c4e3dd.css +0 -2
  87. /package/.next/static/{Cs23uxWG6AxS72F2yrjHu → warzWo25tDxo_Eiv9T6f2}/_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.8",
3
+ "version": "2.10.10",
4
4
  "description": "Scrabble Solver 2 - App",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -21,28 +21,29 @@
21
21
  "homepage": "https://github.com/kamilmielnik/scrabble-solver#readme",
22
22
  "scripts": {
23
23
  "build": "env-cmd next build",
24
- "clean": "rimraf .next/ node_modules/ scrabble-solver-all.log scrabble-solver-error.log",
24
+ "clean": "rimraf .next/ node_modules/",
25
25
  "clean:force": "npm run clean && rimraf package-lock.json",
26
26
  "debug": "NODE_OPTIONS='--inspect' next dev",
27
27
  "dev": "env-cmd next dev",
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.8",
35
- "@scrabble-solver/constants": "^2.10.8",
36
- "@scrabble-solver/dictionaries": "^2.10.8",
37
- "@scrabble-solver/logger": "^2.10.8",
38
- "@scrabble-solver/solver": "^2.10.8",
39
- "@scrabble-solver/types": "^2.10.8",
40
- "@scrabble-solver/word-definitions": "^2.10.8",
35
+ "@scrabble-solver/configs": "^2.10.10",
36
+ "@scrabble-solver/constants": "^2.10.10",
37
+ "@scrabble-solver/dictionaries": "^2.10.10",
38
+ "@scrabble-solver/logger": "^2.10.10",
39
+ "@scrabble-solver/solver": "^2.10.10",
40
+ "@scrabble-solver/types": "^2.10.10",
41
+ "@scrabble-solver/word-definitions": "^2.10.10",
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",
45
- "next": "^13.1.6",
46
+ "next": "^13.2.1",
46
47
  "normalize.css": "^8.0.1",
47
48
  "react": "^18.2.0",
48
49
  "react-dom": "^18.2.0",
@@ -77,5 +78,5 @@
77
78
  "sass": "^1.58.3",
78
79
  "workbox-webpack-plugin": "^6.5.4"
79
80
  },
80
- "gitHead": "faa8a69c239fd14a2b07fe18744580e8713e93ea"
81
+ "gitHead": "42551ac84b78ed24543230c19b861e1543f7a50a"
81
82
  }
@@ -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 { FunctionComponent, Ref } from 'react';
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 { selectBoard, selectRowsWithCandidate, useTypedSelector } from 'state';
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, innerRef }) => {
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 [{ direction, refs }, { onChange, onDirectionToggle, onFocus, onKeyDown, onPaste }] = useGrid(rows);
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
- <BoardPure
21
- className={className}
22
- cellSize={cellSize}
23
- center={board.center}
24
- direction={direction}
25
- innerRef={innerRef}
26
- refs={refs}
27
- rows={rows}
28
- onChange={onChange}
29
- onDirectionToggle={onDirectionToggle}
30
- onFocus={onFocus}
31
- onKeyDown={onKeyDown}
32
- onPaste={onPaste}
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
- direction: Direction;
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
- direction,
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)} ref={innerRef} onKeyDown={onKeyDown} onPaste={onPaste}>
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
- direction={direction}
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,74 @@
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
+ // On iOS it helps with losing focus too early which makes Actions disappear
29
+ const handleMouseDown: MouseEventHandler = (event) => event.preventDefault();
30
+
31
+ return (
32
+ <div className={classNames(styles.actions, className)} ref={ref} {...props}>
33
+ <Button
34
+ aria-label={translate('cell.toggle-direction')}
35
+ className={styles.action}
36
+ Icon={ArrowDown}
37
+ iconClassName={classNames(styles.toggleDirection, {
38
+ [styles.right]: direction === 'horizontal',
39
+ })}
40
+ tabIndex={disabled ? -1 : undefined}
41
+ tooltip={translate('cell.toggle-direction')}
42
+ onClick={onDirectionToggle}
43
+ onMouseDown={handleMouseDown}
44
+ />
45
+
46
+ {isEmpty && (
47
+ <Button
48
+ aria-label={translate('cell.filter-cell')}
49
+ className={classNames(styles.action)}
50
+ Icon={isFiltered ? Flag : FlagFill}
51
+ tabIndex={disabled ? -1 : undefined}
52
+ tooltip={translate('cell.filter-cell')}
53
+ onClick={onToggleFilterCell}
54
+ onMouseDown={handleMouseDown}
55
+ />
56
+ )}
57
+
58
+ {!isEmpty && (
59
+ <Button
60
+ aria-label={isBlank ? translate('cell.set-not-blank') : translate('cell.set-blank')}
61
+ className={styles.action}
62
+ Icon={isBlank ? SquareFill : Square}
63
+ tabIndex={disabled ? -1 : undefined}
64
+ tooltip={isBlank ? translate('cell.set-not-blank') : translate('cell.set-blank')}
65
+ onClick={onToggleBlank}
66
+ onMouseDown={handleMouseDown}
67
+ />
68
+ )}
69
+ </div>
70
+ );
71
+ },
72
+ );
73
+
74
+ export default Actions;
@@ -0,0 +1 @@
1
+ export { default } from './Actions';
@@ -2,6 +2,7 @@
2
2
 
3
3
  .cell {
4
4
  @include focus-effect;
5
+ @include lighthouse-input-size-hack;
5
6
 
6
7
  position: relative;
7
8
  display: table-cell;
@@ -88,10 +89,10 @@
88
89
  }
89
90
  }
90
91
 
91
- &.candidate {
92
+ &.filtered {
92
93
  &::before {
93
94
  content: ' ';
94
- background-color: var(--color--primary);
95
+ background-color: var(--color--foreground--secondary);
95
96
  }
96
97
  }
97
98
 
@@ -114,135 +115,23 @@
114
115
  content: ' ';
115
116
 
116
117
  [lang='fa-IR'] & {
117
- font-family: 'Open Sans', sans-serif;
118
+ font-family: var(--font--family--latin);
118
119
  }
119
120
  }
120
121
 
121
122
  &:focus-within {
122
123
  z-index: 2;
123
-
124
- .actions {
125
- display: flex;
126
- }
127
-
128
- .action {
129
- user-select: initial;
130
- pointer-events: auto;
131
- }
132
- }
133
- }
134
-
135
- .actions {
136
- --offset: var(--spacing--m);
137
-
138
- @include media('<xs') {
139
- --offset: var(--spacing--s);
140
- }
141
-
142
- display: none;
143
- position: absolute;
144
- bottom: calc(100% - var(--offset));
145
- z-index: 2;
146
- transition: var(--transition);
147
- pointer-events: none;
148
- box-shadow: var(--box-shadow);
149
- border-radius: var(--border--radius);
150
-
151
- [dir='ltr'] & {
152
- left: calc(100% - var(--offset));
153
- }
154
-
155
- [dir='rtl'] & {
156
- right: calc(100% - var(--offset));
157
- }
158
- }
159
-
160
- .action {
161
- padding: var(--spacing--m);
162
- box-shadow: none !important;
163
-
164
- & + & {
165
- [dir='ltr'] & {
166
- border-left: none;
167
- }
168
-
169
- [dir='rtl'] & {
170
- border-right: none;
171
- }
172
- }
173
-
174
- [dir='ltr'] & {
175
- &:first-child {
176
- border-top-right-radius: 0;
177
- border-bottom-right-radius: 0;
178
- }
179
-
180
- &:last-child {
181
- border-top-left-radius: 0;
182
- border-bottom-left-radius: 0;
183
- }
184
- }
185
-
186
- [dir='rtl'] & {
187
- &:first-child {
188
- border-top-left-radius: 0;
189
- border-bottom-left-radius: 0;
190
- }
191
-
192
- &:last-child {
193
- border-top-right-radius: 0;
194
- border-bottom-right-radius: 0;
195
- }
196
- }
197
-
198
- &:active,
199
- &:hover {
200
- color: var(--color--foreground);
201
124
  }
202
125
  }
203
126
 
204
- .toggleDirection {
205
- transition: var(--transition);
206
-
207
- &.right {
208
- transform: rotate(-90deg);
209
-
210
- [dir='rtl'] & {
211
- transform: rotate(90deg);
212
- }
213
- }
214
- }
215
-
216
- .iconContainer {
217
- position: absolute;
218
- top: 0;
219
- right: 0;
220
- bottom: 0;
221
- left: 0;
222
- display: flex;
223
- align-items: center;
224
- justify-content: center;
225
- }
226
-
227
- .flagContainer {
228
- background-color: var(--color--primary);
229
- }
230
-
231
- .flag,
232
- .star {
233
- color: var(--color--white);
234
- }
235
-
236
- .star {
127
+ .icon {
237
128
  $size: 40%;
238
129
 
130
+ position: absolute;
131
+ top: 50%;
132
+ left: 50%;
239
133
  width: $size;
240
134
  height: $size;
241
- }
242
-
243
- .flag {
244
- $size: 50%;
245
-
246
- width: $size;
247
- height: $size;
135
+ transform: translate(-50%, -50%);
136
+ color: var(--color--white);
248
137
  }
@@ -1,12 +1,9 @@
1
1
  import { EMPTY_CELL } from '@scrabble-solver/constants';
2
2
  import { Cell as CellModel } from '@scrabble-solver/types';
3
3
  import { ChangeEventHandler, FunctionComponent, RefObject, useCallback, useMemo } from 'react';
4
- import { useDispatch } from 'react-redux';
5
4
 
6
5
  import { getTileSizes } from 'lib';
7
6
  import {
8
- boardSlice,
9
- cellFilterSlice,
10
7
  selectCellBonus,
11
8
  selectCellIsFiltered,
12
9
  selectCellIsValid,
@@ -21,32 +18,27 @@ import CellPure from './CellPure';
21
18
  interface Props {
22
19
  cell: CellModel;
23
20
  className?: string;
24
- direction: 'horizontal' | 'vertical';
25
21
  inputRef: RefObject<HTMLInputElement>;
26
22
  isBottom: boolean;
27
23
  isCenter: boolean;
28
24
  isRight: boolean;
29
25
  size: number;
30
26
  onChange: ChangeEventHandler<HTMLInputElement>;
31
- onDirectionToggle: () => void;
32
27
  onFocus: (x: number, y: number) => void;
33
28
  }
34
29
 
35
30
  const Cell: FunctionComponent<Props> = ({
36
31
  cell,
37
32
  className,
38
- direction,
39
33
  inputRef,
40
34
  isBottom,
41
35
  isCenter,
42
36
  isRight,
43
37
  size,
44
38
  onChange,
45
- onDirectionToggle,
46
39
  onFocus,
47
40
  }) => {
48
41
  const { tile, x, y } = cell;
49
- const dispatch = useDispatch();
50
42
  const translate = useTranslate();
51
43
  const locale = useTypedSelector(selectLocale);
52
44
  const bonus = useTypedSelector((state) => selectCellBonus(state, cell));
@@ -57,32 +49,8 @@ const Cell: FunctionComponent<Props> = ({
57
49
  const isEmpty = tile.character === EMPTY_CELL;
58
50
  const style = useMemo(() => ({ fontSize: tileFontSize }), [tileFontSize]);
59
51
 
60
- const handleDirectionToggleClick = useCallback(() => {
61
- if (inputRef.current) {
62
- inputRef.current.focus();
63
- }
64
-
65
- onDirectionToggle();
66
- }, [onDirectionToggle]);
67
-
68
52
  const handleFocus = useCallback(() => onFocus(x, y), [x, y, onFocus]);
69
53
 
70
- const handleToggleBlankClick = useCallback(() => {
71
- if (inputRef.current) {
72
- inputRef.current.focus();
73
- }
74
-
75
- dispatch(boardSlice.actions.toggleCellIsBlank({ x, y }));
76
- }, [dispatch, x, y]);
77
-
78
- const handleToggleFilterCellClick = useCallback(() => {
79
- if (inputRef.current) {
80
- inputRef.current.focus();
81
- }
82
-
83
- dispatch(cellFilterSlice.actions.toggle({ x, y }));
84
- }, [dispatch, x, y]);
85
-
86
54
  return (
87
55
  <CellPure
88
56
  aria-label={translate('cell.tile.location', {
@@ -92,7 +60,6 @@ const Cell: FunctionComponent<Props> = ({
92
60
  bonus={bonus}
93
61
  cell={cell}
94
62
  className={className}
95
- direction={direction}
96
63
  inputRef={inputRef}
97
64
  isBottom={isBottom}
98
65
  isCenter={isCenter}
@@ -104,12 +71,8 @@ const Cell: FunctionComponent<Props> = ({
104
71
  size={size}
105
72
  style={style}
106
73
  tile={tile}
107
- translate={translate}
108
74
  onChange={onChange}
109
- onDirectionToggleClick={handleDirectionToggleClick}
110
75
  onFocus={handleFocus}
111
- onToggleBlankClick={handleToggleBlankClick}
112
- onToggleFilterCellClick={handleToggleFilterCellClick}
113
76
  />
114
77
  );
115
78
  };