Skip to content

Commit

Permalink
feat: add sonner
Browse files Browse the repository at this point in the history
  • Loading branch information
mickasmt committed Jun 9, 2024
1 parent e59a5b1 commit 668af93
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SessionProvider } from "next-auth/react";
import { ThemeProvider } from "next-themes";

import { cn, constructMetadata } from "@/lib/utils";
import { Toaster } from "@/components/ui/toaster";
import { Toaster } from "@/components/ui/sonner";
import { Analytics } from "@/components/analytics";
import ModalProvider from "@/components/modals/providers";
import { TailwindIndicator } from "@/components/tailwind-indicator";
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
>
<ModalProvider>{children}</ModalProvider>
<Analytics />
<Toaster />
<Toaster richColors closeButton />
<TailwindIndicator />
</ThemeProvider>
</SessionProvider>
Expand Down
31 changes: 31 additions & 0 deletions components/ui/sonner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client"

import { useTheme } from "next-themes"
import { Toaster as Sonner } from "sonner"

type ToasterProps = React.ComponentProps<typeof Sonner>

const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme()

return (
<Sonner
theme={theme as ToasterProps["theme"]}
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-foreground",
actionButton:
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
cancelButton:
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
},
}}
{...props}
/>
)
}

export { Toaster }
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"resend": "^3.2.0",
"sharp": "^0.33.4",
"shiki": "^1.6.1",
"sonner": "^1.5.0",
"stripe": "^15.8.0",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 668af93

Please sign in to comment.