All files / components/Chat ChatFeature.js

100% Statements 9/9
100% Branches 6/6
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                2x 49x   49x 3x     49x             49x             49x             49x                            
import React, {useState} from "react";
import { Button } from "react-bootstrap";
import Image from 'react-bootstrap/Image';
import ChatPanel from "main/components/Chat/ChatPanel";
import ChatOpenedIcon from "../../../assets/ChatOpenedIcon.svg";
import ChatClosedIcon from "../../../assets/ChatClosedIcon.svg";
import ChatBubble from "../../../assets/ChatBubble.svg";
 
const ChatFeature = ({commonsId}) => {
  const [isChatClosed, setIsChatClosed] = useState(true);
 
  const toggleChatWindow = () => {
    setIsChatClosed((prevState) => !prevState);
  };
 
  const chatIconStyle = {
    width: '95px',
    position: 'fixed',
    bottom: '10px',
    right: '30px',
  };
 
  const chatBubbleStyle = {
    width: '67px',
    position: 'fixed',
    bottom: '80px',
    right: '120px',
  };
 
  const chatContainerStyle = {
    width: '550px',
    position: 'fixed',
    bottom: '130px',
    right: '10px',
  };
 
  return (
    <div data-testid="chat-feature-container">
      {isChatClosed && <Image style={chatBubbleStyle} src ={ChatBubble} alt="" data-testid="chat-bubble-icon"/>}
      <div style={chatContainerStyle} data-testid="playpage-chat-div">
        {!isChatClosed && <ChatPanel commonsId={commonsId}/>}
        <Button data-testid="chat-toggle" variant="outline-light" onClick={toggleChatWindow}>
          <Image style={chatIconStyle} src={ChatClosedIcon} alt="Click to open the chat" data-testid="chat-closed-icon"/>
          {!isChatClosed && <Image style={chatIconStyle} src={ChatOpenedIcon} alt="Click to close the chat" data-testid="chat-opened-icon"/>}
        </Button>
      </div>
    </div>
  );
};
 
export default ChatFeature;