Added kofi support me

This commit is contained in:
Hieuhuy Pham 2025-01-15 20:51:08 -05:00
parent 3fb1c6434a
commit 56f871f603
3 changed files with 41 additions and 1 deletions

6
global.d.ts vendored
View File

@ -4,3 +4,9 @@ declare namespace NodeJS {
STRAPI_API_TOKEN: string;
}
}
declare global {
interface Window {
kofiWidgetOverlay: any;
}
}
export {};

View File

@ -5,6 +5,7 @@ import "tailwindcss/tailwind.css";
import React, { useEffect, useState } from "react";
import NightModeToggle from "@/components/NightModeToggle";
import Navbar from "@/components/NavigationBar";
import KofiWidget from "@/components/KofiWidget";
export default function RootLayout({ children }: { children: React.ReactNode }) {
const [isDarkMode, setIsDarkMode] = useState(false);
@ -49,8 +50,10 @@ export default function RootLayout({ children }: { children: React.ReactNode })
`,
}}
/>
</head>
<body className="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 min-h-screen">
<KofiWidget />
<Navbar />
<main className="relative">{children}</main>
<div className="fixed bottom-4 right-4">

View File

@ -0,0 +1,31 @@
"use client"
import { useEffect } from 'react';
const KofiWidget = () => {
useEffect(() => {
// Dynamically create and append the script
const script = document.createElement('script');
script.src = 'https://storage.ko-fi.com/cdn/scripts/overlay-widget.js';
script.async = true;
script.onload = () => {
if (typeof window !== 'undefined' && window.kofiWidgetOverlay) {
window.kofiWidgetOverlay.draw('nulltranslationgroup', {
'type': 'floating-chat',
'floating-chat.donateButton.text': 'Support me',
'floating-chat.donateButton.background-color': '#00b9fe',
'floating-chat.donateButton.text-color': '#fff',
});
}
};
document.body.appendChild(script);
return () => {
// Clean up the script when the component unmounts
document.body.removeChild(script);
};
}, []);
return null; // No visible JSX; the widget is a floating overlay
};
export default KofiWidget;