Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4155b62
refactor: 소켓 연결 실패시 에러처리 핸들러 등록
ShipFriend0516 Nov 9, 2024
afd9ee2
refactor: useSocket로 소켓 초기화하는 코드 커스텀 hook으로 분리
ShipFriend0516 Nov 9, 2024
8c1b7bb
refactor: 세션 페이지의 사이드바 컴포넌트를 분리
ShipFriend0516 Nov 9, 2024
2c143f1
refactor: 세션 페이지의 Footer 툴바 컴포넌트를 분리
ShipFriend0516 Nov 9, 2024
bfc3ff1
feat: 공감 버튼 UI 구현
ShipFriend0516 Nov 9, 2024
71a2c7c
refactor: useSocket 매개변수에 따라 재실행되도록 수정
ShipFriend0516 Nov 9, 2024
08c36d7
feat: 질문 넘기기 버튼을 aria-label로 접근성 향상
ShipFriend0516 Nov 9, 2024
2707dee
refactor: useMediaDevices 훅으로 미디어 장치와 미디어 스트림 관리를 하나로 분리
ShipFriend0516 Nov 9, 2024
066c6cf
feat: 화상회의 도중 미디어 장치를 바꾸면 바로 스트림에 적용되도록 구현
ShipFriend0516 Nov 10, 2024
168fef0
fix: 방 참가를 안해도 미디어 장치가 켜지던 오류 해결
ShipFriend0516 Nov 10, 2024
b669619
feat: 발견된 미디어 장치가 없을 때 없다고 표시하도록 구현
ShipFriend0516 Nov 10, 2024
d43232a
style: 전체 레이아웃 최대 너비 증가 및 각 비디오 컴포넌트 최대크기 지정
ShipFriend0516 Nov 10, 2024
d2ae18e
style: toolbar 버튼 스타일 수정
ShipFriend0516 Nov 10, 2024
e9c8416
style: 미디어 장치 선택 select 너비 증가
ShipFriend0516 Nov 10, 2024
37e9547
style: pretendard font 추가 및 root font 설정
ShipFriend0516 Nov 10, 2024
93d433e
feat: 참가자 목록을 사이드바에서 볼 수 있도록 구현
ShipFriend0516 Nov 10, 2024
cd77996
refactor: 오류메시지 수정
ShipFriend0516 Nov 10, 2024
ee147b0
Merge branch 'dev' into refactor/session-page
ShipFriend0516 Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions frontend/src/App.css

This file was deleted.

Binary file not shown.
50 changes: 50 additions & 0 deletions frontend/src/components/session/SessionSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { FaClipboardList } from "react-icons/fa";
import { FaUserGroup } from "react-icons/fa6";

interface Props {
question: string;
participants: string[];
}

const SessionSidebar = ({ question, participants }: Props) => {
return (
<div className={"flex flex-col justify-between w-[440px] px-6"}>
<div className={"flex flex-col gap-4"}>
<div className={"flex flex-col gap-2"}>
<h2 className={"inline-flex gap-1 items-center text-semibold-s"}>
<FaClipboardList />
질문
</h2>
<p
className={
"border border-accent-gray p-2 bg-transparent rounded-xl"
}
>
{question}
</p>
</div>
<div className={"flex flex-col gap-2"}>
<h2 className={"inline-flex gap-1 items-center text-semibold-s"}>
<FaUserGroup />
참가자
</h2>
<ul>
{participants.map((participant, index) => (
<li key={index} className={"flex items-center gap-2"}>
<span className={"w-4 h-4 bg-accent-gray rounded-full"} />
<span>{participant}</span>
</li>
))}
</ul>
</div>
</div>
<div className={"h-16 items-center flex w-full"}>
<button className={"w-full bg-red-500 text-white rounded-md py-2"}>
종료하기
</button>
</div>
</div>
);
};

