Skip to content

Commit

Permalink
๐Ÿ”ง Fix : ์ƒˆ๋ธŒ๋ Œ์น˜ ์ƒ์„ฑํ•˜์—ฌ ์ถฉ๋Œ ์ˆ˜์ • (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
g89g6 committed Oct 2, 2024
1 parent 5480248 commit e05ad0c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
import PostDetailPage from '@pages/PostDetail/PostDetailPage'
import MyPage from './pages/MyPage/MyPage'
import PostCreate from './pages/PostCreate/PostCreate'
import { Routes, Route } from 'react-router-dom'
import { Routes, Route, Navigate } from 'react-router-dom'
import NotificationPage from './pages/NotificationPage/NotificationPage'
import PostList from './pages/PostList/List'
import LoginPage from './pages/LoginPage/LoginPage'
import SplashScreen from '@pages/SplashScreen/SplashScreen'
import { useState, useEffect } from 'react'

const App = () => {

const [showSplash, setShowSplash] = useState(true)

useEffect(() => {
// ์„ธ์…˜ ์Šคํ† ๋ฆฌ์ง€ ์‚ฌ์šฉ
const hasVisitedBefore = sessionStorage.getItem('hasVisitedBefore')
if (hasVisitedBefore) {
setShowSplash(false)
}
}, [])

const handleSplashFinished = () => {
sessionStorage.setItem('hasVisitedBefore', 'true')
setShowSplash(false)
}

if (showSplash) {
return <SplashScreen onFinished={handleSplashFinished} />
}

return (
<Routes>
<Route
Expand All @@ -33,6 +55,10 @@ const App = () => {
path='/'
element={<PostList />}
/>
<Route
path="*"
element={<Navigate to="/" replace />}
/>
</Routes>
)
}
Expand Down
26 changes: 26 additions & 0 deletions src/pages/SplashScreen/SplashScreen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.splash-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
background-color: white;
}

.logo {
height: auto;
margin-bottom: 20px;
}

.subtitle {
font-size: 16px;
text-align: center;
color: #393939;
}

.footer {
position: absolute;
bottom: 20px;
font-size: 14px;
color: #7D7D7D;
}
34 changes: 34 additions & 0 deletions src/pages/SplashScreen/SplashScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import Logo from '@assets/imgs/logo.png';
import './SplashScreen.css';
import Container from '@components/Conatiner/Container'

interface SplashScreenProps {
onFinished: () => void;
}

const SplashScreen: React.FC<SplashScreenProps> = ({ onFinished }) => {
const navigate = useNavigate();

useEffect(() => {
const timer = setTimeout(() => {
onFinished();
navigate('/', { replace: true });
}, 3000);

return () => clearTimeout(timer);
}, [navigate, onFinished]);

return (
<Container>
<section className="splash-container">
<img src={Logo} alt="Vote Solve Logo" className="logo" />
<p className="subtitle">์—ฐ์˜ˆ ๊ณ ๋ฏผ, ํ•จ๊ป˜ ๊ฒฐ์ •ํ•˜๊ณ  ํ•ด๊ฒฐํ•˜๋Š” ๊ณต๊ฐ„</p>
<footer className="footer">Uh? Ban Team</footer>
</section>
</Container>
);
};

export default SplashScreen;

0 comments on commit e05ad0c

Please sign in to comment.