Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversations UI - create chat window #421

Merged

Conversation

olipyskoty
Copy link
Contributor

@olipyskoty olipyskoty commented Feb 17, 2021

Contributing to Twilio

All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

Pull Request Details

JIRA link(s):

Description

  • created chat button using svg icon from figma designs
  • created close chat window button using svg icon from figma designs
  • created ChatProvider and useChatContext hook
  • created ToggleChatButton component and added to MenuBar component
  • created ChatWindow component
  • added ChatWindow component to Room component and included ui for chat window on web and mobile
  • created ChatWindowHeader component and added to ChatWindow component
  • created CloseChatWindowButton component and added to ChatWindowHeader component
  • created unit tests for Room, CloseChatWindowButton, ToggleChatButton components and useChatContext hook
  • gif below shows chat window opening and closing on web and mobile!
  • note: when gif gets to mobile example, there appears to be whitespace in the chat header. I tested this on my iphone and locally in Device Mode in the Chrome Devtools and confirm it only happens in the gif 🤷‍♀️
    3731

Burndown

Before review

  • Updated CHANGELOG.md if necessary
  • Added unit tests if necessary
  • Updated affected documentation
  • Verified locally with npm test
  • Manually sanity tested running locally
  • Included screenshot as PR comment (if needed)
  • Ready for review

Before merge

  • Got one or more +1s
  • Re-tested if necessary

};

return (
<div onClick={closeChatWindow}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This function can just be inline. It's less code:

  return (
    <div onClick={() => setIsChatWindowOpen(false)}>
      <CloseChatWindowIcon />
    </div>
  );

This change makes this component quite small, so I don't think it needs to be in its own file. What do you think about moving all of this (and tests) into the ChatWindowHeader component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree 👍 i moved all CloseChatWindowButton code into the ChatWindowHeader component and deleted this folder from the Buttons directory

};

