From 73349f4b30878eb31b54e3eb171b37562f8e5684 Mon Sep 17 00:00:00 2001 From: Chris Karle Date: Thu, 18 Jun 2020 22:39:43 -0400 Subject: [PATCH] ChatPanel, CardTable CardTable will forward the text of an error message into the ChatPanel for display. ChatPanel uses a different className of 'err__post' to permit for styling differently and (soon, tbd) hiding the messages. --- assets/app.scss | 6 +++++- assets/components/CardTable.js | 23 ++++++++++++++++++++++- assets/components/ChatPanel.js | 10 ++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/assets/app.scss b/assets/app.scss index 6c0a74c..60c6eaf 100644 --- a/assets/app.scss +++ b/assets/app.scss @@ -1,3 +1,7 @@ +.err__post { + color: red; +} + @import 'carbon-components/scss/globals/scss/styles.scss'; .lobby__outer { @@ -177,7 +181,7 @@ .chat__input__row { display: flex; } -.chat__post { +.chat__post, .err__post { padding-right: 0.3rem; padding-left: 0.3rem; } diff --git a/assets/components/CardTable.js b/assets/components/CardTable.js index 23c726b..459defc 100644 --- a/assets/components/CardTable.js +++ b/assets/components/CardTable.js @@ -58,6 +58,7 @@ export default class CardTable extends React.Component { noPass: false, amSpectator: false, latestPost: '', + showErrors: true, hard_order: true, hard_pick: true, stick_dealer: false @@ -104,6 +105,17 @@ export default class CardTable extends React.Component { } } else if ('chat' == msg.msg_type) { this.processChat(msg); + } else if ('error' == msg.msg_type) { + this.processError(msg); + } + }; + + processError = msg => { + if (msg.msg) { + const post = '< { + console.log('coming soon :-)'); + } + genGameOver = () => { const {innerWinMsg, amSpectator} = this.state; let retVal = []; @@ -707,7 +723,7 @@ export default class CardTable extends React.Component { partnerHandInfo, partnerTurnInfo, partnerSeat, leftTurnInfo, leftHandInfo, leftSeat, rightHandInfo, rightTurnInfo, rightSeat, trumpPlace, trumpNom, turnSeat, spectators, dealSeat, trump, handLengths, score, trickWinner, bannerMsg, noPick, noPass, onlyAlone, - hard_pick, hard_order, stick_dealer, latestPost } = this.state; + hard_pick, hard_order, stick_dealer, latestPost, showErrors } = this.state; const {tableName} = this.props; const showSeatPicker = phase == 'lobby'; const showGameOver = phase == 'end'; @@ -724,6 +740,7 @@ export default class CardTable extends React.Component { const themLabel = amSpectator ? playerNames[0] + ' & ' + playerNames[2] + ': ' : 'Them: '; const hasSpec = spectators.length > 0; const specMsgObj = this.genSpecMsgObj(); + const toggleErrorMsg = showErrors ? 'Hide errors in chat' : 'Show errors in chat'; return (
@@ -749,6 +766,10 @@ export default class CardTable extends React.Component { itemText="Exit to Lobby" onClick={this.sendExit} /> +
)} diff --git a/assets/components/ChatPanel.js b/assets/components/ChatPanel.js index 457bc2f..c454d66 100644 --- a/assets/components/ChatPanel.js +++ b/assets/components/ChatPanel.js @@ -23,10 +23,16 @@ class ChatPanel extends React.Component { if (receivedChat && (receivedChat != prevProps.receivedChat)){ const nextNum = numPosts + 1; const id = 'post-' + nextNum; + let clsName = 'chat__post'; + let postMsg = receivedChat; + if (receivedChat.startsWith('<{receivedChat}

+ id={id}>{postMsg}

); if (nextArray.length > MAX_POSTS){ nextArray = nextArray.slice(1); -- libgit2 1.1.1