diff --git a/webapp/src/components/Board/index.jsx b/webapp/src/components/Board/index.jsx index 9ce884c..f3e2e86 100644 --- a/webapp/src/components/Board/index.jsx +++ b/webapp/src/components/Board/index.jsx @@ -1,7 +1,7 @@ import './index.css'; import React from 'react'; -import { WhiteStone, BlackStone } from '../Stone' +import { WhiteStone, BlackStone } from '../Game/Stone' export default function Board() { diff --git a/webapp/src/components/GameHeader/index.css b/webapp/src/components/Game/GameHeader.css similarity index 100% rename from webapp/src/components/GameHeader/index.css rename to webapp/src/components/Game/GameHeader.css diff --git a/webapp/src/components/Game/GameHeader.jsx b/webapp/src/components/Game/GameHeader.jsx new file mode 100644 index 0000000..4b9ffe9 --- /dev/null +++ b/webapp/src/components/Game/GameHeader.jsx @@ -0,0 +1,14 @@ +import './GameHeader.css'; +import React from 'react'; +import { NavLink } from "react-router-dom"; + +export default function GameHeader() { + + return ( + + ) +} diff --git a/webapp/src/components/GameSelector/index.css b/webapp/src/components/Game/GameSelector.css similarity index 100% rename from webapp/src/components/GameSelector/index.css rename to webapp/src/components/Game/GameSelector.css diff --git a/webapp/src/components/Game/GameSelector.jsx b/webapp/src/components/Game/GameSelector.jsx new file mode 100644 index 0000000..6c99e1a --- /dev/null +++ b/webapp/src/components/Game/GameSelector.jsx @@ -0,0 +1,26 @@ +import './GameSelector.css'; +import React from 'react'; +import { useLocation, matchPath } from "react-router"; + +import { AppData } from "../../context/data" +import Proposal from './GameSelector/GameProposal'; + +export default function Game() { + const [data] = React.useContext(AppData) + + const { pathname } = useLocation(); + const isProposalPath = matchPath("/game/proposal/*", pathname); + const isActivelPath = matchPath("/game/active/*", pathname); + const isArchivePath = matchPath("/game/archive/*", pathname); + + if (!data.games) + return
Loading..
+ + return ( +
+ {isProposalPath && } + {isActivelPath &&
TBD #1
} + {isArchivePath &&
TBD #2
} +
+ ) +} \ No newline at end of file diff --git a/webapp/src/components/Game/GameSelector/ActiveGames.jsx b/webapp/src/components/Game/GameSelector/ActiveGames.jsx new file mode 100644 index 0000000..ed68149 --- /dev/null +++ b/webapp/src/components/Game/GameSelector/ActiveGames.jsx @@ -0,0 +1,32 @@ +import './ProposalSelector.css' +import React from 'react'; +import Selectable from './Selectable'; + +export default function ProposalSelector({ games }) { + + const waitForYou = games + .filter(game => game.status === Status.WaitForYou) + .map(game => ) + + const WaitForOpponent = games + .filter(game => game.status === Status.WaitForOpponent) + .map(game => ) + + return
+
+ {waitForYou} + {WaitForOpponent.length > 0 && +
+ waiting for opponent ({WaitForOpponent.length}) +
+ } + {WaitForOpponent} +
+
+}; + + +const Status = { + WaitForOpponent: "GAME_PROPOSAL_WAIT_FOR_OPPONENT", + WaitForYou: "GAME_PROPOSAL_WAIT_FOR_YOU", +} diff --git a/webapp/src/components/Game/GameSelector/GameArchive.jsx b/webapp/src/components/Game/GameSelector/GameArchive.jsx new file mode 100644 index 0000000..ed68149 --- /dev/null +++ b/webapp/src/components/Game/GameSelector/GameArchive.jsx @@ -0,0 +1,32 @@ +import './ProposalSelector.css' +import React from 'react'; +import Selectable from './Selectable'; + +export default function ProposalSelector({ games }) { + + const waitForYou = games + .filter(game => game.status === Status.WaitForYou) + .map(game => ) + + const WaitForOpponent = games + .filter(game => game.status === Status.WaitForOpponent) + .map(game => ) + + return
+
+ {waitForYou} + {WaitForOpponent.length > 0 && +
+ waiting for opponent ({WaitForOpponent.length}) +
+ } + {WaitForOpponent} +
+
+}; + + +const Status = { + WaitForOpponent: "GAME_PROPOSAL_WAIT_FOR_OPPONENT", + WaitForYou: "GAME_PROPOSAL_WAIT_FOR_YOU", +} diff --git a/webapp/src/components/Game/GameSelector/GameProposal.jsx b/webapp/src/components/Game/GameSelector/GameProposal.jsx new file mode 100644 index 0000000..322c547 --- /dev/null +++ b/webapp/src/components/Game/GameSelector/GameProposal.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import Selectable from './Selectable'; + +export default function ProposalSelector({ games }) { + + const waitForYou = games + .filter(game => game.status === Status.WaitForYou) + .map(game => ) + + const WaitForOpponent = games + .filter(game => game.status === Status.WaitForOpponent) + .map(game => ) + + return ( +
+ {waitForYou} + {WaitForOpponent.length > 0 && +
+ waiting for opponent ({WaitForOpponent.length}) +
+ } + {WaitForOpponent} +
+ ) +} + +const Status = { + WaitForOpponent: "GAME_PROPOSAL_WAIT_FOR_OPPONENT", + WaitForYou: "GAME_PROPOSAL_WAIT_FOR_YOU", +} diff --git a/webapp/src/components/Game/GameSelector/Selectable.css b/webapp/src/components/Game/GameSelector/Selectable.css new file mode 100644 index 0000000..f1efadc --- /dev/null +++ b/webapp/src/components/Game/GameSelector/Selectable.css @@ -0,0 +1,35 @@ +.selectable { + border: 1px solid black; + margin-bottom: 5px; +} + +.selectable q { + color: gray; +} + +.selectable i { + font-size: 70%; +} + +/* .Games .li button.action { + display: none; +} + +.Games .li:hover button.action { + display: initial; +} */ + +.separator { + /* width: 20%; */ + /* height: 20px; */ + border-bottom: 1px dotted black; + text-align: center; + font-size: 50%; + padding-left: 50%; + margin-bottom: 7px; +} + +.stone { + vertical-align: -3px; + margin: 3px 3px; +} diff --git a/webapp/src/components/Game/GameSelector/Selectable.jsx b/webapp/src/components/Game/GameSelector/Selectable.jsx new file mode 100644 index 0000000..ba3c8a0 --- /dev/null +++ b/webapp/src/components/Game/GameSelector/Selectable.jsx @@ -0,0 +1,19 @@ +import './Selectable.css' +import React from 'react'; +import { Stone, oppositeColor } from '../Stone'; + +export default function Selectable({game}) { + + return ( +
+
+ {Stone(game.myColor)} + vs + {Stone(oppositeColor(game.myColor))} + {game.opponentName} +
+ {game.message} +
+ ) +}; + diff --git a/webapp/src/components/Game/Proposal/index.css b/webapp/src/components/Game/Proposal/index.css deleted file mode 100644 index e69de29..0000000 diff --git a/webapp/src/components/Game/Proposal/index.jsx b/webapp/src/components/Game/Proposal/index.jsx deleted file mode 100644 index 6fc4fa2..0000000 --- a/webapp/src/components/Game/Proposal/index.jsx +++ /dev/null @@ -1,22 +0,0 @@ -import './index.css'; -import React from 'react'; -// import { NavLink } from "react-router-dom"; -// import { AppData } from "../../../context/data" -import GameHeader from '../../GameHeader' -import GameSelector from '../../GameSelector' -import Board from '../../Board' - -export default function Proposal() { - // const [data] = React.useContext(AppData) - - return
-
- - - -
- -
- -
-}; diff --git a/webapp/src/components/Stone/index.css b/webapp/src/components/Game/Stone.css similarity index 100% rename from webapp/src/components/Stone/index.css rename to webapp/src/components/Game/Stone.css diff --git a/webapp/src/components/Stone/index.jsx b/webapp/src/components/Game/Stone.jsx similarity index 96% rename from webapp/src/components/Stone/index.jsx rename to webapp/src/components/Game/Stone.jsx index 829782c..0c7cfcc 100644 --- a/webapp/src/components/Stone/index.jsx +++ b/webapp/src/components/Game/Stone.jsx @@ -1,4 +1,4 @@ -import './index.css'; +import './Stone.css'; import React from 'react'; export function Stone( color ) { diff --git a/webapp/src/components/Game/index.jsx b/webapp/src/components/Game/index.jsx index 34f0e6b..d5860db 100644 --- a/webapp/src/components/Game/index.jsx +++ b/webapp/src/components/Game/index.jsx @@ -1,7 +1,7 @@ import './index.css'; import React from 'react'; -import GameHeader from '../GameHeader' -import GameSelector from '../GameSelector' +import GameHeader from './GameHeader' +import GameSelector from './GameSelector' import Board from '../Board' // import { AppData } from "../../context/data" @@ -15,8 +15,9 @@ export default function Game() { -
- +
+ +
-}; +} diff --git a/webapp/src/components/GameHeader/index.jsx b/webapp/src/components/GameHeader/index.jsx deleted file mode 100644 index af0dad6..0000000 --- a/webapp/src/components/GameHeader/index.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import './index.css'; -import React from 'react'; -import { NavLink } from "react-router-dom"; -// import { AppData } from "../../context/data" - -export default function GameHeader() { - // const [data] = React.useContext(AppData) - - - return -}; diff --git a/webapp/src/components/GameSelector/index.jsx b/webapp/src/components/GameSelector/index.jsx deleted file mode 100644 index af4ff88..0000000 --- a/webapp/src/components/GameSelector/index.jsx +++ /dev/null @@ -1,89 +0,0 @@ -import './index.css'; -import React from 'react'; -import { useLocation, matchPath } from "react-router"; - -import { AppData } from "../../context/data" - -export default function Game() { - const [data] = React.useContext(AppData) - -const { pathname } = useLocation(); -const isProposalPath = matchPath("/game/proposal/*", pathname); -const isActivelPath = matchPath("/game/active/*", pathname); -const isArchivePath = matchPath("/game/archive/*", pathname); - -console.log("path: Proposal ", isProposalPath != null, "Active", isActivelPath != null, "Archive", isArchivePath != null ) - - if (!data?.games) - return
Loading..
- - // for (const [key, value] of Object.entries(data.games)) - // console.log(key, value); - - const waitForYou = data.games - .filter(game => game.status === Status.WaitForYou) - .map(game => { - return
-

- You {Stone(game.myColor)} vs {game.opponentName} {Stone(oppositeColor(game.myColor))} -
- {game.message} -
- {/* - */} -

-
- }); - - const WaitForOpponent = data.games - .filter(game => game.status === Status.WaitForOpponent) - .map(game => { - return
-

- You {Stone(game.myColor)} vs {game.opponentName} {Stone(oppositeColor(game.myColor))} -
- {game.message} -
- {/* */} -

-
- }); - - return
-
- {waitForYou} - {WaitForOpponent.length > 0 && -
- waiting for opponent ({WaitForOpponent.length}) -
- } - {WaitForOpponent} -
-
-}; - - -const Status = { - WaitForOpponent: "GAME_PROPOSAL_WAIT_FOR_OPPONENT", - WaitForYou: "GAME_PROPOSAL_WAIT_FOR_YOU", -} - -function Stone(color) { - if (color === "WHITE") - return - - if (color === "BLACK") - return - - return {color} -} - -function oppositeColor(color) { - if (color === "WHITE") - return "BLACK" - - if (color === "BLACK") - return "WHITE" - - return color -}