-
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 toaster, custom modal and updated it in layout.
- Loading branch information
1 parent
bf9036c
commit 47781f0
Showing
3 changed files
with
78 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use client' | ||
import { useModal } from '@/providers/modal-provider' | ||
import React from 'react' | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
} from '../ui/dialog' | ||
import { DialogTitle } from '@radix-ui/react-dialog' | ||
|
||
type Props = { | ||
title: string | ||
subheading: string | ||
children: React.ReactNode | ||
defaultOpen?: boolean | ||
} | ||
|
||
const CustomModal = ({ children, defaultOpen, subheading, title }: Props) => { | ||
const { isOpen, setClose } = useModal() | ||
return ( | ||
<Dialog | ||
open={isOpen || defaultOpen} | ||
onOpenChange={setClose} | ||
> | ||
<DialogContent className="overflow-scroll md:max-h-[700px] md:h-fit h-screen bg-card"> | ||
<DialogHeader className="pt-8 text-left"> | ||
<DialogTitle className="text-2xl font-bold">{title}</DialogTitle> | ||
<DialogDescription>{subheading}</DialogDescription> | ||
{children} | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default CustomModal |
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,35 @@ | ||
"use client" | ||
|
||
import { | ||
Toast, | ||
ToastClose, | ||
ToastDescription, | ||
ToastProvider, | ||
ToastTitle, | ||
ToastViewport, | ||
} from "@/components/ui/toast" | ||
import { useToast } from "@/components/ui/use-toast" | ||
|
||
export function Toaster() { | ||
const { toasts } = useToast() | ||
|
||
return ( | ||
<ToastProvider> | ||
{toasts.map(function ({ id, title, description, action, ...props }) { | ||
return ( | ||
<Toast key={id} {...props}> | ||
<div className="grid gap-1"> | ||
{title && <ToastTitle>{title}</ToastTitle>} | ||
{description && ( | ||
<ToastDescription>{description}</ToastDescription> | ||
)} | ||
</div> | ||
{action} | ||
<ToastClose /> | ||
</Toast> | ||
) | ||
})} | ||
<ToastViewport /> | ||
</ToastProvider> | ||
) | ||
} |