scrabble-solver 2.10.3 → 2.10.4

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 (208) hide show
  1. package/README.md +29 -18
  2. package/lerna.json +1 -1
  3. package/package.json +2 -2
  4. package/packages/configs/package-lock.json +4 -4
  5. package/packages/configs/package.json +3 -3
  6. package/packages/constants/package-lock.json +2 -2
  7. package/packages/constants/package.json +1 -1
  8. package/packages/dictionaries/package-lock.json +2 -2
  9. package/packages/dictionaries/package.json +4 -4
  10. package/packages/logger/package-lock.json +2 -2
  11. package/packages/logger/package.json +1 -1
  12. package/packages/scrabble-solver/.next/BUILD_ID +1 -1
  13. package/packages/scrabble-solver/.next/build-manifest.json +13 -13
  14. package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
  15. package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
  16. package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +1 -1
  17. package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
  18. package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
  19. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/0.pack +0 -0
  20. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
  21. package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
  22. package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
  23. package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
  24. package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
  25. package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
  26. package/packages/scrabble-solver/.next/server/chunks/176.js +1269 -1559
  27. package/packages/scrabble-solver/.next/server/chunks/579.js +50 -26
  28. package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
  29. package/packages/scrabble-solver/.next/server/pages/404.html +2 -2
  30. package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
  31. package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
  32. package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
  33. package/packages/scrabble-solver/.next/server/pages/api/solve.js +22 -6
  34. package/packages/scrabble-solver/.next/server/pages/index.html +2 -2
  35. package/packages/scrabble-solver/.next/server/pages/index.js +1539 -52
  36. package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
  37. package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
  38. package/packages/scrabble-solver/.next/server/pages-manifest.json +3 -3
  39. package/packages/scrabble-solver/.next/static/P7XhuDLmwJJqC8kgPjX42/_buildManifest.js +1 -0
  40. package/packages/scrabble-solver/.next/static/{FJkPF91uL-OCAJKTTpVSP → P7XhuDLmwJJqC8kgPjX42}/_ssgManifest.js +0 -0
  41. package/packages/scrabble-solver/.next/static/chunks/490-d29992f1c264d70e.js +5 -0
  42. package/packages/scrabble-solver/.next/static/chunks/528-9942ddad0031ff79.js +1 -0
  43. package/packages/scrabble-solver/.next/static/chunks/pages/{404-24f9617eeb8d6dc1.js → 404-6c99a0c91257c60b.js} +1 -1
  44. package/packages/scrabble-solver/.next/static/chunks/pages/_app-fa0661b072fc6af9.js +24 -0
  45. package/packages/scrabble-solver/.next/static/chunks/pages/index-d761f0af070273d2.js +1 -0
  46. package/packages/scrabble-solver/.next/static/css/78e42ad01f580f64.css +1 -0
  47. package/packages/scrabble-solver/.next/static/css/97eb6ee0c4300c83.css +1 -0
  48. package/packages/scrabble-solver/.next/static/css/dcca0c1a39cf5ef5.css +1 -0
  49. package/packages/scrabble-solver/.next/trace +55 -52
  50. package/packages/scrabble-solver/package-lock.json +27 -2
  51. package/packages/scrabble-solver/package.json +10 -8
  52. package/packages/scrabble-solver/src/components/Badge/Badge.module.scss +4 -5
  53. package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +5 -5
  54. package/packages/scrabble-solver/src/components/Button/Button.module.scss +10 -38
  55. package/packages/scrabble-solver/src/components/Button/Button.tsx +6 -5
  56. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.module.scss +1 -2
  57. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +2 -6
  58. package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.module.scss +1 -3
  59. package/packages/scrabble-solver/src/components/EmptyState/EmptyState.module.scss +6 -7
  60. package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +6 -6
  61. package/packages/scrabble-solver/src/components/Key/Key.module.scss +0 -1
  62. package/packages/scrabble-solver/src/components/{Splash/Splash.module.scss → LogoSplashScreen/LogoSplashScreen.module.scss} +1 -1
  63. package/packages/scrabble-solver/src/components/{Splash/Splash.tsx → LogoSplashScreen/LogoSplashScreen.tsx} +7 -7
  64. package/packages/scrabble-solver/src/components/LogoSplashScreen/index.ts +1 -0
  65. package/packages/scrabble-solver/src/components/{Sidebar/Sidebar.module.scss → Modal/Modal.module.scss} +25 -20
  66. package/packages/scrabble-solver/src/components/{Sidebar/Sidebar.tsx → Modal/Modal.tsx} +9 -9
  67. package/packages/scrabble-solver/src/components/{Sidebar → Modal}/components/Section/Section.module.scss +0 -0
  68. package/packages/scrabble-solver/src/components/{Sidebar → Modal}/components/Section/Section.tsx +0 -0
  69. package/packages/scrabble-solver/src/components/{Sidebar → Modal}/components/Section/index.ts +0 -0
  70. package/packages/scrabble-solver/src/components/{Sidebar → Modal}/components/index.ts +0 -0
  71. package/packages/scrabble-solver/src/components/Modal/index.ts +1 -0
  72. package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +22 -3
  73. package/packages/scrabble-solver/src/components/Progress/Progress.module.scss +9 -0
  74. package/packages/scrabble-solver/src/components/Progress/Progress.tsx +38 -0
  75. package/packages/scrabble-solver/src/components/Progress/index.ts +1 -0
  76. package/packages/scrabble-solver/src/components/Rack/Rack.module.scss +2 -0
  77. package/packages/scrabble-solver/src/components/Rack/Rack.tsx +3 -1
  78. package/packages/scrabble-solver/src/components/Rack/RackTile.tsx +3 -2
  79. package/packages/scrabble-solver/src/components/ResultCandidatePicker/ResultCandidatePicker.module.scss +76 -0
  80. package/packages/scrabble-solver/src/components/ResultCandidatePicker/ResultCandidatePicker.tsx +38 -0
  81. package/packages/scrabble-solver/src/components/ResultCandidatePicker/index.ts +1 -0
  82. package/packages/scrabble-solver/src/components/Results/Result.tsx +64 -43
  83. package/packages/scrabble-solver/src/components/Results/Results.module.scss +9 -16
  84. package/packages/scrabble-solver/src/components/Results/Results.tsx +45 -28
  85. package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +9 -7
  86. package/packages/scrabble-solver/src/components/Results/{getColumns.ts → getLocaleColumns.ts} +2 -2
  87. package/packages/scrabble-solver/src/components/Results/types.ts +16 -0
  88. package/packages/scrabble-solver/src/components/Results/useColumns.ts +44 -0
  89. package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.module.scss +1 -3
  90. package/packages/scrabble-solver/src/components/Sizer/Sizer.module.scss +10 -0
  91. package/packages/scrabble-solver/src/components/Sizer/Sizer.tsx +10 -0
  92. package/packages/scrabble-solver/src/components/Sizer/index.ts +1 -0
  93. package/packages/scrabble-solver/src/components/Solver/Solver.module.scss +83 -27
  94. package/packages/scrabble-solver/src/components/Solver/Solver.tsx +157 -24
  95. package/packages/scrabble-solver/src/components/Solver/components/ApplyButton/ApplyButton.module.scss +5 -0
  96. package/packages/scrabble-solver/src/components/Solver/components/ApplyButton/ApplyButton.tsx +37 -0
  97. package/packages/scrabble-solver/src/components/Solver/components/ApplyButton/index.ts +1 -0
  98. package/packages/scrabble-solver/src/components/Solver/components/EmptyState/EmptyState.module.scss +59 -0
  99. package/packages/scrabble-solver/src/components/Solver/components/EmptyState/EmptyState.tsx +41 -0
  100. package/packages/scrabble-solver/src/components/Solver/components/EmptyState/index.ts +1 -0
  101. package/packages/scrabble-solver/src/components/Solver/components/SolveButton/SolveButton.module.scss +4 -0
  102. package/packages/scrabble-solver/src/components/Solver/components/SolveButton/SolveButton.tsx +42 -0
  103. package/packages/scrabble-solver/src/components/Solver/components/SolveButton/index.ts +1 -0
  104. package/packages/scrabble-solver/src/components/Solver/components/index.ts +3 -0
  105. package/packages/scrabble-solver/src/components/{Screen/Screen.module.scss → SplashScreen/SplashScreen.module.scss} +2 -12
  106. package/packages/scrabble-solver/src/components/{Screen/Screen.tsx → SplashScreen/SplashScreen.tsx} +4 -4
  107. package/packages/scrabble-solver/src/components/SplashScreen/index.ts +1 -0
  108. package/packages/scrabble-solver/src/components/SquareButton/SquareButton.module.scss +3 -3
  109. package/packages/scrabble-solver/src/components/Tile/Tile.module.scss +7 -15
  110. package/packages/scrabble-solver/src/components/Tooltip/Tooltip.module.scss +0 -1
  111. package/packages/scrabble-solver/src/components/index.ts +6 -7
  112. package/packages/scrabble-solver/src/hooks/index.ts +1 -1
  113. package/packages/scrabble-solver/src/hooks/useMediaQuery.ts +11 -0
  114. package/packages/scrabble-solver/src/hooks/usePortal.tsx +1 -1
  115. package/packages/scrabble-solver/src/i18n/de.json +2 -0
  116. package/packages/scrabble-solver/src/i18n/en.json +2 -0
  117. package/packages/scrabble-solver/src/i18n/es.json +2 -0
  118. package/packages/scrabble-solver/src/i18n/fa.json +2 -0
  119. package/packages/scrabble-solver/src/i18n/fr.json +2 -0
  120. package/packages/scrabble-solver/src/i18n/pl.json +2 -0
  121. package/packages/scrabble-solver/src/icons/CardChecklist.svg +5 -0
  122. package/packages/scrabble-solver/src/icons/Check.svg +2 -2
  123. package/packages/scrabble-solver/src/icons/ChevronDown.svg +4 -0
  124. package/packages/scrabble-solver/src/icons/CrossCircleFill.svg +4 -0
  125. package/packages/scrabble-solver/src/icons/{CrossFill.svg → CrossSquareFill.svg} +0 -0
  126. package/packages/scrabble-solver/src/icons/ExclamationTriangleFill.svg +4 -0
  127. package/packages/scrabble-solver/src/icons/InfoCircleFill.svg +4 -0
  128. package/packages/scrabble-solver/src/icons/List.svg +4 -0
  129. package/packages/scrabble-solver/src/icons/Search.svg +4 -0
  130. package/packages/scrabble-solver/src/icons/index.ts +8 -2
  131. package/packages/scrabble-solver/src/{components/KeyMap/KeyMap.tsx → modals/KeyMapModal/KeyMapModal.tsx} +11 -13
  132. package/packages/scrabble-solver/src/{components/KeyMap → modals/KeyMapModal}/components/Mapping/Mapping.module.scss +0 -0
  133. package/packages/scrabble-solver/src/{components/KeyMap → modals/KeyMapModal}/components/Mapping/Mapping.tsx +0 -0
  134. package/packages/scrabble-solver/src/{components/KeyMap → modals/KeyMapModal}/components/Mapping/index.ts +0 -0
  135. package/packages/scrabble-solver/src/{components/KeyMap → modals/KeyMapModal}/components/index.ts +0 -0
  136. package/packages/scrabble-solver/src/modals/KeyMapModal/index.ts +1 -0
  137. package/packages/scrabble-solver/src/{components/KeyMap → modals/KeyMapModal}/keys.tsx +1 -2
  138. package/packages/scrabble-solver/src/modals/MenuModal/MenuModal.module.scss +46 -0
  139. package/packages/scrabble-solver/src/modals/MenuModal/MenuModal.tsx +54 -0
  140. package/packages/scrabble-solver/src/modals/MenuModal/index.ts +1 -0
  141. package/packages/scrabble-solver/src/modals/RemainingTilesModal/RemainingTilesModal.module.scss +28 -0
  142. package/packages/scrabble-solver/src/{components/RemainingTiles/RemainingTiles.tsx → modals/RemainingTilesModal/RemainingTilesModal.tsx} +14 -12
  143. package/packages/scrabble-solver/src/{components/RemainingTiles → modals/RemainingTilesModal/components/Character}/Character.module.scss +6 -2
  144. package/packages/scrabble-solver/src/{components/RemainingTiles → modals/RemainingTilesModal/components/Character}/Character.tsx +11 -3
  145. package/packages/scrabble-solver/src/modals/RemainingTilesModal/components/Character/index.ts +1 -0
  146. package/packages/scrabble-solver/src/modals/RemainingTilesModal/components/index.ts +1 -0
  147. package/packages/scrabble-solver/src/modals/RemainingTilesModal/index.ts +1 -0
  148. package/packages/scrabble-solver/src/modals/ResultsModal/ResultsModal.module.scss +7 -0
  149. package/packages/scrabble-solver/src/modals/ResultsModal/ResultsModal.tsx +58 -0
  150. package/packages/scrabble-solver/src/modals/ResultsModal/index.ts +1 -0
  151. package/packages/scrabble-solver/src/modals/SettingsModal/SettingsModal.tsx +34 -0
  152. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/AutoGroupTilesSetting/AutoGroupTilesSetting.module.scss +0 -0
  153. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -2
  154. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/AutoGroupTilesSetting/constants.ts +0 -0
  155. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/AutoGroupTilesSetting/index.ts +0 -0
  156. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/AutoGroupTilesSetting/lib.ts +0 -0
  157. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/ConfigSetting/ConfigSetting.module.scss +0 -0
  158. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/ConfigSetting/ConfigSetting.tsx +1 -2
  159. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/ConfigSetting/index.ts +0 -0
  160. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/ConfigSetting/options.ts +0 -0
  161. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/ConfigSetting/types.ts +0 -0
  162. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/LocaleSetting/LocaleSetting.module.scss +0 -0
  163. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/LocaleSetting/LocaleSetting.tsx +1 -2
  164. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/LocaleSetting/index.ts +0 -0
  165. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/LocaleSetting/options.ts +0 -0
  166. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/LocaleSetting/types.ts +0 -0
  167. package/packages/scrabble-solver/src/{components/Settings → modals/SettingsModal}/components/index.ts +0 -0
  168. package/packages/scrabble-solver/src/modals/SettingsModal/index.ts +1 -0
  169. package/packages/scrabble-solver/src/{components/Words/Words.module.scss → modals/WordsModal/WordsModal.module.scss} +7 -1
  170. package/packages/scrabble-solver/src/{components/Words/Words.tsx → modals/WordsModal/WordsModal.tsx} +10 -12
  171. package/packages/scrabble-solver/src/modals/WordsModal/index.ts +1 -0
  172. package/packages/scrabble-solver/src/modals/index.ts +6 -0
  173. package/packages/scrabble-solver/src/pages/index.module.scss +6 -4
  174. package/packages/scrabble-solver/src/pages/index.tsx +63 -26
  175. package/packages/scrabble-solver/src/parameters/index.ts +28 -6
  176. package/packages/scrabble-solver/src/state/createAppStore.ts +7 -4
  177. package/packages/scrabble-solver/src/styles/mixins.scss +15 -13
  178. package/packages/scrabble-solver/src/styles/variables.scss +15 -17
  179. package/packages/scrabble-solver/src/types/index.ts +2 -0
  180. package/packages/scrabble-solver/tsconfig.json +1 -0
  181. package/packages/solver/package-lock.json +2 -2
  182. package/packages/solver/package.json +5 -5
  183. package/packages/types/package-lock.json +3 -3
  184. package/packages/types/package.json +2 -2
  185. package/packages/word-definitions/package-lock.json +8 -8
  186. package/packages/word-definitions/package.json +2 -2
  187. package/packages/word-lists/package-lock.json +2 -2
  188. package/packages/word-lists/package.json +2 -2
  189. package/packages/scrabble-solver/.next/cache/webpack/client-development/7.pack_ +0 -0
  190. package/packages/scrabble-solver/.next/static/FJkPF91uL-OCAJKTTpVSP/_buildManifest.js +0 -1
  191. package/packages/scrabble-solver/.next/static/chunks/361-d16f336a9752a55a.js +0 -1
  192. package/packages/scrabble-solver/.next/static/chunks/724-eb48df4d1ba3df8b.js +0 -5
  193. package/packages/scrabble-solver/.next/static/chunks/pages/_app-959e495f0f221247.js +0 -24
  194. package/packages/scrabble-solver/.next/static/chunks/pages/index-1e30dafa41bddb80.js +0 -1
  195. package/packages/scrabble-solver/.next/static/css/aafd07997120f1e4.css +0 -1
  196. package/packages/scrabble-solver/.next/static/css/cb5b206454513f3c.css +0 -1
  197. package/packages/scrabble-solver/.next/static/css/eb9d57f7103525ab.css +0 -1
  198. package/packages/scrabble-solver/src/components/KeyMap/index.ts +0 -1
  199. package/packages/scrabble-solver/src/components/RemainingTiles/RemainingTiles.module.scss +0 -16
  200. package/packages/scrabble-solver/src/components/RemainingTiles/index.ts +0 -1
  201. package/packages/scrabble-solver/src/components/Screen/index.ts +0 -1
  202. package/packages/scrabble-solver/src/components/Settings/Settings.tsx +0 -35
  203. package/packages/scrabble-solver/src/components/Settings/index.ts +0 -1
  204. package/packages/scrabble-solver/src/components/Sidebar/index.ts +0 -1
  205. package/packages/scrabble-solver/src/components/Splash/index.ts +0 -1
  206. package/packages/scrabble-solver/src/components/Words/index.ts +0 -1
  207. package/packages/scrabble-solver/src/hooks/useIsTablet.ts +0 -10
  208. package/packages/scrabble-solver/src/icons/Play.svg +0 -4
