diff --git a/webapp/src/App.css b/webapp/src/App.css index 91ba01d..4931613 100644 --- a/webapp/src/App.css +++ b/webapp/src/App.css @@ -1,7 +1,3 @@ .App { text-align: center; } - -.Container { - margin-top: 25px; -} \ No newline at end of file diff --git a/webapp/src/App.js b/webapp/src/App.js index aa7b6e4..7f1f6ad 100644 --- a/webapp/src/App.js +++ b/webapp/src/App.js @@ -1,17 +1,21 @@ import './App.css'; -import React from 'react' +import React, { useReducer } from 'react' import { BrowserRouter, Routes, Route } from "react-router-dom" -import Header from "./components/Header" +import Header from "./container/Header" import Leaderboard from "./components/Leaderboard" import Game from "./components/Game" import About from "./components/About" -function App() { +import { pollingReducer, pollingDefaults } from './reducer/polling'; +function App() { + const [polling, dispatchPolling] = useReducer(pollingReducer, pollingDefaults) + + console.log('polling', polling) return
-
+
{/* https://stackoverflow.com/questions/40541994/multiple-path-names-for-a-same-component-in-react-router */} } /> @@ -19,7 +23,6 @@ function App() { } /> } /> } /> - } /> } /> diff --git a/webapp/src/components/Game/GameSelector.jsx b/webapp/src/components/Game/GameSelector.jsx index 73c08f8..404e434 100644 --- a/webapp/src/components/Game/GameSelector.jsx +++ b/webapp/src/components/Game/GameSelector.jsx @@ -32,6 +32,8 @@ export default function GameSelector() { if (!data.games) return
Loading..
+ console.log("Games", data.games) + return (
{isProposalPath && } diff --git a/webapp/src/components/Header.jsx b/webapp/src/components/Header.jsx deleted file mode 100644 index 71d4b9f..0000000 --- a/webapp/src/components/Header.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import './Header.css'; -import React from "react" -import { NavLink } from "react-router-dom"; -import OnlineToggle from './OnlineTgl'; -import { AppData } from "../context/data" -import Wobler from './Wobler'; - -export default function Header() { - const [data] = React.useContext(AppData) - - return ( -
-

- CordaCheckers -

- - -
- ) -} diff --git a/webapp/src/components/OnlineTgl/index.jsx b/webapp/src/components/OnlineTgl/index.jsx deleted file mode 100644 index 52ef048..0000000 --- a/webapp/src/components/OnlineTgl/index.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import "./index.css" -import React from "react" -import { AppData } from "../../context/data" - -export default function OnlineTgl() { - const [/*appData*/, dispatchData] = React.useContext(AppData) - - return
- dispatchData({type: "toggleOfflineMode"})}/> -
-} diff --git a/webapp/src/components/OnlineTgl/index.css b/webapp/src/components/OnlineToggle.css similarity index 100% rename from webapp/src/components/OnlineTgl/index.css rename to webapp/src/components/OnlineToggle.css diff --git a/webapp/src/components/OnlineToggle.jsx b/webapp/src/components/OnlineToggle.jsx new file mode 100644 index 0000000..7f80f59 --- /dev/null +++ b/webapp/src/components/OnlineToggle.jsx @@ -0,0 +1,11 @@ +import "./OnlineToggle.css" +import React from "react" + +export default function OnlineToggle({ isOnline, onClick }) { + return ( +
+ +
+ ) +} diff --git a/webapp/src/components/Header.css b/webapp/src/container/Header.css similarity index 74% rename from webapp/src/components/Header.css rename to webapp/src/container/Header.css index 299bc64..651fa5e 100644 --- a/webapp/src/components/Header.css +++ b/webapp/src/container/Header.css @@ -1,13 +1,13 @@ -.OnlineTgl { +.OnlineToggle { transform: scale(.5); margin-left: -19px; } -.app-header { +.Header { display: flex; } -.app-header nav { +.Header nav { align-items: center; justify-content: center; display: flex; @@ -16,7 +16,7 @@ padding-top: 10px; } -.app-header a { +.Header a { color: lightgray; text-decoration: none; transition: .25s ease; @@ -27,7 +27,7 @@ padding: 0.25rem 1rem; } -.app-header .active { +.Header .active { color: white; border-radius: 2px; background-color: cadetblue; @@ -35,17 +35,17 @@ padding: 0.25rem 1rem; } -.app-header a:hover:not(.active) { +.Header a:hover:not(.active) { color: cadetblue; box-shadow: 0 1.5px 0 0 currentcolor; } -[data-darkreader-scheme="dark"] .app-header a { +[data-darkreader-scheme="dark"] .Header a { color: darkslategrey; } -[data-darkreader-scheme="dark"] .app-header .active { +[data-darkreader-scheme="dark"] .Header .active { color: white; box-shadow: 0 1.5px 0 0 currentcolor; } \ No newline at end of file diff --git a/webapp/src/container/Header.jsx b/webapp/src/container/Header.jsx new file mode 100644 index 0000000..b6a446a --- /dev/null +++ b/webapp/src/container/Header.jsx @@ -0,0 +1,35 @@ +import './Header.css'; +import React from "react" +import { NavLink } from "react-router-dom"; +import OnlineToggle from '../components/OnlineToggle'; +import Wobler from '../components/Wobler'; + +export default function Header({ polling, dispatchPolling }) { + + return ( +
+

+ CordaCheckers +

+ + dispatchPolling({ type: "toggleOnOff" })} + /> + + +
+ ) +} diff --git a/webapp/src/reducer/polling.js b/webapp/src/reducer/polling.js new file mode 100644 index 0000000..a5f343c --- /dev/null +++ b/webapp/src/reducer/polling.js @@ -0,0 +1,32 @@ +export function pollingReducer(polling, action) { + switch (action.type) { + + case "toggleOnOff": + return { + ...polling, + enabled: !polling.enabled + }; + + case "games": + return { + ...polling, + games: action.value + }; + + case "leaderboard": + return { + ...polling, + leaderboard: action.value + }; + + default: + throw Error("Unknown action: " + action.type); + } +} + +export const pollingDefaults = { + enabled: true, + + games: false, + leaderboard: false, +};