Move to Typescript.
This commit is contained in:
parent
34618860a4
commit
ac964ddd3f
16 changed files with 482 additions and 119 deletions
32
src/App.tsx
Normal file
32
src/App.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import {useReducer} from 'react';
|
||||
import Maze from "./Maze.tsx";
|
||||
import InputForm from "./InputForm.tsx";
|
||||
import reduce from "./state/reducer.ts";
|
||||
import MessageBanner from "./MessageBanner.tsx";
|
||||
import {INITIAL_STATE} from "./state/state.ts";
|
||||
import {actionToggledShowSolution} from "./state/action.ts";
|
||||
|
||||
export default function App() {
|
||||
const [state, dispatch] = useReducer(reduce, INITIAL_STATE);
|
||||
const hasValidMaze = !!state.maze;
|
||||
return (
|
||||
<>
|
||||
<MessageBanner state={state}
|
||||
dispatch={dispatch}/>
|
||||
<InputForm state={state}
|
||||
dispatch={dispatch}/>
|
||||
{hasValidMaze &&
|
||||
<>
|
||||
<h1>The Maze ({state.maze.width}x{state.maze.height}, ID: {state.maze.id})</h1>
|
||||
<input type={"checkbox"}
|
||||
onChange={(e) => {
|
||||
dispatch(actionToggledShowSolution(e.target.checked));
|
||||
}}
|
||||
id={"showSolution"}/><label htmlFor="showSolution">Show Solution</label>
|
||||
<Maze state={state}
|
||||
dispatch={dispatch}/>
|
||||
</>
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue