From 567160caa1ffc494ac131fc108cafec12196ab95 Mon Sep 17 00:00:00 2001 From: djmil Date: Fri, 27 Oct 2023 19:36:00 +0200 Subject: [PATCH] front: NewGame component --- webapp/src/components/Game/GameBoard.jsx | 32 ++++--------------- .../Game/GameSelector/Selectable.jsx | 2 +- webapp/src/components/Game/NewGame.css | 17 ++++++++++ webapp/src/components/Game/NewGame.jsx | 32 +++++++++++++++++-- webapp/src/components/Game/Player.jsx | 2 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/webapp/src/components/Game/GameBoard.jsx b/webapp/src/components/Game/GameBoard.jsx index 84fa5a5..1e758d6 100644 --- a/webapp/src/components/Game/GameBoard.jsx +++ b/webapp/src/components/Game/GameBoard.jsx @@ -1,39 +1,19 @@ import './GameBoard.css' import React, { useState } from 'react' -import { AppData } from '../../context/data' import Board from './GameBoard/Board' -import { SelectPlayer } from './Player' -// import { WHITE, BLACK, WhiteStone, BlackStone } from './Stone' +import { WHITE, BLACK } from './Stone' +import { Player } from './Player' export default function GameBoard() { - const [data] = React.useContext(AppData) - - const [whiteName, setWhiteName] = useState(''); - const [blackName, setBlackName] = useState(''); - - - const nameOptions = data.leaderboard - ? Object.keys(data.leaderboard).map(playerName => { - const displayName = data.isCurrentUser(playerName) ? 'You' : playerName - return - }) - : [] - - const whiteOptions = Array(nameOptions) - whiteOptions.push() - - const blackOptions = Array(nameOptions) - blackOptions.push() - + const [whiteName] = useState(''); + const [blackName] = useState(''); return (
- - {/* */} + - {/* */} - +
) } diff --git a/webapp/src/components/Game/GameSelector/Selectable.jsx b/webapp/src/components/Game/GameSelector/Selectable.jsx index 15a6740..7e7a53e 100644 --- a/webapp/src/components/Game/GameSelector/Selectable.jsx +++ b/webapp/src/components/Game/GameSelector/Selectable.jsx @@ -1,7 +1,7 @@ import './Selectable.css' import React from 'react'; import { oppositeColor } from '../Stone'; -import Player from '../Player'; +import { Player } from '../Player'; export default function Selectable({ game, onClick }) { diff --git a/webapp/src/components/Game/NewGame.css b/webapp/src/components/Game/NewGame.css index e69de29..8b9fe77 100644 --- a/webapp/src/components/Game/NewGame.css +++ b/webapp/src/components/Game/NewGame.css @@ -0,0 +1,17 @@ +.new-game { + margin-top: 70px; +} + +.new-game * { + width: 230px; +} + +.new-game .container { + margin-top: 40px; + margin-bottom: 40px; +} + +.new-game .stone { + font-size: 150%; + vertical-align: -3px; +} \ No newline at end of file diff --git a/webapp/src/components/Game/NewGame.jsx b/webapp/src/components/Game/NewGame.jsx index 700b049..d6804e1 100644 --- a/webapp/src/components/Game/NewGame.jsx +++ b/webapp/src/components/Game/NewGame.jsx @@ -1,21 +1,47 @@ import './NewGame.css'; import React from 'react'; +import { AppData } from '../../context/data' import { useLocation, matchPath } from "react-router"; +import { SelectPlayer } from './Player'; +import { WhiteStone, BlackStone } from './Stone'; // import { AppContext } from '../../context/app' export default function NewGame() { // const [ctx, dispatchCtx] = React.useContext(AppContext) + const [data] = React.useContext(AppData) + const [whiteName, setWhiteName] = React.useState(''); + const [blackName, setBlackName] = React.useState(''); const { pathname } = useLocation(); const isMyPath = matchPath("/game/new", pathname); if (!isMyPath) - return - + return + + const nameOptions = data.leaderboard + ? Object.keys(data.leaderboard).map(playerName => { + const displayName = data.isCurrentUser(playerName) ? 'You' : playerName + return + }) + : [] + + const whiteOptions = Array(nameOptions) + whiteOptions.push() + + const blackOptions = Array(nameOptions) + blackOptions.push() + return (
-
New game TBD
+
+ player + +
+
+ + player +
) } \ No newline at end of file diff --git a/webapp/src/components/Game/Player.jsx b/webapp/src/components/Game/Player.jsx index d4855f3..ab55ad5 100644 --- a/webapp/src/components/Game/Player.jsx +++ b/webapp/src/components/Game/Player.jsx @@ -2,7 +2,7 @@ import './Player.css' import React from 'react' import { Stone } from './Stone' -export default function Player({ color, name }) { +export function Player({ color, name }) { return (