🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Update dependencies and refactor toast notifications
Bill Yange716d706435e
diff --git a/client/package-lock.json b/client/package-lock.jsonindex 9c3982ec9..9aae648a7 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -70,11 +70,11 @@"react-day-picker": "^9.11.3","react-dom": "19.2.1","react-hook-form": "7.56.3",+ "react-hot-toast": "^2.6.0","react-scan": "^0.3.4","react-select": "5.10.1","react-syntax-highlighter": "^16.1.0","rrweb-player": "^2.0.0-alpha.11",- "sonner": "2.0.3","tailwind-merge": "2.6.0","tailwindcss-animate": "1.0.7","unique-names-generator": "^4.7.1",@@ -9195,6 +9195,15 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/goober": {+ "version": "2.1.18",+ "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.18.tgz",+ "integrity": "sha512-2vFqsaDVIT9Gz7N6kAL++pLpp41l3PfDuusHcjnGLfR6+huZkl6ziX+zgVC3ZxpqWhzH6pyDdGrCeDhMIvwaxw==",+ "license": "MIT",+ "peerDependencies": {+ "csstype": "^3.0.10"+ }+ },"node_modules/gopd": {"version": "1.2.0","resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",@@ -11704,6 +11713,23 @@"react": "^16.8.0 || ^17 || ^18 || ^19"}},+ "node_modules/react-hot-toast": {+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.6.0.tgz",+ "integrity": "sha512-bH+2EBMZ4sdyou/DPrfgIouFpcRLCJ+HoCA32UoAYHn6T3Ur5yfcDCeSr5mwldl6pFOsiocmrXMuoCJ1vV8bWg==",+ "license": "MIT",+ "dependencies": {+ "csstype": "^3.1.3",+ "goober": "^2.1.16"+ },+ "engines": {+ "node": ">=10"+ },+ "peerDependencies": {+ "react": ">=16",+ "react-dom": ">=16"+ }+ },"node_modules/react-is": {"version": "16.13.1","resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",@@ -12448,16 +12474,6 @@"url": "https://github.com/sponsors/cyyynthia"}},- "node_modules/sonner": {- "version": "2.0.3",- "resolved": "https://registry.npmjs.org/sonner/-/sonner-2.0.3.tgz",- "integrity": "sha512-njQ4Hht92m0sMqqHVDL32V2Oun9W1+PHO9NDv9FHfJjT3JT22IG4Jpo3FPQy+mouRKCXFWO+r67v6MrHX2zeIA==",- "license": "MIT",- "peerDependencies": {- "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",- "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc"- }- },"node_modules/source-map": {"version": "0.5.7","resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",diff --git a/client/package.json b/client/package.jsonindex 2f0210f71..ae1a38957 100644--- a/client/package.json+++ b/client/package.json@@ -74,11 +74,11 @@"react-day-picker": "^9.11.3","react-dom": "19.2.1","react-hook-form": "7.56.3",+ "react-hot-toast": "^2.6.0","react-scan": "^0.3.4","react-select": "5.10.1","react-syntax-highlighter": "^16.1.0","rrweb-player": "^2.0.0-alpha.11",- "sonner": "2.0.3","tailwind-merge": "2.6.0","tailwindcss-animate": "1.0.7","unique-names-generator": "^4.7.1",diff --git a/client/src/components/VersionCheck.tsx b/client/src/components/VersionCheck.tsxindex a31479cab..e4121e1b6 100644--- a/client/src/components/VersionCheck.tsx+++ b/client/src/components/VersionCheck.tsx@@ -1,10 +1,12 @@"use client";import { useEffect } from "react";-import { toast } from "sonner";+import { toast } from "@/components/ui/sonner";import { IS_CLOUD } from "../lib/const";import packageJson from "../../package.json";+import { X } from "lucide-react";+import { Button } from "./ui/button";export function VersionCheck() {useEffect(() => {@@ -19,20 +21,39 @@ export function VersionCheck() {const latest = data.version;const current = packageJson.version;- console.log("latest", latest);- console.log("current", current);if (latest && latest !== current && isNewer(latest, current)) {- toast.info(`Rybbit v${latest} is available (you're on v${current})`, {- duration: Infinity,- action: {- label: "Upgrade",- onClick: () =>- window.open(- "https://www.rybbit.io/docs/self-hosting",- "_blank"- ),- },- });+ toast.custom(+ (t) => (+ <div+ style={{+ opacity: t.visible ? 1 : 0,+ transform: t.visible ? "translateY(0)" : "translateY(-8px)",+ transition: "opacity 200ms ease, transform 200ms ease",+ }}+ className="flex items-center gap-3 bg-white dark:bg-neutral-850 border border-neutral-150 dark:border-neutral-850 rounded-lg shadow-lg py-2 px-3 text-sm"+ >+ <span>+ Rybbit v{latest} is available (you're on v{current})+ </span>+ <a+ href="https://rybbit.com/docs/managing-your-installation#updating-your-installation"+ target="_blank"+ rel="noopener noreferrer"+ >+ <Button variant="success" size="sm">+ Upgrade+ </Button>+ </a>+ <button+ onClick={() => toast.dismiss(t.id)}+ className="text-neutral-400 hover:text-neutral-600 dark:text-neutral-500 dark:hover:text-neutral-300"+ >+ <X size={16} />+ </button>+ </div>+ ),+ { duration: 10000 }+ );}}).catch(() => {diff --git a/client/src/components/ui/button.tsx b/client/src/components/ui/button.tsxindex a29e259ac..5f4d7f197 100644--- a/client/src/components/ui/button.tsx+++ b/client/src/components/ui/button.tsx@@ -30,7 +30,7 @@ const buttonVariants = cva(size: {default: "h-9 px-3 py-2 rounded-lg text-sm",sm: "h-8 rounded-lg px-2.5 text-xs",- xs: "h-6 px-1.5 text-xs",+ xs: "h-6 rounded-md px-1.5 text-xs",lg: "h-10 rounded-lg px-8 text-sm",icon: "h-9 w-9 rounded-lg",smIcon: "h-7 w-7 rounded-md",@@ -45,7 +45,7 @@ const buttonVariants = cva(export interface ButtonPropsextends React.ButtonHTMLAttributes<HTMLButtonElement>,- VariantProps<typeof buttonVariants> {+ VariantProps<typeof buttonVariants> {asChild?: boolean;}diff --git a/client/src/components/ui/sonner.tsx b/client/src/components/ui/sonner.tsxindex 2632ad439..c17baed0a 100644--- a/client/src/components/ui/sonner.tsx+++ b/client/src/components/ui/sonner.tsx@@ -1,32 +1,48 @@"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();+import hotToast, { Toaster as HotToaster } from "react-hot-toast";+const Toaster = () => {return (- <Sonner- theme={theme as ToasterProps["theme"]}- className="toaster group"+ <HotToaster+ position="bottom-right"toastOptions={{- classNames: {- toast:- "group toast group-[.toaster]:bg-white group-[.toaster]:text-neutral-950 group-[.toaster]:border-neutral-200 group-[.toaster]:shadow-lg dark:group-[.toaster]:bg-neutral-850 dark:group-[.toaster]:text-neutral-50 dark:group-[.toaster]:border-neutral-700",- description: "group-[.toast]:text-neutral-500 dark:group-[.toast]:text-neutral-400",- actionButton:- "group-[.toast]:bg-neutral-900 group-[.toast]:text-neutral-50 dark:group-[.toast]:bg-neutral-50 dark:group-[.toast]:text-neutral-900",- cancelButton:- "group-[.toast]:bg-neutral-100 group-[.toast]:text-neutral-500 dark:group-[.toast]:bg-neutral-800 dark:group-[.toast]:text-neutral-400",+ className: [+ "!bg-white !text-neutral-800",+ "!border !border-neutral-150 !shadow-lg",+ "!rounded-lg !text-sm !font-medium",+ "dark:!bg-neutral-850 dark:!text-neutral-200",+ "dark:!border-neutral-850",+ ].join(" "),+ success: {+ iconTheme: {+ primary: "#10b981",+ secondary: "#fff",+ },+ },+ error: {+ iconTheme: {+ primary: "#ef4444",+ secondary: "#fff",+ },},}}- {...props}/>);};-export { Toaster };-export { toast } from "sonner";+const toast = Object.assign(+ (message: string) => hotToast(message),+ {+ success: (message: string) => hotToast.success(message),+ error: (message: string) => hotToast.error(message),+ info: (message: string) =>+ hotToast(message, {+ icon: "ℹ️",+ }),+ dismiss: (id?: string) => hotToast.dismiss(id),+ custom: hotToast.custom,+ }+);++export { Toaster, toast };