-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/84 헤더 마이페이지, 로그아웃 드롭다운 추가 및 로그인 성공 UI 적용 #87
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
Merged
Changes from all commits
Commits
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
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
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,77 @@ | ||
| 'use client'; | ||
|
|
||
| import Image from 'next/image'; | ||
| import Link from 'next/link'; | ||
| import { useEffect, useRef, useState } from 'react'; | ||
| import { usePathname } from 'next/navigation'; | ||
| import ProfileDefaultIcon from '@assets/svg/profile-default'; | ||
|
|
||
| import { ProfileDropdownProps } from '@/types/profileDropdownTypes'; | ||
|
|
||
| export default function ProfileDropdown({ nickname, profileImageUrl, onLogout }: ProfileDropdownProps) { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const dropdownRef = useRef<HTMLDivElement>(null); | ||
| const pathname = usePathname(); | ||
|
|
||
| // 외부 클릭 시 드롭다운 닫기 | ||
| useEffect(() => { | ||
| const handleClickOutside = (e: MouseEvent) => { | ||
| if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) { | ||
| setIsOpen(false); | ||
| } | ||
| }; | ||
| document.addEventListener('mousedown', handleClickOutside); | ||
| return () => document.removeEventListener('mousedown', handleClickOutside); | ||
| }, []); | ||
|
|
||
| // 경로 변경 시 드롭다운 닫기 | ||
| useEffect(() => { | ||
| setIsOpen(false); | ||
| }, [pathname]); | ||
|
|
||
| return ( | ||
| <div className='relative' ref={dropdownRef}> | ||
| {/* 프로필 영역 (드롭다운 토글) */} | ||
| <div | ||
| className='flex items-center gap-8 cursor-pointer' | ||
| onClick={() => setIsOpen((prev) => !prev)} | ||
|
Comment on lines
+35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) 접근성 개선을 위한 키보드 이벤트 처리 추가를 권장합니다. 현재 클릭 이벤트만 처리하고 있는데, 키보드 접근성을 위해 Enter나 Space 키 처리를 추가하는 것이 좋겠습니다. 다음과 같이 키보드 이벤트 처리를 추가할 수 있습니다: <div
className='flex items-center gap-8 cursor-pointer'
+ role='button'
+ tabIndex={0}
onClick={() => setIsOpen((prev) => !prev)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ setIsOpen((prev) => !prev);
+ }
+ }}
>🤖 Prompt for AI Agents |
||
| > | ||
| {profileImageUrl ? ( | ||
| <Image | ||
| src={profileImageUrl} | ||
| alt='프로필 이미지' | ||
| width={32} | ||
| height={32} | ||
| className='rounded-full border border-gray-300' | ||
| /> | ||
| ) : ( | ||
| <div className='size-32 rounded-full border border-gray-300 overflow-hidden'> | ||
| <ProfileDefaultIcon size={32} /> | ||
| </div> | ||
| )} | ||
| <span>{nickname || '사용자'}</span> | ||
| </div> | ||
|
|
||
| {/* 드롭다운 메뉴 */} | ||
| {isOpen && ( | ||
| <div | ||
| className='absolute top-50 right-0 z-50 mt-12 w-140 rounded-md border border-gray-200 bg-white shadow-md' | ||
| onClick={(e) => e.stopPropagation()} | ||
| > | ||
| <Link | ||
| href='/mypage' | ||
| className='block w-full px-16 py-12 text-left hover:bg-gray-50' | ||
| > | ||
| 마이페이지 | ||
| </Link> | ||
| <button | ||
| onClick={onLogout} | ||
| className='w-full px-16 py-12 text-left hover:bg-gray-50' | ||
| > | ||
| 로그아웃 | ||
| </button> | ||
| </div> | ||
| )} | ||
| </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,5 @@ | ||
| export interface ProfileDropdownProps { | ||
| nickname: string; | ||
| profileImageUrl: string | null; | ||
| onLogout: () => void; | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 이 부분 오류나서 수정했는데 ㅋㅋ 동일하시네용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅋㅋㅋㅋ동일이슈,,