From 865619428c458e66d0123951fdd8d048243263fe Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Tue, 31 Oct 2023 17:33:56 -0500 Subject: [PATCH 1/2] feat(chat): [closes #453] Add chat (#464) * feat(chat): [#453] scaffold chat dialog * feat(chat): [#453] load chat room * feat(chat): only render for non-default room * feat(chat): add button to open chat * feat(chat): improve chat dialog display * feat(chat): move chat trigger to navigation pane --- package-lock.json | 49 +++++++++++++ package.json | 1 + src/components/ChatRoom/ChatRoom.js | 76 ++++++++++++++++++++ src/components/ChatRoom/ChatRoom.sass | 4 ++ src/components/ChatRoom/index.js | 1 + src/components/Farmhand/Farmhand.js | 12 ++++ src/components/Navigation/Navigation.js | 51 ++++++++++--- src/components/Navigation/Navigation.sass | 5 ++ src/components/Navigation/Navigation.test.js | 2 + src/handlers/ui-events.js | 7 ++ 10 files changed, 198 insertions(+), 10 deletions(-) create mode 100644 src/components/ChatRoom/ChatRoom.js create mode 100644 src/components/ChatRoom/ChatRoom.sass create mode 100644 src/components/ChatRoom/index.js diff --git a/package-lock.json b/package-lock.json index 6f810530e..305d79c2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "react-confetti": "^6.1.0", "react-dom": "^17.0.2", "react-file-reader-input": "^2.0.0", + "react-helmet": "^6.1.0", "react-hotkeys": "^2.0.0", "react-markdown": "^4.3.1", "react-number-format": "^4.4.1", @@ -26995,6 +26996,11 @@ "dev": true, "license": "MIT" }, + "node_modules/react-fast-compare": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", + "integrity": "sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==" + }, "node_modules/react-file-reader-input": { "version": "2.0.0", "license": "MIT", @@ -27003,6 +27009,20 @@ "react-dom": "^15.0.0 || ^16.0.0" } }, + "node_modules/react-helmet": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", + "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", + "dependencies": { + "object-assign": "^4.1.1", + "prop-types": "^15.7.2", + "react-fast-compare": "^3.1.1", + "react-side-effect": "^2.1.0" + }, + "peerDependencies": { + "react": ">=16.3.0" + } + }, "node_modules/react-hotkeys": { "version": "2.0.0", "license": "ISC", @@ -27537,6 +27557,14 @@ "node": ">= 10.0.0" } }, + "node_modules/react-side-effect": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.2.tgz", + "integrity": "sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==", + "peerDependencies": { + "react": "^16.3.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-test-renderer": { "version": "16.14.0", "dev": true, @@ -51959,9 +51987,25 @@ "version": "6.0.11", "dev": true }, + "react-fast-compare": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", + "integrity": "sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==" + }, "react-file-reader-input": { "version": "2.0.0" }, + "react-helmet": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", + "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", + "requires": { + "object-assign": "^4.1.1", + "prop-types": "^15.7.2", + "react-fast-compare": "^3.1.1", + "react-side-effect": "^2.1.0" + } + }, "react-hotkeys": { "version": "2.0.0", "requires": { @@ -52305,6 +52349,11 @@ } } }, + "react-side-effect": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.2.tgz", + "integrity": "sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==" + }, "react-test-renderer": { "version": "16.14.0", "dev": true, diff --git a/package.json b/package.json index ddc6cfb9e..443acfb64 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,7 @@ "react-confetti": "^6.1.0", "react-dom": "^17.0.2", "react-file-reader-input": "^2.0.0", + "react-helmet": "^6.1.0", "react-hotkeys": "^2.0.0", "react-markdown": "^4.3.1", "react-number-format": "^4.4.1", diff --git a/src/components/ChatRoom/ChatRoom.js b/src/components/ChatRoom/ChatRoom.js new file mode 100644 index 000000000..c948ddcf2 --- /dev/null +++ b/src/components/ChatRoom/ChatRoom.js @@ -0,0 +1,76 @@ +import React, { useContext } from 'react' +import { Helmet } from 'react-helmet' +import classNames from 'classnames' +import Button from '@material-ui/core/Button' +import Dialog from '@material-ui/core/Dialog' +import DialogTitle from '@material-ui/core/DialogTitle' +import DialogContent from '@material-ui/core/DialogContent' +import DialogActions from '@material-ui/core/DialogActions' +import Typography from '@material-ui/core/Typography' + +import FarmhandContext from '../Farmhand/Farmhand.context' + +import './ChatRoom.sass' + +const chitchatterDomain = 'https://chitchatter.im' + +export const ChatRoom = () => { + const dialogTitleId = 'chat-title' + const dialogContentId = 'chat-content' + + const { + handlers: { handleChatRoomOpenStateChange }, + gameState: { id, isChatOpen, room }, + } = useContext(FarmhandContext) + + const handleChatRoomClose = () => { + handleChatRoomOpenStateChange(false) + } + + const chatRoomComponent = ( + // @ts-ignore + + ) + + return ( + <> + +