-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FE] feat: 방 입장 전 세팅 화면 구성 #48
Merged
Merged
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
959066f
feat: [FE] 비디오 컴포넌트 공통 컴포넌트로 분리
d0422 46b94d0
feat: [FE] Button컴포넌트 합성 컴포넌트로 변경
d0422 e6004c9
chore: [FE] Button컴포넌트 합성 적용
d0422 9f24d89
feat: [FE] user의 Stream을 관리하는 useMedia 커스텀 훅 기능 구현
d0422 ea2295a
feat: [FE] media목록을 보여주고 media를 결정하는 MediaSelector 구현
d0422 870cbb4
feat: [FE] Video와 MediaSelector를 보여주는 SettingVideo컴포넌트 구현
d0422 72b8bae
feat: [FE] 방 입장 전 Setting을 할 수 있는 Setting컴포넌트 기능 구현
d0422 45a2d39
feat: [FE] useMedia muted, offVideo 함수 추가
d0422 948541c
feat: [FE] 기본 stream track을 selected 된 상태로 렌더링하는 기능 구현
d0422 bbe8eed
chore: [FE] video audio ControlButton을 위한 svg 파일 추가
d0422 7095939
fix: [FE] stream이 useEffect로 변경되어 micOff와 videoOff가 제대로 동작하지 않던 문제 함수 삭제
d0422 f463c6e
feat: [FE] audio, video Control Button추가
d0422 779d843
chore: [FE] useMedia 반환타입 명시
d0422 6cef3ad
feat: [FE] Video 음성 추가 및 조건부 muted처리
d0422 bb7f2d4
chore: [FE] mediaObject props로 내려주기 적용
d0422 9b5e3d4
feat: [FE] settings에서 참여하기 전까지 socket연결을 하지 않는 기능 추가
d0422 4432dab
config: [FE] lint default Props관련 룰 해제
d0422 dee14e0
chore: [FE] zustand 설치
d0422 23ffee9
feat: [FE] 전역상태 useSpeaker 생성
d0422 050c501
feat: [FE] useMedia에서 반환하는 setSpeaker 삭제
d0422 461cc9d
feat: [FE] 전역 setSpeaker 적용
d0422 3f96b15
feat: [FE] 변경된 speaker를 적용시키는 부분 구현
d0422 0ef75c0
refactor: [FE] import.meta.env를 유지하되, test코드에서 모킹하여 사용할 수 있도록 상수형태로 e…
d0422 b5d4d86
fix: [FE] videoRef.current에 setSinkId가 없는 경우 호출하지 않도록 처리
d0422 64afd46
test: [FE] Room 조건부 렌더링 테스트 추가
d0422 4c7bf93
test: [FE] useInput 커스텀훅 기능 테스트
d0422 1bfcf38
test: [FE] useMedia 기능 테스트
d0422 ac410b7
refactor: [FE] 코드리뷰 반영
d0422 2590b22
chore: [FE] 불필요한 파일 삭제
d0422 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export default function MediaSelector({ | ||
stream, | ||
optionsData, | ||
setFunc, | ||
}: { | ||
stream: MediaStream; | ||
optionsData: MediaDeviceInfo[]; | ||
setFunc: React.Dispatch<React.SetStateAction<string>>; | ||
}) { | ||
const onChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
setFunc(e.target.value); | ||
}; | ||
return ( | ||
<select className="w-[33%] font-Pretendard text-xl" onChange={onChange}> | ||
{optionsData?.map((device) => { | ||
const isSelected = stream.getTracks().find((track) => track.label === device.label); | ||
if (isSelected) | ||
return ( | ||
<option key={device.label} value={device.deviceId} selected className="font-Pretendard"> | ||
{device.label} | ||
</option> | ||
); | ||
|
||
return ( | ||
<option key={device.label} value={device.deviceId} className="font-Pretendard"> | ||
{device.label} | ||
</option> | ||
); | ||
})} | ||
</select> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { ReactNode, useState } from 'react'; | ||
import { MediaObject } from '@/hooks/useMedia'; | ||
import MediaSelector from './MediaSelector'; | ||
import Video from './Video'; | ||
import micOnSVG from '@/assets/micOn.svg'; | ||
import micOffSVG from '@/assets/micOff.svg'; | ||
import videoOffSVG from '@/assets/videoOff.svg'; | ||
import videoOnSVG from '@/assets/videoOn.svg'; | ||
import useSpeaker from '@/stores/useSpeaker'; | ||
|
||
function ControlButton({ onClick, style, children }: { onClick: () => void; style: Record<string, string>; children: ReactNode }) { | ||
return ( | ||
<button | ||
type="button" | ||
onClick={onClick} | ||
className="w-[5vw] p-[1vw] hover:opacity-50 border-solid border-[1px] rounded-[50%] border-white" | ||
style={style} | ||
> | ||
{children} | ||
</button> | ||
); | ||
} | ||
|
||
export default function SettingVideo({ mediaObject }: { mediaObject: MediaObject }) { | ||
const { stream, camera, mic, speaker } = mediaObject; | ||
const { list: cameraList, setCamera } = camera; | ||
const { list: micList, setMic } = mic; | ||
const { list: speakerList } = speaker; | ||
const setSpeaker = useSpeaker((state) => state.setSpeaker); | ||
const [micOn, setMicOn] = useState(true); | ||
|
||
const [videoOn, setVideoOn] = useState(true); | ||
|
||
const offVideo = () => { | ||
stream?.getVideoTracks().forEach((track) => { | ||
track.enabled = !track.enabled; | ||
}); | ||
}; | ||
|
||
const muteMic = () => { | ||
stream?.getAudioTracks().forEach((track) => { | ||
track.enabled = !track.enabled; | ||
}); | ||
}; | ||
const handleMicClick = () => { | ||
setMicOn((prev) => !prev); | ||
muteMic(); | ||
}; | ||
const handleVideoClick = () => { | ||
setVideoOn((prev) => !prev); | ||
offVideo(); | ||
}; | ||
return ( | ||
stream && ( | ||
<div className="flex flex-col gap-[20px] "> | ||
<div className="relative"> | ||
<Video stream={stream} muted /> | ||
<div className="absolute flex items-center justify-center w-full gap-[1vw] bottom-[10px]"> | ||
<ControlButton onClick={handleMicClick} style={{ backgroundColor: micOn ? 'transparent' : '#ea4335', transition: 'all 0.5s' }}> | ||
<img src={micOn ? micOnSVG : micOffSVG} alt="micButton" /> | ||
</ControlButton> | ||
<ControlButton | ||
onClick={handleVideoClick} | ||
style={{ backgroundColor: videoOn ? 'transparent' : '#ea4335', transition: 'all 0.5s' }} | ||
> | ||
<img src={videoOn ? videoOnSVG : videoOffSVG} alt="videoButton" /> | ||
</ControlButton> | ||
</div> | ||
</div> | ||
<div className="flex gap-[10px]"> | ||
{[ | ||
[cameraList, setCamera], | ||
[micList, setMic], | ||
[speakerList, setSpeaker], | ||
].map( | ||
([deviceList, setFunc], i) => | ||
deviceList && ( | ||
<MediaSelector | ||
key={i} | ||
stream={stream} | ||
optionsData={deviceList as MediaDeviceInfo[]} | ||
setFunc={setFunc as React.Dispatch<React.SetStateAction<string>>} | ||
/> | ||
), | ||
)} | ||
</div> | ||
</div> | ||
) | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 것에 대한
map
인지 한 번에 알아볼 수 있도록 변수로 분리하는 것도 좋을 것 같아요.현재로서는 어떤 역할을 하는지 한 번에 확인하기 어려운 것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런식으로 개선해보았습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다!