Enable use of <>-fragment (update dependencies).
Update style of solution-AND-usermarked fields.
This commit is contained in:
parent
4b300004b9
commit
ae5a58acf8
6 changed files with 13766 additions and 9763 deletions
23460
package-lock.json
generated
23460
package-lock.json
generated
File diff suppressed because it is too large
Load diff
16
package.json
16
package.json
|
@ -6,7 +6,7 @@
|
||||||
},
|
},
|
||||||
"main": "/index.js",
|
"main": "/index.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"react-scripts": "1.0.0"
|
"react-scripts": "^5.0.0"
|
||||||
},
|
},
|
||||||
"name": "a-maze-r",
|
"name": "a-maze-r",
|
||||||
"description": "The A-Maze-Ing Generator!",
|
"description": "The A-Maze-Ing Generator!",
|
||||||
|
@ -16,5 +16,17 @@
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test --env=jsdom",
|
"test": "react-scripts test --env=jsdom",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
src/App.js
30
src/App.js
|
@ -4,18 +4,26 @@ import InputForm from "./InputForm";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [maze, setMaze] = useState({});
|
const [maze, setMaze] = useState({});
|
||||||
let title;
|
const [showSolution, setShowSolution] = useState(false);
|
||||||
if (!!maze.grid) {
|
const hasValidMaze = !!maze.width &&
|
||||||
title = <h1>The Maze ({maze.width}x{maze.height}, ID: {maze.id})</h1>;
|
!!maze.height &&
|
||||||
} else {
|
!!maze.id &&
|
||||||
title = <span/>;
|
!!maze.grid;
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<InputForm handleResult={setMaze}/>
|
<InputForm handleResult={setMaze}/>
|
||||||
{title}
|
{hasValidMaze &&
|
||||||
<Maze labyrinth={maze}
|
<>
|
||||||
showSolution={true}/>
|
<h1>The Maze ({maze.width}x{maze.height}, ID: {maze.id})</h1>
|
||||||
</div>
|
<input type={"checkbox"}
|
||||||
|
onChange={(e) => {
|
||||||
|
setShowSolution(e.target.checked);
|
||||||
|
}}
|
||||||
|
id={"showSolution"}/><label htmlFor="showSolution">Show Solution</label>
|
||||||
|
<Maze labyrinth={maze}
|
||||||
|
showSolution={showSolution}/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ import React, {useState} from 'react';
|
||||||
import ValidatingInputNumberField from "./ValidatingInputNumberField";
|
import ValidatingInputNumberField from "./ValidatingInputNumberField";
|
||||||
|
|
||||||
export default function InputForm({handleResult}) {
|
export default function InputForm({handleResult}) {
|
||||||
const [width, setWidth] = useState(2);
|
const [width, setWidth] = useState(10);
|
||||||
const [height, setHeight] = useState(2);
|
const [height, setHeight] = useState(10);
|
||||||
const [id, setId] = useState(null);
|
const [id, setId] = useState(null);
|
||||||
const [status, setStatus] = useState("typing"); // "typing", "submitting"
|
const [status, setStatus] = useState("typing"); // "typing", "submitting"
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,8 @@ export default function ValidatingInputNumberField({
|
||||||
}
|
}
|
||||||
onChange(validation.value);
|
onChange(validation.value);
|
||||||
};
|
};
|
||||||
let errorComponent;
|
|
||||||
if (!!error) {
|
|
||||||
errorComponent = <span>{error}</span>;
|
|
||||||
} else {
|
|
||||||
errorComponent = <span/>;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<>
|
||||||
<label htmlFor={id}>{label}: </label>
|
<label htmlFor={id}>{label}: </label>
|
||||||
<input id={id}
|
<input id={id}
|
||||||
type={"number"}
|
type={"number"}
|
||||||
|
@ -41,7 +35,7 @@ export default function ValidatingInputNumberField({
|
||||||
max={constraints.max || null}
|
max={constraints.max || null}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
{errorComponent}
|
{!!error && <span>{error}</span>}
|
||||||
</span>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,12 @@ div.cell.bottom {
|
||||||
div.cell.left {
|
div.cell.left {
|
||||||
border-left-color: #000;
|
border-left-color: #000;
|
||||||
}
|
}
|
||||||
|
div.cell.user {
|
||||||
|
background-color: hotpink;
|
||||||
|
}
|
||||||
|
div.cell.solution.user {
|
||||||
|
background-color: darkred;
|
||||||
|
}
|
||||||
input:invalid {
|
input:invalid {
|
||||||
border-color: #f00;
|
border-color: #f00;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue