Skip to content

Commit

Permalink
Upgrade packages and fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
romw314 committed Dec 1, 2023
1 parent e1599f7 commit b014b04
Show file tree
Hide file tree
Showing 3 changed files with 1,632 additions and 1,465 deletions.
15 changes: 9 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Button, Dialog, DialogTitle, DialogContent, DialogContentText, DialogAc
import { Theme, getImage } from './Theme';
import * as gameLogic from './gameLogic.js';
import styles from './App.module.css';
import { DebugRunContext } from './DebugRunContext';
import { DebugRunContext, getLg } from './DebugRunContext';
import clone from 'just-clone';
import Columns from 'react-columns';
import NavBar from './NavBar';
import { useNavigate } from 'react-router-dom';
import { useNavigate, useSearchParams } from 'react-router-dom';

function Square({ currentMove, value, onSquareClick, selectedPiece, index, theme, squares, testid }) {
const isDark = ((Math.floor(index / 8) % 2) !== (index % 2));
Expand Down Expand Up @@ -256,7 +256,7 @@ function Game({ theme, data }) {
);
}

function App({ setupData }) {
function App({ setupData, navigate }) {
const theme = setupData.theme;
const reRender = useState(0)[1];

Expand Down Expand Up @@ -316,8 +316,6 @@ re-render the game:
console.adlog(1, 'set body style to', theme.bodyStyle);
}, [theme]);

const navigate = useNavigate();

return (
<HelmetProvider>
<NavBar onNavigate={href => navigate(href)} />
Expand All @@ -335,6 +333,11 @@ function DefaultApp() {
return <App setupData={new setupData(Theme('default', useContext(DebugRunContext)))} />;
}

function ThemedApp() {
const [params] = useSearchParams();
return <App setupData={new setupData(Theme(params.get('theme') || 'dark', getLg))} navigate={useNavigate()} />;
}

function createHistoryObject(squares) {
console.adlog(2, 'creating history object, squares:', squares, '_gameLogic:', window._gameLogic);
return { squares: squares, set: { _gameLogic: clone(window._gameLogic) } };
Expand Down Expand Up @@ -386,5 +389,5 @@ class setupData {
}
}

export { setupData, DefaultApp };
export { setupData, DefaultApp, ThemedApp };
export default App;
7 changes: 1 addition & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App, { setupData } from './App';
import App, { setupData, ThemedApp } from './App';
import Home, { HomePage, ThemesPage } from './Home';
import { Theme } from './Theme';
import { DebugRunProvider, getLg, setLg } from './DebugRunContext';
Expand All @@ -22,11 +22,6 @@ setLg(f => f());
global.error = null;
global.catch = (error) => global.error = error;

function ThemedApp() {
const [params] = useSearchParams();
return <App setupData={new setupData(Theme(params.get('theme') || 'dark', getLg))} />;
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
Expand Down
Loading

0 comments on commit b014b04

Please sign in to comment.