-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add toast component * refactor: update toast css * fix: fix merge conflict * fix: fix toast exit animation timolins/react-hot-toast#165 (comment) * fix: update toast position * fix: fix translateY causing scrollbar - width를 유연하게 조절하기 위해서 toast container의 position을 'sticky'로 설정하니까, translateY 애니메이션으로 인해 스크롤바가 잠시 표시되는 이슈 발생 - toast의 maxWidth를 최대 viewport width - 2 * marginX로 설정해서 임시 해결
- Loading branch information
Showing
5 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,68 @@ | ||
import toast, { Toaster, type ToastOptions } from 'react-hot-toast' | ||
import Icon from './icon' | ||
import Typography from './typography' | ||
|
||
type ToastType = 'success' | 'error' | ||
|
||
const toastCustom = ({ | ||
type, | ||
message, | ||
options, | ||
}: { | ||
type: ToastType | ||
message: string | ||
options?: ToastOptions | ||
}) => { | ||
toast.custom( | ||
(t) => ( | ||
<div | ||
className={`${t.visible ? 'animate-enter' : 'animate-leave'} bg-opacity-70 bg-[#212124] w-full max-w-[calc(420px-2*25px)] flex items-center justify-center gap-2 px-6 py-[14px] rounded-full leading-tight`} | ||
> | ||
{type === 'success' ? ( | ||
<Icon type="info" fill="profile-sky-blue" aria-hidden /> | ||
) : ( | ||
<Icon type="infoCircle" fill="orange-400" aria-hidden /> | ||
)} | ||
<Typography size="h6" color="neutral-100"> | ||
{message} | ||
</Typography> | ||
</div> | ||
), | ||
options, | ||
) | ||
} | ||
|
||
const notify = { | ||
success: (message: string, options?: ToastOptions) => | ||
toastCustom({ | ||
type: 'success', | ||
message, | ||
options: { id: 'toast-success', ...options }, | ||
}), | ||
error: (message: string, options?: ToastOptions) => | ||
toastCustom({ | ||
type: 'error', | ||
message, | ||
options: { id: 'toast-error', ...options }, | ||
}), | ||
} | ||
|
||
const CustomToaster = () => { | ||
return ( | ||
<Toaster | ||
position="bottom-center" | ||
toastOptions={{ | ||
duration: 3000, | ||
}} | ||
containerStyle={{ | ||
top: 20, | ||
left: 25, | ||
bottom: 20, | ||
right: 25, | ||
position: 'fixed', | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
export { CustomToaster, notify } |
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