-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#102][FEATURE] 특정 알림 삭제 기능 구현 및 실시간 알림 테스트
- Loading branch information
Showing
9 changed files
with
172 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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,42 @@ | ||
import styled from '@emotion/styled'; | ||
import Image from 'next/image'; | ||
import INotify from '@/types/notify'; | ||
|
||
interface INotificationBox { | ||
notification: INotify; | ||
openDeleteModal: (notificationId: number) => void; | ||
} | ||
function NotificationBox({ notification, openDeleteModal }: INotificationBox) { | ||
return ( | ||
<SNotificationBox> | ||
<button | ||
type="button" | ||
onClick={() => openDeleteModal(notification.notificationId)} | ||
> | ||
<SDeleteIcon | ||
src="/icons/icon-trash.svg" | ||
alt="삭제 아이콘" | ||
width={16} | ||
height={16} | ||
priority | ||
/> | ||
</button> | ||
<p>{notification.title}</p> | ||
<p>{notification.message}</p> | ||
<p>{notification.createDate}</p> | ||
</SNotificationBox> | ||
); | ||
} | ||
|
||
const SNotificationBox = styled.div` | ||
border: 1px solid ${({ theme }) => theme.color.gray_3c}; | ||
border-radius: 10px; | ||
margin: 0.625rem; | ||
padding: 0.625rem 0.3125rem; | ||
`; | ||
|
||
const SDeleteIcon = styled(Image)` | ||
cursor: pointer; | ||
`; | ||
|
||
export default NotificationBox; |
This file contains 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,71 @@ | ||
import styled from '@emotion/styled'; | ||
import Portal from '../modal/ModalPortal'; | ||
|
||
interface INotificationModal { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onDelete: () => void; | ||
} | ||
|
||
export default function NotificationModal({ | ||
isOpen, | ||
onClose, | ||
onDelete, | ||
}: INotificationModal) { | ||
const handleBackgroundClick = (event: React.MouseEvent<HTMLElement>) => { | ||
if (event.target === event.currentTarget) { | ||
onClose(); | ||
} | ||
}; | ||
|
||
return ( | ||
isOpen && ( | ||
<Portal> | ||
<SModalWrapper onClick={handleBackgroundClick}> | ||
<SModalContent> | ||
<SModalBtn type="button" onClick={onDelete} deleteBtn> | ||
삭제하기 | ||
</SModalBtn> | ||
<SModalBtn type="button" onClick={onClose} deleteBtn={false}> | ||
취소하기 | ||
</SModalBtn> | ||
</SModalContent> | ||
</SModalWrapper> | ||
</Portal> | ||
) | ||
); | ||
} | ||
|
||
export const SModalWrapper = styled.div` | ||
z-index: 20; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: flex-end; | ||
background-color: rgba(0, 0, 0, 0.6); | ||
`; | ||
|
||
const SModalContent = styled.div` | ||
display: flex; | ||
flex-flow: column nowrap; | ||
justify-content: center; | ||
align-items: center; | ||
margin-bottom: 2.5rem; | ||
`; | ||
|
||
const SModalBtn = styled.button<{ deleteBtn: boolean }>` | ||
width: 19.5rem; | ||
height: 48px; | ||
background-color: ${({ theme }) => theme.color.white}; | ||
margin-top: 1rem; | ||
border-radius: 8px; | ||
text-align: center; | ||
font-size: ${({ theme }) => theme.fontSize.subtitle1}; | ||
font-weight: ${({ theme }) => theme.fontWeight.subtitle1}; | ||
color: ${({ theme, deleteBtn }) => | ||
deleteBtn ? theme.color.error : theme.color.normal}; | ||
`; |
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
interface INotify { | ||
notificationId: number; | ||
title: string; | ||
message: string; | ||
createDate: string; | ||
|