front: GameHeader: add New gameView
- GameActions for each GameView - activate GameAction per relevan GameView
This commit is contained in:
parent
1ea6d22286
commit
21dd37521b
@ -16,6 +16,7 @@ function App() {
|
||||
<Routes>
|
||||
{/* https://stackoverflow.com/questions/40541994/multiple-path-names-for-a-same-component-in-react-router */}
|
||||
<Route path="/game" element={<Game/>} />
|
||||
<Route path="/game/new" element={<Game/>} />
|
||||
<Route path="/game/proposal" element={<Game/>} />
|
||||
<Route path="/game/active" element={<Game/>} />
|
||||
<Route path="/game/archive" element={<Game/>} />
|
||||
|
@ -1,24 +1,45 @@
|
||||
import './GameAction.css';
|
||||
import React from 'react';
|
||||
import { useLocation, matchPath } from "react-router";
|
||||
|
||||
import Create from './GameAction/Create';
|
||||
|
||||
import Reject from './GameAction/Reject';
|
||||
import Cancel from './GameAction/Cancel';
|
||||
import Accept from './GameAction/Accept';
|
||||
|
||||
import DrawReq from './GameAction/DrawReq';
|
||||
import DrawAcq from './GameAction/DrawAcq';
|
||||
import Surrender from './GameAction/Surrender';
|
||||
|
||||
import Backward from './GameAction/Backward';
|
||||
import Forward from './GameAction/Forward';
|
||||
|
||||
import Create from './GameAction/Create'
|
||||
import Reject from './GameAction/Reject'
|
||||
import Cancel from './GameAction/Cancel'
|
||||
import Accept from './GameAction/Accept'
|
||||
// import { AppContext } from '../../context/app'
|
||||
|
||||
export default function GameAction() {
|
||||
// const [ctx, dispatchCtx] = React.useContext(AppContext)
|
||||
|
||||
const { pathname } = useLocation();
|
||||
const isNewGamePath = matchPath("/game/new", pathname);
|
||||
const isProposalPath = matchPath("/game/proposal/*", pathname);
|
||||
const isActivelPath = matchPath("/game/active/*", pathname);
|
||||
const isArchivePath = matchPath("/game/archive/*", pathname);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='action-panel'>
|
||||
<Create />
|
||||
<Reject />
|
||||
<Cancel />
|
||||
<Accept />
|
||||
</div>
|
||||
{/* {isProposalPath && <Proposal games={data.games} />} */}
|
||||
{isNewGamePath && <Create />}
|
||||
|
||||
{isProposalPath && <Reject />}
|
||||
{isProposalPath && <Cancel />}
|
||||
{isProposalPath && <Accept />}
|
||||
|
||||
{isActivelPath && <DrawReq />}
|
||||
{isActivelPath && <DrawAcq />}
|
||||
{isActivelPath && <Surrender />}
|
||||
|
||||
{isArchivePath && <Backward />}
|
||||
{isArchivePath && <Forward />}
|
||||
</div>
|
||||
)
|
||||
}
|
6
webapp/src/components/Game/GameAction/Backward.jsx
Normal file
6
webapp/src/components/Game/GameAction/Backward.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function Backward() {
|
||||
|
||||
return <button className='game-action backward'>Backward</button>
|
||||
}
|
6
webapp/src/components/Game/GameAction/DrawAcq.jsx
Normal file
6
webapp/src/components/Game/GameAction/DrawAcq.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function DrawAcq() {
|
||||
|
||||
return <button className='game-action draw-acq'>Draw acquire</button>
|
||||
}
|
6
webapp/src/components/Game/GameAction/DrawReq.jsx
Normal file
6
webapp/src/components/Game/GameAction/DrawReq.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function DrawReq() {
|
||||
|
||||
return <button className='game-action drawreq'>Draw request</button>
|
||||
}
|
6
webapp/src/components/Game/GameAction/Forward.jsx
Normal file
6
webapp/src/components/Game/GameAction/Forward.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function Forward() {
|
||||
|
||||
return <button className='game-action forward'>Forward</button>
|
||||
}
|
6
webapp/src/components/Game/GameAction/Surrender.jsx
Normal file
6
webapp/src/components/Game/GameAction/Surrender.jsx
Normal file
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function Surrender() {
|
||||
|
||||
return <button className='game-action surrender'>Surrender</button>
|
||||
}
|
@ -6,6 +6,7 @@ export default function GameHeader() {
|
||||
|
||||
return (
|
||||
<nav className='game-header'>
|
||||
<NavLink to="/game/new">New</NavLink>
|
||||
<NavLink to="/game/proposal">Proposal</NavLink>
|
||||
<NavLink to="/game/active">Active</NavLink>
|
||||
<NavLink to="/game/archive">Archive</NavLink>
|
||||
|
0
webapp/src/components/Game/NewGame.css
Normal file
0
webapp/src/components/Game/NewGame.css
Normal file
21
webapp/src/components/Game/NewGame.jsx
Normal file
21
webapp/src/components/Game/NewGame.jsx
Normal file
@ -0,0 +1,21 @@
|
||||
import './NewGame.css';
|
||||
import React from 'react';
|
||||
import { useLocation, matchPath } from "react-router";
|
||||
|
||||
// import { AppContext } from '../../context/app'
|
||||
|
||||
export default function NewGame() {
|
||||
// const [ctx, dispatchCtx] = React.useContext(AppContext)
|
||||
|
||||
const { pathname } = useLocation();
|
||||
const isMyPath = matchPath("/game/new", pathname);
|
||||
|
||||
if (!isMyPath)
|
||||
return
|
||||
|
||||
return (
|
||||
<div className='new-game'>
|
||||
<div>New game TBD</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -4,22 +4,22 @@ import GameHeader from './GameHeader'
|
||||
import GameSelector from './GameSelector'
|
||||
import GameAction from './GameAction'
|
||||
import GameBoard from './GameBoard'
|
||||
|
||||
// import { AppData } from "../../context/data"
|
||||
import NewGame from './NewGame';
|
||||
|
||||
export default function Game() {
|
||||
|
||||
return <div className="split">
|
||||
|
||||
return (
|
||||
<div className="split">
|
||||
<div className='split left'>
|
||||
<GameHeader />
|
||||
<GameSelector />
|
||||
<NewGame />
|
||||
</div>
|
||||
|
||||
<div className='split right'>
|
||||
<GameAction />
|
||||
<GameBoard />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user