-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { keyframes, css } from "@emotion/react"; | ||
import styled from "@emotion/styled"; | ||
|
||
// 페이드아웃 애니메이션 정의 | ||
const fadeOut = keyframes` | ||
from { | ||
opacity: 1; | ||
} | ||
to { | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
// fade prop의 타입 정의 | ||
interface ContainerProps { | ||
fade: boolean; | ||
} | ||
|
||
// 애니메이션 스타일이 적용된 컨테이너 | ||
export const Container = styled.div<ContainerProps>` | ||
max-width: 400px; | ||
height: 100vh; | ||
max-height: 956px; | ||
margin: 0 auto; | ||
background-color: var(--color-primary); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
/* 페이드아웃 애니메이션을 조건부로 적용 */ | ||
${({ fade }) => | ||
fade && | ||
css` | ||
animation: ${fadeOut} 1s ease forwards; | ||
`} | ||
`; |
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,31 @@ | ||
// HomePage.tsx | ||
import React, { useEffect, useState } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import * as Styles from "./index.style"; | ||
|
||
export const HomePage: React.FC = () => { | ||
const navigate = useNavigate(); | ||
const [fade, setFade] = useState(false); | ||
|
||
useEffect(() => { | ||
// 3초 후 페이드아웃 시작 | ||
const fadeTimer = setTimeout(() => setFade(true), 1500); | ||
|
||
// 페이드아웃 애니메이션 후 페이지 이동 | ||
const navigateTimer = setTimeout(() => { | ||
navigate("/login"); | ||
}, 2000); | ||
|
||
// 타이머 정리 | ||
return () => { | ||
clearTimeout(fadeTimer); | ||
clearTimeout(navigateTimer); | ||
}; | ||
}, [navigate]); | ||
|
||
return ( | ||
<Styles.Container fade={fade}> | ||
<img src="" alt="LOGO" /> | ||
</Styles.Container> | ||
); | ||
}; |