-
Notifications
You must be signed in to change notification settings - Fork 2
feat : 토스트 UI 구현 + 알림 페이지 코드 작업 90% 완료 + 실시간 알림, 편지 작성 예외처리에 토스트UI 연결 #98
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
13 commits
Select commit
Hold shift + click to select a range
1a81fe6
feat : 알림 타입에 SENDING 추가
wldnjs990 647f150
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-fin…
wldnjs990 68c79e3
feat : 알림 페이지 타임라인 데이터바인딩 + 알림타입에 따른 UI작업 완료(구독 UI작업만 남음)
wldnjs990 959306a
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-fin…
wldnjs990 21faa53
feat : 토스트UI 작업중
wldnjs990 e74e0c4
feat : SSE훅 호출 위치 App에서 PrivateRouter로 이동 + Home 라우트 PrivateRouter 안으…
wldnjs990 2ff73f6
feat : 토스트 기능 1차 구현(알림기능 알림도착, 편지작성 내용 미입력시 토스트 넣어둠)
wldnjs990 b99a781
feat : 토스트알림 최대넓이 지정
wldnjs990 ce6b37b
feat : 토스트 컨텐츠 타입별 이모지 추가
wldnjs990 0d39b7b
refactor : 토스트UI 알림 1개만 표시 => 알림 1개 이상 표시 되도록 업그레이드(단일 객체 -> 객체 배열로 데…
wldnjs990 bf389cf
refactor : 토스트UI position 타입 수정
wldnjs990 c758de3
Merge branch 'develop' into 88-feat-notification-nd
wldnjs990 c314b2d
Merge branch 'develop' into 88-feat-notification-nd
wldnjs990 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,16 @@ | ||
| import useToastStore from '@/stores/toastStore'; | ||
| import ToastItem from './ToastItem'; | ||
|
|
||
| interface Toast {} | ||
| export default function Toast({}: Toast) { | ||
| const toastObjects = useToastStore((state) => state.toastObjects); | ||
|
|
||
| if (toastObjects.length <= 0) return; | ||
| return ( | ||
| <> | ||
| {toastObjects.map((toastObj, index) => ( | ||
| <ToastItem toastObj={toastObj} index={index} key={index} /> | ||
| ))} | ||
| </> | ||
| ); | ||
| } |
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,54 @@ | ||
| import useToastStore from '@/stores/toastStore'; | ||
| import { useEffect } from 'react'; | ||
| import { twMerge } from 'tailwind-merge'; | ||
|
|
||
| interface ToastObj { | ||
| time: number; | ||
| toastType: 'Warning' | 'Success' | 'Error' | 'Info'; | ||
| position: 'Top' | 'Bottom'; | ||
| title: string; | ||
| onClick?: () => void; | ||
| } | ||
| export default function ToastItem({ toastObj, index }: { toastObj: ToastObj; index: number }) { | ||
| const setToastUnActive = useToastStore((state) => state.setToastUnActive); | ||
|
|
||
| const TOAST_DESIGN = { | ||
| Warning: { style: 'bg-primary-4', imoji: '⚠️' }, | ||
| Success: { style: 'bg-[#38d9a9] text-[#FFFFFF]', imoji: '✅' }, | ||
| Error: { style: 'bg-[#FFDCD8] text-[#FF0000]', imoji: '🚨' }, | ||
| Info: { style: 'bg-[#FFFFFF]', imoji: '📫' }, | ||
| }; | ||
|
|
||
| const TOAST_POSITION = { | ||
| Top: 'top-20', | ||
| Bottom: 'bottom-20', | ||
| }; | ||
|
|
||
| const animation = `toast-blink ${toastObj.time}s ease-in-out forwards`; | ||
| const toastStyle = twMerge( | ||
| 'fixed bottom-20 left-1/2 z-40 flex h-[40px] max-w-150 min-w-[335px] w-[85%] -translate-1/2 items-center justify-center rounded-2xl caption-sb', | ||
| TOAST_POSITION[toastObj.position], | ||
| TOAST_DESIGN[toastObj.toastType].style, | ||
| ); | ||
|
|
||
| const activeTime = toastObj.time * 1000; | ||
| useEffect(() => { | ||
| const closeToast = setTimeout(() => { | ||
| setToastUnActive(index); | ||
| }, activeTime); | ||
|
|
||
| return () => clearTimeout(closeToast); | ||
| }); | ||
| return ( | ||
| <div | ||
| className={toastStyle} | ||
| style={{ animation: animation }} | ||
| onClick={() => { | ||
| setToastUnActive(index); | ||
| if (toastObj.onClick) toastObj.onClick(); | ||
| }} | ||
| > | ||
| {`${TOAST_DESIGN[toastObj.toastType].imoji} ${toastObj.title} ${TOAST_DESIGN[toastObj.toastType].imoji}`} | ||
| </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
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,36 @@ | ||
| import LetterWrapper from '@/components/LetterWrapper'; | ||
| import ModalOverlay from '@/components/ModalOverlay'; | ||
| import { useNavigate } from 'react-router'; | ||
|
|
||
| export default function SendingModal({ | ||
| isOpenSendingModal, | ||
| setIsOpenSendingModal, | ||
| }: { | ||
| isOpenSendingModal: boolean; | ||
| setIsOpenSendingModal: React.Dispatch<React.SetStateAction<boolean>>; | ||
| }) { | ||
| const navigate = useNavigate(); | ||
| if (!isOpenSendingModal) return null; | ||
| const onClose = () => { | ||
| setIsOpenSendingModal(false); | ||
| }; | ||
| return ( | ||
| <> | ||
| <ModalOverlay closeOnOutsideClick onClose={onClose}> | ||
| <LetterWrapper className="w-77"> | ||
| <div className="caption-r flex flex-col gap-2"> | ||
| <h2 className="body-b mb-3">편지 도착</h2> | ||
| <span>편지는 작성된 시점으로 1시간 이후에 도착합니다.</span> | ||
| <span>남은시간은 홈 화면의 편지 도착 시간 버튼을 눌러 확인 가능합니다.</span> | ||
| <button | ||
| className="body-b mt-3 flex items-center justify-center" | ||
| onClick={() => navigate('/')} | ||
| > | ||
| 홈 화면으로 이동 {'>'} | ||
| </button> | ||
| </div> | ||
| </LetterWrapper> | ||
| </ModalOverlay> | ||
| </> | ||
| ); | ||
| } |
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
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.
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.
100%로 해도 될것 같아용! 양옆 마진 20씩해서?
이건 같이 보면서 수정할까용?
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.
헉 그런 방법이
바로 적용하겠습니다!!!🥕🥕🥕