-
Notifications
You must be signed in to change notification settings - Fork 2
[FEAT] 청중용 라이브 토론 공유 페이지 개선 #464
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c1f5cd7
design: 프로그레스 바 추가
i-meant-to-be 6eb323e
feat: 일반 타이머에 맞게 로직 수정
i-meant-to-be 84fca95
feat: 새로 추가된 API 활용하여 UI 개선
i-meant-to-be 308cfb9
fix: 타이머 화면이 잘못된 시간을 전송하던 문제 수정
i-meant-to-be 07c1ba0
feat: 남은 시간 계산을 위한 함수 추가
i-meant-to-be fe14e05
feat: 자유토론 타이머 카운트다운 로직 별도 분리
i-meant-to-be aee5cbf
feat: 재사용 가능한 자유토론 타이머 디스플레이 구현
i-meant-to-be 7ee6045
feat: 기존 로직 요구사항에 맞게 수정
i-meant-to-be cac970f
feat: 자유토론 타이머 내부 구현을 새로 추가한 디스플레이로 교체
i-meant-to-be 944e338
feat: 기능 구현
i-meant-to-be 69ade37
test: 테스트 버그 수정
i-meant-to-be 2c4e9a7
chore: 불필요 파일 삭제
i-meant-to-be 222086b
fix: 디자인 시안에 맞게 UI 일부 수정
i-meant-to-be e8ad5fa
fix: Gemini 리뷰 반영
i-meant-to-be 3dc378f
fix: CodeRabbit 리뷰 반영
i-meant-to-be 8ba2610
refactor: 도메인 로직 분리
i-meant-to-be 124870a
fix: 리뷰 반영
i-meant-to-be a11f6ec
fix: 추가 리뷰 반영
i-meant-to-be 8b191b2
test: 테스트 오류 수정
i-meant-to-be 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 hidden or 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 hidden or 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
102 changes: 102 additions & 0 deletions
102
src/components/TimerProgressBar/TimerProgressBar.test.tsx
This file contains hidden or 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,102 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import TimerProgressBar from './TimerProgressBar'; | ||
|
|
||
| const animateMock = vi.hoisted(() => vi.fn()); | ||
|
|
||
| vi.mock('framer-motion', async () => { | ||
| const actual = | ||
| await vi.importActual<typeof import('framer-motion')>('framer-motion'); | ||
|
|
||
| return { | ||
| ...actual, | ||
| animate: animateMock, | ||
| }; | ||
| }); | ||
|
|
||
| describe('TimerProgressBar', () => { | ||
| beforeEach(() => { | ||
| animateMock.mockReset(); | ||
| animateMock.mockImplementation( | ||
| (motionValue: { set: (value: number) => void }, target: number) => { | ||
| motionValue.set(target); | ||
| return { stop: vi.fn() }; | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| it('기본 크기와 전달받은 className 및 접근성 진행률을 적용한다', () => { | ||
| render( | ||
| <TimerProgressBar | ||
| progress={35} | ||
| team="PROS" | ||
| isRunning={false} | ||
| className="max-w-[1280px]" | ||
| />, | ||
| ); | ||
|
|
||
| const progressBar = screen.getByRole('progressbar'); | ||
|
|
||
| expect(progressBar).toHaveClass( | ||
| 'h-[24px]', | ||
| 'w-full', | ||
| 'overflow-hidden', | ||
| 'rounded-full', | ||
| 'max-w-[1280px]', | ||
| ); | ||
| expect(progressBar).toHaveAttribute('aria-valuemin', '0'); | ||
| expect(progressBar).toHaveAttribute('aria-valuemax', '100'); | ||
| expect(progressBar).toHaveAttribute('aria-valuenow', '35'); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ['PROS', 'bg-camp-blue'], | ||
| ['CONS', 'bg-camp-red'], | ||
| ['DISABLED', 'bg-default-neutral'], | ||
| ] as const)('%s 팀 색상을 진행 영역에 적용한다', (team, colorClass) => { | ||
| render(<TimerProgressBar progress={50} team={team} isRunning={false} />); | ||
|
|
||
| expect(screen.getByTestId('timer-progress-fill')).toHaveClass(colorClass); | ||
| }); | ||
|
|
||
| it.each([ | ||
| [-10, 0], | ||
| [120, 100], | ||
| ])('진행률 %s를 %s 범위로 제한한다', (progress, expectedProgress) => { | ||
| render( | ||
| <TimerProgressBar | ||
| progress={progress} | ||
| team="DISABLED" | ||
| isRunning={false} | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.getByRole('progressbar')).toHaveAttribute( | ||
| 'aria-valuenow', | ||
| String(expectedProgress), | ||
| ); | ||
| expect(animateMock).toHaveBeenCalledWith( | ||
| expect.anything(), | ||
| expectedProgress, | ||
| expect.objectContaining({ duration: 0 }), | ||
| ); | ||
| }); | ||
|
|
||
| it('실행 중에는 0.7초 easeOut으로 애니메이션하고 정지 상태에서는 즉시 동기화한다', () => { | ||
| const { rerender } = render( | ||
| <TimerProgressBar progress={30} team="PROS" isRunning={true} />, | ||
| ); | ||
|
|
||
| expect(animateMock).toHaveBeenLastCalledWith(expect.anything(), 30, { | ||
| duration: 0.7, | ||
| ease: 'easeOut', | ||
| }); | ||
|
|
||
| rerender(<TimerProgressBar progress={60} team="PROS" isRunning={false} />); | ||
|
|
||
| expect(animateMock).toHaveBeenLastCalledWith(expect.anything(), 60, { | ||
| duration: 0, | ||
| ease: 'easeOut', | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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,66 @@ | ||
| import clsx from 'clsx'; | ||
| import { | ||
| animate, | ||
| clamp, | ||
| motion, | ||
| useMotionValue, | ||
| useTransform, | ||
| } from 'framer-motion'; | ||
| import { useEffect } from 'react'; | ||
|
|
||
| export type TimerProgressBarTeam = 'PROS' | 'CONS' | 'DISABLED'; | ||
|
|
||
| interface TimerProgressBarProps { | ||
| progress: number; | ||
| team: TimerProgressBarTeam; | ||
| isRunning: boolean; | ||
| className?: string; | ||
| } | ||
|
|
||
| const TEAM_COLOR_CLASS: Record<TimerProgressBarTeam, string> = { | ||
| PROS: 'bg-camp-blue', | ||
| CONS: 'bg-camp-red', | ||
| DISABLED: 'bg-default-neutral', | ||
| }; | ||
|
|
||
| export default function TimerProgressBar({ | ||
| progress, | ||
| team, | ||
| isRunning, | ||
| className, | ||
| }: TimerProgressBarProps) { | ||
| const normalizedProgress = clamp(0, 100, progress); | ||
| const progressMotionValue = useMotionValue(normalizedProgress); | ||
| const width = useTransform( | ||
| progressMotionValue, | ||
| (currentProgress) => `${currentProgress}%`, | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| const controls = animate(progressMotionValue, normalizedProgress, { | ||
| duration: isRunning ? 0.7 : 0, | ||
| ease: 'easeOut', | ||
| }); | ||
|
|
||
| return () => controls.stop(); | ||
| }, [isRunning, normalizedProgress, progressMotionValue]); | ||
|
|
||
| return ( | ||
| <div | ||
| className={clsx( | ||
| 'h-[24px] w-full overflow-hidden rounded-full bg-default-disabled/hover', | ||
| className, | ||
| )} | ||
| role="progressbar" | ||
| aria-valuemin={0} | ||
| aria-valuemax={100} | ||
| aria-valuenow={normalizedProgress} | ||
| > | ||
| <motion.div | ||
| className={clsx('h-full rounded-full', TEAM_COLOR_CLASS[team])} | ||
| data-testid="timer-progress-fill" | ||
| style={{ width }} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.