Skip to content

Commit 40dab0a

Browse files
committed
Add routes for the home and the tile game screen
1 parent 6377976 commit 40dab0a

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/components/app-selection/ApplicationSelection.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import ApplicationOptionComponent from './ApplicationOption';
55
import { useMouseWheel } from '../../hooks/listeners/useScrolling';
66
import { ApplicationPreview } from './ApplicationPreview';
77
import { openTab } from '../../utils';
8-
// import TileGameComponent from './components/tile-game/TileGame';
8+
import { useNavigate } from 'react-router';
99

1010
export default function ApplicationSelection(): ReactElement {
11+
const navigate = useNavigate();
12+
1113
const {
1214
chooseSelection,
1315
currentSelection,
@@ -20,7 +22,7 @@ export default function ApplicationSelection(): ReactElement {
2022
choice: AppChoice.PictureCards,
2123
name: 'Picture Cards',
2224
onSelect: () => {
23-
console.log('Selected Picture Cards');
25+
navigate('/picture-cards');
2426
},
2527
},
2628
{

src/components/tile-game/TileGameRoute.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import useImages from '../../hooks/tile-game/useImages';
44
import { useTileAsset } from '../../hooks';
55
import { TileAsset as TileAssetT } from '../../types';
66
import TileGame from './TileGame';
7+
import { HomeIcon } from '../../svg/HomeIcon';
8+
import { useNavigate } from 'react-router';
79

810
export default function TileGameRoute(): ReactElement {
11+
const navigate = useNavigate();
912
const { images } = useImages();
1013
const { create: createTileAsset } = useTileAsset();
1114

@@ -16,6 +19,16 @@ export default function TileGameRoute(): ReactElement {
1619

1720
return (
1821
<div>
22+
<div
23+
className="
24+
absolute top-5 left-5
25+
hover:cursor-pointer hover:animate-wiggle
26+
active:animate-jump-out
27+
"
28+
onClick={() => navigate('/')}
29+
>
30+
<HomeIcon />
31+
</div>
1932
<TileGame tiles={tileAssets} />
2033
</div>
2134
);

src/index.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ import ReactDOM from 'react-dom/client';
33
import './index.css';
44
import App from './App';
55
import reportWebVitals from './reportWebVitals';
6+
import { BrowserRouter, Routes, Route } from 'react-router';
7+
import TileGameRoute from './components/tile-game/TileGameRoute';
68

79
const root = ReactDOM.createRoot(
810
document.getElementById('root') as HTMLElement,
911
);
1012
root.render(
11-
<React.StrictMode>
12-
<App />
13-
</React.StrictMode>,
13+
<BrowserRouter>
14+
<Routes>
15+
<Route index element={<App />} />
16+
<Route path="/picture-cards" element={<TileGameRoute />} />
17+
</Routes>
18+
</BrowserRouter>,
1419
);
1520

1621
// If you want to start measuring performance in your app, pass a function

0 commit comments

Comments
 (0)