diff --git "a/client/public/Asset/\352\262\214\354\236\204/0.jpeg" "b/client/public/Asset/\352\262\214\354\236\204/0.jpeg" deleted file mode 100644 index 59f4a0dd..00000000 Binary files "a/client/public/Asset/\352\262\214\354\236\204/0.jpeg" and /dev/null differ diff --git "a/client/public/Asset/\352\262\214\354\236\204/1.gif" "b/client/public/Asset/\352\262\214\354\236\204/1.gif" deleted file mode 100644 index cb615007..00000000 Binary files "a/client/public/Asset/\352\262\214\354\236\204/1.gif" and /dev/null differ diff --git "a/client/public/Asset/\352\262\214\354\236\204/2.png" "b/client/public/Asset/\352\262\214\354\236\204/2.png" deleted file mode 100644 index 76b74527..00000000 Binary files "a/client/public/Asset/\352\262\214\354\236\204/2.png" and /dev/null differ diff --git a/client/src/Component/Atom/Video.tsx b/client/src/Component/Atom/Video.tsx index 0a582150..2e43382e 100644 --- a/client/src/Component/Atom/Video.tsx +++ b/client/src/Component/Atom/Video.tsx @@ -2,23 +2,10 @@ import React, { useEffect, useRef, useState } from "react"; import styled from "@emotion/styled"; import { css } from "@emotion/react"; -const GameStyle = css` - top: -10%; - width: 150px; - height: 150px; -`; - -const GatherStyle = css` - width: 150px; - height: 150px; -`; - -const containerStyle = (props: { type: string }) => css` +const containerStyle = css` width: 240px; height: 240px; border: 1px solid #000000; - ${props.type === "Game" && GameStyle} - ${props.type === "Gather" && GatherStyle} `; const VideoContainer = styled.video` @@ -29,11 +16,10 @@ const VideoContainer = styled.video` interface Props { stream: MediaStream; - type: string; muted?: boolean; } -export const Video = ({ type, stream, muted }: Props) => { +export const Video = ({ stream, muted }: Props) => { const videoRef = useRef(null); const [isMuted, setIsMuted] = useState(false); @@ -45,7 +31,7 @@ export const Video = ({ type, stream, muted }: Props) => { }, [stream, muted]); return ( -
+
); diff --git a/client/src/Component/Molecules/Chat/ChatInput.tsx b/client/src/Component/Molecules/Chat/ChatInput.tsx deleted file mode 100644 index 953a1d91..00000000 --- a/client/src/Component/Molecules/Chat/ChatInput.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import React, { ChangeEvent, ChangeEventHandler, useRef } from "react"; -import { css } from "@emotion/react"; -import { useRecoilValue } from "recoil"; -import { Input } from "@Atom/."; -import { chatTarget } from "../../../Recoil/Atom"; -import { userState } from "@Recoil/UserData"; -import ClientSocket from "../../../Socket"; -import { postChat } from "@Util/data"; -const ImageSendButton = "/Asset/ImageSendButton.svg"; -const SendButton = "/Asset/SendButton.svg"; - -const InputContainer = css` - display: flex; - justify-content: center; - padding-top: 10px; - align-items: center; - height: fit-content; -`; - -const sendImageStyle = css` - background-image: url(${ImageSendButton}); - background-position: center; - background-repeat: no-repeat; - background-size: cover; - width: 25px; - height: 25px; - margin-right: 10px; - cursor: pointer; -`; - -const sendButtonStyle = css` - background-image: url(${SendButton}); - background-position: center; - background-repeat: no-repeat; - background-size: cover; - width: 25px; - height: 25px; - margin-left: 10px; - cursor: pointer; -`; - -const ImageInputStlye = css` - display: none; -`; - -export const ChatInput = () => { - const { chatRoomId } = useRecoilValue(chatTarget); - const { id: uid } = useRecoilValue(userState); - - const messageRef = useRef(null); - const imageInputTag = useRef(null); - - const handleSendMessageClick = () => { - if (!messageRef.current) return; - if (!messageRef.current.value) return; - - const chat = messageRef.current.value; - - const { socket } = new ClientSocket(uid); - socket?.emit("sendChat", { chatRoomId, message: { from: uid, message: chat, read: false, source: "" } }); - messageRef.current.value = ""; - }; - - const handleEnterPress = (e: React.KeyboardEvent) => { - if (e.code !== "Enter") return; - handleSendMessageClick(); - }; - - const handleImageButtonClick = () => { - (imageInputTag.current as HTMLInputElement).click(); - }; - - const changeImage: ChangeEventHandler = (event: ChangeEvent) => { - if (!event.target.files) return; - - postChat(chatRoomId, uid, event.target.files[0]); - }; - - return ( -
-
- -
- -
- ); -}; diff --git a/client/src/Component/Molecules/Chat/ChatInput/ChatInput.hook.tsx b/client/src/Component/Molecules/Chat/ChatInput/ChatInput.hook.tsx new file mode 100644 index 00000000..0021469b --- /dev/null +++ b/client/src/Component/Molecules/Chat/ChatInput/ChatInput.hook.tsx @@ -0,0 +1,40 @@ +import { postChat } from "@Util/data"; +import { ChangeEvent, ChangeEventHandler, useRef } from "react"; +import ClientSocket from "Socket"; + +type chatRoomInfo = { + uid: string; + chatRoomId: number; +}; + +export const useChatMessageControl = ({ uid, chatRoomId }: chatRoomInfo) => { + const messageRef = useRef(null); + const sendMessage = () => { + if (!messageRef.current?.value) return; + sendChat({ uid, chatRoomId, message: messageRef.current.value }); + messageRef.current.value = ""; + }; + const handleEnterPress = (e: React.KeyboardEvent) => { + if (e.code !== "Enter") return; + sendMessage(); + }; + return { messageRef, sendMessage, handleEnterPress }; +}; + +type sendChatPropsType = chatRoomInfo & { message: string }; +const sendChat = ({ uid, chatRoomId, message }: sendChatPropsType) => { + const { socket } = new ClientSocket(uid); + socket?.emit("sendChat", { chatRoomId, message: { from: uid, message, read: false, source: "" } }); +}; + +export const useChatImageControl = ({ uid, chatRoomId }: chatRoomInfo) => { + const imageInputTag = useRef(null); + const handleImageButtonClick = () => (imageInputTag.current as HTMLInputElement).click(); + + const changeImage: ChangeEventHandler = (event: ChangeEvent) => { + if (!event.target.files) return; + postChat(chatRoomId, uid, event.target.files[0]); + }; + + return { imageInputTag, handleImageButtonClick, changeImage }; +}; diff --git a/client/src/Component/Molecules/Chat/ChatInput/ChatInput.tsx b/client/src/Component/Molecules/Chat/ChatInput/ChatInput.tsx new file mode 100644 index 00000000..f7d5e6b1 --- /dev/null +++ b/client/src/Component/Molecules/Chat/ChatInput/ChatInput.tsx @@ -0,0 +1,57 @@ +import { css } from "@emotion/react"; +import { useRecoilValue } from "recoil"; +import { Input } from "@Atom/."; +import { userChatRoomInfo } from "@Recoil/ChatData"; +import { useChatImageControl, useChatMessageControl } from "./ChatInput.hook"; + +export const ChatInput = () => { + const { chatRoomId, id: uid } = useRecoilValue(userChatRoomInfo); + const { messageRef, sendMessage, handleEnterPress } = useChatMessageControl({ uid, chatRoomId }); + const { imageInputTag, handleImageButtonClick, changeImage } = useChatImageControl({ uid, chatRoomId }); + + return ( +
+