-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 리더보드 버튼 추가 및 쿠키 삭제 * feat: api 코드 추가 * fix: 퀴즈 풀이 화면 수정 * feat: 핀코드 입력 시 진행 중인 게임으로 이동하는 로직 추가 * fix: 0보다 작은 경우 quizEnd true로 변경 * feat: show quiz 리턴값에 participantLength 추가 * feat: 퀴즈 참가 인원 데이터를 UI에 추가 * feat: 퀴즈 로딩 fallback 변경 * fix: 퀴즈 평균 점수 소수점 한 자리로 변경 * feat: 퀴즈 헤더 삭제 * fix: height 수정 * feat: 평균 점수 소수점 변경 * feat: my info 이벤트 추가 및 UI 변경 * style: dvh로 변경 * feat: 퀴즈 세션 전용 프로그래스바 추가 * fix: 서버 position 에러 해결 및 my info 이벤트 추가 --------- Co-authored-by: byeong <[email protected]>
- Loading branch information
1 parent
4b09cbc
commit b6c8aa3
Showing
19 changed files
with
266 additions
and
77 deletions.
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
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
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
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
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
17 changes: 17 additions & 0 deletions
17
packages/client/src/pages/quiz-session/model/hooks/useGetMyInfo.ts
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,17 @@ | ||
import { getCookie } from '@/shared/utils/cookie'; | ||
import { emitEventWithAck } from '@/shared/utils/emitEventWithAck'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { Socket } from 'socket.io-client'; | ||
|
||
interface UseGetMyInfoProps { | ||
socket: Socket; | ||
} | ||
|
||
export const useGetMyInfo = ({ socket }: UseGetMyInfoProps) => { | ||
return useSuspenseQuery({ | ||
queryKey: ['myInfo'], | ||
queryFn: () => { | ||
return emitEventWithAck<any>(socket, 'my info', { sid: getCookie('sid') }); | ||
}, | ||
}); | ||
}; |
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,64 @@ | ||
interface ProgressBarProps { | ||
/** 전체 시간 설정 */ | ||
time: number; | ||
/** 프로그래스바 타입 */ | ||
type: 'success' | 'warning' | 'error' | 'info' | 'gradient'; | ||
/** 프로그래스바 모양 */ | ||
barShape?: 'rounded' | 'square'; | ||
/** 마우스 호버 시 정지 여부 */ | ||
pauseOnHover?: boolean; | ||
/** 애니메이션 종료 시 콜백 함수 */ | ||
handleAnimationEnd?: () => void; | ||
/** 현재 진행 시간 */ | ||
currentTime?: number; | ||
} | ||
|
||
const progressBarColors = { | ||
success: 'bg-secondary', | ||
warning: 'bg-yellow-500', | ||
error: 'bg-red-500', | ||
info: 'bg-blue-500', | ||
gradient: 'bg-gradient-to-r from-red-500 to-orange-500', | ||
}; | ||
|
||
const progressBarShapes = { | ||
rounded: 'rounded-r-base', | ||
square: 'rounded-none', | ||
}; | ||
|
||
const ProgressBar = ({ | ||
time = 5, | ||
type = 'success', | ||
barShape = 'rounded', | ||
pauseOnHover, | ||
handleAnimationEnd, | ||
currentTime = 0, | ||
}: ProgressBarProps) => { | ||
const progressBarColor = progressBarColors[type]; | ||
const progressBarShape = progressBarShapes[barShape]; | ||
|
||
// 현재 시간에 따른 진행률 계산 | ||
const progress = Math.min(Math.max((currentTime / time) * 100, 0), 100); | ||
// 남은 시간 비율 계산 | ||
const remainingTimeRatio = 1 - currentTime / time; | ||
// 애니메이션 지속 시간 계산 (초 단위) | ||
const animationDuration = time * remainingTimeRatio; | ||
|
||
return ( | ||
<section className="group" onAnimationEnd={handleAnimationEnd}> | ||
<div className="h-[6px] w-full bg-transparent"> | ||
<div | ||
className={`h-[6px] ${progressBarColor} ${progressBarShape} ${ | ||
pauseOnHover && 'group-hover:[animation-play-state:paused]' | ||
}`} | ||
style={{ | ||
width: `${progress}%`, | ||
animation: `progress ${animationDuration}s linear forwards`, | ||
}} | ||
/> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default ProgressBar; |
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
Oops, something went wrong.