From 4fbca01d4668b3fdb860cdcfa6af6340b1e6a58a Mon Sep 17 00:00:00 2001 From: Robert Ferentz Date: Tue, 23 Jan 2024 09:37:30 +0200 Subject: [PATCH] more fixes --- index.html | 3 +-- src/App.module.css | 0 src/App.tsx | 5 ++--- src/GameMenu.tsx | 4 ++-- src/Header.module.css | 5 ++--- src/NumberSquare.module.css | 5 +++-- src/game/generate.ts | 26 +++----------------------- src/game/types.ts | 32 ++++++++++++++++++++++++++++++++ src/index.css | 12 +++++++----- tsconfig.json | 1 + 10 files changed, 53 insertions(+), 40 deletions(-) delete mode 100644 src/App.module.css create mode 100644 src/game/types.ts diff --git a/index.html b/index.html index 995c5bc..ab4fede 100644 --- a/index.html +++ b/index.html @@ -3,14 +3,13 @@ - + Solidoku - A Sudoku game in Solid.js
- diff --git a/src/App.module.css b/src/App.module.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/App.tsx b/src/App.tsx index a1a6693..2d452b8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,4 @@ import { createSignal, type Component, Show, onMount } from 'solid-js' -import styles from './App.module.css' import { GameContainer } from './GameContainer' import { GameMenu } from './GameMenu' import { gameController } from './stores/GameStore' @@ -13,7 +12,7 @@ const App: Component = () => { const [showGame, setShowGame] = createSignal(false) return ( -
+ <>
{ -
+ ) } diff --git a/src/GameMenu.tsx b/src/GameMenu.tsx index 42a3dd4..61ff7db 100644 --- a/src/GameMenu.tsx +++ b/src/GameMenu.tsx @@ -1,5 +1,5 @@ import { For, Show } from 'solid-js' -import { Difficulty } from './game/generate' +import { Difficulties, Difficulty } from './game/types' import styles from './GameMenu.module.css' import { gameController } from './stores/GameStore' @@ -9,7 +9,7 @@ type GameMenuProps = { onResumeGame: () => void } export const GameMenu = (props: GameMenuProps) => { - const levels = ['Easy', 'Medium', 'Hard'] as const + const levels = Object.keys(Difficulties) as Difficulty[] const handleNewGame = (difficulty: Difficulty) => { gameController.createGame(difficulty) props.onNewGame() diff --git a/src/Header.module.css b/src/Header.module.css index 64939c1..c4b79c6 100644 --- a/src/Header.module.css +++ b/src/Header.module.css @@ -6,15 +6,14 @@ background-color: var(--flame-orange); color: #fff; padding: 15px; - box-shadow: 0 0 3px 5px rgba(0, 0, 0, 0.2); + box-shadow: -5px 0 3px 5px rgba(0, 0, 0, 0.2); background: linear-gradient(to right, var(--fromColor), var(--toColor)); } .appName { display: inline-block; text-align: center; - font-size: 2rem; - font-family: Impact, sans-serif; + font-size: 2rem; text-shadow: 2px 2px 4px #111; margin:0; letter-spacing: 0.6rem; diff --git a/src/NumberSquare.module.css b/src/NumberSquare.module.css index 6c8e258..3cfa2e7 100644 --- a/src/NumberSquare.module.css +++ b/src/NumberSquare.module.css @@ -1,10 +1,11 @@ .square { + --sqw: min(calc((99vw - 1rem) / 9), 50px); border: 1px solid #999; display: flex; align-items: center; justify-content: center; - height: 50px; - width: 50px; + height: var(--sqw); + width: var(--sqw); font-size: 1.2rem; } diff --git a/src/game/generate.ts b/src/game/generate.ts index f21b005..27e66e7 100644 --- a/src/game/generate.ts +++ b/src/game/generate.ts @@ -1,31 +1,11 @@ +import { Difficulties, Difficulty, Game } from "./types" const br = [1, 2, 3, 4, 5, 6, 7, 8, 9] -export type Difficulty = 'Easy' | 'Medium' | 'Hard' + function getNumberToRemove(difficulty: Difficulty): number { - let min = 34, - max = 41 - switch (difficulty) { - case 'Hard': - min = 58 - max = 64 - break - case 'Medium': - min = 42 - max = 57 - break - case 'Easy': - default: - break - } + const { min, max } = Difficulties[difficulty] return Math.floor(Math.random() * (max - min)) + min } -export type Game = { - solution: number[][] - puzzle: number[][] - current: number[][] - mistakes: number - difficulty: Difficulty -} function shuffle(input: number[]) { // Shuffle the array using Fisher-Yates algorithm const row = [...input] diff --git a/src/game/types.ts b/src/game/types.ts new file mode 100644 index 0000000..c7f2e1d --- /dev/null +++ b/src/game/types.ts @@ -0,0 +1,32 @@ + +export const Difficulties = { + Easy: { + min: 36, + max: 40 + }, + Medium: { + min: 40, + max: 47 + }, + Hard: { + min: 48, + max:54 + }, + Expert: { + min: 55, + max: 59 + }, + Insane: { + min: 60, + max: 64 + } +} as const; +export type Difficulty = keyof typeof Difficulties + +export type Game = { + solution: number[][] + puzzle: number[][] + current: number[][] + mistakes: number + difficulty: Difficulty +} \ No newline at end of file diff --git a/src/index.css b/src/index.css index c3dea19..af47249 100644 --- a/src/index.css +++ b/src/index.css @@ -2,19 +2,21 @@ box-sizing: border-box; } body { + width: 100vw; margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; + font-family: Impact, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; --flame-red: #ff105f; --flame-orange: #ffad06; } +#root { + width: 100vw; +} + code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } @property --fromColor { diff --git a/tsconfig.json b/tsconfig.json index 249b273..8347580 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "forceConsistentCasingInFileNames": true, "strict": true, "target": "ESNext", "module": "ESNext",