make toasts look better (:
All checks were successful
Deploy Frontend / docker (17, 3.8.5) (push) Successful in 3m2s

This commit is contained in:
Braydon 2024-04-18 00:31:45 -04:00
parent bf3a09afd4
commit cb75a3a4c8
5 changed files with 38 additions and 10 deletions

Binary file not shown.

@ -15,7 +15,9 @@
"@hookform/resolvers": "^3.3.4", "@hookform/resolvers": "^3.3.4",
"@radix-ui/react-context-menu": "^2.1.5", "@radix-ui/react-context-menu": "^2.1.5",
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-select": "^2.0.0", "@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7", "@radix-ui/react-tooltip": "^1.0.7",
@ -31,6 +33,7 @@
"react-dom": "^18", "react-dom": "^18",
"react-hook-form": "^7.51.3", "react-hook-form": "^7.51.3",
"restfulmc-lib": "^1.1.2", "restfulmc-lib": "^1.1.2",
"sonner": "^1.4.41",
"tailwind-merge": "^2.2.2", "tailwind-merge": "^2.2.2",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "^1.0.7"
}, },

@ -1,8 +1,8 @@
"use client"; "use client";
import { useToast } from "@/components/ui/use-toast";
import copy from "clipboard-copy"; import copy from "clipboard-copy";
import { ReactElement, ReactNode } from "react"; import { ReactElement, ReactNode } from "react";
import { toast } from "sonner";
/** /**
* Props for the copy button. * Props for the copy button.
@ -37,19 +37,13 @@ const CopyButton = ({
children, children,
showToast, showToast,
}: CopyButtonProps): ReactElement => { }: CopyButtonProps): ReactElement => {
const { toast } = useToast();
const handleClick = async (): Promise<void> => { const handleClick = async (): Promise<void> => {
await copy(content); // Copy to the clipboard await copy(content); // Copy to the clipboard
// Show a toast when copied // Show a toast when copied
if (showToast) { if (showToast) {
toast({ toast("Copied", {
title: "Copied", description: `Copied "${content}" to your clipboard`,
description: (
<>
Copied <b>{content}</b> to your clipboard
</>
),
}); });
} }
}; };

@ -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,5 +1,5 @@
import Navbar from "@/components/navbar"; import Navbar from "@/components/navbar";
import { Toaster } from "@/components/ui/toaster"; import { Toaster } from "@/components/ui/sonner"
import { TooltipProvider } from "@/components/ui/tooltip"; import { TooltipProvider } from "@/components/ui/tooltip";
import config from "@/config"; import config from "@/config";
import { notoSans } from "@/font/fonts"; import { notoSans } from "@/font/fonts";