Repository navigation
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 2 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
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,177 @@ | ||
| "use client"; | ||
|
|
||
| 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 pageCount = Math.max(1, Math.ceil(notifications.length / NOTIFICATION_PAGE_SIZE)); | ||
|
youngmis marked this conversation as resolved.
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 absolute top-full right-0 z-50 mt-8 w-[359px] border px-16 py-10 shadow-[2px_2px_8px_0_rgba(0,0,0,0.06)]", | ||
|
youngmis marked this conversation as resolved.
Resolved
|
||
| 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> | ||
|
|
||
| <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 | ||
|
youngmis marked this conversation as resolved.
Resolved
|
||
| key={notification.id} | ||
| className={cn( | ||
| "flex w-full flex-col gap-2 px-24 py-16", | ||
| !isLast && "border-border-default border-b", | ||
| )} | ||
| > | ||
| <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> | ||
|
youngmis marked this conversation as resolved.
Resolved
|
||
| ); | ||
| })} | ||
| </ul> | ||
|
|
||
| {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> | ||
| ); | ||
| } | ||
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,93 @@ | ||
| import type { NotificationType } from "@/types/notification"; | ||
|
|
||
| export interface NotificationMessageTemplate { | ||
| prefix: string; | ||
| suffix: string; | ||
| } | ||
|
|
||
| /** | ||
| * 알림 타입별 고정 문구. | ||
| * 가운데 `content`(가변·주황 강조)가 삽입됩니다. | ||
| */ | ||
| export const NOTIFICATION_MESSAGE_TEMPLATES: Record<NotificationType, NotificationMessageTemplate> = | ||
| { | ||
| ESTIMATE_REQUEST_RECEIVED: { | ||
| prefix: "", | ||
| suffix: " 견적 요청이 도착했어요", | ||
| }, | ||
| DESIGNATED_REQUEST_RECEIVED: { | ||
| prefix: "나를 지정한 ", | ||
| suffix: " 견적 요청이 도착했어요", | ||
| }, | ||
| ESTIMATE_RECEIVED: { | ||
| prefix: "", | ||
| suffix: "이 도착했어요", | ||
| }, | ||
| ESTIMATE_CONFIRMED: { | ||
| prefix: "", | ||
| suffix: "되었어요", | ||
| }, | ||
| ESTIMATE_REQUEST_REJECTED: { | ||
| prefix: "", | ||
| suffix: " 님이 견적 요청을 반려했어요", | ||
| }, | ||
| MOVE_DAY_REMINDER: { | ||
| prefix: "내일은 ", | ||
| suffix: "이에요.", | ||
| }, | ||
| ESTIMATE_EXPIRATION_REMINDER: { | ||
| prefix: "", | ||
| suffix: " 견적 요청이 곧 만료돼요", | ||
| }, | ||
| REVIEW_AVAILABLE: { | ||
| prefix: "작성 가능한 ", | ||
| suffix: "가 있어요", | ||
| }, | ||
| REVIEW_RECEIVED: { | ||
| prefix: "", | ||
| suffix: " 리뷰를 남겼어요", | ||
| }, | ||
| CHAT_MESSAGE_RECEIVED: { | ||
| prefix: "", | ||
| suffix: " 새 메시지가 도착했어요", | ||
| }, | ||
| ESTIMATE_REVISION_REQUESTED: { | ||
| prefix: "", | ||
| suffix: " 견적 수정 요청이 도착했어요", | ||
| }, | ||
| ESTIMATE_REVISION_APPROVED: { | ||
| prefix: "", | ||
| suffix: " 견적 수정 요청이 승인되었어요", | ||
| }, | ||
| ESTIMATE_REVISION_REJECTED: { | ||
| prefix: "", | ||
| suffix: " 견적 수정 요청이 거절되었어요", | ||
| }, | ||
| }; | ||
|
|
||
| export type NotificationMessagePart = { | ||
| text: string; | ||
| highlight?: boolean; | ||
| }; | ||
|
|
||
| export const buildNotificationMessageParts = ( | ||
| type: NotificationType, | ||
| content: string, | ||
| ): NotificationMessagePart[] => { | ||
| const { prefix, suffix } = NOTIFICATION_MESSAGE_TEMPLATES[type]; | ||
|
youngmis marked this conversation as resolved.
Resolved
|
||
| const parts: NotificationMessagePart[] = []; | ||
|
|
||
| if (prefix) { | ||
| parts.push({ text: prefix }); | ||
| } | ||
|
|
||
| if (content) { | ||
| parts.push({ text: content, highlight: true }); | ||
| } | ||
|
|
||
| if (suffix) { | ||
| parts.push({ text: suffix }); | ||
| } | ||
|
|
||
| return parts; | ||
| }; | ||
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
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.