-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/126 알림 표시 기능 구현 #129
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
Feat/126 알림 표시 기능 구현 #129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ import useLogout from '@/hooks/useLogout'; | |||||||||||||||||||||
| import { toast } from 'sonner'; | ||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||
| import NotificationDropdown from './Notification/NotificationDropdown'; | ||||||||||||||||||||||
| import { useNotifications } from '@/hooks/useNotification'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default function Header() { | ||||||||||||||||||||||
| const router = useRouter(); | ||||||||||||||||||||||
|
|
@@ -20,6 +21,9 @@ export default function Header() { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| const toggleOpen = () => setIsOpen((prev) => !prev); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const { data } = useNotifications({ size: 10 }); | ||||||||||||||||||||||
| const hasNotification = (data?.totalCount ?? 0) > 0; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const handleLogoClick = () => { | ||||||||||||||||||||||
| router.push('/'); // 쿼리 제거됨 → 검색어 초기화됨 | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
@@ -51,8 +55,8 @@ export default function Header() { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| {/* 우측 placeholder (스켈레톤 박스) */} | ||||||||||||||||||||||
| <div className='flex gap-24'> | ||||||||||||||||||||||
| <div className='h-32 w-32 rounded-full bg-gray-200 animate-pulse' /> | ||||||||||||||||||||||
| <div className='h-32 w-80 rounded-md bg-gray-200 animate-pulse' /> | ||||||||||||||||||||||
| <div className='h-32 w-32 animate-pulse rounded-full bg-gray-200' /> | ||||||||||||||||||||||
| <div className='h-32 w-80 animate-pulse rounded-md bg-gray-200' /> | ||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
| </header> | ||||||||||||||||||||||
|
|
@@ -78,9 +82,14 @@ export default function Header() { | |||||||||||||||||||||
| <button | ||||||||||||||||||||||
| aria-label='알림' | ||||||||||||||||||||||
| onClick={toggleOpen} | ||||||||||||||||||||||
| className='hover:text-primary' | ||||||||||||||||||||||
| className='hover:text-primary relative' | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| <IconBell /> | ||||||||||||||||||||||
| {hasNotification && ( | ||||||||||||||||||||||
| <span className='font-regular absolute top-[-11px] right-[-3px] text-[10px] text-red-500'> | ||||||||||||||||||||||
| {data?.totalCount} | ||||||||||||||||||||||
| </span> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
|
Comment on lines
+88
to
+92
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) 알림 배지 구현이 기능적으로 올바르지만 개선사항이 있습니다. 조건부 렌더링과 위치 지정이 적절하게 구현되었습니다. 다음 개선사항을 고려해보세요:
큰 알림 개수에 대한 처리를 위해 다음과 같이 개선할 수 있습니다: {hasNotification && (
- <span className='font-regular absolute top-[-11px] right-[-3px] text-[10px] text-red-500'>
- {data?.totalCount}
+ <span className='font-regular absolute top-[-11px] right-[-3px] text-[11px] text-red-500'>
+ {(data?.totalCount ?? 0) > 99 ? '99+' : data?.totalCount}
</span>
)}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| {isOpen && ( | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
🛠️ Refactor suggestion
버튼에 명시적인 type 속성을 추가하세요.
relative포지셔닝 추가는 알림 배지를 위해 적절하지만, 버튼에 명시적인type="button"속성을 추가해야 합니다.<button aria-label='알림' onClick={toggleOpen} - className='hover:text-primary relative' + type="button" + className='hover:text-primary relative' >🧰 Tools
🪛 Biome (2.1.2)
[error] 85-89: Provide an explicit type prop for the button element.
The default type of a button is submit, which causes the submission of a form when placed inside a
formelement. This is likely not the behaviour that you want inside a React application.Allowed button types are: submit, button or reset
(lint/a11y/useButtonType)
🤖 Prompt for AI Agents