-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/#36 gnb 컴포넌트 #42
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
Merged
The head ref may contain hidden characters: "feature/#36_GNB-\uCEF4\uD3EC\uB10C\uD2B8"
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d20fdd2
✨ GNB 초안 작성
solprime b80e800
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime 399c828
⚡️ 외부 클릭 시 메뉴 닫는 기능 커스텀 훅으로 구분
solprime c3766df
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime 2313695
📝 프로필이미지 상태 및 주석 추가
solprime d832b38
🐛 ESLint에 맞게 수정
solprime b2a8012
🐛 ESLint에 맞게 수정
solprime 457a84a
🐛 ESLint에 맞게 수정
solprime a876253
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime a24b195
⚡️ GNB 컴포넌트 분리
solprime 81984b5
🐛 ESLint에 맞게 수정
solprime 0c7230e
⚡️ 코드리뷰 반영
solprime e9e7db0
⚡️ useCheckMobile 커스텀 훅 분리
solprime 278ceae
📝 logo파일 경로 이동 및 불필요한 클래스 수정
solprime 8232a6e
🐛 ESLint에 맞게 수정
solprime 36aa677
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime 22601cf
🐛 로고 경로 수정
solprime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,20 @@ | ||
| interface AlarmProps { | ||
| isLoggedIn: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * 알림 컴포넌트 | ||
| * @param isLoggedIn 로그인 여부 판별 | ||
| */ | ||
|
|
||
| export default function Alarm({ isLoggedIn }: AlarmProps) { | ||
| if (!isLoggedIn) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <button> | ||
| <img src="/icon/icon-alarm.svg" className="mo:hidden" alt="알림 아이콘" /> | ||
| </button> | ||
| ); | ||
| } |
This file contains hidden or 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,14 @@ | ||
| import Link from 'next/link'; | ||
|
|
||
| export default function GNB() { | ||
| return ( | ||
| <div className="flex items-center gap-10"> | ||
| <Link className="mo:hidden" href="/wikilist"> | ||
| 위키목록 | ||
| </Link> | ||
| <Link className="mo:hidden" href="/boards"> | ||
| 자유게시판 | ||
| </Link> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,50 @@ | ||
| import Link from 'next/link'; | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import Alarm from './Alarm'; | ||
| import GNB from './GNB'; | ||
| import Login from './Login'; | ||
|
|
||
| export default function Headers() { | ||
| // TODO 임시 로그인 상태(추후 업데이트예정) | ||
| const [isLoggedIn, setIsLoggedIn] = useState(false); | ||
| const [isMobile, setIsMobile] = useState(false); | ||
| const handleLogin = () => { | ||
| setIsLoggedIn(true); | ||
| }; | ||
|
|
||
| const handleLogout = () => { | ||
| setIsLoggedIn(false); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| const checkMobile = () => setIsMobile(window.innerWidth <= 767); | ||
| checkMobile(); | ||
| window.addEventListener('resize', checkMobile); | ||
|
|
||
| return () => { | ||
| window.removeEventListener('resize', checkMobile); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <header className="z-100 fixed left-0 top-0 flex h-20 w-full items-center justify-between bg-background px-20 py-5 shadow-custom"> | ||
| <div className="flex gap-10"> | ||
| <Link href="/"> | ||
| <img src="/logo.svg" alt="위키드 로고" /> | ||
| </Link> | ||
| <GNB /> | ||
| </div> | ||
| {/* 로그인 여부에 따라 조건부로 노출 */} | ||
| <div className="flex items-center gap-5"> | ||
| <Alarm isLoggedIn={isLoggedIn} /> | ||
| <Login | ||
| login={handleLogin} | ||
| logout={handleLogout} | ||
| isMobile={isMobile} | ||
| isLoggedIn={isLoggedIn} | ||
| /> | ||
| </div> | ||
| </header> | ||
| ); | ||
| } | ||
This file contains hidden or 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,114 @@ | ||
| import useOutsideClick from 'hooks/useOutsideClick'; | ||
| import { useRouter } from 'next/router'; | ||
| import { useEffect, useRef, useState } from 'react'; | ||
|
|
||
| import Menu from '../Menu'; | ||
|
|
||
| interface LoginProps { | ||
| login: () => void; | ||
| logout: () => void; | ||
| isMobile: boolean; | ||
| isLoggedIn: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * 로그인 컴포넌트 | ||
| * @param login 로그인처리를 위한 함수 | ||
| * @param logout 로그아웃처리를 위한 함수 | ||
| * @param isMobile 화면 크기에 따라 모바일 여부 판별 | ||
| * @param isLoggedIn 로그인 여부 판별 | ||
| */ | ||
|
|
||
| export default function Login({ | ||
| login, | ||
| logout, | ||
| isMobile, | ||
| isLoggedIn, | ||
| }: LoginProps) { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [profileMenu, setProfileMenu] = useState<string[]>([]); | ||
|
|
||
| //TODO 프로필 이미지 처리(추후 업데이트) | ||
| const profileImage = null; | ||
| const router = useRouter(); | ||
| const loginMenuRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| const updateProfileMenu = () => { | ||
| if (!isLoggedIn) { | ||
| if (isMobile) return ['로그인', '위키목록', '자유게시판']; | ||
| } else if (isMobile) { | ||
| return ['위키목록', '자유게시판', '알림', '마이페이지', '로그아웃']; | ||
| } else { | ||
| return ['마이페이지', '로그아웃']; | ||
| } | ||
| return []; | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| setProfileMenu(updateProfileMenu()); | ||
| }, [isLoggedIn, isMobile]); | ||
|
|
||
| const handleLoginMenu = (option: string) => { | ||
| if (option === '위키목록') { | ||
| router.push('/wikilist'); | ||
| } else if (option === '자유게시판') { | ||
| router.push('/boards'); | ||
| } else if (option === '마이페이지') { | ||
| router.push('/mypage'); | ||
| } | ||
| //TODO 로그인 처리 (추후 업데이트) | ||
| else if (option === '로그인') { | ||
| login(); | ||
| } else if (option === '로그아웃') { | ||
| logout(); | ||
| } | ||
| }; | ||
|
|
||
| useOutsideClick(loginMenuRef, () => setIsOpen(false)); | ||
|
|
||
| return isLoggedIn ? ( | ||
| <div ref={loginMenuRef} className="flex"> | ||
| <button className="relative" onClick={() => setIsOpen(!isOpen)}> | ||
| <img | ||
| src={profileImage || '/icon/icon-profile.svg'} | ||
| className="mo:hidden" | ||
| alt="프로필 아이콘" | ||
| /> | ||
| <img | ||
| src="/icon/icon-menu.svg" | ||
| className="hidden mo:block" | ||
| alt="메뉴 아이콘" | ||
| /> | ||
|
|
||
| {isOpen && ( | ||
| <Menu | ||
| options={profileMenu} | ||
| onSelect={handleLoginMenu} | ||
| menuSize="w-28" | ||
| /> | ||
| )} | ||
| </button> | ||
| </div> | ||
| ) : isMobile ? ( | ||
| <div ref={loginMenuRef} className="flex"> | ||
| <button className="relative" onClick={() => setIsOpen(!isOpen)}> | ||
| <img | ||
| src="/icon/icon-menu.svg" | ||
| className="hidden mo:block" | ||
| alt="메뉴 아이콘" | ||
| /> | ||
| {isOpen && ( | ||
| <Menu | ||
| options={profileMenu} | ||
| onSelect={handleLoginMenu} | ||
| menuSize="w-28" | ||
| /> | ||
| )} | ||
| </button> | ||
| </div> | ||
| ) : ( | ||
| <div className="mo:hidden" onClick={login}> | ||
| 로그인 | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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
junghwaYang marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,20 @@ | ||
| import { useEffect } from 'react'; | ||
|
|
||
| const useOutsideClick = ( | ||
| ref: React.RefObject<HTMLElement | null>, | ||
| callback: () => void | ||
| ) => { | ||
| useEffect(() => { | ||
| const handleClickOutside = (event: MouseEvent) => { | ||
| if (ref.current && !ref.current.contains(event.target as Node)) { | ||
| callback(); | ||
| } | ||
| }; | ||
| document.addEventListener('mousedown', handleClickOutside); | ||
| return () => { | ||
| document.removeEventListener('mousedown', handleClickOutside); | ||
| }; | ||
| }, [ref, callback]); | ||
| }; | ||
|
|
||
| export default useOutsideClick; |
This file contains hidden or 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,9 @@ | ||
| import Headers from '@/components/Headers/Headers'; | ||
|
|
||
| export default function HeaderTest() { | ||
| return ( | ||
| <div> | ||
| <Headers /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
haksoo0918 marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.