@@ -1,7 +1,7 @@
1
1
  import { FunctionComponent } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
 
4
- import { Play } from 'icons';
4
+ import { Search } from 'icons';
5
5
  import {
6
6
  selectAreResultsOutdated,
7
7
  selectIsLoading,
@@ -13,9 +13,11 @@ import {
13
13
 
14
14
  import Button from '../Button';
15
15
 
16
- import styles from './Results.module.scss';
16
+ interface Props {
17
+ className?: string;
18
+ }
17
19
 
18
- const SolveButton: FunctionComponent = () => {
20
+ const SolveButton: FunctionComponent<Props> = ({ className }) => {
19
21
  const dispatch = useDispatch();
20
22
  const translate = useTranslate();
21
23
  const isLoading = useTypedSelector(selectIsLoading);
@@ -23,17 +25,17 @@ const SolveButton: FunctionComponent = () => {
23
25
  const isOutdated = useTypedSelector(selectAreResultsOutdated);
24
26
  const hasTiles = rack.some((tile) => tile !== null);
25
27
 
26
- const handleRefresh = () => {
28
+ const handleClick = () => {
27
29
  dispatch(solveSlice.actions.submit());
28
30
  };
29
31
 
30
32
  return (
31
33
  <Button
32
- className={styles.outdatedButton}
34
+ className={className}
33
35
  disabled={isLoading || !isOutdated || !hasTiles}
34
- Icon={Play}
36
+ Icon={Search}
35
37
  type="submit"
36
- onClick={handleRefresh}
38
+ onClick={handleClick}
37
39
  >
38
40
  {translate('results.solve')}
39
41
  </Button>
@@ -3,7 +3,7 @@ import { ResultColumn } from 'types';
3
3
  import styles from './Results.module.scss';
4
4
  import { Column } from './types';
5
5
 
6
- const getColumns = (options: { consonants: boolean; vowels: boolean }): Column[] => {
6
+ const getLocaleColumns = (options: { consonants: boolean; vowels: boolean }): Column[] => {
7
7
  const { consonants, vowels } = options;
8
8
  const columns: Column[] = [
9
9
  {
@@ -55,4 +55,4 @@ const getColumns = (options: { consonants: boolean; vowels: boolean }): Column[]
55
55
  return columns;
56
56
  };
57
57
 
58
- export default getColumns;
58
+ export default getLocaleColumns;
@@ -1,3 +1,6 @@
1
+ import { Result } from '@scrabble-solver/types';
2
+ import { FocusEvent, MouseEvent } from 'react';
3
+
1
4
  import { ResultColumn, TranslationKey } from 'types';
2
5
 
3
6
  export interface Column {
@@ -5,3 +8,16 @@ export interface Column {
5
8
  id: ResultColumn;
6
9
  translationKey: TranslationKey;
7
10
  }
11
+
12
+ export interface ResultCallbacks {
13
+ onBlur?: (result: Result, event: FocusEvent) => void;
14
+ onClick?: (result: Result, event: MouseEvent) => void;
15
+ onFocus?: (result: Result, event: FocusEvent) => void;
16
+ onMouseEnter?: (result: Result, event: MouseEvent) => void;
17
+ onMouseLeave?: (result: Result, event: MouseEvent) => void;
18
+ }
19
+
20
+ export interface ResultData extends ResultCallbacks {
21
+ highlightedIndex?: number;
22
+ results: Result[];
23
+ }
@@ -0,0 +1,44 @@
1
+ import { useMediaQuery } from 'hooks';
2
+ import { LOCALE_FEATURES } from 'i18n';
3
+ import { selectLocale, useTypedSelector } from 'state';
4
+ import { ResultColumn } from 'types';
5
+
6
+ import getLocaleColumns from './getLocaleColumns';
7
+ import { Column } from './types';
8
+
9
+ const COLUMNS_XS = [ResultColumn.Word, ResultColumn.Points];
10
+
11
+ const COLUMNS_S = [...COLUMNS_XS, ResultColumn.BlanksCount, ResultColumn.WordsCount];
12
+
13
+ const COLUMNS_M = [...COLUMNS_XS];
14
+
15
+ const COLUMNS_L = [...COLUMNS_XS];
16
+
17
+ const useColumns = (): Column[] => {
18
+ const locale = useTypedSelector(selectLocale);
19
+ const localeColumns = getLocaleColumns(LOCALE_FEATURES[locale]);
20
+ const isLessThanXs = useMediaQuery('<xs');
21
+ const isLessThanS = useMediaQuery('<s');
22
+ const isLessThanM = useMediaQuery('<m');
23
+ const isLessThanL = useMediaQuery('<l');
24
+
25
+ if (isLessThanXs) {
26
+ return localeColumns.filter((column) => COLUMNS_XS.includes(column.id));
27
+ }
28
+
29
+ if (isLessThanS) {
30
+ return localeColumns.filter((column) => COLUMNS_S.includes(column.id));
31
+ }
32
+
33
+ if (isLessThanM) {
34
+ return localeColumns.filter((column) => COLUMNS_M.includes(column.id));
35
+ }
36
+
37
+ if (isLessThanL) {
38
+ return localeColumns.filter((column) => COLUMNS_L.includes(column.id));
39
+ }
40
+
41
+ return localeColumns;
42
+ };
43
+
44
+ export default useColumns;
@@ -1,9 +1,7 @@
1
1
  @import 'styles/mixins';
2
2
 
3
3
  .resultsInput {
4
- &:focus-within {
5
- @include focus-effect;
6
- }
4
+ @include focus-effect;
7
5
  }
8
6
 
9
7
  .input {
@@ -0,0 +1,10 @@
1
+ .sizer {
2
+ position: absolute;
3
+ top: 0;
4
+ right: 0;
5
+ bottom: 0;
6
+ left: 0;
7
+ width: 100%;
8
+ height: 100%;
9
+ visibility: hidden;
10
+ }
@@ -0,0 +1,10 @@
1
+ import classNames from 'classnames';
2
+ import { forwardRef, HTMLProps } from 'react';
3
+
4
+ import styles from './Sizer.module.scss';
5
+
6
+ const Sizer = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(({ className, ...props }, ref) => (
7
+ <div className={classNames(styles.sizer, className)} ref={ref} {...props} />
8
+ ));
9
+
10
+ export default Sizer;
@@ -0,0 +1 @@
1
+ export { default } from './Sizer';
@@ -1,46 +1,60 @@
1
1
  @import 'styles/mixins';
2
2
 
3
3
  .solver {
4
+ --spacing: var(--spacing--xl);
5
+
6
+ position: relative;
7
+ margin: 0 var(--spacing);
4
8
  display: flex;
5
9
  flex-direction: column;
6
- height: 100%;
7
- }
8
10
 
9
- .contentWrapper {
10
- $board-size: 15;
11
- $tile-size-max: 60px;
12
- $tile-border-size: 1px;
11
+ @include media('<xl') {
12
+ --spacing: var(--spacing--l);
13
+ }
13
14
 
14
- flex: 1;
15
- padding: 0 var(--spacing--xl);
16
- max-height: $board-size * ($tile-size-max + $tile-border-size) + $tile-border-size;
15
+ @include media('<l', 'touch') {
16
+ margin-bottom: calc(3 * var(--spacing--l) + var(--button--icon--size));
17
+ }
18
+
19
+ @include media('<xs', 'touch') {
20
+ margin-bottom: calc(1 * var(--spacing--m) + 2 * var(--spacing--l) + var(--button--icon--size));
21
+ }
17
22
  }
18
23
 
19
- .content {
24
+ .container {
25
+ position: relative;
20
26
  display: flex;
21
27
  align-items: center;
22
28
  justify-content: center;
23
- height: 100%;
24
- gap: var(--spacing--xl);
29
+ }
25
30
 
26
- @include tablet {
27
- gap: var(--spacing--l);
31
+ .content {
32
+ display: grid;
33
+ grid-template-columns: minmax(0, 1fr) var(--solver-column--width);
34
+ gap: var(--spacing);
35
+ margin: 0 auto;
36
+
37
+ @include media('<l') {
38
+ grid-template-columns: 1fr;
28
39
  }
29
40
  }
30
41
 
31
42
  .boardContainer {
32
- display: flex;
33
43
  position: relative;
34
44
  }
35
45
 
36
- .sidebar {
46
+ .board {
47
+ margin: 0 auto;
48
+ }
49
+
50
+ .column {
37
51
  display: flex;
38
52
  flex-direction: column;
39
- flex: 0 0 var(--sidebar--width);
40
- gap: var(--spacing--xl);
53
+ flex: 0 0 var(--solver-column--width);
54
+ gap: var(--spacing);
41
55
 
42
- @include tablet {
43
- gap: var(--spacing--l);
56
+ @include media('<l') {
57
+ display: none;
44
58
  }
45
59
  }
46
60
 
@@ -63,17 +77,24 @@
63
77
  position: relative;
64
78
  }
65
79
 
66
- .rackContainer {
67
- position: relative;
68
- z-index: 1;
80
+ .bottomContainer {
69
81
  flex: 0 0 auto;
70
82
  display: flex;
71
83
  justify-content: center;
72
- margin: var(--spacing--xl) var(--spacing--l);
84
+ }
73
85
 
74
- @include tablet {
75
- margin: var(--spacing--l);
76
- }
86
+ .bottomContent {
87
+ display: inline-flex;
88
+ flex-direction: column;
89
+ align-items: center;
90
+ gap: var(--spacing);
91
+ margin: var(--spacing) auto;
92
+ min-width: 0;
93
+ }
94
+
95
+ .rackContainer {
96
+ display: flex;
97
+ justify-content: center;
77
98
  }
78
99
 
79
100
  .rack {
@@ -83,3 +104,38 @@
83
104
  .submitInput {
84
105
  display: none;
85
106
  }
107
+
108
+ .controls {
109
+ width: 100%;
110
+ display: flex;
111
+ align-items: flex-start;
112
+ justify-content: center;
113
+ gap: var(--spacing--l);
114
+ }
115
+
116
+ .resultCandidatePicker {
117
+ flex: 1;
118
+ }
119
+
120
+ .apply {
121
+ flex: 0 0 auto;
122
+ }
123
+
124
+ .solve {
125
+ --spacing: var(--spacing--l);
126
+
127
+ position: fixed;
128
+ bottom: var(--spacing);
129
+
130
+ @include media('<xs') {
131
+ --spacing: var(--spacing--m);
132
+ }
133
+
134
+ [dir='ltr'] & {
135
+ right: var(--spacing);
136
+ }
137
+
138
+ [dir='rtl'] & {
139
+ left: var(--spacing);
140
+ }
141
+ }
@@ -1,56 +1,139 @@
1
+ import { Result } from '@scrabble-solver/types';
1
2
  import classNames from 'classnames';
2
- import { FormEvent, FunctionComponent } from 'react';
3
+ import { FormEvent, FunctionComponent, useEffect, useMemo } from 'react';
3
4
  import { useDispatch } from 'react-redux';
4
5
  import { useMeasure } from 'react-use';
5
6
 
6
- import { useIsTablet } from 'hooks';
7
- import { getCellSize } from 'lib';
8
- import { COMPONENTS_SPACING, COMPONENTS_SPACING_MOBILE, DICTIONARY_HEIGHT } from 'parameters';
9
- import { selectConfig, solveSlice, useTypedSelector } from 'state';
7
+ import { useIsTouchDevice, useMediaQuery } from 'hooks';
8
+ import {
9
+ BOARD_TILE_SIZE_MAX,
10
+ BOARD_TILE_SIZE_MIN,
11
+ BORDER_WIDTH,
12
+ COLUMN_MIN_HEIGHT,
13
+ COMPONENTS_SPACING,
14
+ COMPONENTS_SPACING_SMALL,
15
+ DICTIONARY_HEIGHT,
16
+ RACK_TILE_SIZE_MAX,
17
+ } from 'parameters';
18
+ import {
19
+ resultsSlice,
20
+ selectAreResultsOutdated,
21
+ selectConfig,
22
+ selectResultCandidate,
23
+ selectSolveError,
24
+ selectSortedFilteredResults,
25
+ selectSortedResults,
26
+ solveSlice,
27
+ useTranslate,
28
+ useTypedSelector,
29
+ } from 'state';
10
30
 
11
31
  import Board from '../Board';
12
32
  import Dictionary from '../Dictionary';
13
33
  import DictionaryInput from '../DictionaryInput';
14
34
  import Rack from '../Rack';
35
+ import ResultCandidatePicker from '../ResultCandidatePicker';
15
36
  import Results from '../Results';
16
37
  import Well from '../Well';
17
38
 
39
+ import { ApplyButton, EmptyState, SolveButton } from './components';
18
40
  import styles from './Solver.module.scss';
19
41
 
20
42
  interface Props {
21
43
  className?: string;
44
+ height: number;
45
+ width: number;
46
+ onShowResults: () => void;
22
47
  }
23
48
 
24
- const Solver: FunctionComponent<Props> = ({ className }) => {
49
+ // eslint-disable-next-line max-statements
50
+ const Solver: FunctionComponent<Props> = ({ className, height, width, onShowResults }) => {
25
51
  const dispatch = useDispatch();
26
- const isTablet = useIsTablet();
27
- const [boardRef, { height: boardHeight }] = useMeasure<HTMLDivElement>();
28
- const [contentRef, { height: contentHeight, width: contentWidth }] = useMeasure<HTMLDivElement>();
29
- const [resultsContainerRef, { height: resultsContainerHeight, width: resultsContainerWidth }] =
30
- useMeasure<HTMLDivElement>();
52
+ const translate = useTranslate();
53
+ const isTouchDevice = useIsTouchDevice();
54
+ const [bottomContainerRef, { height: bottomContainerHeight }] = useMeasure<HTMLDivElement>();
55
+ const [resultsContainerRef, { width: resultsContainerWidth }] = useMeasure<HTMLDivElement>();
56
+ const isLessThanXl = useMediaQuery('<xl');
57
+ const isLessThanL = useMediaQuery('<l');
58
+ const componentsSpacing = isLessThanXl ? COMPONENTS_SPACING_SMALL : COMPONENTS_SPACING;
59
+ const maxBoardWidth = width - resultsContainerWidth - (isLessThanL ? 0 : componentsSpacing) - 2 * componentsSpacing;
60
+ const maxBoardHeight = Math.max(height - bottomContainerHeight, isLessThanL ? 0 : COLUMN_MIN_HEIGHT);
31
61
  const config = useTypedSelector(selectConfig);
32
- const cellSize = getCellSize(config, contentWidth - resultsContainerWidth, contentHeight);
33
- const componentsSpacing = isTablet ? COMPONENTS_SPACING_MOBILE : COMPONENTS_SPACING;
34
- const resultsHeight = boardHeight - DICTIONARY_HEIGHT - componentsSpacing;
62
+ const resultCandidate = useTypedSelector(selectResultCandidate);
63
+ const isOutdated = useTypedSelector(selectAreResultsOutdated);
64
+ const allResults = useTypedSelector(selectSortedResults);
65
+ const error = useTypedSelector(selectSolveError);
66
+ const results = useTypedSelector(selectSortedFilteredResults);
67
+ const [bestResult] = results || [];
68
+ const cellWidth = (maxBoardWidth - (config.boardWidth + 1) * BORDER_WIDTH) / config.boardWidth;
69
+ const cellHeight = (maxBoardHeight - (config.boardHeight + 1) * BORDER_WIDTH) / config.boardHeight;
70
+ const cellSize = Math.min(cellWidth, cellHeight);
71
+ const cellSizeSafe = Math.min(Math.max(cellSize, BOARD_TILE_SIZE_MIN), BOARD_TILE_SIZE_MAX);
72
+ const tileSize = Math.min((maxBoardWidth - 2 * BORDER_WIDTH) / config.maximumCharactersCount, RACK_TILE_SIZE_MAX);
73
+ const boardSize = (cellSizeSafe + BORDER_WIDTH) * Math.max(config.boardWidth, config.boardHeight) + BORDER_WIDTH;
74
+ const resultsHeight = boardSize - DICTIONARY_HEIGHT - componentsSpacing - 4 * BORDER_WIDTH;
75
+ const maxControlsWidth = tileSize * config.maximumCharactersCount + 2 * BORDER_WIDTH;
76
+ const touchCallbacks = useMemo(
77
+ () => ({
78
+ onClick: (result: Result) => {
79
+ const isSelected = result === resultCandidate;
80
+
81
+ if (isSelected) {
82
+ dispatch(resultsSlice.actions.applyResult(result));
83
+ } else {
84
+ dispatch(resultsSlice.actions.changeResultCandidate(result));
85
+ }
86
+ },
87
+ }),
88
+ [dispatch, resultCandidate],
89
+ );
90
+ const mouseCallbacks = useMemo(
91
+ () => ({
92
+ onBlur: () => {
93
+ dispatch(resultsSlice.actions.changeResultCandidate(null));
94
+ },
95
+ onClick: (result: Result) => {
96
+ dispatch(resultsSlice.actions.applyResult(result));
97
+ },
98
+ onFocus: (result: Result) => {
99
+ dispatch(resultsSlice.actions.changeResultCandidate(result));
100
+ },
101
+ onMouseEnter: (result: Result) => {
102
+ dispatch(resultsSlice.actions.changeResultCandidate(result));
103
+ },
104
+ onMouseLeave: () => {
105
+ dispatch(resultsSlice.actions.changeResultCandidate(null));
106
+ },
107
+ }),
108
+ [dispatch],
109
+ );
110
+ const callbacks = isTouchDevice ? touchCallbacks : mouseCallbacks;
35
111
 
36
112
  const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
37
113
  event.preventDefault();
114
+ onShowResults();
38
115
  dispatch(solveSlice.actions.submit());
39
116
  };
40
117
 
118
+ useEffect(() => {
119
+ if (bestResult) {
120
+ dispatch(resultsSlice.actions.changeResultCandidate(bestResult));
121
+ }
122
+ }, [bestResult, dispatch]);
123
+
41
124
  return (
42
125
  <div className={classNames(styles.solver, className)}>
43
- <div className={styles.contentWrapper}>
44
- <div className={styles.content} ref={contentRef}>
126
+ <div className={styles.container}>
127
+ <div className={styles.content}>
45
128
  <form className={styles.boardContainer} onSubmit={handleSubmit}>
46
- {contentWidth > 0 && <Board cellSize={cellSize} innerRef={boardRef} />}
129
+ <Board cellSize={cellSizeSafe} className={styles.board} />
47
130
  <input className={styles.submitInput} tabIndex={-1} type="submit" />
48
131
  </form>
49
132
 
50
- <div className={styles.sidebar} style={{ height: boardHeight + 1 }}>
133
+ <div className={styles.column}>
51
134
  <Well className={styles.resultsContainer} ref={resultsContainerRef}>
52
- {resultsContainerWidth > 0 && resultsContainerHeight > 0 && (
53
- <Results height={resultsHeight} width={resultsContainerWidth} />
135
+ {resultsContainerWidth > 0 && resultsHeight > 0 && (
136
+ <Results callbacks={callbacks} height={resultsHeight} width={resultsContainerWidth} />
54
137
  )}
55
138
  </Well>
56
139
 
@@ -64,10 +147,60 @@ const Solver: FunctionComponent<Props> = ({ className }) => {
64
147
  </div>
65
148
  </div>
66
149
 
67
- <form className={styles.rackContainer} onSubmit={handleSubmit}>
68
- <Rack className={styles.rack} />
69
- <input className={styles.submitInput} tabIndex={-1} type="submit" />
70
- </form>
150
+ <div className={styles.bottomContainer} ref={bottomContainerRef}>
151
+ <div className={styles.bottomContent}>
152
+ <form className={styles.rackContainer} onSubmit={handleSubmit}>
153
+ <Rack className={styles.rack} tileSize={tileSize} />
154
+ <input className={styles.submitInput} tabIndex={-1} type="submit" />
155
+ </form>
156
+
157
+ {isLessThanL && (
158
+ <div className={styles.controls} style={{ maxWidth: maxControlsWidth }}>
159
+ {typeof error !== 'undefined' && (
160
+ <EmptyState variant="error" onClick={onShowResults}>
161
+ {error.message}
162
+ </EmptyState>
163
+ )}
164
+
165
+ {typeof error === 'undefined' && typeof results === 'undefined' && (
166
+ <EmptyState variant="info" onClick={onShowResults}>
167
+ {translate('results.empty-state.uninitialized')}
168
+ </EmptyState>
169
+ )}
170
+
171
+ {typeof error === 'undefined' && typeof results !== 'undefined' && typeof allResults !== 'undefined' && (
172
+ <>
173
+ {isOutdated && (
174
+ <EmptyState variant="info" onClick={onShowResults}>
175
+ {translate('results.empty-state.outdated')}
176
+ </EmptyState>
177
+ )}
178
+
179
+ {!isOutdated && (
180
+ <>
181
+ {allResults.length === 0 && (
182
+ <EmptyState variant="warning" onClick={onShowResults}>
183
+ {translate('results.empty-state.no-results')}
184
+ </EmptyState>
185
+ )}
186
+
187
+ {allResults.length > 0 && resultCandidate && (
188
+ <ResultCandidatePicker className={styles.resultCandidatePicker} onClick={onShowResults} />
189
+ )}
190
+ </>
191
+ )}
192
+ </>
193
+ )}
194
+
195
+ {allResults && allResults.length > 0 && !isOutdated && (
196
+ <ApplyButton className={classNames(styles.submit, styles.apply)} />
197
+ )}
198
+ </div>
199
+ )}
200
+ </div>
201
+ </div>
202
+
203
+ {isTouchDevice && <SolveButton className={styles.solve} onClick={onShowResults} />}
71
204
  </div>
72
205
  );
73
206
  };
@@ -0,0 +1,5 @@
1
+ @import 'styles/mixins';
2
+
3
+ .icon {
4
+ transform: scale(1.5);
5
+ }
@@ -0,0 +1,37 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { useDispatch } from 'react-redux';
3
+
4
+ import { Check } from 'icons';
5
+ import { resultsSlice, selectResultCandidate, useTypedSelector } from 'state';
6
+
7
+ import Button from '../../../Button';
8
+
9
+ import styles from './ApplyButton.module.scss';
10
+
11
+ interface Props {
12
+ className?: string;
13
+ }
14
+
15
+ const ApplyButton: FunctionComponent<Props> = ({ className }) => {
16
+ const dispatch = useDispatch();
17
+ const resultCandidate = useTypedSelector(selectResultCandidate);
18
+
19
+ const handleClick = () => {
20
+ if (resultCandidate) {
21
+ dispatch(resultsSlice.actions.applyResult(resultCandidate));
22
+ }
23
+ };
24
+
25
+ return (
26
+ <Button
27
+ className={className}
28
+ disabled={!resultCandidate}
29
+ Icon={Check}
30
+ iconClassName={styles.icon}
31
+ type="submit"
32
+ onClick={handleClick}
33
+ />
34
+ );
35
+ };
36
+
37
+ export default ApplyButton;
@@ -0,0 +1 @@
1
+ export { default } from './ApplyButton';
@@ -0,0 +1,59 @@
1
+ .emptyState {
2
+ display: flex;
3
+ min-width: 0;
4
+ width: 100%;
5
+ border: var(--border);
6
+ border-radius: var(--border--radius);
7
+ background-color: white;
8
+ box-shadow: var(--box-shadow);
9
+ cursor: pointer;
10
+ text-align: center;
11
+ }
12
+
13
+ .iconContainer {
14
+ flex: 0 0 auto;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ padding: var(--spacing--m);
19
+ color: var(--color--foreground--secondary);
20
+
21
+ [dir='ltr'] & {
22
+ border-top-left-radius: var(--border--radius);
23
+ border-bottom-left-radius: var(--border--radius);
24
+ border-right: var(--border);
25
+ }
26
+
27
+ [dir='rtl'] & {
28
+ border-top-right-radius: var(--border--radius);
29
+ border-bottom-right-radius: var(--border--radius);
30
+ border-left: var(--border);
31
+ }
32
+
33
+ .error & {
34
+ background-color: var(--color--red--light);
35
+ color: var(--color--error);
36
+ }
37
+
38
+ .warning & {
39
+ background-color: var(--color--yellow--light);
40
+ color: var(--color--warning);
41
+ }
42
+
43
+ .info & {
44
+ background-color: var(--color--blue--light);
45
+ color: var(--color--info);
46
+ }
47
+ }
48
+
49
+ .icon {
50
+ $size: 24px;
51
+
52
+ width: $size;
53
+ height: $size;
54
+ }
55
+
56
+ .content {
57
+ flex: 1;
58
+ padding: var(--spacing--m) var(--spacing--l);
59
+ }