diff options
| author | Bobby <[email protected]> | 2022-11-30 23:16:07 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-11-30 23:16:07 -0500 |
| commit | daaa789068cebb5fdfcea6197ade6e663be46e0f (patch) | |
| tree | 1cd315851b779ac28fe622da332c3c16fe1c433c /src/components/toaster.tsx | |
| download | tcssocialify-daaa789068cebb5fdfcea6197ade6e663be46e0f.tar.xz tcssocialify-daaa789068cebb5fdfcea6197ade6e663be46e0f.zip | |
socialify update
Diffstat (limited to 'src/components/toaster.tsx')
| -rw-r--r-- | src/components/toaster.tsx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/components/toaster.tsx b/src/components/toaster.tsx new file mode 100644 index 0000000..44abd8e --- /dev/null +++ b/src/components/toaster.tsx @@ -0,0 +1,38 @@ +import { toast as hotToast } from 'react-hot-toast' +import { + MdInfoOutline, + MdCheckCircleOutline, + MdOutlineWarningAmber, + MdErrorOutline +} from 'react-icons/md' + +const ToastTypeMap = { + info: { icon: MdInfoOutline, className: 'alert-info' }, + success: { icon: MdCheckCircleOutline, className: 'alert-success' }, + warning: { icon: MdOutlineWarningAmber, className: 'alert-warning' }, + error: { icon: MdErrorOutline, className: 'alert-error' } +} + +const _helper = (type: keyof typeof ToastTypeMap) => { + const { icon: Icon, className } = ToastTypeMap[type] + + return (message: string) => + hotToast.custom((t) => { + return ( + <div className={`alert ${className} w-fit shadow-lg`}> + <div> + <Icon className="w-6 h-6" /> {message} + </div> + </div> + ) + }) +} + +const toast = { + info: _helper('info'), + success: _helper('success'), + warning: _helper('warning'), + error: _helper('error') +} + +export default toast |
