-
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
1 parent
6635ad2
commit 6baf7e0
Showing
2 changed files
with
87 additions
and
2 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,79 @@ | ||
import Footer from '@/components/Footer'; | ||
import Header from '@/components/Header'; | ||
import NotificationModal from '@/components/ui/notificationModal'; | ||
import ProfileModal from '@/components/ui/profileModal'; | ||
import React, { useRef, useState } from 'react'; | ||
|
||
const LandingPage: React.FC = () => { | ||
const [isProfileModalOpen, setIsProfileModalOpen] = useState(false); | ||
const [isNotificationModalOpen, setIsNotificationModalOpen] = useState(false); | ||
const [isLoggedIn, setIsLoggedIn] = useState(false); | ||
const [hasNotifications, setHasNotifications] = useState(false); | ||
const [profileCoords, setProfileCoords] = useState<{ | ||
top: number; | ||
left: number; | ||
}>({ | ||
top: 0, | ||
left: 0, | ||
}); | ||
const [notificationCoords, setNotificationCoords] = useState<{ | ||
top: number; | ||
left: number; | ||
}>({ | ||
top: 0, | ||
left: 0, | ||
}); | ||
const profileRef = useRef<HTMLImageElement>(null); | ||
|
||
const toggleProfileModal = (e?: React.MouseEvent) => { | ||
if (e) { | ||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); | ||
setProfileCoords({ top: rect.bottom, left: rect.left }); | ||
} | ||
setIsProfileModalOpen(!isProfileModalOpen); | ||
}; | ||
|
||
const toggleNotificationModal = (e?: React.MouseEvent) => { | ||
if (e) { | ||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); | ||
setNotificationCoords({ top: rect.bottom, left: rect.left }); | ||
} | ||
setIsNotificationModalOpen(!isNotificationModalOpen); | ||
}; | ||
|
||
const handleLogout = () => { | ||
setIsLoggedIn(false); | ||
setIsProfileModalOpen(false); | ||
}; | ||
|
||
return ( | ||
<div className="relative"> | ||
<Header | ||
toggleProfileModal={toggleProfileModal} | ||
toggleNotificationModal={toggleNotificationModal} | ||
isLoggedIn={isLoggedIn} | ||
handleLoginLogout={() => setIsLoggedIn(!isLoggedIn)} | ||
profileRef={profileRef} | ||
hasNotifications={hasNotifications} | ||
/> | ||
{/*컨텐츠 영역*/} | ||
<Footer /> | ||
{isProfileModalOpen && ( | ||
<ProfileModal | ||
toggleProfileModal={toggleProfileModal} | ||
handleLogout={handleLogout} | ||
coords={profileCoords} | ||
/> | ||
)} | ||
{isNotificationModalOpen && ( | ||
<NotificationModal | ||
toggleNotificationModal={toggleNotificationModal} | ||
setHasNotifications={setHasNotifications} | ||
coords={notificationCoords} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default LandingPage; |
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