-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 페이지간 이동 로딩바 컴포넌트 구현 - 페이지 이동 후에도 서서히 사라지는 모션을 보여주기 위해 suspense fallback과 분리함 * feat: 마지막 페이지와 함께 로딩 바를 제어하는 suspense fallback 컴포넌트 구현 - 첫 페이지는 기존의 로딩 스피너 활용 * feat: 마지막 페이지를 기록하는 Wrapper 컴포넌트 추가 * feat: Context 대신 Recoil 사용 * chore: MSW delay 3초로 설정 * refactor: 모든 페이지에 PageLogger 적용 * design: backdrop 제거 * chore: PageLogger 적용 * fix: Page effect에 로딩바 숨기기 추가 * style: lastPageValue 네이밍 변경 * design: 로딩바 속도 2배 증가 * chore: MSW 지연 500으로 변경 * design: 왼쪽 border 제거 * design: 프로그래스 바 속도 증가 * refactor: style 파일 분리 * refactor: isShow 대신 isShowPageLoading 재활용 * fix: 로딩바 깜빡거리는 현상 제거 - 이전과는 달리 보여지는 상태를 같은 Effect 안에서 관리 * chore: MSW delay 200으로 변경 * chore: 초기 로딩 속도 증가 * fix: 애니메이션 겹치는 현상 해결 - finish 애니메이션이 재생중일 때 새로 렌더링 되면 setTimeout 및 상태 초기화 * design: 두께 3px로 변경 * chore: useEffect 의존성 배열에 사용되는 값 추가 * chore: || 대신 ?? 사용 * refactor: 페이지에 Main 태그 적용 및 hooks 폴더 이동 * chore: 폴더 이동 import 적용
- Loading branch information
Showing
32 changed files
with
213 additions
and
55 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
43 changes: 43 additions & 0 deletions
43
frontend/src/components/@common/PageLoadingBar/PageLoadingBar.style.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,43 @@ | ||
import { keyframes, styled } from 'styled-components'; | ||
|
||
export const ProgressBar = styled.div` | ||
position: fixed; | ||
z-index: ${(props) => props.theme.zIndex.tooltip}; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 3px; | ||
background-color: ${(props) => props.theme.color.primary}; | ||
border-radius: 0 4px 4px 0; | ||
`; | ||
|
||
export const progressing = keyframes` | ||
0% { transform: translateX(-100%); } | ||
50% { transform: translateX(-20%); } | ||
100% { transform: translateX(0); } | ||
`; | ||
|
||
export const Progressing = styled(ProgressBar)` | ||
animation: ${progressing} 6s ease-out; | ||
`; | ||
|
||
export const fillOut = keyframes` | ||
0% { | ||
opacity: 1; | ||
transform: translateX(-100%); | ||
} | ||
50% { | ||
opacity: 1; | ||
transform: translateX(0); | ||
} | ||
100% { | ||
opacity: 0; | ||
transform: translateX(0); | ||
} | ||
`; | ||
|
||
export const Finish = styled(ProgressBar)<{ $animationTime: number }>` | ||
animation: ${fillOut} ${(props) => props.$animationTime}ms; | ||
`; |
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,44 @@ | ||
import { useEffect, useMemo } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { useRecoilValue } from 'recoil'; | ||
import { Finish, Progressing } from './PageLoadingBar.style'; | ||
import { isShowPageLoadingState } from 'store/atoms/@common'; | ||
import useToggle from 'hooks/@common/useToggle'; | ||
|
||
export const FINISH_ANIMATION_TIME = 600; | ||
|
||
const PageLoadingBar = () => { | ||
const isShowPageLoading = useRecoilValue(isShowPageLoadingState); | ||
|
||
const { isOn: isShow, on: show, off: hide } = useToggle(); | ||
const { isOn: isShowFinish, on: showFinish, off: hideFinish } = useToggle(); | ||
|
||
const root = useMemo(() => document.getElementById('root')!, []); | ||
|
||
useEffect(() => { | ||
if (isShowPageLoading) { | ||
show(); | ||
hideFinish(); | ||
return; | ||
} | ||
|
||
showFinish(); | ||
const hideId = setTimeout(hide, FINISH_ANIMATION_TIME / 2); | ||
const hideFinishId = setTimeout(hideFinish, FINISH_ANIMATION_TIME); | ||
|
||
return () => { | ||
clearTimeout(hideId); | ||
clearTimeout(hideFinishId); | ||
}; | ||
}, [isShowPageLoading, show, hide, showFinish, hideFinish]); | ||
|
||
return createPortal( | ||
<> | ||
{isShow && <Progressing />} | ||
{isShowFinish && <Finish $animationTime={FINISH_ANIMATION_TIME} />} | ||
</>, | ||
root | ||
); | ||
}; | ||
|
||
export default PageLoadingBar; |
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,18 @@ | ||
import { PropsWithChildren, useEffect } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
import { isShowPageLoadingState, lastPageState } from 'store/atoms/@common'; | ||
|
||
const PageLogger = (props: PropsWithChildren) => { | ||
const { children } = props; | ||
const setLastPage = useSetRecoilState(lastPageState); | ||
const setIsShowPageLoadingState = useSetRecoilState(isShowPageLoadingState); | ||
|
||
useEffect(() => { | ||
setLastPage(children); | ||
setIsShowPageLoadingState(false); | ||
}, [children, setLastPage, setIsShowPageLoadingState]); | ||
|
||
return children; | ||
}; | ||
|
||
export default PageLogger; |
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
File renamed without changes.
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...end/src/pages/@common/Main/Main.style.tsx → ...end/src/pages/@common/Home/Home.style.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useEffect } from 'react'; | ||
import { useRecoilValue, useSetRecoilState } from 'recoil'; | ||
import Loading from 'pages/@common/Loading'; | ||
import { isShowPageLoadingState, lastPageState } from 'store/atoms/@common'; | ||
|
||
const LastPageLoading = () => { | ||
const lastPage = useRecoilValue(lastPageState); | ||
const setIsShowPageLoading = useSetRecoilState(isShowPageLoadingState); | ||
|
||
useEffect(() => { | ||
setIsShowPageLoading(true); | ||
|
||
return () => { | ||
setIsShowPageLoading(false); | ||
}; | ||
}, [setIsShowPageLoading]); | ||
|
||
return lastPage ?? <Loading />; | ||
}; | ||
|
||
export default LastPageLoading; |
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
Oops, something went wrong.