Merge pull request #9 from BramSuurdje/feat--sonner-with-colors

Feat  sonner with colors
This commit is contained in:
Bram Suurd
2024-05-17 00:40:31 +02:00
committed by GitHub
3 changed files with 38 additions and 6 deletions

View File

@@ -10,7 +10,7 @@
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--primary: 240 5.9% 10%;
--primary: 201 100% 38%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;

View File

@@ -56,8 +56,6 @@ export default function RootLayout({
}>) {
return (
<html lang="en" suppressHydrationWarning>
<head>
</head>
<body className={inter.className}>
<ThemeProvider
attribute="class"
@@ -70,7 +68,7 @@ export default function RootLayout({
<div className="flex w-full justify-center">
<div className="w-full max-w-7xl ">
{children}
<Toaster />
<Toaster richColors />
</div>
</div>
{/* <Footer /> */}
@@ -79,4 +77,4 @@ export default function RootLayout({
</body>
</html>
);
}
}

View File

@@ -32,7 +32,40 @@ function ScriptItem() {
function handleCopy(type: string, value: any) {
navigator.clipboard.writeText(value);
toast(
let amountOfScriptsCopied = localStorage.getItem("amountOfScriptsCopied");
if (amountOfScriptsCopied === null) {
localStorage.setItem("amountOfScriptsCopied", "1");
} else if (parseInt(amountOfScriptsCopied) >= 3) {
""
} else {
amountOfScriptsCopied = (parseInt(amountOfScriptsCopied) + 1).toString();
localStorage.setItem("amountOfScriptsCopied", amountOfScriptsCopied);
if (parseInt(amountOfScriptsCopied) === 3) {
setTimeout(() => {
toast.info(
<div className="flex flex-col gap-3">
<p className="lg">
If you find these scripts useful, please consider starring the
repository on GitHub. It helps a lot!
</p>
<div>
<Button className="text-white">
<Link href="https://github.com/tteck/Proxmox">
Star on GitHub 💫
</Link>
</Button>
</div>
</div>,
{ duration: 8000 },
);
}, 500);
}
}
toast.success(
<div className="flex items-center gap-2">
<Clipboard className="h-4 w-4" />
<span>Copied {type} to clipboard</span>
@@ -40,6 +73,7 @@ function ScriptItem() {
);
}
function closeScript() {
// remove the id from the url and reset the state
window.history.pushState({}, document.title, window.location.pathname);