export default SessionSidebar;
106 changes: 106 additions & 0 deletions frontend/src/components/session/SessionToolbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { FaAngleLeft, FaAngleRight } from "react-icons/fa6";
import {
BsCameraVideo,
BsCameraVideoOff,
BsMic,
BsMicMute,
BsHandThumbsUp,
} from "react-icons/bs";

interface Props {
handleVideoToggle: () => void;
handleMicToggle: () => void;
userVideoDevices: MediaDeviceInfo[];
userAudioDevices: MediaDeviceInfo[];
setSelectedVideoDeviceId: (deviceId: string) => void;
setSelectedAudioDeviceId: (deviceId: string) => void;
isVideoOn: boolean;
isMicOn: boolean;
}
Comment on lines +10 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

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

인터페이스 구성 좋습니다!

제가 예엣날에 프론트 선배님(?)께 배운 방식은 컴포넌트Props 로 별도로 명세해서 추가적으로 어떤 프로퍼티인지 알려주는 식으로 구성하긴 했어요

Copy link
Collaborator

Choose a reason for hiding this comment

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

이 컴포넌트를 예시로 들 경우 SessionToolbarProps 와 같은 형식이에용

const SessionToolbar = ({
handleVideoToggle,
handleMicToggle,
userVideoDevices,
userAudioDevices,
setSelectedVideoDeviceId,
setSelectedAudioDeviceId,
isVideoOn,
isMicOn,
}: Props) => {
return (
<div
className={
"session-footer h-16 inline-flex w-full justify-between items-center border-t px-6"
}
>
<button
className={"bg-transparent rounded-full border p-3 text-xl"}
aria-label={"이전 질문 버튼"}
>
<FaAngleLeft />
</button>
<div className={"inline-flex center-buttons gap-2"}>
<button
onClick={handleVideoToggle}
className="h-full aspect-square bg-green-500 hover:bg-green-600 text-white p-3 rounded-full"
aria-label={isVideoOn ? `비디오 끄기` : "비디오 켜기"}
>
{isVideoOn ? <BsCameraVideo /> : <BsCameraVideoOff />}
</button>
<button
onClick={handleMicToggle}
className="h-full aspect-square bg-green-500 hover:bg-green-600 text-white p-3 rounded-full"
aria-label={isMicOn ? `마이크 끄기` : "마이크 켜기"}
>
{isMicOn ? <BsMic /> : <BsMicMute />}
</button>
<button
className="h-full aspect-square bg-white text-green-500 border box-border border-accent-gray-50 hover:bg-grayscale-50 p-3 rounded-full"
aria-label={"좋아요"}
>
{<BsHandThumbsUp />}
</button>
<select
className={
"max-w-40 bg-transparent text-gray-700 text-medium-xs border border-accent-gray py-2 px-2 rounded-xl hover:bg-gray-200"
}
onChange={(e) => setSelectedVideoDeviceId(e.target.value)}
>
{userVideoDevices.length > 0 ? (
userVideoDevices.map((device) => (
<option key={device.deviceId} value={device.deviceId}>
{device.label}
</option>
))
) : (
<option value={""}>발견된 비디오 장치가 없습니다.</option>
)}
</select>
<select
className={
"max-w-40 bg-transparent text-gray-700 text-medium-xs border border-accent-gray py-2 px-2 rounded-xl hover:bg-gray-200"
}
onChange={(e) => setSelectedAudioDeviceId(e.target.value)}
>
{userAudioDevices.length > 0 ? (
userAudioDevices.map((device) => (
<option key={device.deviceId} value={device.deviceId}>
{device.label}
</option>
))
) : (
<option value={""}>발견된 오디오 장치가 없습니다.</option>
)}
</select>
</div>
<button
className={"bg-transparent rounded-full border p-3 text-xl"}
aria-label={"다음 질문 버튼"}
>
<FaAngleRight />
</button>
</div>
);
};

