-
Notifications
You must be signed in to change notification settings - Fork 1
feat: header 알림 패널 목업 페이지 추가 #21
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
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b43a219
feat: header 알림 패널 UI 추가 및 견적 이동 경로 수정
7c529ec
feat: 알림 읽음 배지와 타입별 문구 템플릿 반영
de6c670
feat: header 알림 패널 UI 추가 및 견적 이동 경로 수정
0f34765
feat: 알림 읽음 배지와 타입별 문구 템플릿 반영
d2fa706
fix: 알림 패널 링크 이동과 빈 상태 처리
b0e1d0a
chore: dev 브랜치 변경사항 병합 및 충돌 해결
bde8990
chore: 원격 feature 브랜치 병합 충돌 해결
f7687ee
fix: 접근성 라벨과 리뷰 표시명 규칙 정리
57a22e8
fix: 알림 UI 접근성/토큰 스타일 정리
c0d5115
chore: dev 병합 충돌 해결
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,227 @@ | ||
| "use client"; | ||
|
|
||
| import Link from "next/link"; | ||
| import { useState } from "react"; | ||
|
|
||
| import { buildNotificationMessageParts } from "@/components/common/Header/notificationMessages"; | ||
| import { Text } from "@/components/common/Text"; | ||
| import { ChevronLeftIcon, ChevronRightIcon, CloseIcon } from "@/icons"; | ||
| import { MOCK_NOTIFICATIONS, NOTIFICATION_PAGE_SIZE } from "@/lib/mocks/notifications.mock"; | ||
| import type { NotificationItem } from "@/types/notification"; | ||
| import { cn } from "@/lib/utils/cn"; | ||
|
|
||
| interface NotificationPanelProps { | ||
| notifications?: NotificationItem[]; | ||
| onClose: () => void; | ||
| className?: string; | ||
| } | ||
|
|
||
| const pageButtonClassName = | ||
| "flex size-32 items-center justify-center rounded-6 border border-border-dimmed bg-background-surface transition disabled:cursor-not-allowed"; | ||
|
|
||
| export default function NotificationPanel({ | ||
| notifications = MOCK_NOTIFICATIONS, | ||
| onClose, | ||
| className, | ||
| }: NotificationPanelProps) { | ||
| const [currentPage, setCurrentPage] = useState(1); | ||
|
|
||
| const isEmpty = notifications.length === 0; | ||
| const pageCount = Math.max(1, Math.ceil(notifications.length / NOTIFICATION_PAGE_SIZE)); | ||
|
youngmis marked this conversation as resolved.
|
||
| const safePage = Math.min(currentPage, pageCount); | ||
| const startIndex = (safePage - 1) * NOTIFICATION_PAGE_SIZE; | ||
| const pageItems = notifications.slice(startIndex, startIndex + NOTIFICATION_PAGE_SIZE); | ||
|
|
||
| const isPrevDisabled = safePage <= 1; | ||
| const isNextDisabled = safePage >= pageCount; | ||
|
|
||
| const goToPage = (page: number) => { | ||
| setCurrentPage(Math.min(Math.max(page, 1), pageCount)); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| role="dialog" | ||
| aria-modal="false" | ||
| aria-labelledby="notification-panel-title" | ||
| className={cn( | ||
| "border-border-default bg-background-surface rounded-24 shadow-notification absolute top-full right-0 z-50 mt-8 w-[359px] border px-16 py-10", | ||
| className, | ||
| )} | ||
| > | ||
| <div className="flex w-full items-center justify-between py-14 pr-12 pl-24"> | ||
| <Text | ||
| id="notification-panel-title" | ||
| as="h2" | ||
| variant="2lg-bold" | ||
| className="text-text-primary" | ||
| > | ||
| 알림 | ||
| </Text> | ||
| <button | ||
| type="button" | ||
| aria-label="알림 닫기" | ||
| onClick={onClose} | ||
| className="text-icon-default flex size-24 items-center justify-center" | ||
| > | ||
| <CloseIcon className="size-18" /> | ||
| </button> | ||
| </div> | ||
|
|
||
| {isEmpty ? ( | ||
| <div className="flex h-[220px] w-full items-center justify-center px-24"> | ||
| <Text as="p" variant="md-medium" className="text-text-subtle text-center"> | ||
| 새로운 알림이 없습니다 | ||
| </Text> | ||
| </div> | ||
| ) : ( | ||
| <ul className="flex w-full flex-col"> | ||
| {pageItems.map((notification, index) => { | ||
| const isLast = index === pageItems.length - 1; | ||
| const isRead = notification.isRead; | ||
| const messageParts = buildNotificationMessageParts( | ||
| notification.type, | ||
| notification.content, | ||
| ); | ||
|
|
||
| return ( | ||
| <li | ||
| key={notification.id} | ||
| className={cn( | ||
| "flex w-full flex-col gap-2 px-24 py-16", | ||
| !isLast && "border-border-default border-b", | ||
| )} | ||
| > | ||
| {notification.linkUrl ? ( | ||
| <Link | ||
| href={notification.linkUrl} | ||
| onClick={onClose} | ||
| className="hover:bg-background-hover focus-visible:ring-border-brand rounded-8 -mx-8 -my-4 flex flex-col gap-2 px-8 py-4 transition focus-visible:ring-1 focus-visible:outline-none" | ||
| > | ||
| <p className={isRead ? "text-text-weak" : "text-text-secondary"}> | ||
| <Text as="span" variant="lg-medium"> | ||
| {messageParts.map((part, partIndex) => ( | ||
| <span | ||
| key={`${notification.id}-${partIndex}`} | ||
| className={cn( | ||
| isRead | ||
| ? "text-text-weak" | ||
| : part.highlight | ||
| ? "text-text-brand" | ||
| : undefined, | ||
| )} | ||
| > | ||
| {part.text} | ||
| </span> | ||
| ))} | ||
| </Text> | ||
| </p> | ||
| <Text | ||
| as="p" | ||
| variant="md-medium" | ||
| className={isRead ? "text-text-weak" : "text-text-muted"} | ||
| > | ||
| {notification.createdAtLabel} | ||
| </Text> | ||
| </Link> | ||
| ) : ( | ||
| <> | ||
| <p className={isRead ? "text-text-weak" : "text-text-secondary"}> | ||
| <Text as="span" variant="lg-medium"> | ||
| {messageParts.map((part, partIndex) => ( | ||
| <span | ||
| key={`${notification.id}-${partIndex}`} | ||
| className={cn( | ||
| isRead | ||
| ? "text-text-weak" | ||
| : part.highlight | ||
| ? "text-text-brand" | ||
| : undefined, | ||
| )} | ||
| > | ||
| {part.text} | ||
| </span> | ||
| ))} | ||
| </Text> | ||
| </p> | ||
| <Text | ||
| as="p" | ||
| variant="md-medium" | ||
| className={isRead ? "text-text-weak" : "text-text-muted"} | ||
| > | ||
| {notification.createdAtLabel} | ||
| </Text> | ||
| </> | ||
| )} | ||
| </li> | ||
| ); | ||
| })} | ||
| </ul> | ||
| )} | ||
|
|
||
| {!isEmpty && pageCount > 1 ? ( | ||
| <nav | ||
| aria-label="알림 페이지네이션" | ||
| className="flex w-full items-center justify-center py-12" | ||
| > | ||
| <ul className="flex items-center gap-4"> | ||
| <li> | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| pageButtonClassName, | ||
| "text-text-secondary hover:bg-background-hover disabled:text-text-weak disabled:hover:bg-transparent", | ||
| )} | ||
| onClick={() => goToPage(safePage - 1)} | ||
| disabled={isPrevDisabled} | ||
| aria-label="이전 페이지" | ||
| > | ||
| <ChevronLeftIcon className="size-16" /> | ||
| </button> | ||
| </li> | ||
|
|
||
| {Array.from({ length: pageCount }, (_, index) => { | ||
| const page = index + 1; | ||
| const isCurrent = page === safePage; | ||
|
|
||
| return ( | ||
| <li key={page}> | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| pageButtonClassName, | ||
| isCurrent | ||
| ? "text-text-secondary" | ||
| : "text-text-weak hover:bg-background-hover cursor-pointer", | ||
| )} | ||
| onClick={() => goToPage(page)} | ||
| disabled={isCurrent} | ||
| aria-label={`${page} 페이지`} | ||
| aria-current={isCurrent ? "page" : undefined} | ||
| > | ||
| <Text variant="md-regular">{page}</Text> | ||
| </button> | ||
| </li> | ||
| ); | ||
| })} | ||
|
|
||
| <li> | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| pageButtonClassName, | ||
| "text-text-secondary hover:bg-background-hover disabled:text-text-weak disabled:hover:bg-transparent", | ||
| )} | ||
| onClick={() => goToPage(safePage + 1)} | ||
| disabled={isNextDisabled} | ||
| aria-label="다음 페이지" | ||
| > | ||
| <ChevronRightIcon className="size-16" /> | ||
| </button> | ||
| </li> | ||
| </ul> | ||
| </nav> | ||
| ) : null} | ||
| </div> | ||
| ); | ||
| } | ||
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.