Compare commits
2 Commits
b6994554b3
...
567160caa1
Author | SHA1 | Date | |
---|---|---|---|
567160caa1 | |||
984acda704 |
@ -1,39 +1,19 @@
|
|||||||
import './GameBoard.css'
|
import './GameBoard.css'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { AppData } from '../../context/data'
|
|
||||||
import Board from './GameBoard/Board'
|
import Board from './GameBoard/Board'
|
||||||
import { SelectPlayer } from './Player'
|
import { WHITE, BLACK } from './Stone'
|
||||||
// import { WHITE, BLACK, WhiteStone, BlackStone } from './Stone'
|
import { Player } from './Player'
|
||||||
|
|
||||||
export default function GameBoard() {
|
export default function GameBoard() {
|
||||||
|
|
||||||
const [data] = React.useContext(AppData)
|
const [whiteName] = useState('');
|
||||||
|
const [blackName] = useState('');
|
||||||
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 <option key={playerName} value={playerName}>{displayName}</option>
|
|
||||||
})
|
|
||||||
: []
|
|
||||||
|
|
||||||
const whiteOptions = Array(nameOptions)
|
|
||||||
whiteOptions.push(<option key='default' value=''>{'⛀ …'}</option>)
|
|
||||||
|
|
||||||
const blackOptions = Array(nameOptions)
|
|
||||||
blackOptions.push(<option key='default' value=''>{'⛂ …'}</option>)
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='game-board'>
|
<div className='game-board'>
|
||||||
<SelectPlayer name={whiteName} setName={setWhiteName} nameOptions={whiteOptions} />
|
<Player color={WHITE()} name={whiteName} />
|
||||||
{/* <Player color={WHITE()} name={whiteName} setName={setWhiteName} nameOptions={whiteOptions} /> */}
|
|
||||||
<Board />
|
<Board />
|
||||||
{/* <Player color={BLACK()} name={blackName} setName={setBlackName} nameOptions={blackOptions} /> */}
|
<Player color={BLACK()} name={blackName} />
|
||||||
<SelectPlayer name={blackName} setName={setBlackName} nameOptions={blackOptions} />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ export default function GameSelector() {
|
|||||||
dispatchCtx({ component: "game-selector", selectedGameProposal: selectedGame })
|
dispatchCtx({ component: "game-selector", selectedGameProposal: selectedGame })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClick_active = (selectedGame) => {
|
// const onClick_active = (selectedGame) => {
|
||||||
dispatchCtx({ component: "game-selector", selectedActiveGame: selectedGame })
|
// dispatchCtx({ component: "game-selector", selectedActiveGame: selectedGame })
|
||||||
}
|
// }
|
||||||
|
|
||||||
const onClick_archive = (selectedGame) => {
|
// const onClick_archive = (selectedGame) => {
|
||||||
dispatchCtx({ component: "game-selector", selectedArchiveGame: selectedGame })
|
// dispatchCtx({ component: "game-selector", selectedArchiveGame: selectedGame })
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!data.games)
|
if (!data.games)
|
||||||
return <div>Loading..</div>
|
return <div>Loading..</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import './Selectable.css'
|
import './Selectable.css'
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { oppositeColor } from '../Stone';
|
import { oppositeColor } from '../Stone';
|
||||||
import Player from '../Player';
|
import { Player } from '../Player';
|
||||||
|
|
||||||
export default function Selectable({ game, onClick }) {
|
export default function Selectable({ game, onClick }) {
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -1,21 +1,47 @@
|
|||||||
import './NewGame.css';
|
import './NewGame.css';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { AppData } from '../../context/data'
|
||||||
import { useLocation, matchPath } from "react-router";
|
import { useLocation, matchPath } from "react-router";
|
||||||
|
import { SelectPlayer } from './Player';
|
||||||
|
import { WhiteStone, BlackStone } from './Stone';
|
||||||
|
|
||||||
// import { AppContext } from '../../context/app'
|
// import { AppContext } from '../../context/app'
|
||||||
|
|
||||||
export default function NewGame() {
|
export default function NewGame() {
|
||||||
// const [ctx, dispatchCtx] = React.useContext(AppContext)
|
// 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 { pathname } = useLocation();
|
||||||
const isMyPath = matchPath("/game/new", pathname);
|
const isMyPath = matchPath("/game/new", pathname);
|
||||||
|
|
||||||
if (!isMyPath)
|
if (!isMyPath)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
const nameOptions = data.leaderboard
|
||||||
|
? Object.keys(data.leaderboard).map(playerName => {
|
||||||
|
const displayName = data.isCurrentUser(playerName) ? 'You' : playerName
|
||||||
|
return <option key={playerName} value={playerName}>{displayName}</option>
|
||||||
|
})
|
||||||
|
: []
|
||||||
|
|
||||||
|
const whiteOptions = Array(nameOptions)
|
||||||
|
whiteOptions.push(<option key='default' value=''>{'select …'}</option>)
|
||||||
|
|
||||||
|
const blackOptions = Array(nameOptions)
|
||||||
|
blackOptions.push(<option key='default' value=''>{'select …'}</option>)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='new-game'>
|
<div className='new-game'>
|
||||||
<div>New game TBD</div>
|
<div className='container'>
|
||||||
|
<WhiteStone/> player
|
||||||
|
<SelectPlayer name={whiteName} setName={setWhiteName} nameOptions={whiteOptions} />
|
||||||
|
</div>
|
||||||
|
<div className='container'>
|
||||||
|
<SelectPlayer name={blackName} setName={setBlackName} nameOptions={blackOptions} />
|
||||||
|
<BlackStone/> player
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ import './Player.css'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Stone } from './Stone'
|
import { Stone } from './Stone'
|
||||||
|
|
||||||
export default function Player({ color, name }) {
|
export function Player({ color, name }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='player'>
|
<div className='player'>
|
||||||
|
Loading…
Reference in New Issue
Block a user