export default SessionToolbar;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const VideoContainer = forwardRef(
ref: React.Ref<HTMLVideoElement>
) => {
return (
<div className="bg-black rounded-2xl overflow-hidden shadow relative flex-grow">
<div className="bg-black rounded-2xl overflow-hidden shadow relative flex-grow max-w-4xl">
<video
ref={ref}
autoPlay
Expand Down
84 changes: 84 additions & 0 deletions frontend/src/hooks/useMediaDevices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { useEffect, useState } from "react";

const useMediaDevices = () => {
// 유저의 미디어 장치 리스트
const [userAudioDevices, setUserAudioDevices] = useState<MediaDeviceInfo[]>(
[]
);
const [userVideoDevices, setUserVideoDevices] = useState<MediaDeviceInfo[]>(
[]
);

// 유저가 선택한 미디어 장치
const [selectedVideoDeviceId, setSelectedVideoDeviceId] =
useState<string>("");
const [selectedAudioDeviceId, setSelectedAudioDeviceId] =
useState<string>("");

// 본인 미디어 스트림
const [stream, setStream] = useState<MediaStream | null>(null);

useEffect(() => {
// 비디오 디바이스 목록 가져오기

const getUserDevices = async () => {
try {
const devices = await navigator.mediaDevices.enumerateDevices();
const audioDevices = devices.filter(
(device) => device.kind === "audioinput"
);
const videoDevices = devices.filter(
(device) => device.kind === "videoinput"
);

setUserAudioDevices(audioDevices);
setUserVideoDevices(videoDevices);
} catch (error) {
console.error("미디어 기기를 찾는데 문제가 발생했습니다.", error);
}
Comment on lines +25 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

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

try - catch 문 사용 너무 좋습니다!

문제가 발생했을 때 유저에게 어떤 변화를 줄 지도 추후에 생각해보는 식으로 확장해나가면 좋겠네요!

};

getUserDevices();
}, []);

// 미디어 스트림 가져오기: 자신의 스트림을 가져옴
const getMedia = async () => {
try {
if (stream) {
// 이미 스트림이 있으면 종료
stream.getTracks().forEach((track) => {
track.stop();
});
}
const myStream = await navigator.mediaDevices.getUserMedia({
video: selectedVideoDeviceId
? { deviceId: selectedVideoDeviceId }
: true,
audio: selectedAudioDeviceId
? { deviceId: selectedAudioDeviceId }
: true,
});

setStream(myStream);
return myStream;
} catch (error) {
console.error(
"미디어 스트림을 가져오는 도중 문제가 발생했습니다.",
error
);
}
};

return {
userAudioDevices,
userVideoDevices,
selectedAudioDeviceId,
selectedVideoDeviceId,
setSelectedAudioDeviceId,
setSelectedVideoDeviceId,
getMedia,
stream,
};
};

export default useMediaDevices;
28 changes: 28 additions & 0 deletions frontend/src/hooks/useSocket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useEffect, useState } from "react";
import { Socket, io } from "socket.io-client";

const useSocket = (socketURL: string) => {
// 소켓 상태
const [socket, setSocket] = useState<Socket | null>(null);

// 소켓 연결
useEffect(() => {
const newSocket = io(socketURL || "http://localhost:3000");

newSocket.on("connect_error", socketErrorHandler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

함수로 따로 빼주신 것 좋습니다!

setSocket(newSocket);

return () => {
newSocket.disconnect();
setSocket(null);
};
}, [socketURL]);

return { socket };
};

const socketErrorHandler = (error: Error) => {
console.error("시그널링 서버와의 연결에 실패했습니다.", error);
};

export default useSocket;
2 changes: 2 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@tailwind components;
@tailwind utilities;


@layer base {
html {
font-family: Pretendard, system-ui, sans-serif;
Expand All @@ -23,6 +24,7 @@
-moz-osx-font-smoothing: grayscale;
}


@media (prefers-color-scheme: light) {
:root {
color: #171717;
Expand Down
Loading