Skip to content

Commit

Permalink
feat: add sonner toaster
Browse files Browse the repository at this point in the history
  • Loading branch information
nahoc committed Apr 2, 2024
1 parent 1d10468 commit 0394fc2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@risc0/ui",
"version": "0.0.20",
"version": "0.0.21",
"type": "module",
"scripts": {
"bump:version": "bunx changelogen --bump --no-output",
Expand Down Expand Up @@ -39,6 +39,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "7.51.2",
"sonner": "^1.4.41",
"tailwind-merge": "2.2.2",
"tailwind-variants": "0.2.1",
"tailwindcss": "3.4.3",
Expand Down
31 changes: 31 additions & 0 deletions sonner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client";

import { useTheme } from "next-themes";
import type { ComponentProps } from "react";
// @ts-ignore -- not sure why this is not working
import { Toaster as Sonner } from "sonner";
import cn from "./cn";

type ToasterProps = ComponentProps<typeof Sonner>;

export default function Toaster({ ...props }: ToasterProps) {
const { theme = "system" } = useTheme();

return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group border-"
toastOptions={{
classNames: {
toast:
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:border-1 group-[.toaster]:shadow-sm",
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",
},
}}
cn={cn}
{...props}
/>
);
}

0 comments on commit 0394fc2

Please sign in to comment.