Skip to content

Commit

Permalink
Feat: 채팅방 모달 컴포넌트 생성 (#26)
Browse files Browse the repository at this point in the history
- 채팅 기능을 위한 모달 컴포넌트 구현
- 모달 열기 및 닫기 상태 관리 로직 추가
- 메시지 리스트와 입력창 UI를 구성하는 ChatRoom 컴포넌트 포함
  • Loading branch information
sunglitter committed Dec 1, 2024
1 parent f07e515 commit caf9965
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions src/components/pages/community/modal/ChatRoomModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React from 'react';
import styled from 'styled-components';
import ChatRoom from '../../../common/ChatRoom'; // 채팅방 컴포넌트
import { WebSocketService } from '../../../../utils/webSocket';

interface ChatRoomModalProps {
chatRoomId: string;
chatRoomTitle: string;
isOpen: boolean;
onClose: () => void;
webSocketService: WebSocketService;
}

const ChatRoomModal: React.FC<ChatRoomModalProps> = ({
isOpen,
onClose,
chatRoomId,
chatRoomTitle,
}) => {
if (!isOpen) return null;

return (
<ModalOverlay>
<ModalContainer>
<ModalHeader>
<ModalTitle>{chatRoomTitle}</ModalTitle>
<ModalCloseButton onClick={onClose}>&times;</ModalCloseButton>
</ModalHeader>
<ModalContent>
<ChatRoom chatRoomId={chatRoomId} />
</ModalContent>
</ModalContainer>
</ModalOverlay>
);
};

export default ChatRoomModal;

const ModalOverlay = styled.div`
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
`;

const ModalContainer = styled.div`
width: 90%;
max-width: 600px;
background-color: #fff;
border-radius: 10px;
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
`;

const ModalHeader = styled.div`
padding: 16px;
background-color: #f7f7f7;
border-bottom: 1px solid #ddd;
display: flex;
justify-content: space-between;
align-items: center;
`;

const ModalTitle = styled.h2`
font-size: 18px;
font-weight: bold;
color: #333;
`;

const ModalCloseButton = styled.button`
background: none;
border: none;
font-size: 20px;
cursor: pointer;
color: #666;
&:hover {
color: #333;
}
`;

const ModalContent = styled.div`
flex: 1;
padding: 16px;
overflow-y: auto;
`;

0 comments on commit caf9965

Please sign in to comment.