messages/message2opponent (#12)
Reviewed-on: http://192.168.8.55:3000/HQLAx/CordaCheckers/pulls/12
This commit is contained in:
parent
3d9dbd2683
commit
f25fd51572
@ -18,4 +18,9 @@
|
|||||||
.game .right-side {
|
.game .right-side {
|
||||||
float: left;
|
float: left;
|
||||||
width: 55%;
|
width: 55%;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
@ -4,7 +4,9 @@ import GameView from './Game/GameView'
|
|||||||
import GameSelector from './Game/GameSelector'
|
import GameSelector from './Game/GameSelector'
|
||||||
import GameAction from './Game/GameAction'
|
import GameAction from './Game/GameAction'
|
||||||
import GameBoard from './Game/GameBoard'
|
import GameBoard from './Game/GameBoard'
|
||||||
import NewGame from './Game/NewGame';
|
import NewGame from './Game/NewGame'
|
||||||
|
import GameMessage from './Game/GameMessage'
|
||||||
|
import Message2Opponent from './Game/Message2Opponent'
|
||||||
|
|
||||||
export default function Game() {
|
export default function Game() {
|
||||||
|
|
||||||
@ -17,7 +19,9 @@ export default function Game() {
|
|||||||
</div>
|
</div>
|
||||||
<div className='right-side'>
|
<div className='right-side'>
|
||||||
<GameAction />
|
<GameAction />
|
||||||
|
<GameMessage />
|
||||||
<GameBoard />
|
<GameBoard />
|
||||||
|
<Message2Opponent />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -17,7 +17,8 @@ export default function Create() {
|
|||||||
|
|
||||||
postData("/api/gameproposal", request)
|
postData("/api/gameproposal", request)
|
||||||
.then((responce) => {
|
.then((responce) => {
|
||||||
console.log("responce", responce); // JSON data parsed by `data.json()` call
|
console.log("responce", responce) // JSON data parsed by `data.json()` call
|
||||||
|
ctx.clear_Message2Opponent()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ export default function Create() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Definitions() {
|
function Definitions() {
|
||||||
const [ctx] = React.useContext(AppContext)
|
const [ctx, dispatchCtx] = React.useContext(AppContext)
|
||||||
const [data] = React.useContext(AppData)
|
const [data] = React.useContext(AppData)
|
||||||
|
|
||||||
const isCurrentUser = data.isCurrentUser
|
const isCurrentUser = data.isCurrentUser
|
||||||
@ -54,7 +55,7 @@ function Definitions() {
|
|||||||
opponentName,
|
opponentName,
|
||||||
opponentColor,
|
opponentColor,
|
||||||
board: null,
|
board: null,
|
||||||
message: "let's play a game"
|
message: ctx.newGame.message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ function Definitions() {
|
|||||||
isEnabled,
|
isEnabled,
|
||||||
|
|
||||||
get_GameProposalRequest,
|
get_GameProposalRequest,
|
||||||
|
clear_Message2Opponent: () => { dispatchCtx({ update: "newGame", message: '' }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
webapp/src/components/Game/GameMessage.css
Normal file
6
webapp/src/components/Game/GameMessage.css
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.game-message {
|
||||||
|
border-radius: 3px;
|
||||||
|
border-color: lightgray;
|
||||||
|
background-color:violet;
|
||||||
|
width: 70%;
|
||||||
|
}
|
15
webapp/src/components/Game/GameMessage.jsx
Normal file
15
webapp/src/components/Game/GameMessage.jsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import './GameMessage.css'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import { AppContext } from '../../context/app'
|
||||||
|
|
||||||
|
export default function GameMessage() {
|
||||||
|
|
||||||
|
const [ctx] = React.useContext(AppContext)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='game-message'>
|
||||||
|
TBD: Game Message
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
3
webapp/src/components/Game/Message2Opponent.css
Normal file
3
webapp/src/components/Game/Message2Opponent.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.message2opponent input{
|
||||||
|
width: 270px;
|
||||||
|
}
|
23
webapp/src/components/Game/Message2Opponent.jsx
Normal file
23
webapp/src/components/Game/Message2Opponent.jsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import './Message2Opponent.css'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import { AppContext } from '../../context/app'
|
||||||
|
|
||||||
|
export default function Message2Opponent() {
|
||||||
|
const [ctx, dispatchCtx] = React.useContext(AppContext)
|
||||||
|
|
||||||
|
const setMessage = (message) => {
|
||||||
|
dispatchCtx({ update: "newGame", message })
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='message2opponent'>
|
||||||
|
<input
|
||||||
|
placeholder='Message to opponent'
|
||||||
|
value={ctx.newGame.message}
|
||||||
|
maxLength={150}
|
||||||
|
onChange={e => setMessage(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
@ -24,6 +24,7 @@ export const initialState = {
|
|||||||
newGame: {
|
newGame: {
|
||||||
whitePlayer: '',
|
whitePlayer: '',
|
||||||
blackPlayer: '',
|
blackPlayer: '',
|
||||||
|
message: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user