@scrabble-solver/scrabble-solver 2.15.24 → 2.16.0-alpha.0
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 +9 -9
- package/.next/cache/.previewinfo +1 -1
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +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/client-production/index.pack.old +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/.next/diagnostics/framework.json +1 -1
- package/.next/prerender-manifest.json +4 -4
- package/.next/required-server-files.js +2 -1
- package/.next/required-server-files.json +2 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/30.js +1 -1
- package/.next/server/chunks/712.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
- package/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
- package/.next/server/pages/api/solve.js +1 -1
- package/.next/server/pages/api/solve.js.nft.json +1 -1
- package/.next/server/pages/api/verify.js.nft.json +1 -1
- package/.next/server/pages/api/visit.js.nft.json +1 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/server/pages/not-found.html +1 -1
- package/.next/server/webpack-api-runtime.js +1 -1
- package/.next/static/{f_g0t0jBAscXxDrNYOuV0 → HFiEUpdZIGYd_XKb5mCLZ}/_buildManifest.js +1 -1
- package/.next/static/chunks/{main-ca07941c8a544c9a.js → main-65a5015b46ca9827.js} +1 -1
- package/.next/static/chunks/pages/{_app-369e5cb907606ad4.js → _app-9c9aaea7b6881765.js} +4 -4
- package/.next/static/chunks/pages/{index-08b3b0a754095919.js → index-e9ea63e97865edcf.js} +1 -1
- package/.next/static/css/{500cdc9a24075d91.css → 78726ae7cf7a5497.css} +1 -1
- package/.next/trace +21 -21
- package/.next/trace-build +1 -1
- package/README.md +3 -3
- package/next.config.js +1 -0
- package/package.json +12 -11
- package/src/@types/scss.d.ts +5 -0
- package/src/components/Board/Board.module.scss +2 -2
- package/src/components/Board/components/Actions/Actions.module.scss +1 -1
- package/src/components/Board/components/Cell/Cell.module.scss +26 -6
- package/src/components/Board/components/InputPrompt/InputPrompt.module.scss +1 -1
- package/src/components/Button/Button.module.scss +1 -1
- package/src/components/Dictionary/Dictionary.module.scss +1 -1
- package/src/components/DictionaryInput/DictionaryInput.module.scss +1 -1
- package/src/components/IconButton/IconButton.module.scss +1 -1
- package/src/components/Loading/Loading.module.scss +1 -1
- package/src/components/Modal/Modal.module.scss +1 -1
- package/src/components/Modal/Modal.tsx +0 -1
- package/src/components/NotFound/NotFound.module.scss +1 -1
- package/src/components/PlainTiles/PlainTiles.module.scss +1 -1
- package/src/components/Rack/Rack.module.scss +11 -6
- package/src/components/Rack/components/InputPrompt/InputPrompt.module.scss +1 -1
- package/src/components/Rack/components/RackTile/RackTile.module.scss +1 -1
- package/src/components/Radio/Radio.module.scss +1 -1
- package/src/components/Results/Results.module.scss +1 -1
- package/src/components/ResultsInput/ResultsInput.module.scss +1 -1
- package/src/components/Solver/Solver.module.scss +1 -1
- package/src/components/Solver/components/InsertButton/InsertButton.module.scss +1 -1
- package/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.module.scss +1 -1
- package/src/components/Spinner/Spinner.module.scss +1 -1
- package/src/components/Tile/Tile.module.scss +1 -1
- package/src/hooks/useLocalStorage.ts +4 -52
- package/src/hooks/useMedia.ts +0 -1
- package/src/lib/isMac.ts +1 -1
- package/src/modals/MenuModal/MenuModal.module.scss +1 -1
- 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/LocaleSetting/LocaleSetting.module.scss +1 -1
- package/src/pages/_app.tsx +0 -1
- package/src/parameters/index.ts +48 -47
- package/src/sdk/fetchJson.ts +3 -7
- package/src/service-worker/index.ts +0 -1
- package/src/service-worker/routeSolveRequests.ts +18 -12
- package/src/state/board/slice.ts +6 -4
- package/src/state/localStorage.ts +42 -52
- package/src/state/sagas.ts +1 -2
- package/src/state/settings/initialState.ts +7 -7
- package/src/styles/_tokens.scss +59 -0
- package/src/styles/global.scss +3 -3
- package/src/styles/mixins.scss +13 -12
- package/src/styles/variables.module.scss +53 -0
- package/src/styles/variables.scss +44 -41
- package/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- /package/.next/static/{f_g0t0jBAscXxDrNYOuV0 → HFiEUpdZIGYd_XKb5mCLZ}/_ssgManifest.js +0 -0
package/src/parameters/index.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
+
import variables from '@/styles/variables.module.scss';
|
|
1
2
|
import { ResultColumnId } from '@/types';
|
|
2
3
|
|
|
3
4
|
export const BREAKPOINTS = {
|
|
4
|
-
xs:
|
|
5
|
-
s:
|
|
6
|
-
m:
|
|
7
|
-
l:
|
|
8
|
-
xl:
|
|
5
|
+
xs: Number(variables.breakpointXs),
|
|
6
|
+
s: Number(variables.breakpointS),
|
|
7
|
+
m: Number(variables.breakpointM),
|
|
8
|
+
l: Number(variables.breakpointL),
|
|
9
|
+
xl: Number(variables.breakpointXl),
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export const TRANSITION = 'var(--transition)';
|
|
12
13
|
|
|
13
14
|
export const GITHUB_PROJECT_URL = 'https://github.com/kamilmielnik/scrabble-solver';
|
|
14
15
|
|
|
15
|
-
export const TRANSITION_DURATION =
|
|
16
|
-
export const TRANSITION_DURATION_LONG =
|
|
17
|
-
|
|
18
|
-
export const COLOR_BLUE =
|
|
19
|
-
export const COLOR_GREEN =
|
|
20
|
-
export const COLOR_RED =
|
|
21
|
-
export const COLOR_YELLOW =
|
|
22
|
-
|
|
23
|
-
export const COLOR_BONUS_CHARACTER_1 =
|
|
24
|
-
export const COLOR_BONUS_CHARACTER_2 =
|
|
25
|
-
export const COLOR_BONUS_CHARACTER_3 =
|
|
26
|
-
export const COLOR_BONUS_CHARACTER_5 =
|
|
27
|
-
export const COLOR_BONUS_CHARACTER_MULTIPLIER_2 =
|
|
28
|
-
export const COLOR_BONUS_CHARACTER_MULTIPLIER_3 =
|
|
29
|
-
export const COLOR_BONUS_CHARACTER_MULTIPLIER_4 =
|
|
30
|
-
export const COLOR_BONUS_START =
|
|
31
|
-
export const COLOR_BONUS_WORD_MULTIPLIER_2 =
|
|
32
|
-
export const COLOR_BONUS_WORD_MULTIPLIER_3 =
|
|
33
|
-
export const COLOR_BONUS_WORD_MULTIPLIER_4 =
|
|
34
|
-
export const COLOR_FILTERED =
|
|
35
|
-
export const COLOR_BACKGROUND =
|
|
16
|
+
export const TRANSITION_DURATION = Number(variables.transitionDuration);
|
|
17
|
+
export const TRANSITION_DURATION_LONG = Number(variables.transitionDurationLong);
|
|
18
|
+
|
|
19
|
+
export const COLOR_BLUE = variables.colorBlue;
|
|
20
|
+
export const COLOR_GREEN = variables.colorGreen;
|
|
21
|
+
export const COLOR_RED = variables.colorRed;
|
|
22
|
+
export const COLOR_YELLOW = variables.colorYellow;
|
|
23
|
+
|
|
24
|
+
export const COLOR_BONUS_CHARACTER_1 = variables.colorYellowLight;
|
|
25
|
+
export const COLOR_BONUS_CHARACTER_2 = variables.colorGreenLight;
|
|
26
|
+
export const COLOR_BONUS_CHARACTER_3 = variables.colorBlueLight;
|
|
27
|
+
export const COLOR_BONUS_CHARACTER_5 = variables.colorRedLight;
|
|
28
|
+
export const COLOR_BONUS_CHARACTER_MULTIPLIER_2 = variables.colorBonusCharacterMultiplier2;
|
|
29
|
+
export const COLOR_BONUS_CHARACTER_MULTIPLIER_3 = variables.colorBonusCharacterMultiplier3;
|
|
30
|
+
export const COLOR_BONUS_CHARACTER_MULTIPLIER_4 = variables.colorBonusCharacterMultiplier4;
|
|
31
|
+
export const COLOR_BONUS_START = variables.colorVioletLight;
|
|
32
|
+
export const COLOR_BONUS_WORD_MULTIPLIER_2 = variables.colorBonusWordMultiplier2;
|
|
33
|
+
export const COLOR_BONUS_WORD_MULTIPLIER_3 = variables.colorBonusWordMultiplier3;
|
|
34
|
+
export const COLOR_BONUS_WORD_MULTIPLIER_4 = variables.colorBonusWordMultiplier4;
|
|
35
|
+
export const COLOR_FILTERED = variables.colorForegroundSecondary;
|
|
36
|
+
export const COLOR_BACKGROUND = variables.colorBackground;
|
|
36
37
|
|
|
37
38
|
export const COLOR_BONUS_CHARACTER: Record<number, string> = {
|
|
38
39
|
1: COLOR_BONUS_CHARACTER_1,
|
|
@@ -53,39 +54,41 @@ export const COLOR_BONUS_WORD: Record<number, string> = {
|
|
|
53
54
|
4: COLOR_BONUS_WORD_MULTIPLIER_4,
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
export const SPACING_XS =
|
|
57
|
-
export const SPACING_S =
|
|
58
|
-
export const SPACING_M =
|
|
59
|
-
export const SPACING_L =
|
|
60
|
-
export const SPACING_XL =
|
|
57
|
+
export const SPACING_XS = Number(variables.spacingXs);
|
|
58
|
+
export const SPACING_S = Number(variables.spacingS);
|
|
59
|
+
export const SPACING_M = Number(variables.spacingM);
|
|
60
|
+
export const SPACING_L = Number(variables.spacingL);
|
|
61
|
+
export const SPACING_XL = Number(variables.spacingXl);
|
|
61
62
|
|
|
62
63
|
export const COMPONENTS_SPACING = SPACING_XL;
|
|
63
64
|
export const COMPONENTS_SPACING_SMALL = SPACING_L;
|
|
64
65
|
|
|
66
|
+
export const RACK_TILE_SIZE_MAX = 80;
|
|
67
|
+
|
|
65
68
|
export const BOARD_CELL_ACTIONS_OFFSET = 3;
|
|
66
69
|
export const BOARD_CELL_BORDER_WIDTH = 1;
|
|
67
70
|
export const BOARD_TILE_FONT_SIZE_MIN = 14;
|
|
68
71
|
export const BOARD_TILE_FONT_SIZE_POINTS_MIN = 10;
|
|
69
|
-
export const BOARD_TILE_SIZE_MAX =
|
|
72
|
+
export const BOARD_TILE_SIZE_MAX = RACK_TILE_SIZE_MAX;
|
|
70
73
|
|
|
71
|
-
export const BORDER_COLOR =
|
|
72
|
-
export const BORDER_COLOR_LIGHT =
|
|
73
|
-
export const BORDER_RADIUS =
|
|
74
|
-
export const BORDER_WIDTH =
|
|
74
|
+
export const BORDER_COLOR = variables.borderColor;
|
|
75
|
+
export const BORDER_COLOR_LIGHT = variables.borderColorLight;
|
|
76
|
+
export const BORDER_RADIUS = Number(variables.borderRadius);
|
|
77
|
+
export const BORDER_WIDTH = Number(variables.borderWidth);
|
|
75
78
|
|
|
76
|
-
export const BUTTON_ICON_SIZE =
|
|
79
|
+
export const BUTTON_ICON_SIZE = Number(variables.buttonIconSize);
|
|
77
80
|
export const BUTTON_PADDING_VERTICAL = SPACING_M;
|
|
78
81
|
export const BUTTON_HEIGHT = BUTTON_ICON_SIZE + 2 * BUTTON_PADDING_VERTICAL + 2 * BORDER_WIDTH;
|
|
79
82
|
|
|
80
|
-
export const DICTIONARY_HEIGHT =
|
|
81
|
-
export const DICTIONARY_HEIGHT_MOBILE =
|
|
83
|
+
export const DICTIONARY_HEIGHT = Number(variables.dictionaryHeight);
|
|
84
|
+
export const DICTIONARY_HEIGHT_MOBILE = Number(variables.dictionaryHeightMobile);
|
|
82
85
|
|
|
83
86
|
export const LOGO_ASPECT_RATIO = 682 / 166;
|
|
84
|
-
export const LOGO_HEIGHT =
|
|
85
|
-
export const LOGO_HEIGHT_SMALL =
|
|
87
|
+
export const LOGO_HEIGHT = Number(variables.logoHeight);
|
|
88
|
+
export const LOGO_HEIGHT_SMALL = Number(variables.logoHeightSmall);
|
|
86
89
|
export const LOGO_SRC = '/logo.svg';
|
|
87
90
|
|
|
88
|
-
export const MODAL_WIDTH =
|
|
91
|
+
export const MODAL_WIDTH = Number(variables.modalWidth);
|
|
89
92
|
export const MODAL_HEADER_HEIGHT = 45;
|
|
90
93
|
|
|
91
94
|
export const NAV_PADDING = SPACING_L;
|
|
@@ -119,8 +122,6 @@ export const PLAIN_TILES_VERSION_TILE_SIZE = TILE_SIZE;
|
|
|
119
122
|
export const PROGRESS_COLOR_VALUE = 'var(--color--violet--light)';
|
|
120
123
|
export const PROGRESS_COLOR_BACKGROUND = 'var(--color--inactive)';
|
|
121
124
|
|
|
122
|
-
export const RACK_TILE_SIZE_MAX = 80;
|
|
123
|
-
|
|
124
125
|
export const REMAINING_TILES_TILE_SIZE = 50;
|
|
125
126
|
|
|
126
127
|
export const RESULTS_COLUMN_WIDTH: Record<ResultColumnId, number | undefined> = {
|
|
@@ -133,10 +134,10 @@ export const RESULTS_COLUMN_WIDTH: Record<ResultColumnId, number | undefined> =
|
|
|
133
134
|
[ResultColumnId.Word]: undefined,
|
|
134
135
|
[ResultColumnId.WordsCount]: 55,
|
|
135
136
|
};
|
|
136
|
-
export const RESULTS_ITEM_HEIGHT =
|
|
137
|
+
export const RESULTS_ITEM_HEIGHT = Number(variables.resultsItemHeight);
|
|
137
138
|
|
|
138
139
|
export const RESULTS_HEADER_HEIGHT = RESULTS_ITEM_HEIGHT;
|
|
139
140
|
|
|
140
|
-
export const SOLVER_COLUMN_WIDTH =
|
|
141
|
+
export const SOLVER_COLUMN_WIDTH = Number(variables.solverColumnWidth);
|
|
141
142
|
|
|
142
|
-
export const TEXT_INPUT_HEIGHT =
|
|
143
|
+
export const TEXT_INPUT_HEIGHT = Number(variables.textInputHeight);
|
package/src/sdk/fetchJson.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { fetch } from './fetch';
|
|
2
2
|
|
|
3
3
|
export const fetchJson = async <T>(input: RequestInfo | URL, init?: RequestInit): Promise<T> => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
headers: {
|
|
7
|
-
'Content-Type': 'application/json',
|
|
8
|
-
...init?.headers,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
4
|
+
const headers = new Headers(init?.headers);
|
|
5
|
+
headers.set('Content-Type', 'application/json');
|
|
11
6
|
|
|
7
|
+
const response = await fetch(input, { ...init, headers });
|
|
12
8
|
return response.json();
|
|
13
9
|
};
|
|
@@ -19,18 +19,6 @@ const MIN_MEASUREMENTS = 5;
|
|
|
19
19
|
const localDurations: number[] = [];
|
|
20
20
|
const serverDurations: number[] = [];
|
|
21
21
|
|
|
22
|
-
const isSlowDevice = (): boolean | undefined => {
|
|
23
|
-
if (localDurations.length < MIN_MEASUREMENTS || serverDurations.length < MIN_MEASUREMENTS) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const count = Math.min(localDurations.length, serverDurations.length);
|
|
28
|
-
const local = localDurations.slice(0, count).sort().slice(1, -1);
|
|
29
|
-
const server = serverDurations.slice(0, count).sort().slice(1, -1);
|
|
30
|
-
|
|
31
|
-
return average(local) > average(server);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
22
|
export const routeSolveRequests = () => {
|
|
35
23
|
registerRoute(
|
|
36
24
|
({ url }) => url.origin === location.origin && url.pathname === '/api/solve',
|
|
@@ -83,3 +71,21 @@ export const routeSolveRequests = () => {
|
|
|
83
71
|
'POST',
|
|
84
72
|
);
|
|
85
73
|
};
|
|
74
|
+
|
|
75
|
+
const isSlowDevice = (): boolean | undefined => {
|
|
76
|
+
if (localDurations.length < MIN_MEASUREMENTS || serverDurations.length < MIN_MEASUREMENTS) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const count = Math.min(localDurations.length, serverDurations.length);
|
|
81
|
+
const local = localDurations
|
|
82
|
+
.slice(0, count)
|
|
83
|
+
.sort((a, b) => a - b)
|
|
84
|
+
.slice(1, -1);
|
|
85
|
+
const server = localDurations
|
|
86
|
+
.slice(0, count)
|
|
87
|
+
.sort((a, b) => a - b)
|
|
88
|
+
.slice(1, -1);
|
|
89
|
+
|
|
90
|
+
return average(local) > average(server);
|
|
91
|
+
};
|
package/src/state/board/slice.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const boardSlice = createSlice({
|
|
|
16
16
|
const result = action.payload;
|
|
17
17
|
|
|
18
18
|
result.cells.forEach((cell) => {
|
|
19
|
-
newBoard.updateCell(cell.x, cell.y, () => new Cell({
|
|
19
|
+
newBoard.updateCell(cell.x, cell.y, () => new Cell({ isEmpty: false, tile: cell.tile, x: cell.x, y: cell.y }));
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
return newBoard;
|
|
@@ -34,7 +34,7 @@ export const boardSlice = createSlice({
|
|
|
34
34
|
const tile = isEmpty ? Tile.Null : new Tile({ character: value });
|
|
35
35
|
|
|
36
36
|
newBoard.updateCell(x, y, (cell) => {
|
|
37
|
-
return new Cell({
|
|
37
|
+
return new Cell({ isEmpty, tile, x: cell.x, y: cell.y });
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
return newBoard;
|
|
@@ -50,8 +50,10 @@ export const boardSlice = createSlice({
|
|
|
50
50
|
const { x, y } = action.payload;
|
|
51
51
|
|
|
52
52
|
newBoard.updateCell(x, y, (cell) => {
|
|
53
|
-
const tile = cell.isEmpty
|
|
54
|
-
|
|
53
|
+
const tile = cell.isEmpty
|
|
54
|
+
? cell.tile
|
|
55
|
+
: new Tile({ isBlank: !cell.tile.isBlank, character: cell.tile.character });
|
|
56
|
+
return new Cell({ isEmpty: cell.isEmpty, tile, x: cell.x, y: cell.y });
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
return newBoard;
|
|
@@ -1,28 +1,49 @@
|
|
|
1
|
-
import { Board, type BoardJson
|
|
1
|
+
import { Board, type BoardJson } from '@scrabble-solver/types';
|
|
2
2
|
import store2 from 'store2';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { Rack } from '@/types';
|
|
5
|
+
|
|
6
|
+
import type { SettingsState } from './settings/types';
|
|
5
7
|
|
|
6
|
-
const AUTO_GROUP_TILES = 'auto-group-tiles';
|
|
7
8
|
const BOARD = 'board';
|
|
8
|
-
const GAME_ID = 'config-id';
|
|
9
|
-
const INPUT_MODE = 'input-mode';
|
|
10
|
-
const REMOVE_CELL_FILTERS = 'remove-cell-filters';
|
|
11
|
-
const LOCALE = 'locale';
|
|
12
9
|
const RACK = 'rack';
|
|
13
|
-
const
|
|
10
|
+
const SETTINGS = 'settings';
|
|
11
|
+
|
|
12
|
+
const LEGACY_KEYS: Record<keyof SettingsState, string> = {
|
|
13
|
+
autoGroupTiles: 'auto-group-tiles',
|
|
14
|
+
game: 'config-id',
|
|
15
|
+
inputMode: 'input-mode',
|
|
16
|
+
locale: 'locale',
|
|
17
|
+
removeCellFilters: 'remove-cell-filters',
|
|
18
|
+
showCoordinates: 'show-coordinates',
|
|
19
|
+
};
|
|
14
20
|
|
|
15
21
|
const store = store2.namespace('scrabble-solver');
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Introduced in 2.15.26 on 2026/04/27.
|
|
25
|
+
* Life expectancy: 1y.
|
|
26
|
+
*/
|
|
27
|
+
const migrateLegacySettings = (): Partial<SettingsState> => {
|
|
28
|
+
const settings: Partial<SettingsState> = {};
|
|
29
|
+
let hasLegacy = false;
|
|
30
|
+
|
|
31
|
+
for (const [setting, legacyKey] of Object.entries(LEGACY_KEYS) as [keyof SettingsState, string][]) {
|
|
32
|
+
if (store.has(legacyKey)) {
|
|
33
|
+
settings[setting] = store.get(legacyKey);
|
|
34
|
+
store.remove(legacyKey);
|
|
35
|
+
hasLegacy = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (hasLegacy) {
|
|
40
|
+
store.set(SETTINGS, settings, true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return settings;
|
|
44
|
+
};
|
|
25
45
|
|
|
46
|
+
export const localStorage = {
|
|
26
47
|
getBoard(): Board | undefined {
|
|
27
48
|
const serialized = store.get(BOARD) as string | undefined;
|
|
28
49
|
return serialized ? Board.fromJson(JSON.parse(serialized) as BoardJson) : undefined;
|
|
@@ -33,30 +54,6 @@ export const localStorage = {
|
|
|
33
54
|
store.set(BOARD, serialized, true);
|
|
34
55
|
},
|
|
35
56
|
|
|
36
|
-
getGame(): Game | undefined {
|
|
37
|
-
return store.get(GAME_ID) as Game | undefined;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
setGame(game: Game | undefined): void {
|
|
41
|
-
store.set(GAME_ID, game, true);
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
getInputMode(): InputMode | undefined {
|
|
45
|
-
return store.get(INPUT_MODE) as InputMode | undefined;
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
setInputMode(inputMode: InputMode | undefined): void {
|
|
49
|
-
store.set(INPUT_MODE, inputMode, true);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
getLocale(): Locale | undefined {
|
|
53
|
-
return store.get(LOCALE) as Locale | undefined;
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
setLocale(locale: Locale | undefined): void {
|
|
57
|
-
store.set(LOCALE, locale, true);
|
|
58
|
-
},
|
|
59
|
-
|
|
60
57
|
getRack(): Rack | undefined {
|
|
61
58
|
return store.get(RACK) as Rack | undefined;
|
|
62
59
|
},
|
|
@@ -65,19 +62,12 @@ export const localStorage = {
|
|
|
65
62
|
store.set(RACK, rack, true);
|
|
66
63
|
},
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
setShowCoordinates(showCoordinates: ShowCoordinates | undefined): void {
|
|
73
|
-
store.set(SHOW_COORDINATES, showCoordinates, true);
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
getRemoveCellFilters(): RemoveCellFilters | undefined {
|
|
77
|
-
return store.get(REMOVE_CELL_FILTERS) as RemoveCellFilters | undefined;
|
|
65
|
+
getSettings(): Partial<SettingsState> {
|
|
66
|
+
const stored = store.get(SETTINGS) as Partial<SettingsState> | undefined;
|
|
67
|
+
return stored ?? migrateLegacySettings();
|
|
78
68
|
},
|
|
79
69
|
|
|
80
|
-
|
|
81
|
-
store.set(
|
|
70
|
+
setSettings(settings: SettingsState): void {
|
|
71
|
+
store.set(SETTINGS, settings, true);
|
|
82
72
|
},
|
|
83
73
|
};
|
package/src/state/sagas.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable max-lines
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
@@ -35,7 +35,6 @@ const memoizedFindWordDefinitions = memoize(findWordDefinitions);
|
|
|
35
35
|
|
|
36
36
|
// Can't conveniently type generators for sagas yet,
|
|
37
37
|
// see: https://github.com/microsoft/TypeScript/issues/43632
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
38
|
type AnyGenerator = Generator<any, any, any>;
|
|
40
39
|
|
|
41
40
|
export function* rootSaga(): AnyGenerator {
|
|
@@ -5,14 +5,14 @@ import { localStorage } from '../localStorage';
|
|
|
5
5
|
import { guessLocale } from './lib';
|
|
6
6
|
import type { SettingsState } from './types';
|
|
7
7
|
|
|
8
|
-
const localStorageAutoGroupTiles = localStorage.getAutoGroupTiles();
|
|
9
8
|
const isTouchScreen = typeof globalThis.matchMedia !== 'undefined' && globalThis.matchMedia('(hover: none)').matches;
|
|
10
9
|
|
|
11
10
|
export const settingsInitialState: SettingsState = {
|
|
12
|
-
autoGroupTiles:
|
|
13
|
-
game:
|
|
14
|
-
inputMode:
|
|
15
|
-
locale:
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
autoGroupTiles: null,
|
|
12
|
+
game: Game.Scrabble,
|
|
13
|
+
inputMode: isTouchScreen ? 'touchscreen' : 'keyboard',
|
|
14
|
+
locale: guessLocale(),
|
|
15
|
+
removeCellFilters: 'always',
|
|
16
|
+
showCoordinates: 'hidden',
|
|
17
|
+
...localStorage.getSettings(),
|
|
18
18
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
|
|
3
|
+
@function strip-unit($value) {
|
|
4
|
+
@return math.div($value, $value * 0 + 1);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
$breakpoint-xs: 480px;
|
|
8
|
+
$breakpoint-s: 768px;
|
|
9
|
+
$breakpoint-m: 992px;
|
|
10
|
+
$breakpoint-l: 1200px;
|
|
11
|
+
$breakpoint-xl: 1400px;
|
|
12
|
+
|
|
13
|
+
$border-color: #cdcdcd;
|
|
14
|
+
$border-color-light: #d9d9d9;
|
|
15
|
+
$border-radius: 5px;
|
|
16
|
+
$border-width: 1px;
|
|
17
|
+
|
|
18
|
+
$color-blue: #c7d8f9;
|
|
19
|
+
$color-blue-light: #dde4f6;
|
|
20
|
+
$color-green: #bae3ba;
|
|
21
|
+
$color-green-light: #d6ebd6;
|
|
22
|
+
$color-red: #f7c2aa;
|
|
23
|
+
$color-red-light: #fbe0d4;
|
|
24
|
+
$color-violet: #78387f;
|
|
25
|
+
$color-violet-light: #b284b8;
|
|
26
|
+
$color-yellow: #efe3ae;
|
|
27
|
+
$color-yellow-light: #f7f1d6;
|
|
28
|
+
|
|
29
|
+
$color-background: #f4f4f4;
|
|
30
|
+
$color-foreground: #222;
|
|
31
|
+
$color-foreground-secondary: #444;
|
|
32
|
+
$color-inactive: #cdcdcd;
|
|
33
|
+
|
|
34
|
+
$color-bonus-character-multiplier-2: #b8d5ed;
|
|
35
|
+
$color-bonus-character-multiplier-3: #86aed1;
|
|
36
|
+
$color-bonus-character-multiplier-4: #3477b2;
|
|
37
|
+
$color-bonus-word-multiplier-2: #fbc997;
|
|
38
|
+
$color-bonus-word-multiplier-3: #f19393;
|
|
39
|
+
$color-bonus-word-multiplier-4: #ed5e5e;
|
|
40
|
+
|
|
41
|
+
$spacing-xs: 2px;
|
|
42
|
+
$spacing-s: 5px;
|
|
43
|
+
$spacing-m: 10px;
|
|
44
|
+
$spacing-l: 20px;
|
|
45
|
+
$spacing-xl: 40px;
|
|
46
|
+
$spacing-xxl: 80px;
|
|
47
|
+
|
|
48
|
+
$transition-duration: 100ms;
|
|
49
|
+
$transition-duration-long: 250ms;
|
|
50
|
+
|
|
51
|
+
$button-icon-size: 24px;
|
|
52
|
+
$dictionary-height: 260px;
|
|
53
|
+
$dictionary-height-mobile: 110px;
|
|
54
|
+
$logo-height: 60px;
|
|
55
|
+
$logo-height-small: 48px;
|
|
56
|
+
$modal-width: 370px;
|
|
57
|
+
$results-item-height: 40px;
|
|
58
|
+
$solver-column-width: 580px;
|
|
59
|
+
$text-input-height: 40px;
|
package/src/styles/global.scss
CHANGED
package/src/styles/mixins.scss
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
@
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
$media-expressions: (
|
|
12
|
-
|
|
1
|
+
@use 'styles/tokens' as *;
|
|
2
|
+
|
|
3
|
+
@forward 'include-media' with (
|
|
4
|
+
$breakpoints: (
|
|
5
|
+
xs: $breakpoint-xs,
|
|
6
|
+
s: $breakpoint-s,
|
|
7
|
+
m: $breakpoint-m,
|
|
8
|
+
l: $breakpoint-l,
|
|
9
|
+
xl: $breakpoint-xl,
|
|
10
|
+
),
|
|
11
|
+
$media-expressions: (
|
|
12
|
+
touch: '(hover: none)',
|
|
13
|
+
)
|
|
13
14
|
);
|
|
14
15
|
|
|
15
16
|
@mixin scrollbars {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@use 'styles/tokens' as *;
|
|
2
|
+
|
|
3
|
+
:export {
|
|
4
|
+
breakpointXs: strip-unit($breakpoint-xs);
|
|
5
|
+
breakpointS: strip-unit($breakpoint-s);
|
|
6
|
+
breakpointM: strip-unit($breakpoint-m);
|
|
7
|
+
breakpointL: strip-unit($breakpoint-l);
|
|
8
|
+
breakpointXl: strip-unit($breakpoint-xl);
|
|
9
|
+
|
|
10
|
+
borderColor: $border-color;
|
|
11
|
+
borderColorLight: $border-color-light;
|
|
12
|
+
borderRadius: strip-unit($border-radius);
|
|
13
|
+
borderWidth: strip-unit($border-width);
|
|
14
|
+
|
|
15
|
+
colorBlue: $color-blue;
|
|
16
|
+
colorBlueLight: $color-blue-light;
|
|
17
|
+
colorGreen: $color-green;
|
|
18
|
+
colorGreenLight: $color-green-light;
|
|
19
|
+
colorRed: $color-red;
|
|
20
|
+
colorRedLight: $color-red-light;
|
|
21
|
+
colorVioletLight: $color-violet-light;
|
|
22
|
+
colorYellow: $color-yellow;
|
|
23
|
+
colorYellowLight: $color-yellow-light;
|
|
24
|
+
|
|
25
|
+
colorBackground: $color-background;
|
|
26
|
+
colorForegroundSecondary: $color-foreground-secondary;
|
|
27
|
+
|
|
28
|
+
colorBonusCharacterMultiplier2: $color-bonus-character-multiplier-2;
|
|
29
|
+
colorBonusCharacterMultiplier3: $color-bonus-character-multiplier-3;
|
|
30
|
+
colorBonusCharacterMultiplier4: $color-bonus-character-multiplier-4;
|
|
31
|
+
colorBonusWordMultiplier2: $color-bonus-word-multiplier-2;
|
|
32
|
+
colorBonusWordMultiplier3: $color-bonus-word-multiplier-3;
|
|
33
|
+
colorBonusWordMultiplier4: $color-bonus-word-multiplier-4;
|
|
34
|
+
|
|
35
|
+
spacingXs: strip-unit($spacing-xs);
|
|
36
|
+
spacingS: strip-unit($spacing-s);
|
|
37
|
+
spacingM: strip-unit($spacing-m);
|
|
38
|
+
spacingL: strip-unit($spacing-l);
|
|
39
|
+
spacingXl: strip-unit($spacing-xl);
|
|
40
|
+
|
|
41
|
+
transitionDuration: strip-unit($transition-duration);
|
|
42
|
+
transitionDurationLong: strip-unit($transition-duration-long);
|
|
43
|
+
|
|
44
|
+
buttonIconSize: strip-unit($button-icon-size);
|
|
45
|
+
dictionaryHeight: strip-unit($dictionary-height);
|
|
46
|
+
dictionaryHeightMobile: strip-unit($dictionary-height-mobile);
|
|
47
|
+
logoHeight: strip-unit($logo-height);
|
|
48
|
+
logoHeightSmall: strip-unit($logo-height-small);
|
|
49
|
+
modalWidth: strip-unit($modal-width);
|
|
50
|
+
resultsItemHeight: strip-unit($results-item-height);
|
|
51
|
+
solverColumnWidth: strip-unit($solver-column-width);
|
|
52
|
+
textInputHeight: strip-unit($text-input-height);
|
|
53
|
+
}
|