-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ replace old toaster with sonner toaster
- Loading branch information
Showing
9 changed files
with
173 additions
and
400 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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,25 @@ | ||
"use client"; | ||
|
||
import { | ||
Toast, | ||
ToastClose, | ||
ToastDescription, | ||
ToastProvider, | ||
ToastTitle, | ||
ToastViewport, | ||
} from "~/ui/shadcn/components/ui/toast"; | ||
import { useToast } from "~/ui/shadcn/components/ui/use-toast"; | ||
import { Toaster as Sonner } from "sonner"; | ||
|
||
export function Toaster() { | ||
const { toasts } = useToast(); | ||
export type ToasterProps = React.ComponentProps<typeof Sonner>; | ||
|
||
export function Toaster({ ...props }: ToasterProps) { | ||
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> | ||
<Sonner | ||
theme="light" | ||
className="toaster group" | ||
toastOptions={{ | ||
classNames: { | ||
toast: | ||
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg", | ||
description: "group-[.toast]:text-muted group-[.toast]:text-sm", | ||
actionButton: "group-[.toast]:bg-gray-900 group-[.toast]:text-white", | ||
cancelButton: "group-[.toast]:bg-gray-900 group-[.toast]:text-white", | ||
title: "group-[.toast]:text-base", | ||
}, | ||
}} | ||
{...props} | ||
/> | ||
); | ||
} |
Oops, something went wrong.