Skip to content
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

Feat/#247 스와이프 기능 구현 #319

Merged
merged 96 commits into from
Aug 17, 2023
Merged

Feat/#247 스와이프 기능 구현 #319

merged 96 commits into from
Aug 17, 2023

Conversation

Creative-Lee
Copy link
Collaborator

@Creative-Lee Creative-Lee commented Aug 17, 2023

📝작업 내용

API 로직

  • 스와이프 api MSW 관련 로직을 구현한다.
  • 실제 통신함수를 구현한다.

스와이프 관련 Page

  • api 통신 및 응답값으로 하위 컴포넌트를 생성할 page 컴포넌트를 구현한다.
    • 현재의 SongDetailPage 컴포넌트를 하위 컴포넌트로 변경한다.

주요 기능

스와이프

  • 스와이프 방향에 따라 각 트리거를 감지하여 방향별 추가 데이터를 fetch한다.
    • 추가 데이터는 방향에 맞게 누적되어 쌓여야 한다.
    • 누적된 데이터를 바탕으로 새로운 SongDetailItem를 랜더링 한다.
    • 새로운 item이 랜더링 되어도 현재 보고있는 스크롤은 고정되어야한다.

사용성

  • 사용자가 접근한 노래의 SongDetailItem으로 스크롤을 이동시킨다.
  • css 스크롤 스냅을 적용한다.

💬리뷰 참고사항

개선 스와이프

코드에 대해서는 코멘트에 자세하게 작성하였습니다.
참고해주세요!

#️⃣연관된 이슈

close #247

1. 기존 nowPlayingTrack 상태에 사용된 rank는 변동 가능한 값이므로 part의 id로 변경
2. 이에 따른 props 변경
api 응답 type 그대로 받도록 수정
1. 테스트가 끝난 컴포넌트의 상태를 공유하기 위해 변경하였음.
2. 파일명 변경
1. 기존 isPlaying은 플레이어의 play와 혼동이 생길 가능성이 많았음.
개선을 통해 플레이중인 트랙이라는 의미를 강조함

2. 이에따라 props가 변경되었음
1. 플레이어 초기화 이후 ref에 할당하도록 개선
2. 관련 이벤트 핸들러 생성
1. 타이머, 플레이어 프로바이더의 함수에서 pause 관련 함수 제거
2. 트랙 컴포넌트의 타이머가 영상 상태와 동기화 되도록 수정
실행중인 파트 기준이 rank -> partId 로 변경됨에 따라 로직을 삭제함
@Creative-Lee Creative-Lee added [ 🌞 FE ] 프론트엔드 크루들의 빛나는 개발 이야기 하나둘셋 호! ✨ Feat 꼼꼼한 기능 구현 중요하죠 labels Aug 17, 2023
@Creative-Lee Creative-Lee self-assigned this Aug 17, 2023
@github-actions
Copy link

github-actions bot commented Aug 17, 2023

Unit Test Results

  71 files    71 suites   8s ⏱️
278 tests 278 ✔️ 0 💤 0
281 runs  281 ✔️ 0 💤 0

Results for commit 4a3d4a0.

♻️ This comment has been updated with latest results.

@Creative-Lee Creative-Lee merged commit a75486b into main Aug 17, 2023
@Creative-Lee Creative-Lee deleted the feat/#247 branch August 17, 2023 18:17

interface SongDetailItemProps extends SongDetail {}

const SongDetailItem = forwardRef<HTMLDivElement, SongDetailItemProps>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

상위에서 첫 랜더링 시 해당 컴포넌트의 위치로 스크롤 해야하는 정책이 있었기에 forwardRef를 사용하였습니다.

@@ -20,26 +21,23 @@ async function main() {
});
}

await loadIFrameApi();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

유튜브 I frame 로드 api는 최초 1회만 실행되면 되므로 index.tsx로 위치 변경하였습니다.

'top'
);

const itemRef = useRef<HTMLDivElement>(null);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

사용자가 선택한 노래에 해당하는 SongItem Ref 입니다.
스크롤 이동에 사용됩니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

스와이프를 구현을 위한 무한스크롤에 필요한 fetch hook을 구현했습니다.
데이터가 쌓일 방향을 인자로 받아, 기존 데이터 배열에 누적해주는 구조입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ 🌞 FE ] 프론트엔드 크루들의 빛나는 개발 이야기 하나둘셋 호! ✨ Feat 꼼꼼한 기능 구현 중요하죠
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FEAT] DetailPage 스와이프 기능을 구현한다.
1 participant