return (
<div onClick={closeChatWindow}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the close icon isn't perfectly centered. There seems to be a little extra vertical space in that div:

image

Seems that adding display: flex to the div fixes the issue. For a single css property, I think it's fine to just add it as a style prop:

<div style={{ display: 'flex' }}>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice find. because i moved all of this code to the ChatWindowHeader component, I was able to add this css to the existing useStyles object and avoid using the style prop

@@ -0,0 +1,20 @@
import React from 'react';

export default function CloseChatWindowIcon() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this icon can be named a little more generically. It's just an "X", so I don't think it is specific to the ChatWindow component. What do you think about CloseIcon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes more sense so that we can reuse it in the future if need be 👍

src/theme.ts Outdated
@@ -121,4 +125,6 @@ export default createMuiTheme({
sidebarMobilePadding: 8,
participantBorderWidth: 2,
mobileTopBarHeight: 52,
chatWindowWidth: 320,
chatWindowHeaderHeight: 56,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be ok if this value is stored inside the ChatWindowHeader component itself. I think the theme object is a good place to put values that will be used in multiple spots. I think that the chatWindowHeaderHeight value is only going to be used by that component.

I think it's fine to keep chatWindowWidth in here though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will keep that in mind! removed and updated ChatWindowHeader

import { useContext } from 'react';
import { ChatContext } from '../../components/ChatProvider';

export default function useVideoContext() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be useChatContext.

Suggested change
export default function useVideoContext() {
export default function useChatContext() {

justifyContent: 'space-between',
alignItems: 'center',
paddingLeft: '1em',
paddingRight: '1em',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the designs have a border on the bottom of this header.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - equivalent would be: padding: 0 1em

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made update to padding. i used boxShadow as opposed to borderBottom as i think this looks closer to the designs, but let me know what you think!

@@ -0,0 +1,36 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it comes to organizing component directories, I like to keep important components and components that may be used in many places at the top level of the component/ directory. Since this component is a minor component that will only be used by the ChatWindow component, I think it should be moved inside that component:

src/components/ChatWindow/ChatWindowHeader/ChatWindowHeader.tsx.

describe('the CloseChatWindowButton component', () => {
it('should render correctly when chat window is open', () => {
const wrapper = shallow(<CloseChatWindowButton />);
expect(wrapper.containsMatchingElement(<CloseChatWindowIcon />)).toEqual(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this test is needed. When shallow rendering this component, I think the icon will always be there regardless of the value of isChatWindowOpen (which is actually undefined here because it isn't defined on line 14. I think this is ok because this value is not relevant to this test.)

it('should call the correct toggle function when clicked', () => {
const wrapper = shallow(<ToggleChatButton />);
wrapper.find(Button).simulate('click');
expect(mockToggleChatWindow).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we can test that the button is correctly negating the value of isChatWindowOpen. Let's define isChatWindowOpen (say as false) on line 14, then here on line 26 we can use .toHaveBeenCalledWith(true).

Copy link
Contributor

@timmydoza timmydoza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!! 🎉

@olipyskoty olipyskoty merged commit aa2c8c1 into feature/conversations Feb 19, 2021
@olipyskoty olipyskoty deleted the VIDEO-3731-conversations-ui-create-chat-window branch February 19, 2021 17:35
timmydoza pushed a commit that referenced this pull request Mar 31, 2021
* VIDEO 3731 Conversations UI - create chat window (#421)

* Video 4078 add flip camera button to mobile menu (#433)

VIDEO 4078 Conversations - Add flip camera button to 'more' mobile menu

* Video 3730 add conversation hooks (#438)

* Add initial hooks for chat

* Update hooks in chat provider

* Add tests for conversationProvider component

* Fix DeviceSelectionScreen tests

* Update variable names

* Revert proxy url in package.json

* Fix linting issues

* Make error handling more user friendly

* Fix a test in src/state

* Temporarily disable cypress tests

* Undo prettier changes to config.yml

* Update chatProvider test

* Cleanup ChatProvider

* Video 3732 Conversations UI - create message components (#441)

* Add links to TextMessage component (#446)

* Add links to TextMessage component

* Update CSS in TextMessage

* Update snapshot test

* Fix issue in addLinks function

* Use forEach loop in addLinks function

* Add new server (#443)

* Use new server with reused code

* Add firebase auth to server

* Convert server to typescript

* Add tests for firebaseAuthMiddleware

* Refactor server

* Add more server tests

* Add tests for CreateExpressHandler

* Fix linter issue

* Delete old server

* Fix linter issues

* Fix some server issues

* Set up server build steps

* Change request to match new server api

* Fix token fetch test

* Add server build step to circleci config

* Enable cyress tests in CI

* Undo prettier changes in config.yml

* install plugin-rtc from npm

* Fix firebaseAuth test

* Add create_conversation:true to token requests

* Upgrade plugin-rtc to 0.8.0

* Temorarily remove firebaseAuthMiddleware and recording rules route

* Add ChatProvider back in

* Update .env.example

* Change build:server script

* Add firebaseAuthMiddleware

* Add comments to firebaseAuthMiddleware

* Update useFirebaseAuth tests

* Video 3728 Conversations UI - add input field and send button (#451)

* Chat notification (#454)

* Add notification to chat icon

* Add tests for ToggleChatButton

* Some cleanup

* Fix linting issue

* Video-4525 loading screen (#461)

* Video 4454 Conversations UI -  message list scrolling (#467)

* Update MessageList component to change how messages are grouped (#469)

* Update MessageList component to change how messages are grouped

* Simplify MessageList code

* Video 3888 file input for conversations (#458)

* Add FileAttachmentIcon

* Add File Input to ChatInput component

* Add change handler to file input

* Create MediaMessage component and add it to MessageList

* Toggle ChatWindow visibility with CSS

* Update messageList tests

* Add function to format the file size

* Update error handling in ChatInput component

* Add tests for MediaMessage component

* Update snapshot test

* Add tests for ChatInput

* Fix linting issue

* Update filesize formatting

* Update error language and tests

* Reset file input value after file sent

* Center icon in MediaMessage

* Update Icon size

* Fix breaking ChatInput test

* Update snapshot

* Use accept attribute on file input element

* Update readme to add information about the chat feature and conversations api

* Cross browser fixes (#472)

* Update app.yaml for the new server

* Add cache controls for static assets

* Only hide Screenshare button on mobile devices

* Auto focus on chat input when user opens chat window

* Fix iOS bug with media messages

* Fix issues in MessageListScrollContainer

* Fix app.yaml

* Fix infinite loop when there is a conversations error

* Update tests for ChatInput

* Update mediamessage test

* Update menubar tests

* Update messageList snapshot

* Fix linting issue

* Add comments to the server

* Video 3727 - cypress testing (#473)

* Video 4597 feature flag (#475)

* Update plugin-rtc version

* Add feature flag for Twilio Conversations

* Add tests

* Add info to .env.example

* Update readme with info about twilio conversations (#476)

* Update readme with info about twilio conversations

* Update readme to address feedback

* Release 0.3.0 (#479)

* Bump version and update changelog

* Add plugin-rtc upgrade instructions to the readme

Co-authored-by: olipyskoty <77076398+olipyskoty@users.noreply.github.com>
Co-authored-by: Sean Coleman <smcoleman27@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants