From 9fdbcc34f9a3e928b5555efff406da43f6847275 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Sun, 22 May 2022 06:11:07 -0700 Subject: [PATCH] Convert some comp to functions, attempt fix multi-device --- src/components/app/App.jsx | 87 +++++++++---------- .../create-account/CreateAccount.jsx | 8 -- .../create-or-join/CreateOrJoin.jsx | 44 +++++----- src/components/farm/MessagePanel.jsx | 36 ++++---- src/components/welcome/Welcome.jsx | 24 +++-- src/components/widgets.jsx | 72 +++++++-------- src/server/farm.scm | 16 +++- webpack.dev.js | 2 + 8 files changed, 136 insertions(+), 153 deletions(-) diff --git a/src/components/app/App.jsx b/src/components/app/App.jsx index 4002d23..3cfd53f 100644 --- a/src/components/app/App.jsx +++ b/src/components/app/App.jsx @@ -28,67 +28,62 @@ import Welcome from '../welcome/Welcome.jsx' import Tractor from '../tractor/Tractor.jsx' import { SCREENS, messagePanelId } from '../../constants.js' -import { play } from './actions.js' -class Chrome extends React.Component { - render() { - return ( -
-

Alpha Centauri Farming

- {this.props.children} - -
- ); - } +const Chrome = ({ children, spikes, tractorClass }) => { + return ( +
+

Alpha Centauri Farming

+ {children} + +
+ ); } -class App extends React.Component { - render() { - let view; - switch (this.props.screen) { +const App = ({ screen, logout, createAccount, login, errors }) => { + let view; + switch (screen) { case SCREENS.intro: view = (); break; - case SCREENS.start: - view = (); - break; - case SCREENS.newGame: - view = ( + case SCREENS.start: + view = (); + break; + case SCREENS.newGame: + view = ( +
+ +
+
); + break; + case SCREENS.joinGame: + view = ( +
-
); - break; - case SCREENS.joinGame: - view = ( - -
- -
-
); break; case SCREENS.play: view = (); break; - } - return ( - - {view} -
-
- ); } + return ( + + {view} +
+
+ ); } export default connect( diff --git a/src/components/create-account/CreateAccount.jsx b/src/components/create-account/CreateAccount.jsx index c48a5a1..14ed404 100644 --- a/src/components/create-account/CreateAccount.jsx +++ b/src/components/create-account/CreateAccount.jsx @@ -61,14 +61,6 @@ export default class CreateAccount extends React.Component { - - - - -